Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

name-rev: fix names by dropping taggerdate workaround #1468

Closed
wants to merge 1 commit into from

Conversation

newren
Copy link

@newren newren commented Jan 21, 2023

Changes since v2: Fixed nearby comments based on code changes

Changes since v1: Slight tweaks to the commit message

cc: Calvin Wan calvinwan@google.com
cc: Elijah Newren newren@gmail.com

@newren
Copy link
Author

newren commented Jan 21, 2023

/submit

@gitgitgadget
Copy link

gitgitgadget bot commented Jan 21, 2023

Submitted as pull.1468.git.1674275336636.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-1468/newren/fix-name-rev-v1

To fetch this version to local tag pr-1468/newren/fix-name-rev-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-1468/newren/fix-name-rev-v1

@newren newren changed the title name-rev: stop including taggerdate in naming of commits name-rev: fix names by dropping taggerdate workaround Feb 7, 2023
@newren
Copy link
Author

newren commented Feb 7, 2023

/submit

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 7, 2023

Submitted as pull.1468.v2.git.1675751527365.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-1468/newren/fix-name-rev-v2

To fetch this version to local tag pr-1468/newren/fix-name-rev-v2:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-1468/newren/fix-name-rev-v2

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 7, 2023

On the Git mailing list, Calvin Wan wrote (reply to this):

Are there any cases where a taggerdate heuristic would be useful now?
I'm having a hard time coming up with an example of such, so this
change looks very reasonable to me. Even if there existed such a case,
I would imagine it would be better solved using other heuristics rather
than checking the taggerdate since that was a very loose heuristic to
begin with.

