t7701: fix ignored exit code inside loop
authorJeff King <peff@peff.net>
Wed, 25 Mar 2015 05:29:10 +0000 (01:29 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Mar 2015 17:24:13 +0000 (10:24 -0700)
When checking a list of file mtimes, we use a loop and break
out early from the loop if any entry does not match.
However, the exit code of a loop exited via break is always
0, meaning that the test will fail to notice we had a
mismatch. Since the loop is inside a function, we can fix
this by doing an early "return 1".

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7701-repack-unpack-unreachable.sh
index aad8a9c64dda7c0886a40343f07411a90977a37d..b66e3838665ea47d748a7e1a64facd755ee32fb8 100755 (executable)
@@ -57,7 +57,7 @@ compare_mtimes ()
 {
        read tref rest &&
        while read t rest; do
-               test "$tref" = "$t" || break
+               test "$tref" = "$t" || return 1
        done
 }