Skip to content

Commit 1fff303

Browse files
benpeartgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3bd28eb commit 1fff303

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

t/t7519/fsmonitor-watchman

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,10 @@ if ($version == 1) {
2929
"Falling back to scanning...\n";
3030
}
3131

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;
3732
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/\\/\//;
4336
} else {
4437
require Cwd;
4538
$git_work_tree = Cwd::cwd();

templates/hooks--fsmonitor-watchman.sample

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,10 @@ if ($version == 1) {
2828
"Falling back to scanning...\n";
2929
}
3030

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;
3631
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/\\/\//;
4235
} else {
4336
require Cwd;
4437
$git_work_tree = Cwd::cwd();

0 commit comments

Comments
 (0)