git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 01/10] t9700: accommodate for Windows paths

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Dec 5, 2025, 15:02 UTC
Message-ID
<2d329837e34a88cfe28be728fe24bb5a2c6a9752.1764946945.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.2009.v2.git.1764946945.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

Ever since fe53bbc9beb (Git.pm: Always set Repository to absolute path if autodetecting, 2009-05-07), the t9700 test _must_ fail on Windows because of that age-old Unix paths vs Windows paths problem.

The underlying root cause is that Git cannot run with a regular Win32 variant of Perl, the assumption that every path is a Unix path is just too strong in Git's Perl code.

As a consequence, Git for Windows is basically stuck with using the MSYS2 variant of Perl which uses a POSIX emulation layer (which is a friendly fork of Cygwin) _and_ a best-effort Unix <-> Windows paths conversion whenever crossing the boundary between MSYS2 and regular Win32 processes. It is best effort only, though, using heuristics to automagically convert correctly in most cases, but not in all cases.

In the context of this here patch, this means that asking `git.exe` for the absolute path of the `.git/` directory will return a Win32 path because `git.exe` is a regular Win32 executable that has no idea about Unix-ish paths. But above-mentioned commit introduced a test that wants to verify that this path is identical to the one that the Git Perl module reports (which refuses to use Win32 paths and uses Unix-ish paths instead). Obviously, this must fail because no heuristics can kick in at that layer.

