git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Christian Couder <chriscool@tuxfamily.org>
Date
Jan 18, 2009, 17:27 UTC
Message-ID
<20090118182714.78422d0e.chriscool@tuxfamily.org>

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. 
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
Message 1 of 1 in “builtin-fsck: fix off by one head count”
  1. builtin-fsck: fix off by one head countChristian Couder, Jan 18, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.