@matheusbsbs / matheus-bagliano / commits / f2b5792564
Fork 0

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>

Junio C Hamano committed Sep 15, 2006 at 23:19 UTC f2b5792564754d5ba812a0d3eaec2440dfc0652a
1 file changed +19 -4
git-am.sh
+19 -4
@@ -166,10 +166,25 @@ fi
166
167 if test -d "$dotest"
168 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."
188 resume=yes
189 else
190 # Make sure we are not given --skip nor --resolved