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

Re: [PATCH] describe: count the distance correctly when commit dates are skewed

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Nov 2, 2026, 18:37 UTC
Message-ID
<CAHk-=wijLfduoJyOM+AW6FS6c02cuEFRAuQWLE+uf7SGhj8jXA@mail.gmail.com>
In-Reply-To
<auiGP4XhObUzC9vD@pks.im>
On Mon, 2 Nov 2026 at 04:47, Patrick Steinhardt <ps@pks.im> wrote:
Show 8 quoted lines
>
> Out of curiosity, how do you calculate the localversion...? *goes
> checking* Ah, you seem to use `git rev-list --count --left-right $tag`,
> so you basically reimplement parts of git-describe(1).
>
> Is there a reason why you use your own script, e.g. because of a missing
> feature? Besides the fact of course that git-describe(1) is buggy in
> this particular case.

I think it's partly historical, and partly because the kernel version has actually always had the full "three number" version without the 'v' (ie the kernel localversion uses "7.3.0" instead of "v7.3")

The kernel localversion is also configurable and wasn't tied to git specifically, so it was never just "git describe". *I* want the git version (and that's what "CONFIG_LOCALVERSION_AUTO" does for the kernel automatically if you are using a git tree), but I think all distros do their own versioning manually).

So there's a whole 'setlocalversion' script in the kernel that does many different cases, and it's all hacky and historical and I actually suspect some of it predates "git describe" even existing.

Show 5 quoted lines
> Hmm. The big downside of this particular change is that you may now get
> different results depending on whether or not you have a recent commit
> graph. So you may get different results based on when git-maintenance(1)
> last decided to update it, and that would in turn result in highly
> puzzling behaviour for the end user.
Well, honestly, no more puzzling than the odd existing behavior. But:
> ... I wonder whether we should also call `ensure_generations_valid()`
> here.

I suspect that is just *way* too expensive in the bad case, but I would hope/assume that any big repo already has generation numbers in it, so maybe it doesn't matter.

Maybe add a "--exact" flag ot something to force it, and just document that without it, you can get slightly odd numbers.

Becasue rigth now, the numbers may be consistent, but when they can be consistently *wrong*, I don't think that's a good thing either. It took me a week of annoyance to even start looking at *why* they were wrong.

            Linus
Previous: Derrick StoleeNext: Patrick Steinhardt
Message 11 of 13 in “describe: count the distance correctly when commit dates are skewed”
  1. describe: count the distance correctly when commit dates are skewedLinus Torvalds, Oct 31, 2026
  2. Tuomas AholaOct 31, 2026
  3. Junio C HamanoNov 1, 2026
  4. Tuomas AholaNov 1, 2026
  5. Junio C HamanoNov 1, 2026
  6. SZEDER GáborNov 2, 2026
  7. Patrick SteinhardtNov 2, 2026
  8. Derrick StoleeNov 2, 2026
  9. Junio C HamanoNov 2, 2026
  10. Derrick StoleeNov 2, 2026
  11. Linus TorvaldsNov 2, 2026
  12. Patrick SteinhardtNov 3, 2026
  13. Linus TorvaldsNov 3, 2026

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.