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

Re: [PATCH v2] var: add GIT_DEFAULT_BRANCH variable

From
Jeff King <peff@peff.net>
Date
Nov 3, 2021, 11:37 UTC
Message-ID
<YYJ0aQ11uHA/XUt3@coredump.intra.peff.net>
In-Reply-To
<211102.86czni1o72.gmgdl@evledraar.gmail.com>
On Tue, Nov 02, 2021 at 05:53:46PM +0100, Ævar Arnfjörð Bjarmason wrote:
Show 10 quoted lines
> The reason I suggested extending "git config" in [1] is because it seems
> like a natural thing for "git config" to learn to spew out our idea of
> default hardcoded config values to the user.
> 
> But creating a variable form of that existing config just so we can have
> "git var" spew it out just seems weird.
> 
> We don't have or need such a variable now for anything else, so why go
> through that indirection, instead of something that closes the feature
> gap of asking what a config variable default is?

To me, the point is that the user is not asking "what is the default value of this config variable?". They are asking "if I were to init a new repository, what would Git decide the default branch name is?".

Right now that is very tied to the config mechanism (modulo the GIT_TEST_* bits, but I think we can ignore those for regular users), so those two are basically the same question. But it doesn't have to be. Abstracting it to the question the user actually wants to ask future-proofs the mechanism.

I.e., I don't think introducing a new variable into "git var" is that big a deal. They don't have to be related to an environment variable; the documentation calls them "logical variables". This is exactly the kind of thing it's designed for.

-Peff
Previous: Thomas WeißschuhNext: Eric Sunshine
Message 9 of 18 in “builtin: add git-default-branch command”
  1. builtin: add git-default-branch commandThomas Weißschuh, Oct 30, 2021
  2. Ævar Arnfjörð BjarmasonOct 30, 2021
  3. Johannes SchindelinNov 2, 2021
  4. var: add GIT_DEFAULT_BRANCH variableThomas Weißschuh, Nov 2, 2021
  5. Ævar Arnfjörð BjarmasonNov 2, 2021
  6. Thomas WeißschuhNov 2, 2021
  7. Ævar Arnfjörð BjarmasonNov 2, 2021
  8. Thomas WeißschuhNov 2, 2021
  9. Jeff KingNov 3, 2021
  10. Eric SunshineNov 3, 2021
  11. Junio C HamanoNov 3, 2021
  12. var: add GIT_DEFAULT_BRANCH variableThomas Weißschuh, Nov 3, 2021
  13. Eric SunshineNov 3, 2021
  14. Junio C HamanoNov 3, 2021
  15. var: add GIT_DEFAULT_BRANCH variableThomas Weißschuh, Nov 3, 2021
  16. Junio C HamanoNov 3, 2021
  17. Junio C HamanoNov 3, 2021
  18. Johannes SchindelinNov 3, 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.