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

[PATCH] git-fsck-cache: Gracefully handle non-commit IDs

From
Jonas Fonseca <fonseca@diku.dk>
Date
Apr 30, 2005, 00:28 UTC
Message-ID
<20050430002809.GB32339@diku.dk>
Gracefully handle non-commit IDs instead of segfaulting.
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>

--- 09465be469eef9711e93b583f4cd1092baa58f90/fsck-cache.c (mode:100644 sha1:280a104050b665515418c00c33af8e6b0b0e2101) +++ uncommitted/fsck-cache.c (mode:100644)

@@ -174,7 +216,14 @@
 			continue;
 
 		if (!get_sha1_hex(arg, head_sha1)) {
-			struct object *obj = &lookup_commit(head_sha1)->object;
+			struct commit *commit = lookup_commit(head_sha1);
+			struct object *obj;
+
+			/* Error is printed by lookup_commit(). */
+			if (!commit)
+				continue;
+
+			obj = &commit->object;
 			obj->used = 1;
 			mark_reachable(obj, REACHABLE);
 			heads++;
-- 
Jonas Fonseca
Message 1 of 1 in “git-fsck-cache: Gracefully handle non-commit IDs”
  1. git-fsck-cache: Gracefully handle non-commit IDsJonas Fonseca, Apr 30, 2005

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.