Skip to contentSkip to conversation

git-fsck-cache: Gracefully handle non-commit IDs

PATCH New Jonas Fonseca 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-fsck-cache: Gracefully handle non-commit IDs

Gracefully handle non-commit IDs instead of segfaulting.

fsck-cache.c (mode:100644) renamed from fsck-cache.c (mode:100644 sha1:280a104050b665515418c00c33af8e6b0b0e2101) +8 -1
@@ -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++;
Signature · 1 line
Jonas Fonseca