threads / patch / 46233

patchname-rev: Fix tag lookup on repository with mixed types of tags

Subject: [PATCH] name-rev: Fix tag lookup on repository with mixed types of tags

## tl;dr

2 messages between Jun 22, 2017 and Jun 22, 2017. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Orgad Shaneh· Jun 22, 2017, 19:42 UTC · lore

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.

The taggerdate should only be matched if *both tags* have it.
---
 builtin/name-rev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Show changes to builtin/name-rev.c +4 −2
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 92a5d8a5d2..8f77023482 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -46,11 +46,13 @@ static void name_rev(struct commit *commit,
  commit->util = name;
  goto copy_data;
  } else if (name->taggerdate > taggerdate ||
- (name->taggerdate == taggerdate &&
+ ((taggerdate == ULONG_MAX || name->taggerdate == taggerdate) &&
  name->distance > distance)) {
 copy_data:
  name->tip_name = tip_name;
- name->taggerdate = taggerdate;
+ if (taggerdate != ULONG_MAX) {
+ name->taggerdate = taggerdate;
+ }
  name->generation = generation;
  name->distance = distance;
  } else
-- 
2.13.1.windows.1.1.ga36e14b3aa
Junio C Hamano· Jun 22, 2017, 22:03 UTC · re: Orgad Shaneh · lore

Re: [PATCH] name-rev: Fix tag lookup on repository with mixed types of tags

Orgad Shaneh <orgads@gmail.com> writes:
Show 5 quoted lines
> 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.

Thanks. It is a problem that light-weight tags are unduly penalized, and we attempted to address it a few months ago in a slightly different way. The necessary changes are already in 'master' but not yet in any released branch.

Here is an entry in the Release Notes for the next release that will come out of the current 'master'.

 * "git describe --contains" penalized light-weight tags so much that
   they were almost never considered.  Instead, give them about the
   same chance to be considered as an annotated tag that is the same
   age as the underlying commit would.
   (merge ef1e74065c jc/name-rev-lw-tag later to maint).

← back to recent threads