Repository: vscode
Issue: Git - Built-in Git extension does not respect `includeIf` in a symbolic link directory
Labels: bug,git

<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ -->
<!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ -->
<!-- 🕮 Read our guide about submitting issues: https://github.com/microsoft/vscode/wiki/Submitting-Bugs-and-Suggestions -->
<!-- 🔎 Search existing issues to avoid creating duplicates. -->
<!-- 🧪 Test using the latest Insiders build to see if your issue has already been fixed: https://code.visualstudio.com/insiders/ -->
<!-- 💡 Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. -->
<!-- 🔧 Launch with `code --disable-extensions` to check. -->
Does this issue occur when all extensions are disabled?: Yes

<!-- 🪓 If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. -->
<!-- 📣 Issues caused by an extension need to be reported directly to the extension publisher. The 'Help > Report Issue' dialog can assist with this. -->
- VS Code Version: 1.95.1
- OS Version: 6.12.1.zen
- Git Version: 2.47.1

Steps to Reproduce:

1. Make a directory named `git-includeIf` and initialize Git
2. Make a symbolic link that targets it (`ln -s git-includeIf git-includeIf-ln`)
3. Have Git containing this configurations
   ```
   # ~/.gitconfig
   [includeIf "gitdir:**/git-includeIf-ln/"]
   	path = ~/git-includeIf.inc

   # ~/git-includeIf.inc
   [user]
   	name = John Doe
   	email = john@example.com
   ```
4. Open the `git-includeIf-ln` with VSCode
5. Create any file
6. Source Control -> Stage Changes -> Commit (with any message)
7. See that it failed
8. Open Terminal -> `git commit` (with any message)
9. See that it succeed with VSCode used as editor properly

