fsmonitor: simplify determining the git worktree under Windows
Simplify and speed up the process of finding the git worktree when running on Windows by keeping it in perl and avoiding spawning helper processes. Signed-off-by: Ben Peart <benpeart@microsoft.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ben Peart committed
Nov 10, 2017 at 16:03 UTC
1fff303fc2b31d5005f38f55f38c4e8521da5a93
2 files changed
+6
-20
t/t7519/fsmonitor-watchman
+3
-10
@@ -29,17 +29,10 @@ if ($version == 1) {
29
"Falling back to scanning...\n";
30
}
31
32
-# Convert unix style paths to escaped Windows style paths when running
33
-# in Windows command prompt
34
-
35
-my $system = `uname -s`;
36
-$system =~ s/[\r\n]+//g;
32
my $git_work_tree;
38
-
39
-if ($system =~ m/^MSYS_NT/ || $system =~ m/^MINGW/) {
40
- $git_work_tree = `cygpath -aw "\$PWD"`;
41
- $git_work_tree =~ s/[\r\n]+//g;
42
- $git_work_tree =~ s,\\,/,g;
33
+if ($^O =~ 'msys' || $^O =~ 'cygwin') {
34
+ $git_work_tree = Win32::GetCwd();
35
+ $git_work_tree =~ tr/\\/\//;
36
} else {
37
require Cwd;
38
$git_work_tree = Cwd::cwd();
templates/hooks--fsmonitor-watchman.sample
+3
-10
@@ -28,17 +28,10 @@ if ($version == 1) {
28
"Falling back to scanning...\n";
29
}
30
31
-# Convert unix style paths to escaped Windows style paths when running
32
-# in Windows command prompt
33
-
34
-my $system = `uname -s`;
35
-$system =~ s/[\r\n]+//g;
31
my $git_work_tree;
37
-
38
-if ($system =~ m/^MSYS_NT/ || $system =~ m/^MINGW/) {
39
- $git_work_tree = `cygpath -aw "\$PWD"`;
40
- $git_work_tree =~ s/[\r\n]+//g;
41
- $git_work_tree =~ s,\\,/,g;
32
+if ($^O =~ 'msys' || $^O =~ 'cygwin') {
33
+ $git_work_tree = Win32::GetCwd();
34
+ $git_work_tree =~ tr/\\/\//;
35
} else {
36
require Cwd;
37
$git_work_tree = Cwd::cwd();