From: Linus Torvalds Date: Thu, 5 May 2005 00:03:09 +0000 (-0700) Subject: Teach fsck-cache to accept non-commits for reachability analysis. X-Git-Tag: v0.99~648 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=770896e548d0e68ab120507895e1e878c5ee347c;p=git.git Teach fsck-cache to accept non-commits for reachability analysis. In particular, teach it about tags. Also, to make reachability actually work for tags, we need to add the ref to the tagged object. --- diff --git a/fsck-cache.c b/fsck-cache.c index fb0d82f3..e328cec7 100644 --- a/fsck-cache.c +++ b/fsck-cache.c @@ -295,14 +295,12 @@ int main(int argc, char **argv) continue; if (!get_sha1(arg, head_sha1)) { - struct commit *commit = lookup_commit(head_sha1); - struct object *obj; + struct object *obj = lookup_object(head_sha1); - /* Error is printed by lookup_commit(). */ - if (!commit) + /* Error is printed by lookup_object(). */ + if (!obj) continue; - obj = &commit->object; obj->used = 1; mark_reachable(obj, REACHABLE); heads++; diff --git a/tag.c b/tag.c index 9eade750..3a71dd41 100644 --- a/tag.c +++ b/tag.c @@ -49,6 +49,8 @@ int parse_tag(struct tag *item) goto err; item->tagged = parse_object(object); + if (item->tagged) + add_ref(&item->object, item->tagged); type_line = data + 48; if (memcmp("\ntype ", type_line-1, 6))