Skip to content

Commit 08c3609

Browse files
committed
Merge branch 'pt/fsmonitor-watchman-sample-fix'
Fix typo-induced breakages in fsmonitor-watchman sample hook. * pt/fsmonitor-watchman-sample-fix: fsmonitor-watchman: fix variable reference and remove redundant code
2 parents 015cf12 + 41366e4 commit 08c3609

3 files changed

Lines changed: 5 additions & 21 deletions

File tree

t/t7519/fsmonitor-watchman

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ if ($^O =~ 'msys' || $^O =~ 'cygwin') {
3838
$git_work_tree = Cwd::cwd();
3939
}
4040

41-
my $retry = 1;
42-
4341
launch_watchman();
4442

4543
sub launch_watchman {
@@ -92,9 +90,8 @@ sub launch_watchman {
9290

9391
my $o = $json_pkg->new->utf8->decode($response);
9492

95-
if ($retry > 0 and $o->{error} and $o->{error} =~ m/unable to resolve root .* directory (.*) is not watched/) {
93+
if ($o->{error} and $o->{error} =~ m/unable to resolve root .* directory (.*) is not watched/) {
9694
print STDERR "Adding '$git_work_tree' to watchman's watch list.\n";
97-
$retry--;
9895
qx/watchman watch "$git_work_tree"/;
9996
die "Failed to make watchman watch '$git_work_tree'.\n" .
10097
"Falling back to scanning...\n" if $? != 0;
@@ -109,7 +106,6 @@ sub launch_watchman {
109106
close $fh;
110107

111108
print "/\0";
112-
eval { launch_watchman() };
113109
exit 0;
114110
}
115111

t/t7519/fsmonitor-watchman-v2

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ if ($version ne 2) {
2929

3030
my $git_work_tree = get_working_dir();
3131

32-
my $retry = 1;
33-
3432
my $json_pkg;
3533
eval {
3634
require JSON::XS;
@@ -122,8 +120,7 @@ sub watchman_query {
122120
sub is_work_tree_watched {
123121
my ($output) = @_;
124122
my $error = $output->{error};
125-
if ($retry > 0 and $error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) {
126-
$retry--;
123+
if ($error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) {
127124
my $response = qx/watchman watch "$git_work_tree"/;
128125
die "Failed to make watchman watch '$git_work_tree'.\n" .
129126
"Falling back to scanning...\n" if $? != 0;
@@ -141,15 +138,12 @@ sub is_work_tree_watched {
141138
# Watchman query just to get it over with now so we won't pay
142139
# the cost in git to look up each individual file.
143140
my $o = watchman_clock();
144-
$error = $output->{error};
141+
$error = $o->{error};
145142

146143
die "Watchman: $error.\n" .
147144
"Falling back to scanning...\n" if $error;
148145

149146
output_result($o->{clock}, ("/"));
150-
$last_update_token = $o->{clock};
151-
152-
eval { launch_watchman() };
153147
return 0;
154148
}
155149

templates/hooks/fsmonitor-watchman.sample

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ if ($version ne 2) {
2929

3030
my $git_work_tree = get_working_dir();
3131

32-
my $retry = 1;
33-
3432
my $json_pkg;
3533
eval {
3634
require JSON::XS;
@@ -123,8 +121,7 @@ sub watchman_query {
123121
sub is_work_tree_watched {
124122
my ($output) = @_;
125123
my $error = $output->{error};
126-
if ($retry > 0 and $error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) {
127-
$retry--;
124+
if ($error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) {
128125
my $response = qx/watchman watch "$git_work_tree"/;
129126
die "Failed to make watchman watch '$git_work_tree'.\n" .
130127
"Falling back to scanning...\n" if $? != 0;
@@ -142,15 +139,12 @@ sub is_work_tree_watched {
142139
# Watchman query just to get it over with now so we won't pay
143140
# the cost in git to look up each individual file.
144141
my $o = watchman_clock();
145-
$error = $output->{error};
142+
$error = $o->{error};
146143

147144
die "Watchman: $error.\n" .
148145
"Falling back to scanning...\n" if $error;
149146

150147
output_result($o->{clock}, ("/"));
151-
$last_update_token = $o->{clock};
152-
153-
eval { launch_watchman() };
154148
return 0;
155149
}
156150

0 commit comments

Comments
 (0)