This test failure has not even been caught when Git introduced Windows support in its CI definition in 2e90484eb4a (ci: add a Windows job to the Azure Pipelines definition, 2019-01-29), as all tests relying on Perl had to be disabled even from the start (because the CI runs would otherwise have resulted in prohibitively long runtimes, not because Windows is super slow per se, but because Git's test suite keeps insisting on using technology that requires a POSIX emulation layer, which _is_ super slow on Windows).

To work around this failure, let's use the `cygpath` utility to convert the absolute `gitdir` path into the form that the Perl code expects.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 t/t9700/test.pl | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/t/t9700/test.pl b/t/t9700/test.pl
index 58a9b328d5..570b0c5680 100755
--- a/t/t9700/test.pl
+++ b/t/t9700/test.pl
@@ -117,7 +117,12 @@ close TEMPFILE;
 unlink $tmpfile;
 
 # paths
-is($r->repo_path, $abs_repo_dir . "/.git", "repo_path");
+my $abs_git_dir = $abs_repo_dir . "/.git";
+if ($^O eq 'msys' or $^O eq 'cygwin') {
+  $abs_git_dir = `cygpath -am "$abs_repo_dir/.git"`;
+  $abs_git_dir =~ s/\r?\n?$//;
+}
+is($r->repo_path, $abs_git_dir, "repo_path");
 is($r->wc_path, $abs_repo_dir . "/", "wc_path");
 is($r->wc_subdir, "", "wc_subdir initial");
 $r->wc_chdir("directory1");
@@ -127,7 +132,7 @@ is($r->config("test.string"), "value", "config after wc_chdir");
 # Object generation in sub directory
 chdir("directory2");
 my $r2 = Git->repository();
-is($r2->repo_path, $abs_repo_dir . "/.git", "repo_path (2)");
+is($r2->repo_path, $abs_git_dir, "repo_path (2)");
 is($r2->wc_path, $abs_repo_dir . "/", "wc_path (2)");
 is($r2->wc_subdir, "directory2/", "wc_subdir initial (2)");
 
-- 
gitgitgadget
Previous: Johannes Schindelin via GitGitGadgetNext: Johannes Schindelin via GitGitGadget
Message 33 of 68 in “Prepare Git's test suite for symbolic link support on Windows”
  1. 00/10 Prepare Git's test suite for symbolic link support on WindowsJohannes Schindelin via GitGitGadget, Nov 29, 2025
  2. 01/10 t9700: accommodate for Windows pathsJohannes Schindelin via GitGitGadget, Nov 29, 2025
  3. 02/10 apply: symbolic links lack a "trustable executable bit"Johannes Schindelin via GitGitGadget, Nov 29, 2025
  4. 03/10 mingw: special-case `open(symlink, O_CREAT | O_EXCL)`Johannes Schindelin via GitGitGadget, Nov 29, 2025
  5. Junio C HamanoNov 30, 2025
  6. Johannes SchindelinDec 1, 2025
  7. Junio C HamanoDec 6, 2025
  8. 04/10 t0001: handle `diff --no-index` gracefullyJohannes Schindelin via GitGitGadget, Nov 29, 2025
  9. Junio C HamanoNov 30, 2025
  10. Johannes SchindelinDec 1, 2025
  11. Junio C HamanoDec 2, 2025
  12. 05/10 t0301: another fix for Windows compatibilityJohannes Schindelin via GitGitGadget, Nov 29, 2025
  13. Junio C HamanoNov 30, 2025
  14. Johannes SchindelinDec 1, 2025
  15. Junio C HamanoDec 2, 2025
  16. Johannes SchindelinDec 2, 2025
  17. Junio C HamanoDec 6, 2025
  18. 06/10 t0600: fix incomplete prerequisite for a test caseJohannes Schindelin via GitGitGadget, Nov 29, 2025
  19. Patrick SteinhardtDec 1, 2025
  20. Johannes SchindelinDec 1, 2025
  21. 07/10 t1006: accommodate for symlink support in MSYS2Johannes Schindelin via GitGitGadget, Nov 29, 2025
  22. Patrick SteinhardtDec 1, 2025
  23. Johannes SchindelinDec 1, 2025
  24. Patrick SteinhardtDec 1, 2025
  25. 08/10 t1305: skip symlink tests that do not apply to WindowsJohannes Schindelin via GitGitGadget, Nov 29, 2025
  26. 09/10 t6423: introduce Windows-specific handling for symlinking to /dev/nullJohannes Schindelin via GitGitGadget, Nov 29, 2025
  27. 10/10 t7800: work around the MSYS path conversion on WindowsJohannes Schindelin via GitGitGadget, Nov 29, 2025
  28. Junio C HamanoNov 30, 2025
  29. Eric SunshineNov 30, 2025
  30. Johannes SchindelinDec 1, 2025
  31. 00/10 Prepare Git's test suite for symbolic link support on WindowsJohannes Schindelin via GitGitGadget, Dec 5, 2025
  32. 02/10 apply: symbolic links lack a "trustable executable bit"Johannes Schindelin via GitGitGadget, Dec 5, 2025
  33. 01/10 t9700: accommodate for Windows pathsJohannes Schindelin via GitGitGadget, Dec 5, 2025
  34. 03/10 mingw: special-case `open(symlink, O_CREAT | O_EXCL)`Johannes Schindelin via GitGitGadget, Dec 5, 2025
  35. 04/10 t0001: handle `diff --no-index` gracefullyJohannes Schindelin via GitGitGadget, Dec 5, 2025
  36. 05/10 t0301: another fix for Windows compatibilityJohannes Schindelin via GitGitGadget, Dec 5, 2025
  37. 06/10 t0600: fix incomplete prerequisite for a test caseJohannes Schindelin via GitGitGadget, Dec 5, 2025
  38. 07/10 t1006: accommodate for symlink support in MSYS2Johannes Schindelin via GitGitGadget, Dec 5, 2025
  39. 08/10 t1305: skip symlink tests that do not apply to WindowsJohannes Schindelin via GitGitGadget, Dec 5, 2025
  40. 09/10 t6423: introduce Windows-specific handling for symlinking to /dev/nullJohannes Schindelin via GitGitGadget, Dec 5, 2025
  41. 10/10 t7800: work around the MSYS path conversion on WindowsJohannes Schindelin via GitGitGadget, Dec 5, 2025
  42. Patrick SteinhardtDec 9, 2025
  43. Junio C HamanoDec 9, 2025
  44. 00/10 Prepare Git's test suite for symbolic link support on WindowsJohannes Schindelin via GitGitGadget, Dec 16, 2025
  45. 01/10 t9700: accommodate for Windows pathsJohannes Schindelin via GitGitGadget, Dec 16, 2025
  46. 02/10 apply: symbolic links lack a "trustable executable bit"Johannes Schindelin via GitGitGadget, Dec 16, 2025
  47. 03/10 mingw: special-case `open(symlink, O_CREAT | O_EXCL)`Johannes Schindelin via GitGitGadget, Dec 16, 2025
  48. 04/10 t0001: handle `diff --no-index` gracefullyJohannes Schindelin via GitGitGadget, Dec 16, 2025
  49. 05/10 t0301: another fix for Windows compatibilityJohannes Schindelin via GitGitGadget, Dec 16, 2025
  50. 07/10 t1006: accommodate for symlink support in MSYS2Johannes Schindelin via GitGitGadget, Dec 16, 2025
  51. 08/10 t1305: skip symlink tests that do not apply to WindowsJohannes Schindelin via GitGitGadget, Dec 16, 2025
  52. 09/10 t6423: introduce Windows-specific handling for symlinking to /dev/nullJohannes Schindelin via GitGitGadget, Dec 16, 2025
  53. 10/10 t7800: work around the MSYS path conversion on WindowsJohannes Schindelin via GitGitGadget, Dec 16, 2025
  54. Junio C HamanoDec 16, 2025
  55. Johannes SchindelinDec 16, 2025
  56. Junio C HamanoDec 17, 2025
  57. 00/10 Prepare Git's test suite for symbolic link support on WindowsJohannes Schindelin via GitGitGadget, Dec 17, 2025
  58. 01/10 t9700: accommodate for Windows pathsJohannes Schindelin via GitGitGadget, Dec 17, 2025
  59. 02/10 apply: symbolic links lack a "trustable executable bit"Johannes Schindelin via GitGitGadget, Dec 17, 2025
  60. 03/10 mingw: special-case `open(symlink, O_CREAT | O_EXCL)`Johannes Schindelin via GitGitGadget, Dec 17, 2025
  61. 04/10 t0001: handle `diff --no-index` gracefullyJohannes Schindelin via GitGitGadget, Dec 17, 2025
  62. 05/10 t0301: another fix for Windows compatibilityJohannes Schindelin via GitGitGadget, Dec 17, 2025
  63. 06/10 t0600: fix incomplete prerequisite for a test caseJohannes Schindelin via GitGitGadget, Dec 17, 2025
  64. 07/10 t1006: accommodate for symlink support in MSYS2Johannes Schindelin via GitGitGadget, Dec 17, 2025
  65. 08/10 t1305: skip symlink tests that do not apply to WindowsJohannes Schindelin via GitGitGadget, Dec 17, 2025
  66. 09/10 t6423: introduce Windows-specific handling for symlinking to /dev/nullJohannes Schindelin via GitGitGadget, Dec 17, 2025
  67. 10/10 t7800: work around the MSYS path conversion on WindowsJohannes Schindelin via GitGitGadget, Dec 17, 2025
  68. Junio C HamanoDec 17, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.