summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f1f1b96)
raw | patch | inline | side by side (parent: f1f1b96)
author | Junio C Hamano <gitster@pobox.com> | |
Thu, 23 Feb 2012 19:24:44 +0000 (11:24 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 23 Feb 2012 20:48:26 +0000 (12:48 -0800) |
The heuristic used by "git merge" to decide if it automatically gives an
editor upon clean automerge is to see if the standard input and the
standard output is the same device and is a tty, we are in an interactive
session. "The same device" test was done by comparing fstat(2) result on
the two file descriptors (and they must match), and we asked isatty() only
for the standard input (we insist that they are the same device and there
is no point asking tty-ness of the standard output).
The stat(2) emulation in the Windows port however does not give a usable
value in the st_ino field, so even if the standard output is connected to
something different from the standard input, "The same device" test may
incorrectly return true. To accomodate it, add another isatty() check for
the standard output stream as well.
Reported-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
editor upon clean automerge is to see if the standard input and the
standard output is the same device and is a tty, we are in an interactive
session. "The same device" test was done by comparing fstat(2) result on
the two file descriptors (and they must match), and we asked isatty() only
for the standard input (we insist that they are the same device and there
is no point asking tty-ness of the standard output).
The stat(2) emulation in the Windows port however does not give a usable
value in the st_ino field, so even if the standard output is connected to
something different from the standard input, "The same device" test may
incorrectly return true. To accomodate it, add another isatty() check for
the standard output stream as well.
Reported-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/merge.c | patch | blob | history |
diff --git a/builtin/merge.c b/builtin/merge.c
index ed0f959ac49c02aaffa77bc748a9efc69f1fd339..d3e1e8dc9e478aaea7ef4da855fb7c2e10397644 100644 (file)
--- a/builtin/merge.c
+++ b/builtin/merge.c
/* Use editor if stdin and stdout are the same and is a tty */
return (!fstat(0, &st_stdin) &&
!fstat(1, &st_stdout) &&
- isatty(0) &&
+ isatty(0) && isatty(1) &&
st_stdin.st_dev == st_stdout.st_dev &&
st_stdin.st_ino == st_stdout.st_ino &&
st_stdin.st_mode == st_stdout.st_mode);