git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] name-rev: prefer shorter names over following merges

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Nov 13, 2021, 09:42 UTC
Message-ID
<211113.86pmr4tm7p.gmgdl@evledraar.gmail.com>
In-Reply-To
<pull.1119.git.git.1636762454792.gitgitgadget@gmail.com>
On Sat, Nov 13 2021, Elijah Newren via GitGitGadget wrote:
Show 42 quoted lines
> From: Elijah Newren <newren@gmail.com>
>
> name-rev has a MERGE_TRAVERSAL_WEIGHT to say that traversing a second or
> later parent of a merge should be 65535 times more expensive than a
> first-parent traversal, as per ac076c29ae8d (name-rev: Fix non-shortest
> description, 2007-08-27).  The point of this weight is to prefer names
> like
>
>     v2.32.0~1471^2
>
> over names like
>
>     v2.32.0~43^2~15^2~11^2~20^2~31^2
>
> which are two equally valid names in git.git for the same commit.  Note
> that the first follows 1472 parent traversals compared to a mere 125 for
> the second.  Weighting all traversals equally would clearly prefer the
> second name since it has fewer parent traversals, but humans aren't
> going to be traversing commits and they tend to have an easier time
> digesting names with fewer segments.  The fact that the former only has
> two segments (~1471, ^2) makes it much simpler than the latter which has
> six segments (~43, ^2, ~15, etc.).  Since name-rev is meant to "find
> symbolic names suitable for human digestion", we prefer fewer segments.
>
> However, the particular rule implemented in name-rev would actually
> prefer
>
>     v2.33.0-rc0~11^2~1
>
> over
>
>     v2.33.0-rc0~20^2
>
> because both have precisely one second parent traversal, and it gives
> the tie breaker to shortest number of total parent traversals.  Fewer
> segments is more important for human consumption than number of hops, so
> we'd rather see the latter which has one fewer segment.
>
> Include the generation in is_better_name() and use a new
> effective_distance() calculation so that we prefer fewer segments in
> the printed name over fewer total parent traversals performed to get the
> answer.

So it's the case that if you were to print out the output of "git log --graph --oneline" for these ranges and draw the path we'd take for either variant of these examples we'd take different path, i.e. the first version takes the ^1 parent every time, and the second traverses various ^2 parents.

I think this change looks good in the context of name-rev, but I wonder if longer names wouldn't be easier to understand in some cases, i.e. you'd more clearly get an idea of how this change was tangled up with other topics.

Does one or the other of these versions provide a better hint for the "this branch is used by" relationships in What's Cooking?

Previous: Elijah Newren via GitGitGadgetNext: Elijah Newren
Message 2 of 7 in “name-rev: prefer shorter names over following merges”
  1. name-rev: prefer shorter names over following mergesElijah Newren via GitGitGadget, Nov 13, 2021
  2. Ævar Arnfjörð BjarmasonNov 13, 2021
  3. Elijah NewrenNov 13, 2021
  4. Johannes SchindelinNov 16, 2021
  5. Junio C HamanoNov 17, 2021
  6. name-rev: prefer shorter names over following mergesElijah Newren via GitGitGadget, Dec 4, 2021
  7. Johannes SchindelinDec 8, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.