{"thread":{"id":"46233","subject":"[PATCH] name-rev: Fix tag lookup on repository with mixed types of tags","startedAt":"2017-06-22T19:42:24Z","lastAt":"2017-06-22T22:03:59Z","messageCount":2,"participants":["Orgad Shaneh","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"322973","messageId":"CAGHpTBLXrrt0DykbCQHqp2up_BqOVftc8_8Towi3sDbh3M12LQ@mail.gmail.com","threadId":"46233","inReplyTo":null,"subject":"[PATCH] name-rev: Fix tag lookup on repository with mixed types of tags","fromName":"Orgad Shaneh","fromEmail":"orgads@gmail.com","sentAt":"2017-06-22T19:42:16Z","receivedAt":"2017-06-22T19:42:24Z","isPatch":true,"sender":{"key":"orgads@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1246544?v=4"},"body":"Commit 7550424804 (name-rev: include taggerdate in considering the best\nname) introduced a bug in name-rev.\n\nIf a repository has both annotated and non-annotated tags, annotated\ntag will always win, even if it was created decades after the commit.\n\nConsider a repository that always used non-annotated tags, and at some\npoint started using annotated tags - name-rev --tags will return the\nfirst annotated tags for all the old commits (in our repository it is\nfollowed by ~5067 for one commit, or by ~120^2~21^2~88^2~87 for\nanother...). This is obviously not what the user expects.\n\nThe taggerdate should only be matched if *both tags* have it.\n---\n builtin/name-rev.c | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 92a5d8a5d2..8f77023482 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -46,11 +46,13 @@ static void name_rev(struct commit *commit,\n  commit->util = name;\n  goto copy_data;\n  } else if (name->taggerdate > taggerdate ||\n- (name->taggerdate == taggerdate &&\n+ ((taggerdate == ULONG_MAX || name->taggerdate == taggerdate) &&\n  name->distance > distance)) {\n copy_data:\n  name->tip_name = tip_name;\n- name->taggerdate = taggerdate;\n+ if (taggerdate != ULONG_MAX) {\n+ name->taggerdate = taggerdate;\n+ }\n  name->generation = generation;\n  name->distance = distance;\n  } else\n-- \n2.13.1.windows.1.1.ga36e14b3aa\n"},{"id":"323006","messageId":"xmqq4lv7issd.fsf@gitster.mtv.corp.google.com","threadId":"46233","inReplyTo":"CAGHpTBLXrrt0DykbCQHqp2up_BqOVftc8_8Towi3sDbh3M12LQ@mail.gmail.com","subject":"Re: [PATCH] name-rev: Fix tag lookup on repository with mixed types of tags","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-22T22:03:46Z","receivedAt":"2017-06-22T22:03:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Orgad Shaneh <orgads@gmail.com> writes:\n\n> Commit 7550424804 (name-rev: include taggerdate in considering the best\n> name) introduced a bug in name-rev.\n>\n> If a repository has both annotated and non-annotated tags, annotated\n> tag will always win, even if it was created decades after the commit.\n\nThanks.  It is a problem that light-weight tags are unduly\npenalized, and we attempted to address it a few months ago in a\nslightly different way.  The necessary changes are already in\n'master' but not yet in any released branch.\n\nHere is an entry in the Release Notes for the next release that will\ncome out of the current 'master'.\n\n * \"git describe --contains\" penalized light-weight tags so much that\n   they were almost never considered.  Instead, give them about the\n   same chance to be considered as an annotated tag that is the same\n   age as the underlying commit would.\n   (merge ef1e74065c jc/name-rev-lw-tag later to maint).\n\n"}]}