<details><summary>Logs</summary>
<pre><code>
2024-12-01 20:29:56.116 [info] > git rev-parse --show-toplevel [1ms]
2024-12-01 20:29:56.122 [info] > git rev-parse --path-format=relative --show-toplevel [1ms]
2024-12-01 20:29:56.129 [info] > git rev-parse --git-dir --git-common-dir [1ms]
2024-12-01 20:29:56.148 [info] [Model][openRepository] Opened repository: /home/nexus/git-includeIf-ln
2024-12-01 20:29:56.156 [info] > git fetch [9ms]
2024-12-01 20:29:56.168 [info] > git config --get commit.template [13ms]
2024-12-01 20:29:56.169 [info] > git config --get commit.template [2ms]
2024-12-01 20:29:56.175 [info] [Git][getRemotes] No remotes found in the git config file
2024-12-01 20:29:56.181 [info] [Git][getRemotes] No remotes found in the git config file
2024-12-01 20:29:56.181 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/master refs/remotes/master [6ms]
2024-12-01 20:29:56.181 [warning] [Git][getBranch] No such branch: master
2024-12-01 20:29:56.197 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/master refs/remotes/master [7ms]
2024-12-01 20:29:56.197 [warning] [Git][getBranch] No such branch: master
2024-12-01 20:29:56.198 [error] [GitHistoryProvider][resolveHEADMergeBase] Failed to resolve merge base for master: Error: No such branch: master.
2024-12-01 20:29:56.199 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/master refs/remotes/master [19ms]
2024-12-01 20:29:56.199 [warning] [Git][getBranch] No such branch: master
2024-12-01 20:29:56.202 [info] > git config --get commit.template [5ms]
2024-12-01 20:29:56.208 [info] [Git][getRemotes] No remotes found in the git config file
2024-12-01 20:29:56.209 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/master refs/remotes/master [1ms]
2024-12-01 20:29:56.209 [warning] [Git][getBranch] No such branch: master
2024-12-01 20:29:56.221 [info] > git status -z -uall [6ms]
2024-12-01 20:29:56.222 [info] > git for-each-ref --sort -committerdate --format %(refname) %(objectname) %(*objectname) [2ms]
2024-12-01 20:29:57.241 [info] [Git][getRemotes] No remotes found in the git config file
2024-12-01 20:29:57.242 [info] > git config --get commit.template [7ms]
2024-12-01 20:29:57.242 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/master refs/remotes/master [1ms]
2024-12-01 20:29:57.242 [warning] [Git][getBranch] No such branch: master
2024-12-01 20:29:57.254 [info] > git status -z -uall [6ms]
2024-12-01 20:29:57.255 [info] > git for-each-ref --sort -committerdate --format %(refname) %(objectname) %(*objectname) [2ms]
2024-12-01 20:30:02.264 [info] > git config --get commit.template [1ms]
2024-12-01 20:30:02.272 [info] [Git][getRemotes] No remotes found in the git config file
2024-12-01 20:30:02.273 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/master refs/remotes/master [1ms]
2024-12-01 20:30:02.273 [warning] [Git][getBranch] No such branch: master
2024-12-01 20:30:02.285 [info] > git status -z -uall [6ms]
2024-12-01 20:30:02.287 [info] > git for-each-ref --sort -committerdate --format %(refname) %(objectname) %(*objectname) [1ms]
2024-12-01 20:30:09.486 [info] > git show --textconv :any.file [7ms]
2024-12-01 20:30:09.488 [info] > git ls-files --stage -- /home/nexus/git-includeIf-ln/any.file [3ms]
2024-12-01 20:30:09.732 [info] > git check-ignore -v -z --stdin [1ms]
2024-12-01 20:30:10.318 [info] [Git][getRemotes] No remotes found in the git config file
2024-12-01 20:30:10.319 [info] > git config --get commit.template [8ms]
2024-12-01 20:30:10.320 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/master refs/remotes/master [2ms]
2024-12-01 20:30:10.320 [warning] [Git][getBranch] No such branch: master
2024-12-01 20:30:10.337 [info] > git status -z -uall [9ms]
2024-12-01 20:30:10.339 [info] > git for-each-ref --sort -committerdate --format %(refname) %(objectname) %(*objectname) [3ms]
2024-12-01 20:30:10.884 [info] > git log --format=%H%n%aN%n%aE%n%at%n%ct%n%P%n%D%n%B -z --shortstat --diff-merges=first-parent -n50 --skip=0 --topo-order --decorate=full --stdin [2ms]
2024-12-01 20:30:10.884 [info] fatal: bad revision 'refs/heads/master'
2024-12-01 20:30:10.885 [error] [GitHistoryProvider][provideHistoryItems] Failed to get history items with options '{"historyItemRefs":["refs/heads/master"],"limit":50,"skip":0}': Failed to execute git {
  "exitCode": 128,
  "gitCommand": "log",
  "stdout": "",
  "stderr": "fatal: bad revision 'refs/heads/master'\n"
}
2024-12-01 20:30:39.147 [info] > git add -A -- . [2ms]
2024-12-01 20:30:39.154 [info] > git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file - [2ms]
2024-12-01 20:30:39.154 [info] Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: no email was given and auto-detection is disabled
2024-12-01 20:30:39.162 [info] > git config --get-all user.name [3ms]
2024-12-01 20:30:39.176 [info] [Git][getRemotes] No remotes found in the git config file
2024-12-01 20:30:39.177 [info] > git config --get commit.template [9ms]
2024-12-01 20:30:39.177 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/master refs/remotes/master [1ms]
2024-12-01 20:30:39.178 [warning] [Git][getBranch] No such branch: master
2024-12-01 20:30:39.191 [info] > git status -z -uall [7ms]
2024-12-01 20:30:39.192 [info] > git for-each-ref --sort -committerdate --format %(refname) %(objectname) %(*objectname) [2ms]
2024-12-01 20:30:40.257 [info] [Git][getRemotes] No remotes found in the git config file
2024-12-01 20:30:40.258 [info] > git config --get commit.template [6ms]
2024-12-01 20:30:40.258 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/master refs/remotes/master [2ms]
2024-12-01 20:30:40.258 [warning] [Git][getBranch] No such branch: master
2024-12-01 20:30:40.272 [info] > git status -z -uall [6ms]
2024-12-01 20:30:40.274 [info] > git for-each-ref --sort -committerdate --format %(refname) %(objectname) %(*objectname) [2ms]
2024-12-01 20:30:40.353 [info] > git ls-files --stage -- /home/nexus/git-includeIf-ln/any.file [1ms]
2024-12-01 20:30:40.361 [info] > git cat-file -s e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 [1ms]
2024-12-01 20:30:40.385 [info] > git show --textconv :any.file [11ms]
2024-12-01 20:30:52.772 [info] > git rev-parse --show-toplevel [2ms]
2024-12-01 20:30:52.772 [info] fatal: this operation must be run in a work tree
2024-12-01 20:30:53.630 [info] [Git][getRemotes] No remotes found in the git config file
2024-12-01 20:30:53.631 [info] > git config --get commit.template [7ms]
2024-12-01 20:30:53.631 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/master refs/remotes/master [1ms]
2024-12-01 20:30:53.631 [warning] [Git][getBranch] No such branch: master
2024-12-01 20:30:53.646 [info] > git status -z -uall [9ms]
2024-12-01 20:30:53.647 [info] > git for-each-ref --sort -committerdate --format %(refname) %(objectname) %(*objectname) [2ms]
2024-12-01 20:30:58.770 [info] [Git][getRemotes] No remotes found in the git config file
2024-12-01 20:30:58.770 [info] > git config --get commit.template [7ms]
2024-12-01 20:30:58.771 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/master refs/remotes/master [1ms]
2024-12-01 20:30:58.782 [info] > git status -z -uall [6ms]
2024-12-01 20:30:58.784 [info] > git for-each-ref --sort -committerdate --format %(refname) %(objectname) %(*objectname) [2ms]
2024-12-01 20:30:58.810 [info] > git log --format=%H%n%aN%n%aE%n%at%n%ct%n%P%n%D%n%B -z --shortstat --diff-merges=first-parent -n50 --skip=0 --topo-order --decorate=full --stdin [3ms]
2024-12-01 20:30:58.886 [info] > git show --textconv :any.file [7ms]
2024-12-01 20:30:58.887 [info] > git ls-files --stage -- /home/nexus/git-includeIf-ln/any.file [2ms]
2024-12-01 20:30:58.894 [info] > git cat-file -s e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 [1ms]
2024-12-01 20:30:59.816 [info] [Git][getRemotes] No remotes found in the git config file
2024-12-01 20:30:59.822 [info] > git config --get commit.template [6ms]
2024-12-01 20:30:59.823 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/master refs/remotes/master [1ms]
2024-12-01 20:30:59.836 [info] > git status -z -uall [7ms]
2024-12-01 20:30:59.837 [info] > git for-each-ref --sort -committerdate --format %(refname) %(objectname) %(*objectname) [2ms]
2024-12-01 20:30:59.917 [info] > git ls-files --stage -- /home/nexus/git-includeIf-ln/any.file [1ms]
2024-12-01 20:30:59.925 [info] > git cat-file -s e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 [2ms]
2024-12-01 20:30:59.932 [info] > git show --textconv :any.file [1ms]
</code></pre>
</details>