Skip to content

includeIf broken in 2.25.0 64bit #2510

Closed

Description

@Russ-K
  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options

git version 2.25.0.windows.1
cpu: x86_64
built from commit: 7c71c859c97853ed057da5cbab12f3c13b5554df
sizeof-long: 4
sizeof-size_t: 8
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.17763.973]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

Editor Option: VisualStudioCode
Custom Editor Path:
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Use Credential Manager: Disabled
Enable Symlinks: Disabled

  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

Don't think so

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

cmd / powershell / gitbash

git config --list --show-origin
  • What did you expect to occur after running these commands?

the additional git config file would be included as per the includeIf rule

  • What actually happened instead?

additional git config file is not included

  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

all repos

  • Further details

I can fix the issue by going to an earlier version and I've tried a few:

  • 2.24.1.2
  • 2.23.0
  • 2.20.1
  • 2.15.1.2

As soon as I upgrade to 2.25.0, the includeIf stops working. Then I roll back to an earlier version of git and it starts working again. I can switch between working and not working by reinstalling the different versions. I'm currently back on 2.24.1.2 and everything is working fine.

Activity

  1. dscho commented on Feb 6, 2020

    @dscho
    Member

    the additional git config file would be included as per the includeIf rule

    That sounds interesting, if a little vague. Can you construct a config that displays the issue?

  2. dscho commented on Feb 6, 2020

    @dscho
    Member

    Can you construct a config that displays the issue?

    (By that, I mean a config that I can drop into a freshly git inited worktree to try to repro on my side?)

  3. Russ-K commented on Feb 7, 2020

    @Russ-K
    Author

    ok, sorry, there is a bit more to this...
    And it looks like it's only broken for mapped drives.

    C: is a normal drive
    W: is a mapped drive (actually maps to c:\work)

    I have the following folder / file structure:

    C:\Users\Redacted\.gitconfig
    
    C:\personal
    C:\personal\.gitconfig
    C:\personal\repoa
    C:\personal\repoa\.git <-- empty initialised git repo
    
    W:\corp1
    W:\corp1\.gitconfig
    W:\corp1\repob
    W:\corp1\repob\.git <-- empty initialised git repo
    

    C:\Users\Redacted\.gitconfig looks like this:

    [includeIf "gitdir/i:C:/personal/"]
    	path = C:/personal/.gitconfig
    [includeIf "gitdir/i:W:/corp1/"]
    	path = W:/corp1/.gitconfig
    
    [user]
    	name = Peter Piper
    

    C:\personal\.gitconfig looks like this:

    [user]
    	name = Mr Smith
    	email = Smith@personal.com
    

    W:\corp1\.gitconfig looks like this:

    [user]
    	name = Joe Bloggs
    	email = Joe.Bloggs@corporate.co.uk
    

    Using the following command in each folder:
    git config --list --show-origin

    2.25.0.windows.1

    This is what I get on 2.25.0.windows.1 in C:\personal\repoa (this is working fine)

    file:C:/Program Files/Git/etc/gitconfig http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
    file:C:/Program Files/Git/etc/gitconfig http.sslbackend=openssl
    file:C:/Program Files/Git/etc/gitconfig diff.astextplain.textconv=astextplain
    file:C:/Program Files/Git/etc/gitconfig filter.lfs.clean=git-lfs clean -- %f
    file:C:/Program Files/Git/etc/gitconfig filter.lfs.smudge=git-lfs smudge -- %f
    file:C:/Program Files/Git/etc/gitconfig filter.lfs.process=git-lfs filter-process
    file:C:/Program Files/Git/etc/gitconfig filter.lfs.required=true
    file:C:/Program Files/Git/etc/gitconfig core.autocrlf=true
    file:C:/Program Files/Git/etc/gitconfig core.fscache=true
    file:C:/Program Files/Git/etc/gitconfig core.symlinks=false
    file:C:/Program Files/Git/etc/gitconfig core.editor="C:\\Program Files\\Microsoft VS Code\\Code.exe" --wait
    file:C:/Users/Redacted/.gitconfig  includeif.gitdir/i:C:/personal/.path=C:/personal/.gitconfig
    file:C:/personal/.gitconfig     user.name=Mr Red
    file:C:/personal/.gitconfig     user.email=Red@personal.com
    file:C:/Users/Redacted/.gitconfig  includeif.gitdir/i:W:/corp1/.path=W:/corp1/.gitconfig
    file:C:/Users/Redacted/.gitconfig  user.name=Peter Piper
    file:.git/config        core.repositoryformatversion=0
    file:.git/config        core.filemode=false
    file:.git/config        core.bare=false
    file:.git/config        core.logallrefupdates=true
    file:.git/config        core.symlinks=false
    file:.git/config        core.ignorecase=true
    
    

    This is what I get on 2.25.0.windows.1 in W:\corp1\repob (this is broken)

    file:C:/Program Files/Git/etc/gitconfig http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
    file:C:/Program Files/Git/etc/gitconfig http.sslbackend=openssl
    file:C:/Program Files/Git/etc/gitconfig diff.astextplain.textconv=astextplain
    file:C:/Program Files/Git/etc/gitconfig filter.lfs.clean=git-lfs clean -- %f
    file:C:/Program Files/Git/etc/gitconfig filter.lfs.smudge=git-lfs smudge -- %f
    file:C:/Program Files/Git/etc/gitconfig filter.lfs.process=git-lfs filter-process
    file:C:/Program Files/Git/etc/gitconfig filter.lfs.required=true
    file:C:/Program Files/Git/etc/gitconfig core.autocrlf=true
    file:C:/Program Files/Git/etc/gitconfig core.fscache=true
    file:C:/Program Files/Git/etc/gitconfig core.symlinks=false
    file:C:/Program Files/Git/etc/gitconfig core.editor="C:\\Program Files\\Microsoft VS Code\\Code.exe" --wait
    file:C:/Users/Redacted/.gitconfig  includeif.gitdir/i:C:/personal/.path=C:/personal/.gitconfig
    file:C:/Users/Redacted/.gitconfig  includeif.gitdir/i:W:/corp1/.path=W:/corp1/.gitconfig
    file:C:/Users/Redacted/.gitconfig  user.name=Peter Piper
    file:.git/config        core.repositoryformatversion=0
    file:.git/config        core.filemode=false
    file:.git/config        core.bare=false
    file:.git/config        core.logallrefupdates=true
    file:.git/config        core.symlinks=false
    file:.git/config        core.ignorecase=true
    
    

    2.24.1.windows.2

    And if I revert to 2.24.1.windows.2 and change nothing else then in C:\personal\repoa (this is working fine)

    file:C:/Program Files/Git/etc/gitconfig http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
    file:C:/Program Files/Git/etc/gitconfig http.sslbackend=openssl
    file:C:/Program Files/Git/etc/gitconfig diff.astextplain.textconv=astextplain
    file:C:/Program Files/Git/etc/gitconfig filter.lfs.clean=git-lfs clean -- %f
    file:C:/Program Files/Git/etc/gitconfig filter.lfs.smudge=git-lfs smudge -- %f
    file:C:/Program Files/Git/etc/gitconfig filter.lfs.process=git-lfs filter-process
    file:C:/Program Files/Git/etc/gitconfig filter.lfs.required=true
    file:C:/Program Files/Git/etc/gitconfig core.autocrlf=true
    file:C:/Program Files/Git/etc/gitconfig core.fscache=true
    file:C:/Program Files/Git/etc/gitconfig core.symlinks=false
    file:C:/Program Files/Git/etc/gitconfig core.editor="C:\\Program Files\\Microsoft VS Code\\Code.exe" --wait
    file:C:/Users/Redacted/.gitconfig  includeif.gitdir/i:C:/personal/.path=C:/personal/.gitconfig
    file:C:/personal/.gitconfig     user.name=Mr Red
    file:C:/personal/.gitconfig     user.email=Red@personal.com
    file:C:/Users/Redacted/.gitconfig  includeif.gitdir/i:W:/corp1/.path=W:/corp1/.gitconfig
    file:C:/Users/Redacted/.gitconfig  user.name=Peter Piper
    file:C:/Users/Redacted/.gitconfig  includeif.gitdir:W:/inps/.path=W:/inps/.gitconfig
    file:.git/config        core.repositoryformatversion=0
    file:.git/config        core.filemode=false
    file:.git/config        core.bare=false
    file:.git/config        core.logallrefupdates=true
    file:.git/config        core.symlinks=false
    file:.git/config        core.ignorecase=true
    

    and in W:\corp1\repob (this is working fine)

    file:C:/Program Files/Git/etc/gitconfig http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
    file:C:/Program Files/Git/etc/gitconfig http.sslbackend=openssl
    file:C:/Program Files/Git/etc/gitconfig diff.astextplain.textconv=astextplain
    file:C:/Program Files/Git/etc/gitconfig filter.lfs.clean=git-lfs clean -- %f
    file:C:/Program Files/Git/etc/gitconfig filter.lfs.smudge=git-lfs smudge -- %f
    file:C:/Program Files/Git/etc/gitconfig filter.lfs.process=git-lfs filter-process
    file:C:/Program Files/Git/etc/gitconfig filter.lfs.required=true
    file:C:/Program Files/Git/etc/gitconfig core.autocrlf=true
    file:C:/Program Files/Git/etc/gitconfig core.fscache=true
    file:C:/Program Files/Git/etc/gitconfig core.symlinks=false
    file:C:/Program Files/Git/etc/gitconfig core.editor="C:\\Program Files\\Microsoft VS Code\\Code.exe" --wait
    file:C:/Users/Redacted/.gitconfig  includeif.gitdir/i:C:/personal/.path=C:/personal/.gitconfig
    file:C:/Users/Redacted/.gitconfig  includeif.gitdir/i:W:/corp1/.path=W:/corp1/.gitconfig
    file:W:/corp1/.gitconfig        user.name=Joe Bloggs
    file:W:/corp1/.gitconfig        user.email=Joe.Bloggs@corporate.co.uk
    file:C:/Users/Redacted/.gitconfig  user.name=Peter Piper
    file:.git/config        core.repositoryformatversion=0
    file:.git/config        core.filemode=false
    file:.git/config        core.bare=false
    file:.git/config        core.logallrefupdates=true
    file:.git/config        core.symlinks=false
    file:.git/config        core.ignorecase=true
    
    

    The difference being that running the command in W:\corp1\repob on 2.24.1.windows.2 these additional 2 lines are shown

    file:W:/corp1/.gitconfig        user.name=Joe Bloggs
    file:W:/corp1/.gitconfig        user.email=Joe.Bloggs@corporate.co.uk
    

    Hope that helps narrow it down.
    Let me know if you need any further details.

  4. dscho commented on Feb 9, 2020

    @dscho
    Member

    And it looks like it's only broken for mapped drives.

    Oooh, this is interesting, as I fixed another bug for mapped drives recently. Could you test with the latest snapshot? You can use the Portable Git if you don't want to mess with your current installed Git.

  5. Russ-K commented on Feb 10, 2020

    @Russ-K
    Author

    Using version:
    2.25.0.windows.1.17.g89a5bbfd1e

    The issue still exists.

  6. dscho commented on Feb 10, 2020

    @dscho
    Member

    Thanks for testing!

  7. Russ-K commented on Feb 10, 2020

    @Russ-K
    Author

    No worries, let me know if you need me to test more.

  8. dscho commented on Feb 10, 2020

    @dscho
    Member

    ok, sorry, there is a bit more to this...

    I thought so.

    And it looks like it's only broken for mapped drives.

    Okay, that is a good find!

    C: is a normal drive
    W: is a mapped drive (actually maps to c:\work)

    So an MCVE would start by subst W: C:\work or something.

    The problem is that we actually fixed a bug here: symlinked git dirs are now resolved properly. And that fix implies that the gitdir for W:\... is now resolved to C:\work\..., too.

  9. dscho commented on Feb 10, 2020

    @dscho
    Member

    @Russ-K to understand what I mean, please run git rev-parse --git-dir in W:\... both with v2.25.0 and with any previous Git for Windows version. You will see that v2.25.0 successfully figures out the actual Git directory while previous versions did not...

    Now, arguably we could try to let Git be smart and to resolve the path provided via includeIf. That is an option, but it is not totally trivial, as the argument is actually allowed to contain wildcards. And if you have NTFS junctions, that means that you simply cannot resolve something like W:/abc/**/hello, as there might be an NTFS junction under W:/abc/ that makes things resolve to a totally different location.

  10. dscho commented on Feb 10, 2020

    @dscho
    Member

    Now, arguably we could try to let Git be smart and to resolve the path provided via includeIf.

    @Russ-K so if you want to go along those lines (with the caveat that it cannot be complete for wildcards), you could do something like this:

    diff --git a/config.c b/config.c
    index 65c19f953ba..ba6cfc4031f 100644
    --- a/config.c
    +++ b/config.c
    @@ -205,6 +205,13 @@ static int prepare_include_condition_pattern(struct strbuf *pat)
     		prefix = slash - path.buf + 1 /* slash */;
     	} else if (!is_absolute_path(pat->buf))
     		strbuf_insert(pat, 0, "**/", 3);
    +	else if (file_exists(pat->buf)) {
    +		strbuf_realpath(&path, pat->buf, 1);
    +		if (pat->len && is_dir_sep(pat->buf[pat->len - 1]))
    +			strbuf_complete(&path, '/');
    +		strbuf_swap(&path,pat);
    +		prefix = (int)pat->len;
    +	}
     
     	add_trailing_starstar_for_dir(pat);
     

    To play with this,

    1. install Git for Windows' SDK,
    2. sdk cd git,
    3. apply the patch
    4. build Git via make -j$(nproc)
    5. test in-place via ./git --exec-path="$PWD" -C <directory> <command>?
    6. write an excellent commit message
    7. open a PR?
  11. dscho commented on Feb 10, 2020

    @dscho
    Member

    Now, arguably we could try to let Git be smart and to resolve the path provided via includeIf.

    @Russ-K so if you want to go along those lines (with the caveat that it cannot be complete for wildcards), you could do something like this:

    diff --git a/config.c b/config.c
    index 65c19f953ba..ba6cfc4031f 100644
    --- a/config.c
    +++ b/config.c
    @@ -205,6 +205,13 @@ static int prepare_include_condition_pattern(struct strbuf *pat)
     		prefix = slash - path.buf + 1 /* slash */;
     	} else if (!is_absolute_path(pat->buf))
     		strbuf_insert(pat, 0, "**/", 3);
    +	else if (file_exists(pat->buf)) {
    +		strbuf_realpath(&path, pat->buf, 1);
    +		if (pat->len && is_dir_sep(pat->buf[pat->len - 1]))
    +			strbuf_complete(&path, '/');
    +		strbuf_swap(&path,pat);
    +		prefix = (int)pat->len;
    +	}
     
     	add_trailing_starstar_for_dir(pat);
     

    To play with this,

    1. install Git for Windows' SDK,
    2. sdk cd git,
    3. apply the patch
    4. build Git via make -j$(nproc)
    5. test in-place via ./git --exec-path="$PWD" -C <directory> <command>?
    6. write an excellent commit message
    7. open a PR?
  12. dscho commented on Mar 7, 2020

    @dscho
    Member

    Well, this is disappointing. No effort whatsoever? I should not have bothered.

  13. Russ-K commented on Mar 9, 2020

    @Russ-K
    Author

    Apologies, I have a day job and I spent a lot of time identifying the exact scenario for the issue.

    I will try to look at this soon as I still require it but as you've identified a workaround, it is of less importance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions