From: orgads@gmail.com
To: git@vger.kernel.org
Cc: Orgad Shaneh <orgads@gmail.com>
Subject: [PATCH] name-rev: Fix tag lookup on repository with mixed types of tags
Date: Wed, 18 Oct 2017 16:24:20 +0300 [thread overview]
Message-ID: <20171018132420.4577-1-orgads@gmail.com> (raw)
From: Orgad Shaneh <orgads@gmail.com>
Commit 7550424804 (name-rev: include taggerdate in considering the best
name) introduced a bug in name-rev.
If a repository has both annotated and non-annotated tags, annotated
tag will always win, even if it was created decades after the commit.
Consider a repository that always used non-annotated tags, and at some
point started using annotated tags - name-rev --tags will return the
first annotated tags for all the old commits (in our repository it is
followed by ~5067 for one commit, or by ~120^2~21^2~88^2~87 for
another...). This is obviously not what the user expects.
There was an attempt to fix this in ef1e74065, but it is not enough.
The taggerdate should only be matched if *both tags* have it.
Signed-off-by: Orgad Shaneh <orgads@gmail.com>
---
builtin/name-rev.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 9e088ebd11..dc9eaf21fa 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -35,7 +35,7 @@ static int is_better_name(struct rev_name *name,
*/
if (from_tag && name->from_tag)
return (name->taggerdate > taggerdate ||
- (name->taggerdate == taggerdate &&
+ ((taggerdate == TIME_MAX || name->taggerdate == taggerdate) &&
name->distance > distance));
/*
@@ -53,7 +53,7 @@ static int is_better_name(struct rev_name *name,
return name->distance > distance;
/* ... or tiebreak to favor older date */
- if (name->taggerdate != taggerdate)
+ if (taggerdate != TIME_MAX && name->taggerdate != taggerdate)
return name->taggerdate > taggerdate;
/* keep the current one if we cannot decide */
@@ -90,7 +90,8 @@ static void name_rev(struct commit *commit,
generation, distance, from_tag)) {
copy_data:
name->tip_name = tip_name;
- name->taggerdate = taggerdate;
+ if (taggerdate != TIME_MAX)
+ name->taggerdate = taggerdate;
name->generation = generation;
name->distance = distance;
name->from_tag = from_tag;
--
2.14.2.windows.3
next reply other threads:[~2017-10-18 13:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-18 13:24 orgads [this message]
2017-10-19 1:54 ` [PATCH] name-rev: Fix tag lookup on repository with mixed types of tags Junio C Hamano
-- strict thread matches above, loose matches on Subject: below --
2017-06-22 19:52 orgads
2017-06-22 20:38 ` Stefan Beller
2017-06-22 19:42 Orgad Shaneh
2017-06-22 22:03 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171018132420.4577-1-orgads@gmail.com \
--to=orgads@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).