Gracefully handle non-commit IDs instead of segfaulting.
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
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++;