microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.23k stars 28.56k forks source link

Git repository auto-detection not working for junctions on windows #144780

Open pm-ur opened 2 years ago

pm-ur commented 2 years ago

Issue Type: Bug

My current use-case is a multi-root workspace, where one of the workspaces (a source workspace) contains junctions that point to git worktree folders. Since last few releases, the Source Control tab doesn't detect any of the repositories that are in a junction until I open a file from the repository. A repository is detected only after I open a file from that repository (auto-detection via parent folders for opened file). So, for 10 repositories, I'd have to open one file from each repository to populate the source control tab correctly.

I was able to simplify the issue scenario to the following:

  1. Create git repositories in folders like: 'C:/repos/r1', 'C:/repos/r2',...
  2. Create a folder for VS workspace (e.g. 'C:/ws') and create junctions in it pointing to repositories. e.g. 'C:/ws/j1 -> C:/repos/r1', 'C:/ws/j2 -> C:/repos/r2',...
  3. Open VS Code in the workspace folder (i.e. 'C:/ws' in this example).
  4. Wait until workspace is loaded and switch to Source Control tab.
  5. None of the repositories are detected.
  6. Switch back to Explorer tab and open a file from one of the subfolders.
  7. Switch to Source Control tab and you'll notice that the git repository for that file has been detected. The others are still undetected until their files are opened as well.

VS Code version: Code 1.65.1 (8908a9ca0f221f36507231afb39d2d8d1e182702, 2022-03-08T02:06:27.846Z) OS version: Windows_NT x64 10.0.19044 Restricted Mode: No

Extensions (63) Extension|Author (truncated)|Version ---|---|--- better-comments|aar|2.1.0 urscript|Ahe|0.1.9 Bookmarks|ale|13.2.4 cpp-helper|ami|0.3.1 qml-formatter|And|1.2.4 Doxygen|bbe|1.0.0 vagrant|bbe|0.5.0 proto3-nav|bri|0.2.2 doxdocgen|csc|1.4.0 vscode-eslint|dba|2.2.2 githistory|don|0.6.19 xml|Dot|2.5.1 clipboard-manager|Edg|1.4.2 felgo|fel|1.0.3 cmake-test-adapter|fre|0.15.4 vscode-pull-request-github|Git|0.38.0 gitkraken-authentication|git|1.0.3 gitlab-workflow|Git|3.41.0 vscode-test-explorer|hbe|2.21.1 output-colorizer|IBM|0.1.2 plantuml|jeb|2.17.2 better-cpp-syntax|jef|1.15.13 vscode-ksdiff|kal|1.0.0 auto-comment-blocks|kev|1.0.1 gitless|maa|11.7.1 git-graph|mhu|1.30.0 vscode-docker|ms-|1.20.0 python|ms-|2022.2.1924087327 vscode-pylance|ms-|2022.3.0 jupyter|ms-|2022.2.1030672458 jupyter-keymap|ms-|1.0.0 remote-containers|ms-|0.224.2 remote-ssh|ms-|0.76.1 remote-ssh-edit|ms-|0.76.1 remote-wsl|ms-|0.64.2 cmake-tools|ms-|1.9.2 cpptools|ms-|1.8.4 cpptools-extension-pack|ms-|1.1.0 test-adapter-converter|ms-|0.1.5 vsliveshare|ms-|1.0.5418 vsliveshare-audio|ms-|0.1.91 vsliveshare-pack|ms-|0.4.0 qml-debug|orc|0.1.0 ruby|reb|0.28.1 java|red|1.4.0 vscode-commons|red|0.0.6 vscode-xml|red|0.19.1 FileGroup|rio|1.0.1 html-related-links|rio|0.15.1 multi-command|ryu|1.5.1 vscode-qt-for-python|sea|1.1.7 comment-divider|sta|0.4.0 vscode-mermaid-editor|tom|0.14.0 qtvsctools|ton|0.10.1 cmake|twx|0.0.17 vscodeintellicode|Vis|1.2.17 vscode-java-debug|vsc|0.38.0 vscode-java-dependency|vsc|0.19.0 vscode-java-pack|vsc|0.22.0 vscode-maven|vsc|0.35.1 vscode-ruby|win|0.28.0 vscode-markdown-everywhere|zha|0.0.12 vscode-proto3|zxh|0.5.5 (1 theme extensions excluded)
A/B Experiments ``` vsliv368cf:30146710 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 pythonvspyl392:30443607 pythontb:30283811 pythonptprofiler:30281270 vsdfh931:30280409 vshan820:30294714 vstes263:30335439 pythondataviewer:30285071 vscod805cf:30301675 pythonvspyt200:30340761 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593cf:30376535 vsc1dst:30438360 pythonvs932:30410667 wslgetstarted:30449410 vsclayoutctrt:30448491 dsvsc008:30440022 pythonvspyt640:30450904 vsbas813:30436447 vscscmwlcmt:30438805 vscgsvidc:30447482 helix:30440343 pynewfile477:30450038 ```
pm-ur commented 2 years ago

