git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 4/4] fsmonitor: update documentation for hook version and watchman hooks

From
KGKevin Willford via GitGitGadget <gitgitgadget@gmail.com>
Date
Jan 23, 2020, 15:26 UTC
Message-ID
<1db2a699ba3749bfb4ab1c048492f76f82830ee6.1579793208.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.510.v2.git.1579793207.gitgitgadget@gmail.com>
From: Kevin Willford <Kevin.Willford@microsoft.com>

A new config value for core.fsmonitorHookVersion was added to be able to force the version of the fsmonitor hook. Possible values are 1 or 2. When this is not set the code will use a value of -1 and attempt to use version 2 of the hook first and if that fails will attempt version 1.

Signed-off-by: Kevin Willford <Kevin.Willford@microsoft.com>
---
 Documentation/config/core.txt | 11 +++++++++++
 Documentation/githooks.txt    | 13 ++++++++++---
 2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/Documentation/config/core.txt b/Documentation/config/core.txt
index 9e440b160d..74619a9c03 100644
--- a/Documentation/config/core.txt
+++ b/Documentation/config/core.txt
@@ -68,6 +68,17 @@ core.fsmonitor::
 	avoiding unnecessary processing of files that have not changed.
 	See the "fsmonitor-watchman" section of linkgit:githooks[5].
 
+core.fsmonitorHookVersion::
+	Sets the version of hook that is to be used when calling fsmonitor.
+	There are currently versions 1 and 2. When this is not set,
+	version 2 will be tried first and if it fails then version 1
+	will be tried. Version 1 uses a timestamp as input to determine
+	which files have changes since that time but some monitors
+	like watchman have race conditions when used with a timestamp.
+	Version 2 uses an opaque string so that the monitor can return
+	something that can be used to determine what files have changed
+	without race conditions.
+
 core.trustctime::
 	If false, the ctime differences between the index and the
 	working tree are ignored; useful when the inode change time
diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt
index 50365f2914..3dccab5375 100644
--- a/Documentation/githooks.txt
+++ b/Documentation/githooks.txt
@@ -490,9 +490,16 @@ fsmonitor-watchman
 ~~~~~~~~~~~~~~~~~~
 
 This hook is invoked when the configuration option `core.fsmonitor` is
-set to `.git/hooks/fsmonitor-watchman`.  It takes two arguments, a version
-(currently 1) and the time in elapsed nanoseconds since midnight,
-January 1, 1970.
+set to `.git/hooks/fsmonitor-watchman` or `.git/hooks/fsmonitor-watchmanv2`
+depending on the version of the hook to use.
+
+Version 1 takes two arguments, a version (1) and the time in elapsed
+nanoseconds since midnight, January 1, 1970.
+
+Version 2 takes two arguments, a version (2) and a token that is used
+for identifying changes since the token. For watchman this would be
+a clock id. This version must output to stdout the new token followed
+by a NUL before the list of files.
 
 The hook should output to stdout the list of all files in the working
 directory that may have changed since the requested time.  The logic
-- 
gitgitgadget
Previous: Johannes SchindelinNext: Kevin Willford via GitGitGadget
Message 11 of 13 in “fsmonitor: start using an opaque token for last update”
  1. 0/4 fsmonitor: start using an opaque token for last updateKevin Willford via GitGitGadget, Jan 7, 2020
  2. 1/4 fsmonitor: change last update timestamp on the index_state to opaque tokenKevin Willford via GitGitGadget, Jan 7, 2020
  3. 2/4 fsmonitor: handle version 2 of the hooks that will use opaque tokenKevin Willford via GitGitGadget, Jan 7, 2020
  4. 3/4 fsmonitor: add fsmonitor hook scripts for version 2Kevin Willford via GitGitGadget, Jan 7, 2020
  5. 4/4 fsmonitor: update documentation for hook version and watchman hooksKevin Willford via GitGitGadget, Jan 7, 2020
  6. 0/4 fsmonitor: start using an opaque token for last updateKevin Willford via GitGitGadget, Jan 23, 2020
  7. 2/4 fsmonitor: handle version 2 of the hooks that will use opaque tokenKevin Willford via GitGitGadget, Jan 23, 2020
  8. Johannes SchindelinFeb 5, 2020
  9. 1/4 fsmonitor: change last update timestamp on the index_state to opaque tokenKevin Willford via GitGitGadget, Jan 23, 2020
  10. Johannes SchindelinFeb 5, 2020
  11. 4/4 fsmonitor: update documentation for hook version and watchman hooksKevin Willford via GitGitGadget, Jan 23, 2020
  12. 3/4 fsmonitor: add fsmonitor hook scripts for version 2Kevin Willford via GitGitGadget, Jan 23, 2020
  13. Johannes SchindelinFeb 5, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.