Description
Setup
$ git --version --build-options
git version 2.40.1.windows.1
cpu: x86_64
built from commit: ceee26d5cac05a3437097b43d034c4ad2e99d571
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
$ cmd.exe /c ver
Microsoft Windows [Version 10.0.19045.3208]
- Default installation, symlinks on
cat /etc/install-options.txt
Editor Option: VisualStudioCode
Custom Editor Path:
Default Branch Option: main
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: WinSSL
CRLF Option: CRLFCommitAsIs
Bash Terminal Option: MinTTY
Git Pull Behavior Option: Merge
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Enabled
Enable Pseudo Console Support: Disabled
Enable FSMonitor: Disabled
- Any other interesting things about your environment that might be related
to the issue you're seeing?
** Windows developer mode on, symlink creation policy enabled **
Details
- Which terminal/shell are you running Git from?
cmd,git bash
- What commands did you run to trigger this issue? If you can provide a
Minimal, Complete, and Verifiable example
this will help us understand the issue.
I am creating an absolute symlink to root (e.g. \opt\v1.0 - /opt/v1.0 in the database). The symlink should work both on windows and linux platforms
git init
echo "*" symlink=dir>.git/info/attributes
MSYS_NO_PATHCONV=1 cmd /c 'mklink /d latest \opt\v1.0 & dir latest?'
git commit -a -m"Test"
git checkout -B develop
MSYS_NO_PATHCONV=1 cmd /c 'rmdir latest && mklink /d latest \opt\v1.1'
git commit -a -m"Update v1.1"
git switch main
When switching back to main, git sees a change from the worktree to the index:
$ git ls-files -s
120000 095e8e4fe7e9867daddd50592cde400256a4b1cc 0 latest
$ git cat-file blob 095e8e4fe7e9867daddd50592cde400256a4b1cc
/opt/v1.0
$ git diff
diff --git a/latest b/latest
index 095e8e4..81c08f5 120000
--- a/latest
+++ b/latest
@@ -1 +1 @@
-/opt/v1.0
\ No newline at end of file
+C:/opt/v1.0
\ No newline at end of file
However, an absolute symlink only containing \ (or / in the database) does work. So the workaround currently is to create this intermediary symlink root symlink:
04.09.2023 14:17 <SYMLINKD> latest [root\opt\v1.0]
04.09.2023 14:16 <SYMLINKD> root [\]
UPDATE: Of course this doesn't work well. The root symlink causes recursion for some processes which are not guarded against loops (see https://unix.stackexchange.com/a/277170/346937)
The root symlink ist left alone by git as [\] (and not updated as [C:\]). mkdir /d can create \opt\v1.0 symlinks without problems (doesnt make sense, but its for cross platform dev and linux can use symlinks like this)
- If the problem was occurring with a specific repository, can you provide the
URL to that repository to help us with testing?