Today, after update to 1.66.0 the handling of junctions has broken down even further. Now the SCM panel recognizes only the repository for the first file I open. For all files opened later from other repository folders (junctions), it doesn't even detect the repository any more.

pm-ur commented 2 years ago

Hi! I'm wondering if this issue would be fixed any time soon. Since I'm not familiar with VS code source code, it won't be possible for me to provide a patch.

For now, I've frozen my VS code version to 1.65.2, but I hope someone can work on it soon enough :)

JonnyOThan commented 7 months ago

I had this behavior as well (the repository is only detected once a file is opened), and it didn't really bother me. But I just updated to 1.86.0 and now it's not detected at all. It just says image

I'm not sure what version I was on previously - is there a way to tell?

Ooh additional note: with GitLens installed they are detected.

lszomoru commented 6 months ago

@JonnyOThan, could you please share the contents of the git output window?

JonnyOThan commented 6 months ago

@lszomoru

2024-02-12 11:16:20.468 [info] Log level: Info
2024-02-12 11:16:20.468 [info] Validating found git in: "C:\Program Files\Git\cmd\git.exe"
2024-02-12 11:16:20.495 [info] Using git "2.35.1.windows.2" from "C:\Program Files\Git\cmd\git.exe"
2024-02-12 11:16:31.608 [info] Log level: Info
2024-02-12 11:16:31.608 [info] Validating found git in: "C:\Program Files\Git\cmd\git.exe"
2024-02-12 11:16:31.608 [info] Using git "2.35.1.windows.2" from "C:\Program Files\Git\cmd\git.exe"
2024-02-12 11:16:31.639 [info] > git rev-parse --show-toplevel [33ms]
2024-02-12 11:16:31.639 [info] fatal: not a git repository (or any of the parent directories): .git
2024-02-12 11:16:31.673 [info] > git rev-parse --show-toplevel [32ms]
2024-02-12 11:16:31.673 [info] fatal: not a git repository (or any of the parent directories): .git
2024-02-12 11:16:31.708 [info] > git rev-parse --show-toplevel [33ms]
2024-02-12 11:16:31.708 [info] fatal: not a git repository (or any of the parent directories): .git
2024-02-12 11:16:31.743 [info] > git rev-parse --show-toplevel [33ms]
2024-02-12 11:16:31.743 [info] fatal: not a git repository (or any of the parent directories): .git
2024-02-12 11:16:31.779 [info] > git rev-parse --show-toplevel [33ms]
2024-02-12 11:16:31.779 [info] fatal: not a git repository (or any of the parent directories): .git
2024-02-12 11:16:31.813 [info] > git rev-parse --show-toplevel [32ms]
2024-02-12 11:16:31.813 [info] fatal: not a git repository (or any of the parent directories): .git
2024-02-12 11:16:31.850 [info] > git rev-parse --show-toplevel [34ms]
2024-02-12 11:16:31.850 [info] fatal: not a git repository (or any of the parent directories): .git
2024-02-12 11:16:31.887 [info] > git rev-parse --show-toplevel [35ms]
2024-02-12 11:16:31.887 [info] fatal: not a git repository (or any of the parent directories): .git
2024-02-12 11:16:31.922 [info] > git rev-parse --show-toplevel [33ms]
2024-02-12 11:16:31.922 [info] fatal: not a git repository (or any of the parent directories): .git
2024-02-12 11:16:31.956 [info] > git rev-parse --show-toplevel [31ms]
2024-02-12 11:16:31.956 [info] fatal: not a git repository (or any of the parent directories): .git
2024-02-12 11:16:31.987 [info] > git rev-parse --show-toplevel [29ms]
2024-02-12 11:16:31.987 [info] fatal: not a git repository (or any of the parent directories): .git
2024-02-12 11:16:32.019 [info] > git rev-parse --show-toplevel [31ms]
2024-02-12 11:16:32.019 [info] fatal: not a git repository (or any of the parent directories): .git
2024-02-12 11:16:32.051 [info] > git rev-parse --show-toplevel [29ms]
2024-02-12 11:16:32.051 [info] fatal: not a git repository (or any of the parent directories): .git
2024-02-12 11:16:38.247 [info] > git rev-parse --show-toplevel [26ms]
2024-02-12 11:16:38.275 [info] > git rev-parse --path-format=relative --show-toplevel [26ms]
2024-02-12 11:16:38.307 [info] > git rev-parse --git-dir --git-common-dir [29ms]
2024-02-12 11:16:38.307 [info] fatal: not a git repository (or any of the parent directories): .git
2024-02-12 11:16:44.864 [info] > git rev-parse --show-toplevel [26ms]
2024-02-12 11:16:44.896 [info] > git rev-parse --path-format=relative --show-toplevel [30ms]
2024-02-12 11:16:44.930 [info] > git rev-parse --git-dir --git-common-dir [32ms]
2024-02-12 11:16:44.930 [info] fatal: not a git repository (or any of the parent directories): .git
2024-02-12 11:16:45.535 [info] > git rev-parse --show-toplevel [38ms]
2024-02-12 11:16:45.564 [info] > git rev-parse --path-format=relative --show-toplevel [27ms]
2024-02-12 11:16:45.596 [info] > git rev-parse --git-dir --git-common-dir [30ms]
2024-02-12 11:16:45.596 [info] fatal: not a git repository (or any of the parent directories): .git
2024-02-12 11:16:46.054 [info] > git rev-parse --show-toplevel [27ms]
2024-02-12 11:16:46.087 [info] > git rev-parse --path-format=relative --show-toplevel [33ms]
2024-02-12 11:16:46.118 [info] > git rev-parse --git-dir --git-common-dir [29ms]
2024-02-12 11:16:46.118 [info] fatal: not a git repository (or any of the parent directories): .git
2024-02-12 11:17:03.071 [info] > git rev-parse --show-toplevel [27ms]
2024-02-12 11:17:03.102 [info] > git rev-parse --path-format=relative --show-toplevel [29ms]
2024-02-12 11:17:03.133 [info] > git rev-parse --git-dir --git-common-dir [29ms]
2024-02-12 11:17:03.133 [info] fatal: not a git repository (or any of the parent directories): .git
2024-02-12 11:17:10.973 [info] > git rev-parse --show-toplevel [28ms]
2024-02-12 11:17:11.004 [info] > git rev-parse --path-format=relative --show-toplevel [28ms]
2024-02-12 11:17:11.035 [info] > git rev-parse --git-dir --git-common-dir [29ms]
2024-02-12 11:17:11.035 [info] fatal: not a git repository (or any of the parent directories): .git
2024-02-12 11:17:11.062 [info] > git rev-parse --show-toplevel [26ms]
2024-02-12 11:17:11.090 [info] > git rev-parse --path-format=relative --show-toplevel [26ms]
2024-02-12 11:17:11.121 [info] > git rev-parse --git-dir --git-common-dir [30ms]
2024-02-12 11:17:11.121 [info] fatal: not a git repository (or any of the parent directories): .git