Browse Source

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>
maint
Ben Peart 7 years ago committed by Junio C Hamano
parent
commit
1fff303fc2
  1. 13
      t/t7519/fsmonitor-watchman
  2. 13
      templates/hooks--fsmonitor-watchman.sample

13
t/t7519/fsmonitor-watchman

@ -29,17 +29,10 @@ if ($version == 1) {
"Falling back to scanning...\n"; "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; my $git_work_tree;

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

13
templates/hooks--fsmonitor-watchman.sample

@ -28,17 +28,10 @@ if ($version == 1) {
"Falling back to scanning...\n"; "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; my $git_work_tree;

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

Loading…
Cancel
Save