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

Re: [PATCH v4] var: add GIT_DEFAULT_BRANCH variable

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 3, 2021, 20:23 UTC
Message-ID
<xmqq1r3x6l9q.fsf@gitster.g>
In-Reply-To
<20211103201702.117771-1-thomas@t-8ch.de>
Thomas Weißschuh <thomas@t-8ch.de> writes:
> Introduce the logical variable GIT_DEFAULT_BRANCH which represents the
> the default branch name that will be used by "git init".

Sorry for not realizing this earlier, but we are not reporting the "default" with this feature. If you have ~/.gitconfig with your favourite configuration in it, what this reports is the name of the branch created by "git init" without the "--initial-branch=<name>" option.

So GIT_INITIAL_BRANCH_NAME might be a more appropriate name for the variable from that realization. But I do not feel too strongly about it, so let's not keep rerolling but see what others think first.

Thanks.  Will queue this version as-is.  The updated test looks good.
Show 25 quoted lines
> +test_expect_success 'get GIT_DEFAULT_BRANCH without configuration' '
> +	(
> +		sane_unset GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME &&
> +		git init defbranch &&
> +		git -C defbranch symbolic-ref --short HEAD >expect &&
> +		git var GIT_DEFAULT_BRANCH >actual &&
> +		test_cmp expect actual
> +	)
> +'
> +
> +test_expect_success 'get GIT_DEFAULT_BRANCH with configuration' '
> +	test_config init.defaultbranch foo &&
> +	(
> +		sane_unset GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME &&
> +		echo foo >expect &&
> +		git var GIT_DEFAULT_BRANCH >actual &&
> +		test_cmp expect actual
> +	)
> +'
> +
>  # For git var -l, we check only a representative variable;
>  # testing the whole output would make our test too brittle with
>  # respect to unrelated changes in the test suite's environment.
>
> base-commit: 0cddd84c9f3e9c3d793ec93034ef679335f35e49
Previous: Thomas WeißschuhNext: Junio C Hamano
Message 16 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.