summaryrefslogtreecommitdiff
path: root/builtin/fsck.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-01-16 21:34:21 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-01-17 22:24:33 (GMT)
commitc3271a0e4715eb9c3f03dde4fdda23f50cc176c3 (patch)
treea0ce101b98a3311f2fa18186f6fcc31476d815b9 /builtin/fsck.c
parentc6c7b16d23a4cb6af26acee865c2ade1a3822bef (diff)
downloadgit-c3271a0e4715eb9c3f03dde4fdda23f50cc176c3.zip
git-c3271a0e4715eb9c3f03dde4fdda23f50cc176c3.tar.gz
git-c3271a0e4715eb9c3f03dde4fdda23f50cc176c3.tar.bz2
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 'builtin/fsck.c')
-rw-r--r--builtin/fsck.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/fsck.c b/builtin/fsck.c
index bacc899..3d9ee31 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -778,7 +778,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
* default ones from .git/refs. We also consider the index file
* in this case (ie this implies --cache).
*/
- if (!heads) {
+ if (!argc) {
get_default_heads();
keep_cache_objects = 1;
}