From e1a1388d858fa8522f187d3fdea92ff84e21528c Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Fri, 29 Apr 2005 20:00:40 -0700 Subject: [PATCH] [PATCH] git-fsck-cache: Gracefully handle non-commit IDs Gracefully handle non-commit IDs instead of segfaulting. Signed-off-by: Jonas Fonseca Signed-off-by: Linus Torvalds --- fsck-cache.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fsck-cache.c b/fsck-cache.c index 280a10405..164fc2eae 100644 --- a/fsck-cache.c +++ b/fsck-cache.c @@ -174,7 +174,14 @@ int main(int argc, char **argv) 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++; -- 2.30.2