Skip to content

Commit

Permalink
fsmonitor: simplify determining the git worktree under Windows
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
benpeart authored and gitster committed Nov 13, 2017
1 parent 3bd28eb commit 1fff303
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
13 changes: 3 additions & 10 deletions t/t7519/fsmonitor-watchman
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,10 @@ if ($version == 1) {
"Falling back to scanning...\n";
}

# Convert unix style paths to escaped Windows style paths when running
# in Windows command prompt

my $system = `uname -s`;
$system =~ s/[\r\n]+//g;
my $git_work_tree;

if ($system =~ m/^MSYS_NT/ || $system =~ m/^MINGW/) {
$git_work_tree = `cygpath -aw "\$PWD"`;
$git_work_tree =~ s/[\r\n]+//g;
$git_work_tree =~ s,\\,/,g;
if ($^O =~ 'msys' || $^O =~ 'cygwin') {
$git_work_tree = Win32::GetCwd();
$git_work_tree =~ tr/\\/\//;
} else {
require Cwd;
$git_work_tree = Cwd::cwd();
Expand Down
13 changes: 3 additions & 10 deletions templates/hooks--fsmonitor-watchman.sample
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,10 @@ if ($version == 1) {
"Falling back to scanning...\n";
}

# Convert unix style paths to escaped Windows style paths when running
# in Windows command prompt

my $system = `uname -s`;
$system =~ s/[\r\n]+//g;
my $git_work_tree;

if ($system =~ m/^MSYS_NT/ || $system =~ m/^MINGW/) {
$git_work_tree = `cygpath -aw "\$PWD"`;
$git_work_tree =~ s/[\r\n]+//g;
$git_work_tree =~ s,\\,/,g;
if ($^O =~ 'msys' || $^O =~ 'cygwin') {
$git_work_tree = Win32::GetCwd();
$git_work_tree =~ tr/\\/\//;
} else {
require Cwd;
$git_work_tree = Cwd::cwd();
Expand Down

0 comments on commit 1fff303

Please sign in to comment.