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

Re: git-checkout doesn't seem to respect config from include.path

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Feb 3, 2022, 15:54 UTC
Message-ID
<0b8222c2-7337-7e8f-33d1-7926462daac1@gmail.com>
In-Reply-To
<ee1dd453-e698-440a-911b-d14389e33715@beta.fastmail.com>
Hi Greg
On 02/02/2022 16:04, Greg Hurrell wrote:
Show 38 quoted lines
> Hi,
> 
> Not sure if this is confined specifically to `git-checkout`, but that's
> the command I noticed the issue with:
> 
> With the release of the v2.35.0 and the "zdiff3" setting for
> "merge.conflictStyle", I find myself wanting to use "zdiff3" on machines
> running the new version, and falling back to "diff3" on machines with an
> older version.
> 
> To this end, I have a ~/.gitconfig that contains:
> 
>      [merge]
>      	conflictStyle = zdiff3
>      [include]
>      	path = ~/.gitconfig.local
> 
> The idea is that I can use the same `~/.gitconfig` on every machine I
> use, but on machines that only have an older Git version, I drop in a
> ~/.gitconfig.local with overrides like this:
> 
>      [merge]
>      	conflictStyle = diff3
> 
> `git config --get merge.conflictStyle` correctly reports that my setting is
> "diff3" on such machines, and `git config --get-all merge.conflictStyle`
> shows:
> 
>      diff3
>      zdiff3
> 
> In other words, it knows that I have multiple values set, but it uses
> a last-one-wins policy.
> 
> However, when I try to run a command like `git checkout -b something`,
> Git dies with:
> 
>      fatal: unknown style 'zdiff3' given for 'merge.conflictstyle'

I think what is happening is that git parses each line of the config file as it reads it so the old version of git sees "zdiff3" and errors out before it reads the include line. I'm afraid I don't have any useful suggestions for avoiding this other than switching the include around so that it contains zdiff3 and is only included by newer versions of git.

Show 5 quoted lines
> So, it looks like something in `git-checkout`'s option processing is
> causing it to disregard the override set via "include.path". In fact, it
> even disregards a value passed in with `-c` like this:
> 
>      git -c merge.conflictStyle=diff3 checkout -b something

I think the values passed with -c are parsed after all the config files so the override works. What we really want in this case is to store the string value for each config option as we read each config source and then parse those values at the end, unfortunately I think that would break multi-valued config keys.

Best Wishes
Phillip
Show 6 quoted lines
> Does this sound like a bug, or are my expectations off? I'd be happy to
> look into fixing this, but first would like to know whether it is
> expected behavior.
> 
> Cheers,
> Greg
Previous: Greg HurrellNext: Greg Hurrell
Message 4 of 10 in “git-checkout doesn't seem to respect config from include.path”
  1. Greg HurrellFeb 2, 2022
  2. brian m. carlsonFeb 2, 2022
  3. Greg HurrellFeb 3, 2022
  4. Phillip WoodFeb 3, 2022
  5. Greg HurrellFeb 3, 2022
  6. Greg HurrellFeb 3, 2022
  7. Phillip WoodFeb 7, 2022
  8. Junio C HamanoFeb 3, 2022
  9. Phillip WoodFeb 7, 2022
  10. Junio C HamanoFeb 7, 2022

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.