diff --git a/Documentation/git-difftool.adoc b/Documentation/git-difftool.adoc index dd7cacf95e35df..5faca9fb91e9c6 100644 --- a/Documentation/git-difftool.adoc +++ b/Documentation/git-difftool.adoc @@ -85,7 +85,9 @@ with custom merge tool commands and has the same value as `$MERGED`. the working tree. + Specifying `--no-symlinks` instructs `git difftool` to create copies -instead. `--no-symlinks` is the default on Windows. +instead. The default follows `core.symlinks`. If unset, native Windows +builds default to copies unless `MSYS=winsymlinks:nativestrict` is set; +other builds default to symlinks. `-x `:: `--extcmd=`:: diff --git a/builtin/difftool.c b/builtin/difftool.c index a08928cb664414..9f60254cac53e5 100644 --- a/builtin/difftool.c +++ b/builtin/difftool.c @@ -56,7 +56,6 @@ static int difftool_config(const char *var, const char *value, } if (!strcmp(var, "core.symlinks")) { dt_options->has_symlinks = git_config_bool(var, value); - return 0; } return git_default_config(var, value, ctx, cb); @@ -734,7 +733,7 @@ int cmd_difftool(int argc, int use_gui_tool = -1, dir_diff = 0, prompt = -1, tool_help = 0, no_index = 0; static char *difftool_cmd = NULL, *extcmd = NULL; struct difftool_options dt_options = { - .has_symlinks = 1, + .has_symlinks = platform_has_symlinks(), .symlinks = 1, .trust_exit_code = 0 }; diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index 40983602b7e9a6..f9b18d907078e9 100755 --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@ -645,6 +645,20 @@ test_expect_success SYMLINKS 'difftool --dir-diff --symlinks without unstaged ch test_cmp expect actual ' +test_expect_success MINGW,SYMLINKS 'difftool honors core.symlinks on Windows' ' + test_config difftool.test-tool.cmd "test -L \"\$REMOTE/file\"" && + MSYS= git -c core.symlinks=true difftool --dir-diff \ + --tool=test-tool --trust-exit-code branch HEAD +' + +test_expect_success MINGW 'difftool defaults to copies on Windows' ' + test_unconfig core.symlinks && + test_config difftool.test-tool.cmd \ + "test -f \"\$REMOTE/file\" && test ! -L \"\$REMOTE/file\"" && + MSYS= git difftool --dir-diff --tool=test-tool --trust-exit-code \ + branch HEAD +' + write_script modify-right-file <<\EOF echo "modified content" >"$2/file" EOF