> diff --git a/builtin/name-rev.c b/builtin/name-rev.c
> index 15535e914a6..df50abcdeb9 100644
> --- a/builtin/name-rev.c
> +++ b/builtin/name-rev.c
> @@ -113,9 +113,7 @@ static int is_better_name(struct rev_name *name,
>  	 * based on the older tag, even if it is farther away.
>  	 */
>  	if (from_tag && name->from_tag)
> -		return (name->taggerdate > taggerdate ||
> -			(name->taggerdate == taggerdate &&
> -			 name_distance > new_distance));
> +		return name_distance > new_distance;

Comment above this block should be updated to match the new logic.

-Calvin

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 7, 2023

User Calvin Wan <calvinwan@google.com> has been added to the cc: list.

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 8, 2023

On the Git mailing list, Elijah Newren wrote (reply to this):

On Tue, Feb 7, 2023 at 11:34 AM Calvin Wan <calvinwan@google.com> wrote:
>
> Are there any cases where a taggerdate heuristic would be useful now?
> I'm having a hard time coming up with an example of such, so this
> change looks very reasonable to me. Even if there existed such a case,
> I would imagine it would be better solved using other heuristics rather
> than checking the taggerdate since that was a very loose heuristic to
> begin with.

I'm currently only aware of cases where the heuristic hurts and none
where it helps.  I know it historically helped, but that was just a
workaround to the algorithm being suboptimal.  Since the algorithm has
been fixed, I think the workaround can be shelved.

> > diff --git a/builtin/name-rev.c b/builtin/name-rev.c
> > index 15535e914a6..df50abcdeb9 100644
> > --- a/builtin/name-rev.c
> > +++ b/builtin/name-rev.c
> > @@ -113,9 +113,7 @@ static int is_better_name(struct rev_name *name,
> >        * based on the older tag, even if it is farther away.
> >        */
> >       if (from_tag && name->from_tag)
> > -             return (name->taggerdate > taggerdate ||
> > -                     (name->taggerdate == taggerdate &&
> > -                      name_distance > new_distance));
> > +             return name_distance > new_distance;
>
> Comment above this block should be updated to match the new logic.

Good catch; will fix.

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 8, 2023

User Elijah Newren <newren@gmail.com> has been added to the cc: list.

Commit 7550424 ("name-rev: include taggerdate in considering the best
name", 2016-04-22) introduced the idea of using taggerdate in the
criteria for selecting the best name.  At the time, a certain commit in
linux.git -- namely, aed06b9 -- was being named by name-rev as
    v4.6-rc1~9^2~792
which, while correct, was very suboptimal.  Some investigation found
that tweaking the MERGE_TRAVERSAL_WEIGHT to lower it could give
alternate answers such as
    v3.13-rc7~9^2~14^2~42
or
    v3.13~5^2~4^2~2^2~1^2~42
A manual solution involving looking at tagger dates came up with
    v3.13-rc1~65^2^2~42
which is much nicer.  That workaround was then implemented in name-rev.

Unfortunately, the taggerdate heuristic is causing bugs.  I was pointed
to a case in a private repository where name-rev reports a name of the
form
    v2022.10.02~86
when users expected to see one of the form
    v2022.10.01~2
(I've modified the names and numbers a bit from the real testcase.)  As
you can probably guess, v2022.10.01 was created after v2022.10.02 (by a
few hours), even though it pointed to an older commit.  While the
condition is unusual even in the repository in question, it is not the
only problematic set of tags in that repository.  The taggerdate logic
is causing problems.

Further, it turns out that this taggerdate heuristic isn't even helping
anymore.  Due to the fix to naming logic in 3656f84 ("name-rev:
prefer shorter names over following merges", 2021-12-04), we get
improved names without the taggerdate heuristic.  For the original
commit of interest in linux.git, a modern git without the taggerdate
heuristic still provides the same optimal answer of interest, namely:
    v3.13-rc1~65^2^2~42

So, the taggerdate is no longer providing benefit, and it is causing
problems.  Simply get rid of it.

However, note that "taggerdate" as a variable is used to store things
besides a taggerdate these days.  Ever since commit ef1e740
("name-rev: favor describing with tags and use committer date to
tiebreak", 2017-03-29), this has been used to store committer dates and
there it is used as a fallback tiebreaker (as opposed to a primary
criteria overriding effective distance calculations).  We do not want to
remove that fallback tiebreaker, so not all instances of "taggerdate"
are removed in this change.

Signed-off-by: Elijah Newren <newren@gmail.com>
@gitgitgadget
Copy link

gitgitgadget bot commented Feb 8, 2023

This branch is now known as en/name-rev-make-taggerdate-much-less-important.

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 8, 2023

This patch series was integrated into seen via git@19fa6cc.

@gitgitgadget gitgitgadget bot added the seen label Feb 8, 2023
@gitgitgadget
Copy link

gitgitgadget bot commented Feb 8, 2023

This patch series was integrated into seen via git@2547678.

@newren
Copy link
Author

newren commented Feb 9, 2023

/submit

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 9, 2023

Submitted as pull.1468.v3.git.1675933906906.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-1468/newren/fix-name-rev-v3

To fetch this version to local tag pr-1468/newren/fix-name-rev-v3:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-1468/newren/fix-name-rev-v3

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 9, 2023

On the Git mailing list, Junio C Hamano wrote (reply to this):

"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.

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 10, 2023

This patch series was integrated into seen via git@5a21d4f.

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 10, 2023

This patch series was integrated into seen via git@09f61f8.

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 10, 2023

There was a status update in the "New Topics" section about the branch en/name-rev-make-taggerdate-much-less-important on the Git mailing list:

"git name-rev" heuristics update.

Will merge to 'next'.
source: <pull.1468.v3.git.1675933906906.gitgitgadget@gmail.com>

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 10, 2023

This patch series was integrated into seen via git@2c58a9a.

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 10, 2023

This patch series was integrated into next via git@059bc95.

@gitgitgadget gitgitgadget bot added the next label Feb 10, 2023
@gitgitgadget
Copy link

gitgitgadget bot commented Feb 14, 2023

This patch series was integrated into seen via git@0198d16.

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 14, 2023

This patch series was integrated into seen via git@c750225.

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 14, 2023

There was a status update in the "Cooking" section about the branch en/name-rev-make-taggerdate-much-less-important on the Git mailing list:

"git name-rev" heuristics update.

Will merge to 'master'.
source: <pull.1468.v3.git.1675933906906.gitgitgadget@gmail.com>

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 14, 2023

This patch series was integrated into seen via git@a1ddf24.

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 15, 2023

This patch series was integrated into seen via git@d5e62b8.

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 17, 2023

This patch series was integrated into seen via git@d0cb923.

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 17, 2023

This patch series was integrated into seen via git@10f1cf8.

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 22, 2023

This patch series was integrated into seen via git@5fc6d00.

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 22, 2023

This patch series was integrated into master via git@5fc6d00.

@gitgitgadget
Copy link

gitgitgadget bot commented Feb 22, 2023

This patch series was integrated into next via git@5fc6d00.

@gitgitgadget gitgitgadget bot added the master label Feb 22, 2023
@gitgitgadget gitgitgadget bot closed this Feb 22, 2023
@gitgitgadget
Copy link

gitgitgadget bot commented Feb 22, 2023

Closed via 5fc6d00.

@newren newren deleted the fix-name-rev branch March 1, 2023 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant