mirror of
https://github.com/git/git.git
synced 2026-01-08 09:13:48 +00:00
t9700: accommodate for Windows paths
Ever sincefe53bbc9be(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 in2e90484eb4(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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
b31ab939fe
commit
4ec7ac101b
@@ -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)");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user