From 013aab8265a806c8d3c9b040485839091bca30f4 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 10 Jul 2005 23:55:56 -0700 Subject: [PATCH] Dereference tag repeatedly until we get a non-tag. When we allow a tag object in place of a commit object, we only dereferenced the given tag once, which causes a tag that points at a tag that points at a commit to be rejected. Instead, dereference tag repeatedly until we get a non-tag. This patch makes change to two functions: - commit.c::lookup_commit_reference() is used by merge-base, rev-tree and rev-parse to convert user supplied SHA1 to that of a commit. - rev-list uses its own get_commit_reference() to do the same. Dereferencing tags this way helps both of these uses. Signed-off-by: Junio C Hamano Signed-off-by: Linus Torvalds --- commit.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'commit.c') diff --git a/commit.c b/commit.c index 0bbfa2ab31..caee5bc218 100644 --- a/commit.c +++ b/commit.c @@ -52,8 +52,9 @@ struct commit *lookup_commit_reference(const unsigned char *sha1) if (!obj) return NULL; - if (obj->type == tag_type) - obj = ((struct tag *)obj)->tagged; + while (obj->type == tag_type) + obj = parse_object(((struct tag *)obj)->tagged->sha1); + return check_commit(obj, sha1); } -- cgit v1.2.1