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

Gracefully handle non-commit IDs instead of segfaulting.

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Jonas Fonseca 2005-04-29 20:00:40 -07:00 коммит произвёл Linus Torvalds
Родитель 87fec8fc9e
Коммит e1a1388d85
1 изменённых файлов: 8 добавлений и 1 удалений

Просмотреть файл

@ -174,7 +174,14 @@ int main(int argc, char **argv)
continue; continue;
if (!get_sha1_hex(arg, head_sha1)) { 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; obj->used = 1;
mark_reachable(obj, REACHABLE); mark_reachable(obj, REACHABLE);
heads++; heads++;