{"thread":{"id":"53138","subject":"Unexpected tag chosen by git describe","startedAt":"2020-03-31T01:13:06Z","lastAt":"2020-03-31T01:13:06Z","messageCount":1,"participants":["Andrew Fuller"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"394400","messageId":"MWHPR19MB004604CA28B77762DC44E880D5C80@MWHPR19MB0046.namprd19.prod.outlook.com","threadId":"53138","inReplyTo":null,"subject":"Unexpected tag chosen by git describe","fromName":"Andrew Fuller","fromEmail":"afuller@teradici.com","sentAt":"2020-03-31T01:12:57Z","receivedAt":"2020-03-31T01:13:06Z","isPatch":false,"sender":{"key":"afuller@teradici.com","avatar":null},"body":"Twice now we've found ourselves in a situation where git describe chooses a tag that we weren't expecting.  I'm wondering if this is an obscure bug, or whether somehow We're Doing It Wrong.\n\n$ git --version\ngit version 2.25.1\n\n$ git describe --debug --candidates=10\ndescribe HEAD\nNo exact match on refs or tags, searching to describe\n annotated        432 release/20.01.1\n annotated         71 release/20.04.0-rc9\n annotated         75 release/19.11.2\n annotated         77 release/20.04.0-rc8\n annotated         79 release/20.04.0-rc7\n annotated         85 release/20.04.0-rc6\n annotated         87 release/20.04.0-rc5\n annotated         91 release/20.04.0-rc4\n annotated         94 release/2.14.7-rc1\n annotated        121 release/20.04.0-rc3\ntraversed 866 commits\nmore than 10 tags found; listed 10 most recent\ngave up search at 704bbef36b7f66ea0d56ecf4fe1ad9812dfb126a\nrelease/20.01.1-432-gd11dd98b90\n\n$  git describe --debug --candidates=11\ndescribe HEAD\nNo exact match on refs or tags, searching to describe\n annotated         71 release/20.04.0-rc9\n annotated         77 release/20.04.0-rc8\n annotated         79 release/20.04.0-rc7\n annotated         83 release/20.01.1\n annotated         85 release/20.04.0-rc6\n annotated         87 release/20.04.0-rc5\n annotated         91 release/20.04.0-rc4\n annotated        113 release/19.11.2\n annotated        121 release/20.04.0-rc3\n annotated        159 release/2.14.7-rc1\n annotated        171 release/20.04.0-rc2\ntraversed 634 commits\nmore than 11 tags found; listed 11 most recent\ngave up search at 65df08f972d970f0e85dfa5503cb02b48c9238ec\nrelease/20.04.0-rc9-71-gd11dd98b90\n\nSo when git describe looks for the 10 most \"recent\" (I don't claim to know whether that means date, shortest commit distance, fewest commit delta, etc) it finds release/20.01.1 with a weight of 432 and tagged recently and chooses that over release/20.04.0-rc9 which is only weighted 71, but tagged at an earlier time.  Here git describe chose the highest weighted tag when instead we were expecting the lowest weighted tag.\n\nHowever when git describe looks for the 11 most recent, the weightings of some of the tags are actually different.  release/20.01.1 drops from 432 down to 83, and release/19.11.2 rises from 75 to 113.  And then the tag with the lowest weighting is chosen.  We're happy with this result.\n\nSo my question is why is the distant (but fresh) release/20.01.1 tag chosen by git describe when candidates=n is low but we get the tag we expect when candidates=n is high, even though both tags were considered in both scenarios?  A bug or PEBKAC?\n\nThanks,\n-Andrew"}]}