]> git.ipfire.org Git - thirdparty/git.git/commitdiff
mingw: change default of `core.symlinks` to false
authorKarsten Blees <blees@dcon.de>
Wed, 17 Dec 2025 14:08:45 +0000 (14:08 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 17 Dec 2025 23:22:18 +0000 (08:22 +0900)
Symlinks on Windows don't work the same way as on Unix systems. For
example, there are different types of symlinks for directories and
files, and unless using a recent-ish Windows version in Developer Mode,
creating symlinks requires administrative privileges.

By default, disable symlink support on Windows. That is, users
explicitly have to enable it with `git config [--system|--global]
core.symlinks true`; For convenience, `git init` (and `git clone`)
will perform a test whether the current setup allows creating symlinks
and will configure that setting in the repository config.

The test suite ignores system / global config files. Allow
testing *with* symlink support by checking if native symlinks are
enabled in MSYS2 (via setting the special environment variable
`MSYS=winsymlinks:nativestrict` to ask the MSYS2 runtime to enable
creating symlinks).

Note: This assumes that Git's test suite is run in MSYS2's Bash, which
is true for the time being (an experiment to switch to BusyBox-w32
failed due to the experimental nature of BusyBox-w32).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/mingw.c

index 26e64c6a5a299703c32e65ddc366432540906504..0fe00a5b703d0727bcc88c18f6bbeb443f08baaf 100644 (file)
@@ -2862,6 +2862,15 @@ static void setup_windows_environment(void)
                if (!tmp && (tmp = getenv("USERPROFILE")))
                        setenv("HOME", tmp, 1);
        }
+
+       /*
+        * Change 'core.symlinks' default to false, unless native symlinks are
+        * enabled in MSys2 (via 'MSYS=winsymlinks:nativestrict'). Thus we can
+        * run the test suite (which doesn't obey config files) with or without
+        * symlink support.
+        */
+       if (!(tmp = getenv("MSYS")) || !strstr(tmp, "winsymlinks:nativestrict"))
+               has_symlinks = 0;
 }
 
 static void get_current_user_sid(PSID *sid, HANDLE *linked_token)