git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Kevin Willford via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Kevin Willford <Kevin.Willford@microsoft.com>
Subject: [PATCH v2 0/4] fsmonitor: start using an opaque token for last update
Date: Thu, 23 Jan 2020 15:26:43 +0000	[thread overview]
Message-ID: <pull.510.v2.git.1579793207.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.510.git.1578423871.gitgitgadget@gmail.com>

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

  parent reply	other threads:[~2020-01-23 15:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-07 19:04 [PATCH 0/4] fsmonitor: start using an opaque token for last update Kevin Willford via GitGitGadget
2020-01-07 19:04 ` [PATCH 1/4] fsmonitor: change last update timestamp on the index_state to opaque token Kevin Willford via GitGitGadget
2020-01-07 19:04 ` [PATCH 2/4] fsmonitor: handle version 2 of the hooks that will use " Kevin Willford via GitGitGadget
2020-01-07 19:04 ` [PATCH 3/4] fsmonitor: add fsmonitor hook scripts for version 2 Kevin Willford via GitGitGadget
2020-01-07 19:04 ` [PATCH 4/4] fsmonitor: update documentation for hook version and watchman hooks Kevin Willford via GitGitGadget
2020-01-23 15:26 ` Kevin Willford via GitGitGadget [this message]
2020-01-23 15:26   ` [PATCH v2 1/4] fsmonitor: change last update timestamp on the index_state to opaque token Kevin Willford via GitGitGadget
2020-02-05 12:49     ` Johannes Schindelin
2020-01-23 15:26   ` [PATCH v2 2/4] fsmonitor: handle version 2 of the hooks that will use " Kevin Willford via GitGitGadget
2020-02-05 13:11     ` Johannes Schindelin
2020-01-23 15:26   ` [PATCH v2 3/4] fsmonitor: add fsmonitor hook scripts for version 2 Kevin Willford via GitGitGadget
2020-01-23 15:26   ` [PATCH v2 4/4] fsmonitor: update documentation for hook version and watchman hooks Kevin Willford via GitGitGadget
2020-02-05 13:15   ` [PATCH v2 0/4] fsmonitor: start using an opaque token for last update Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pull.510.v2.git.1579793207.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=Kevin.Willford@microsoft.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).