* tag referring to a commit but not directly?
@ 2005-07-09 10:00 Junio C Hamano
2005-07-11 6:55 ` [PATCH] Dereference tag repeatedly until we get a non-tag Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2005-07-09 10:00 UTC (permalink / raw
To: Linus Torvalds; +Cc: git
I was playing with a tag that refers to another tag which refers
to a commit, and found out that some things did not work as I
expected.
Is it a PEBCAK on my part to expect tag-to-tag-to-commit to
behave the same way as a bare commit (or a tag to commit), or is
this just a bug? I think the following two would fix what I
found, but I am not sure if I am using the "struct object" and
friends the way they are expected to be used. I am uncertain
about what the expected behaviour should be either for that
matter; I admit that tags are new to me.
---
*** To find whom to ask about the thing I am butchering, I
*** used the following pickaxe:
git-rev-list linus |
git-diff-tree --stdin -v -s \
-S' if (obj->type == tag_type)
obj = ((struct tag *)obj)->tagged;'
git-rev-list linus |
git-diff-tree --stdin -v -s \
-S' /*
* Tag object? Look what it points to..
*/
if (object->type == tag_type) {'
------------
cd /opt/packrat/playpen/public/in-place/git/git.junio/
jit-diff 0:5
# - master: format-patch: fix skipping of blank-lines (take 2)
# + 5: tag deref until we get non tag
diff --git a/commit.c b/commit.c
--- a/commit.c
+++ b/commit.c
@@ -52,8 +52,9 @@ struct commit *lookup_commit_reference(c
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);
}
diff --git a/rev-list.c b/rev-list.c
--- a/rev-list.c
+++ b/rev-list.c
@@ -354,12 +354,12 @@ static struct commit *get_commit_referen
/*
* 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);
}
/*
Compilation finished at Sat Jul 9 02:37:16
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] Dereference tag repeatedly until we get a non-tag.
2005-07-09 10:00 tag referring to a commit but not directly? Junio C Hamano
@ 2005-07-11 6:55 ` Junio C Hamano
2005-07-11 15:14 ` Jon Seymour
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2005-07-11 6:55 UTC (permalink / raw
To: Linus Torvalds; +Cc: git
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>
---
*** Whether having a tag pointing at another tag is a separate
*** issue, but I do not see a reason to forbid it. Maybe it
*** is used to represent a chain of trust.
commit.c | 5 +++--
rev-list.c | 4 ++--
2 files changed, 5 insertions(+), 4 deletions(-)
0dc9377363ee73c5e3f3711d6f82e49886ce8c6a
diff --git a/commit.c b/commit.c
--- a/commit.c
+++ b/commit.c
@@ -52,8 +52,9 @@ struct commit *lookup_commit_reference(c
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);
}
diff --git a/rev-list.c b/rev-list.c
--- a/rev-list.c
+++ b/rev-list.c
@@ -367,12 +367,12 @@ static struct commit *get_commit_referen
/*
* 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);
}
/*
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Dereference tag repeatedly until we get a non-tag.
2005-07-11 6:55 ` [PATCH] Dereference tag repeatedly until we get a non-tag Junio C Hamano
@ 2005-07-11 15:14 ` Jon Seymour
0 siblings, 0 replies; 3+ messages in thread
From: Jon Seymour @ 2005-07-11 15:14 UTC (permalink / raw
To: Junio C Hamano; +Cc: git
This seems reasonable to me. I have thought this would be useful on
several occasions and haven't yet conceived of a counterexample where
it would break something.
On 7/11/05, Junio C Hamano <junkio@cox.net> wrote:
> 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>
> ---
>
> *** Whether having a tag pointing at another tag is a separate
> *** issue, but I do not see a reason to forbid it. Maybe it
> *** is used to represent a chain of trust.
>
> commit.c | 5 +++--
> rev-list.c | 4 ++--
> 2 files changed, 5 insertions(+), 4 deletions(-)
>
> 0dc9377363ee73c5e3f3711d6f82e49886ce8c6a
> diff --git a/commit.c b/commit.c
> --- a/commit.c
> +++ b/commit.c
> @@ -52,8 +52,9 @@ struct commit *lookup_commit_reference(c
>
> 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);
> }
>
> diff --git a/rev-list.c b/rev-list.c
> --- a/rev-list.c
> +++ b/rev-list.c
> @@ -367,12 +367,12 @@ static struct commit *get_commit_referen
> /*
> * 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);
> }
>
> /*
>
> -
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
homepage: http://www.zeta.org.au/~jon/
blog: http://orwelliantremors.blogspot.com/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-07-11 18:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-09 10:00 tag referring to a commit but not directly? Junio C Hamano
2005-07-11 6:55 ` [PATCH] Dereference tag repeatedly until we get a non-tag Junio C Hamano
2005-07-11 15:14 ` Jon Seymour
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).