[PATCH v2 0/4] fsmonitor: start using an opaque token for last update

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Only change for this version is to sync the watchman script that is in
templates with the one in t/t7519 since it had some commented out debug code
that could be useful.

Also haven't received any feedback on this patch series which would be good
to make sure I'm not making any obvious mistakes.

Thanks!

Kevin Willford (4):
  fsmonitor: change last update timestamp on the index_state to opaque
    token
  fsmonitor: handle version 2 of the hooks that will use opaque token
  fsmonitor: add fsmonitor hook scripts for version 2
  fsmonitor: update documentation for hook version and watchman hooks

 Documentation/config/core.txt              |  11 ++
 Documentation/githooks.txt                 |  13 +-
 cache.h                                    |   2 +-
 fsmonitor.c                                | 120 ++++++++++----
 t/helper/test-dump-fsmonitor.c             |   2 +-
 t/t7519-status-fsmonitor.sh                |   7 +-
 t/t7519/fsmonitor-all                      |   1 -
 t/t7519/fsmonitor-all-v2                   |  21 +++
 t/t7519/fsmonitor-watchman                 |   3 +-
 t/t7519/fsmonitor-watchman-v2              | 173 +++++++++++++++++++++
 templates/hooks--fsmonitor-watchman.sample | 168 +++++++++++++-------
 11 files changed, 434 insertions(+), 87 deletions(-)
 create mode 100755 t/t7519/fsmonitor-all-v2
 create mode 100755 t/t7519/fsmonitor-watchman-v2


base-commit: 0a76bd7381ec0dbb7c43776eb6d1ac906bca29e6
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-510%2Fkewillford%2Ffsmonitor_opaque_token-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-510/kewillford/fsmonitor_opaque_token-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/510

Range-diff vs v1:

 1:  679bf4e0dd = 1:  679bf4e0dd fsmonitor: change last update timestamp on the index_state to opaque token
 2:  f969c4bc17 = 2:  f969c4bc17 fsmonitor: handle version 2 of the hooks that will use opaque token
 3:  e1fd5924d0 ! 3:  ecc288c848 fsmonitor: add fsmonitor hook scripts for version 2
     @@ -236,13 +236,16 @@ $^
      -my ($version, $time) = @ARGV;
      +my ($version, $last_update_token) = @ARGV;
       
     - # Check the hook interface version
     --
     +-# Check the hook interface version
     ++# Uncomment for debugging
     ++# print STDERR "$0 $version $last_update_token\n";
     + 
      -if ($version == 1) {
      -	# convert nanoseconds to seconds
      -	# subtract one second to make sure watchman will return all changes
      -	$time = int ($time / 1000000000) - 1;
      -} else {
     ++# Check the hook interface version
      +if ($version ne 2) {
       	die "Unsupported query-fsmonitor hook version '$version'.\n" .
       	    "Falling back to scanning...\n";
     @@ -273,7 +276,7 @@ $^
       launch_watchman();
       
       sub launch_watchman {
     -+	$o = watchman_query();
     ++	my $o = watchman_query();
      +	if (is_work_tree_watched($o)) {
      +		output_result($o->{clock}, @{$o->{files}});
      +	}
     @@ -281,6 +284,12 @@ $^
      +
      +sub output_result {
      +	my ($clockid, @files) = @_;
     + 
     ++	# Uncomment for debugging watchman output
     ++	# open (my $fh, ">", ".git/watchman-output.out");
     ++	# binmode $fh, ":utf8";
     ++	# print $fh "$clockid\n@files\n";
     ++	# close $fh;
      +
      +	binmode STDOUT, ":utf8";
      +	print $clockid;
     @@ -293,7 +302,7 @@ $^
      +	my $response = qx/watchman clock "$git_work_tree"/;
      +	die "Failed to get clock id on '$git_work_tree'.\n" .
      +		"Falling back to scanning...\n" if $? != 0;
     - 
     ++
      +	return $json_pkg->new->utf8->decode($response);
      +}
      +
     @@ -328,9 +337,20 @@ $^
       		}]
       	END
       
     -@@
     ++	# Uncomment for debugging the watchman query
     ++	# open (my $fh, ">", ".git/watchman-query.json");
     ++	# print $fh $query;
     ++	# close $fh;
     ++
     + 	print CHLD_IN $query;
     + 	close CHLD_IN;
       	my $response = do {local $/; <CHLD_OUT>};
       
     ++	# Uncomment for debugging the watch response
     ++	# open ($fh, ">", ".git/watchman-response.json");
     ++	# print $fh $response;
     ++	# close $fh;
     ++
       	die "Watchman: command returned no output.\n" .
      -	    "Falling back to scanning...\n" if $response eq "";
      +	"Falling back to scanning...\n" if $response eq "";
     @@ -358,11 +378,23 @@ $^
      +
      +sub is_work_tree_watched {
      +	my ($output) = @_;
     -+	if ($retry > 0 and $output->{error} and $output->{error} =~ m/unable to resolve root .* directory (.*) is not watched/) {
     ++	my $error = $output->{error};
     ++	if ($retry > 0 and $error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) {
       		$retry--;
     - 		qx/watchman watch "$git_work_tree"/;
     +-		qx/watchman watch "$git_work_tree"/;
     ++		my $response = qx/watchman watch "$git_work_tree"/;
       		die "Failed to make watchman watch '$git_work_tree'.\n" .
     -@@
     + 		    "Falling back to scanning...\n" if $? != 0;
     ++		$output = $json_pkg->new->utf8->decode($response);
     ++		$error = $output->{error};
     ++		die "Watchman: $error.\n" .
     ++		"Falling back to scanning...\n" if $error;
     ++
     ++		# Uncomment for debugging watchman output
     ++		# open (my $fh, ">", ".git/watchman-output.out");
     ++		# close $fh;
     + 
     + 		# Watchman will always return all files on the first query so
       		# return the fast "everything is dirty" flag to git and do the
       		# Watchman query just to get it over with now so we won't pay
       		# the cost in git to look up each individual file.
     @@ -383,8 +415,8 @@ $^
       
      -	die "Watchman: $o->{error}.\n" .
      -	    "Falling back to scanning...\n" if $o->{error};
     -+	die "Watchman: $output->{error}.\n" .
     -+	"Falling back to scanning...\n" if $output->{error};
     ++	die "Watchman: $error.\n" .
     ++	"Falling back to scanning...\n" if $error;
       
      -	binmode STDOUT, ":utf8";
      -	local $, = "\0";
 4:  8d381b7d44 = 4:  1db2a699ba fsmonitor: update documentation for hook version and watchman hooks

-- 
gitgitgadget



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux