Skip to content

Commit f2b5792

Browse files
author
Junio C Hamano
committed
Fix git-am safety checks
An earlier commit cbd64af added a check that prevents "git-am" to run without its standard input connected to a terminal while resuming operation. This was to catch a user error to try feeding a new patch from its standard input while recovery. The assumption of the check was that it is an indication that a new patch is being fed if the standard input is not connected to a terminal. It is however not quite correct (the standard input can be /dev/null if the user knows the operation does not need any input, for example). This broke t3403 when the test was run with its standard input connected to /dev/null. When git-am is given an explicit command such as --skip, there is no reason to insist that the standard input is a terminal; we are not going to read a new patch anyway. Credit goes to Gerrit Pape for noticing and reporting the problem with t3403-rebase-skip test. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 0b7c5a5 commit f2b5792

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

git-am.sh

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,25 @@ fi
166166

167167
if test -d "$dotest"
168168
then
169-
if test ",$#," != ",0," || ! tty -s
170-
then
171-
die "previous dotest directory $dotest still exists but mbox given."
172-
fi
169+
case "$#,$skip$resolved" in
170+
0,*t*)
171+
# Explicit resume command and we do not have file, so
172+
# we are happy.
173+
: ;;
174+
0,)
175+
# No file input but without resume parameters; catch
176+
# user error to feed us a patch from standard input
177+
# when there is already .dotest. This is somewhat
178+
# unreliable -- stdin could be /dev/null for example
179+
# and the caller did not intend to feed us a patch but
180+
# wanted to continue unattended.
181+
tty -s
182+
;;
183+
*)
184+
false
185+
;;
186+
esac ||
187+
die "previous dotest directory $dotest still exists but mbox given."
173188
resume=yes
174189
else
175190
# Make sure we are not given --skip nor --resolved

0 commit comments

Comments
 (0)