Message ID | pull.1468.v3.git.1675933906906.gitgitgadget@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | b2182a8730a2ad0a214f9118b5bd5d1f39c89544 |
Headers | show |
Series | [v3] name-rev: fix names by dropping taggerdate workaround | expand |
"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes: > - /* > - * When comparing names based on tags, prefer names > - * based on the older tag, even if it is farther away. > - */ > + /* If both are tags, we prefer the nearer one. */ > if (from_tag && name->from_tag) > - return (name->taggerdate > taggerdate || > - (name->taggerdate == taggerdate && > - name_distance > new_distance)); > + return name_distance > new_distance; OK. > - /* > - * We know that at least one of them is a non-tag at this point. > - * favor a tag over a non-tag. > - */ > + /* Favor a tag over a non-tag. */ > if (name->from_tag != from_tag) > return from_tag; The removed sentence is not something whose validity has changed due to the code change. We still know at this point one of from_tag or name->from_tag is false, thanks to the previous check, whose condition did not change (only what is returned when the condition holds changed). But it may be obvious to readers, so, ... OK.
diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 15535e914a6..0ebf06fad5a 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -108,19 +108,11 @@ static int is_better_name(struct rev_name *name, int name_distance = effective_distance(name->distance, name->generation); int new_distance = effective_distance(distance, generation); - /* - * When comparing names based on tags, prefer names - * based on the older tag, even if it is farther away. - */ + /* If both are tags, we prefer the nearer one. */ if (from_tag && name->from_tag) - return (name->taggerdate > taggerdate || - (name->taggerdate == taggerdate && - name_distance > new_distance)); + return name_distance > new_distance; - /* - * We know that at least one of them is a non-tag at this point. - * favor a tag over a non-tag. - */ + /* Favor a tag over a non-tag. */ if (name->from_tag != from_tag) return from_tag; diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh index 9a35e783a75..c9afcef2018 100755 --- a/t/t6120-describe.sh +++ b/t/t6120-describe.sh @@ -657,4 +657,10 @@ test_expect_success 'setup: describe commits with disjoint bases 2' ' check_describe -C disjoint2 "B-3-gHASH" HEAD +test_expect_success 'setup misleading taggerdates' ' + GIT_COMMITTER_DATE="2006-12-12 12:31" git tag -a -m "another tag" newer-tag-older-commit unique-file~1 +' + +check_describe newer-tag-older-commit~1 --contains unique-file~2 + test_done