threads / patch / 17240

patchbuiltin-fsck: fix off by one head count

Subject: [PATCH] builtin-fsck: fix off by one head count

## tl;dr

One message between Jan 18, 2009 and Jan 18, 2009. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Christian Couder· Jan 18, 2009, 17:27 UTC · lore

According to the man page, if "git fsck" is passed one or more heads, it should verify connectivity and validity of only objects reachable from the heads it is passed.

But before this patch, when it was passed only one head, then it behaved as if no heads were passed (that is it used the index file, all references in $GIT_DIR/refs/* and all reflogs). In fact it just ignored the first head it was passed.

It looks like this bug was introduced when "builtin-fsck.c" was changed to use "parse_options" (commit 5ac0a2063e8f824f6e8ffb4d18de74c55aae7131).

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 builtin-fsck.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
	Sorry if you receive this patch more than once, but it
	seems that something did not work when I tried to send
	it to the mailing list before. 
Show changes to builtin-fsck.c +1 −1
diff --git a/builtin-fsck.c b/builtin-fsck.c
index 5a08ec1..fb35554 100644
--- a/builtin-fsck.c
+++ b/builtin-fsck.c
@@ -629,7 +629,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
 	}
 
 	heads = 0;
-	for (i = 1; i < argc; i++) {
+	for (i = 0; i < argc; i++) {
 		const char *arg = argv[i];
 		if (!get_sha1(arg, head_sha1)) {
 			struct object *obj = lookup_object(head_sha1);
-- 
1.6.1.85.g8ffc

← back to recent threads