VSCodium version: 1.75.1, 1.76
Problem: switching to a different branch shows makes editor think that files were changed, but not commited.
There are no uncommited files/changes in my repository. Source control tab does not show any uncommited changes and git diff returns nothing. It's as if it's comparing the current branch to the one that I was on before opening the editor. Same happens if I switch the branch using git switch externally, from terminal.
The only way to "fix" this issue is to call a fill VSCode window reload, but if I switch to a different branch after that - the issue appears again. I tried creating a demo repo to show this issue, but it was not reproduced.
UPD1: here is what it looks like:
Before this I switched to a different branch (say from develop branch to a feature-1) and hit refresh on source control.
UPD2: VSCode git output from a repo that works fine
2023-03-05 17:02:53.265 [info] > git checkout -q lineageos-19.1 [796ms]
2023-03-05 17:02:53.273 [info] > git config --get commit.template [3ms]
2023-03-05 17:02:53.273 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/lineageos-19.1 refs/remotes/lineageos-19.1 [1ms]
2023-03-05 17:02:53.397 [info] > git status -z -uall [121ms]
2023-03-05 17:02:54.496 [info] > git ls-files --stage -- /mnt/sdb2/Kernels/SAKE_Kernel/drivers/cpufreq/qcom-cpufreq-hw.c [4ms]
2023-03-05 17:02:54.502 [info] > git cat-file -s 98f9456f8697fa03731b9db72b22d264ea51219d [1ms]
2023-03-05 17:02:54.513 [info] > git show --textconv :drivers/cpufreq/qcom-cpufreq-hw.c [5ms]
2023-03-05 17:03:00.801 [info] > git for-each-ref --sort -committerdate --format %(refname) %(objectname) %(*objectname) [78ms]
2023-03-05 17:03:01.993 [info] > git checkout -q lineage-19.1-yaro [141ms]
2023-03-05 17:03:02.000 [info] > git config --get commit.template [3ms]
2023-03-05 17:03:02.004 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/lineage-19.1-yaro refs/remotes/lineage-19.1-yaro [1ms]
2023-03-05 17:03:02.130 [info] > git status -z -uall [123ms]
2023-03-05 17:03:03.228 [info] > git ls-files --stage -- /mnt/sdb2/Kernels/SAKE_Kernel/drivers/cpufreq/qcom-cpufreq-hw.c [4ms]
2023-03-05 17:03:03.232 [info] > git cat-file -s 6a3f6cff159509b868f1ec14c97fc17fbaebdf86 [1ms]
2023-03-05 17:03:03.243 [info] > git show --textconv :drivers/cpufreq/qcom-cpufreq-hw.c [5ms]
2023-03-05 17:03:06.027 [info] > git check-ignore -v -z --stdin [27ms]
2023-03-05 17:03:11.230 [info] > git ls-files --stage -- /mnt/sdb2/Kernels/SAKE_Kernel/drivers/cpufreq/qcom-cpufreq-hw.c [5ms]
2023-03-05 17:03:11.236 [info] > git cat-file -s 6a3f6cff159509b868f1ec14c97fc17fbaebdf86 [1ms]
2023-03-05 17:03:11.251 [info] > git show --textconv :drivers/cpufreq/qcom-cpufreq-hw.c [5ms]
2023-03-05 17:03:11.675 [info] > git fetch [1637ms]
2023-03-05 17:03:11.683 [info] > git config --get commit.template [4ms]
2023-03-05 17:03:11.684 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/lineage-19.1-yaro refs/remotes/lineage-19.1-yaro [1ms]
2023-03-05 17:03:11.801 [info] > git status -z -uall [113ms]
2023-03-05 17:03:12.740 [info] > git ls-files --stage -- /mnt/sdb2/Kernels/SAKE_Kernel/drivers/cpufreq/qcom-cpufreq-hw.c [4ms]
2023-03-05 17:03:12.744 [info] > git cat-file -s 6a3f6cff159509b868f1ec14c97fc17fbaebdf86 [1ms]
2023-03-05 17:03:12.755 [info] > git show --textconv :drivers/cpufreq/qcom-cpufreq-hw.c [5ms]
And here is from a broken one:
2023-03-05 15:57:40.780 [info] > git checkout -q <branch name> [220ms]
2023-03-05 15:57:40.789 [info] > git config --get commit.template [4ms]
2023-03-05 15:57:40.789 [info] > git for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) refs/heads/<branch name> refs/remotes/<branch name> [1ms]
2023-03-05 15:57:40.795 [info] > git status -z -uall [2ms]
UPD3: I was able to narrow it down a little bit:
- The issue is reproduced only in repos where .git is a symlink to another folder (I am working in AOSP repos)
- Repos that do not have symlinks are not affected
- I finally learned that those bars are called git gutters
- Opened an issue in the official VSCode issue tracker: https://github.com/microsoft/vscode/issues/176497
UPD4: as a workaround I made the following script and added it to vscode's settings.json ("git.path": "/home/yaro/set-actual-git-dir"):
#!/bin/bash
git --git-dir="$(realpath .git/)" "${@}"
UPD5: git blame extension stopped working after the workaround from UPD4 so I had to update it:
#!/bin/bash
if [ -z "$VSCODE_GIT_COMMAND" ]; then
git "${@}"
else
git --git-dir="$(realpath .git/)" "${@}"
fi
Now it only sets --git-dir for VSCODE commands and not for extensions (at least not for git blame that I use: https://github.com/Sertion/vscode-gitblame/)