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

Re: [PATCH] git-prompt: stop manually parsing HEAD

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Nov 24, 2023, 18:28 UTC
Message-ID
<20231124182803.GA11157@szeder.dev>
In-Reply-To
<CAPig+cSa9zxEhKXtXHrVuB3Eb6=vnD1Ppnfj59rA+nPEO-9j-w@mail.gmail.com>
On Fri, Nov 24, 2023 at 01:09:03PM -0500, Eric Sunshine wrote:
Show 23 quoted lines
> On Fri, Nov 24, 2023 at 6:37 AM Patrick Steinhardt <ps@pks.im> wrote:
> > We're manually parsing the HEAD reference in git-prompt to figure out
> > whether it is a symbolic or direct reference. This makes it intimately
> > tied to the on-disk format we use to store references and will stop
> > working once we gain additional reference backends in the Git project.
> >
> > Refactor the code to always use git-symbolic-ref(1) to read HEAD, which
> > is both simpler and compatible with alternate reference backends.
> 
> This may get some push-back from Windows folks due to high
> process-creation cost on that platform. As I recall, over the years, a
> good deal of effort has been put into reducing the number of programs
> run each time the prompt is displayed, precisely because invoking Git
> (or other programs) multiple times became unbearably slow. In
> particular, optimizations efforts have focussed on computing as much
> as possible within the shell itself rather than invoking external
> programs for the same purpose. Thus, this seems to be taking a step
> backwards in that regard for the common or status quo case.
> 
> Would it be possible instead to, within shell, detect if the historic
> file-based backend is being used in the current repository, thus
> continue using the existing shell code for that case, and only employ
> git-symbolic-ref if some other backend is in use?
Thanks for sharing my worries :)

I sent a patch a while ago to Han-Wen to make our Bash prompt script work with the reftable backend without incurring the overhead of extra subshells or processes when using the files based refs backend. He picked it up and used to include it in rerolls of the reftable patch series; the last version of that patch is I believe at:

  https://public-inbox.org/git/patch-v4-21.28-443bdebfb5d-20210823T120208Z-avarab@gmail.com/
Previous: Eric SunshineNext: Patrick Steinhardt
Message 3 of 7 in “git-prompt: stop manually parsing HEAD”
  1. git-prompt: stop manually parsing HEADPatrick Steinhardt, Nov 24, 2023
  2. Eric SunshineNov 24, 2023
  3. SZEDER GáborNov 24, 2023
  4. Patrick SteinhardtDec 1, 2023
  5. git-prompt: stop manually parsing HEAD with unknown ref formatsPatrick Steinhardt, Jan 4, 2024
  6. Oswald BuddenhagenJan 4, 2024
  7. Patrick SteinhardtJan 4, 2024

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.