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

Re: [PATCH 1/2] remote: add camel-cased *.tagOpt key, like clone

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 25, 2021, 03:16 UTC
Message-ID
<xmqqwnuwx2ea.fsf@gitster.g>
In-Reply-To
<20210225012117.17331-1-avarab@gmail.com>
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
> It's easy enough to add a test for this, so let's do that. We can't
> use "git config -l" there, because it'll normalize the keys to their
> lower-cased form.

I wondered if we want "git config -l --preserve-case" or something like that, but an extra grep for "tagOpt" would be sufficient in a simple test like these that are unlikely to have unrelated tagOpt defined in the file. More importantly, I am starting to doubt if this should even be tested.

If there were existing "section.varname" variable definition and we ask

	git_config_set("section.varName", "newvalue");

we may end up with "[section] varname = newvalue", and that is perfectly OK, I would think, because the first and the last component of the configuration variable names are defined to be case insensitive, and here may be "[Section] varname = oldvalue" in the configuration file before we try to set it, and the implementation is free to replace "oldvalue" with "newvalue", instead of first removing "[Section] varname = oldvalue" and then adding a new "[section] varName = newvalue" (after all, there may be variables other than "varname" in the section, and the existing "[Section]" header may need to be kept for the remaining variables while we futz with the varname or varName).

Which means that while we do want to spell the names in our source code correctly (i.e. "tagOpt", not "tagopt") when we tell which variable we want to get modified to the git_config_set() function, we should not care how exactly git_config_set() chooses to spell the variable in the resulting configuration file, no?

So, ...
Show 11 quoted lines
> diff --git a/t/t5612-clone-refspec.sh b/t/t5612-clone-refspec.sh
> index 6a6af7449ca..3126cfd7e9d 100755
> --- a/t/t5612-clone-refspec.sh
> +++ b/t/t5612-clone-refspec.sh
> @@ -97,6 +97,7 @@ test_expect_success 'by default no tags will be kept updated' '
>  test_expect_success 'clone with --no-tags' '
>  	(
>  		cd dir_all_no_tags &&
> +		grep tagOpt .git/config &&
>  		git fetch &&
>  		git for-each-ref refs/tags >../actual

...as long as "git config remote.origin.tagopt" yields what we expect, we should be OK, I would think. Insisting that the variable name is kept by git_config_set() API may be expecting too much.

>  	) &&
Previous: Junio C HamanoNext: Ævar Arnfjörð Bjarmason
Message 6 of 8 in “remote: add camel-cased *.tagOpt key, like clone”
  1. 1/2 remote: add camel-cased *.tagOpt key, like cloneÆvar Arnfjörð Bjarmason, Feb 25, 2021
  2. 2/2 remote: write camel-cased *.pushRemote on renameÆvar Arnfjörð Bjarmason, Feb 25, 2021
  3. Junio C HamanoFeb 25, 2021
  4. Bert WesargMar 18, 2021
  5. Junio C HamanoFeb 25, 2021
  6. Junio C HamanoFeb 25, 2021
  7. Ævar Arnfjörð BjarmasonFeb 25, 2021
  8. Junio C HamanoFeb 25, 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.