diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-03-15 15:24:44 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-03-15 15:24:44 -0700 |
commit | 0ac54421ff5b7d6a21a61a9e9dfd9fec1486cba6 (patch) | |
tree | 9eaa789112a71f2fbb0e42c7bb83facd29250593 /git-send-email.perl | |
parent | bad6c3b73a6ff3e0e919f94c5ac3b75eb2a47892 (diff) | |
download | git-jc/name-rev-wip.tar.gz |
name-rev: favor describing with tags and use committer date to tiebreakjc/name-rev-wip
"git name-rev" assigned a phony "far in the future" date to tips of
refs that are not pointing at tag objects, and favored names based
on a ref with the oldest date. This made it almost impossible for
an unannotated tags and branches to be counted as a viable base,
which was especially problematic when the command is run with the
"--tags" option. If an unannotated tag that points at an ancient
commit and an annotated tag that points at a much newer commit
reaches the commit that is being named, the old unannotated tag was
ignored.
Update the "taggerdate" field of the rev-name structure, which is
initialized from the tip of ref, to have the committer date if the
object at the tip of ref is a commit, not a tag, so that we can
optionally take it into account when doing "is this name better?"
comparison logic.
When "name-rev" is run without the "--tags" option, the general
expectation is still to name the commit based on a tag if possible,
but use non-tag refs as fallback, and tiebreak among these non-tag
refs by favoring names with shorter hops from the tip. The use of a
phony "far in the future" date in the original code was an effective
way to ensure this expectation is held: a non-tag tip gets the same
"far in the future" timestamp, giving precedence to tags, and among
non-tag tips, names with shorter hops are preferred over longer
hops, without taking the "taggerdate" into account. As we are
taking over the "taggerdate" field to store the committer date for
tips with commits:
(1) keep the original logic when comparing names based on two refs
both of which are from refs/tags/;
(2) favoring a name based on a ref in refs/tags/ hierarchy over
a ref outside the hierarchy;
(3) between two names based on a ref both outside refs/tags/, give
precedence to a name with shorter hops and use "taggerdate"
only to tie-break.
A change to t4202 is a natural consequence. The test creates a
commit on a branch "side" and points at it with an unannotated tag
"refs/tags/side-2". The original code couldn't decide which one to
favor at all, and gave a name based on a branch (simply because
refs/heads/side sorts earlier than refs/tags/side-2). Because the
updated logic is taught to favor refs in refs/tags/ hierarchy, the
the test is updated to expect to see tags/side-2 instead.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
* I am sure others can add better heurisitics in is_better_name()
for comparing names based on non-tag refs, and I do not mind
people disagreeing with the logic that this patch happens to
implement. This is done primarily to illustrate the value of
using a separate helper function is_better_name() instead of
open-coding the selection logic in name_rev() function.
Diffstat (limited to 'git-send-email.perl')
0 files changed, 0 insertions, 0 deletions