aboutsummaryrefslogtreecommitdiff
path: root/fsck-cache.c
diff options
context:
space:
mode:
authorJonas Fonseca <fonseca@diku.dk>2005-04-29 20:00:40 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-29 20:00:40 -0700
commite1a1388d858fa8522f187d3fdea92ff84e21528c (patch)
tree4020d4bd241ae6a890bc1b14d9376b13acbcb6ed /fsck-cache.c
parent87fec8fc9e790fedbee0c9fc810dbd1bf006d7b6 (diff)
downloadgit-e1a1388d858fa8522f187d3fdea92ff84e21528c.tar.gz
git-e1a1388d858fa8522f187d3fdea92ff84e21528c.tar.xz
[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>
Diffstat (limited to 'fsck-cache.c')
-rw-r--r--fsck-cache.c9
1 files changed, 8 insertions, 1 deletions
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++;