Skip to content

Commit

Permalink
[PATCH] Dereference tag repeatedly until we get a non-tag.
Browse files Browse the repository at this point in the history
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 <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Junio C Hamano authored and Linus Torvalds committed Jul 11, 2005
1 parent a3eb250 commit 013aab8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions rev-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,12 @@ static struct commit *get_commit_reference(const char *name, unsigned int flags)
/*
* Tag object? Look what it points to..
*/
if (object->type == tag_type) {
while (object->type == tag_type) {
struct tag *tag = (struct tag *) object;
object->flags |= flags;
if (tag_objects && !(object->flags & UNINTERESTING))
add_pending_object(object, tag->tag);
object = tag->tagged;
object = parse_object(tag->tagged->sha1);
}

/*
Expand Down

0 comments on commit 013aab8

Please sign in to comment.