diff options
author | Jeff King <peff@peff.net> | 2017-01-16 22:34:21 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-01-17 23:24:33 +0100 |
commit | c3271a0e4715eb9c3f03dde4fdda23f50cc176c3 (patch) | |
tree | a0ce101b98a3311f2fa18186f6fcc31476d815b9 /t | |
parent | fsck: tighten error-checks of "git fsck <head>" (diff) | |
download | git-c3271a0e4715eb9c3f03dde4fdda23f50cc176c3.tar.xz git-c3271a0e4715eb9c3f03dde4fdda23f50cc176c3.zip |
fsck: do not fallback "git fsck <bogus>" to "git fsck"
Since fsck tries to continue as much as it can after seeing
an error, we still do the reachability check even if some
heads we were given on the command-line are bogus. But if
_none_ of the heads is is valid, we fallback to checking all
refs and the index, which is not what the user asked for at
all.
Instead of checking "heads", the number of successful heads
we got, check "argc" (which we know only has non-options in
it, because parse_options removed the others).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t1450-fsck.sh | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index 6b6db62c4e..509d69c90e 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -616,4 +616,15 @@ test_expect_success 'fsck $name notices bogus $name' ' test_must_fail git fsck $_z40 ' +test_expect_success 'bogus head does not fallback to all heads' ' + # set up a case that will cause a reachability complaint + echo to-be-deleted >foo && + git add foo && + blob=$(git rev-parse :foo) && + test_when_finished "git rm --cached foo" && + remove_object $blob && + test_must_fail git fsck $_z40 >out 2>&1 && + ! grep $blob out +' + test_done |