Skip to content

Commit e354e7f

Browse files
dschoGit for Windows Build Agent
authored andcommitted
Merge branch 'fsmonitor4' of https://github.com/jeffhostetler/git
This branch thicket adds an built-in, Git-aware FSMonitor. Signed-off-by: Johannes Schindelin <[email protected]>
2 parents 27376ef + 41e9251 commit e354e7f

File tree

4 files changed

+144
-12
lines changed

4 files changed

+144
-12
lines changed

Documentation/config/core.txt

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,43 @@ core.fsmonitor::
6666
will identify all files that may have changed since the
6767
requested date/time. This information is used to speed up git by
6868
avoiding unnecessary processing of files that have not changed.
69-
See the "fsmonitor-watchman" section of linkgit:githooks[5].
69+
+
70+
See the "fsmonitor-watchman" section of linkgit:githooks[5].
71+
+
72+
Note: FSMonitor hooks (and this config setting) are ignored if the
73+
built-in FSMonitor is enabled (see `core.useBuiltinFSMonitor`).
7074

7175
core.fsmonitorHookVersion::
72-
Sets the version of hook that is to be used when calling fsmonitor.
73-
There are currently versions 1 and 2. When this is not set,
74-
version 2 will be tried first and if it fails then version 1
75-
will be tried. Version 1 uses a timestamp as input to determine
76-
which files have changes since that time but some monitors
77-
like watchman have race conditions when used with a timestamp.
78-
Version 2 uses an opaque string so that the monitor can return
79-
something that can be used to determine what files have changed
80-
without race conditions.
76+
Sets the version of hook that is to be used when calling the
77+
FSMonitor hook (as configured via `core.fsmonitor`).
78+
+
79+
There are currently versions 1 and 2. When this is not set,
80+
version 2 will be tried first and if it fails then version 1
81+
will be tried. Version 1 uses a timestamp as input to determine
82+
which files have changes since that time but some monitors
83+
like watchman have race conditions when used with a timestamp.
84+
Version 2 uses an opaque string so that the monitor can return
85+
something that can be used to determine what files have changed
86+
without race conditions.
87+
+
88+
Note: FSMonitor hooks (and this config setting) are ignored if the
89+
built-in FSMonitor is enabled (see `core.useBuiltinFSMonitor`).
90+
91+
core.useBuiltinFSMonitor::
92+
If set to true, enable the built-in filesystem event watcher (for
93+
technical details, see linkgit:git-fsmonitor--daemon[1]).
94+
+
95+
Like external (hook-based) FSMonitors, the built-in FSMonitor can speed up
96+
Git commands that need to refresh the Git index (e.g. `git status`) in a
97+
worktree with many files. The built-in FSMonitor facility eliminates the
98+
need to install and maintain an external third-party monitoring tool.
99+
+
100+
The built-in FSMonitor is currently available only on a limited set of
101+
supported platforms.
102+
+
103+
Note: if this config setting is set to `true`, any FSMonitor hook
104+
configured via `core.fsmonitor` (and possibly `core.fsmonitorHookVersion`)
105+
is ignored.
81106

82107
core.trustctime::
83108
If false, the ctime differences between the index and the
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
git-fsmonitor--daemon(1)
2+
========================
3+
4+
NAME
5+
----
6+
git-fsmonitor--daemon - Builtin file system monitor daemon
7+
8+
SYNOPSIS
9+
--------
10+
[verse]
11+
'git fsmonitor--daemon' --start
12+
'git fsmonitor--daemon' --run
13+
'git fsmonitor--daemon' --stop
14+
'git fsmonitor--daemon' --is-running
15+
'git fsmonitor--daemon' --is-supported
16+
'git fsmonitor--daemon' --query <token>
17+
'git fsmonitor--daemon' --query-index
18+
'git fsmonitor--daemon' --flush
19+
20+
DESCRIPTION
21+
-----------
22+
23+
Monitors files and directories in the working directory for changes using
24+
platform-specific file system notification facilities.
25+
26+
It communicates directly with commands like `git status` using the
27+
link:technical/api-simple-ipc.html[simple IPC] interface instead of
28+
the slower linkgit:githooks[5] interface.
29+
30+
OPTIONS
31+
-------
32+
33+
--start::
34+
Starts the fsmonitor daemon in the background.
35+
36+
--run::
37+
Runs the fsmonitor daemon in the foreground.
38+
39+
--stop::
40+
Stops the fsmonitor daemon running for the current working
41+
directory, if present.
42+
43+
--is-running::
44+
Exits with zero status if the fsmonitor daemon is watching the
45+
current working directory.
46+
47+
--is-supported::
48+
Exits with zero status if the fsmonitor daemon feature is supported
49+
on this platform.
50+
51+
--query <token>::
52+
Connects to the fsmonitor daemon (starting it if necessary) and
53+
requests the list of changed files and directories since the
54+
given token.
55+
This is intended for testing purposes.
56+
57+
--query-index::
58+
Read the current `<token>` from the File System Monitor index
59+
extension (if present) and use it to query the fsmonitor daemon.
60+
This is intended for testing purposes.
61+
62+
--flush::
63+
Force the fsmonitor daemon to flush its in-memory cache and
64+
re-sync with the file system.
65+
This is intended for testing purposes.
66+
67+
REMARKS
68+
-------
69+
The fsmonitor daemon is a long running process that will watch a single
70+
working directory. Commands, such as `git status`, should automatically
71+
start it (if necessary) when `core.useBuiltinFSMonitor` is set to `true`
72+
(see linkgit:git-config[1]).
73+
74+
Configure the built-in FSMonitor via `core.useBuiltinFSMonitor` in each
75+
working directory separately, or globally via `git config --global
76+
core.useBuiltinFSMonitor true`.
77+
78+
Tokens are opaque strings. They are used by the fsmonitor daemon to
79+
mark a point in time and the associated internal state. Callers should
80+
make no assumptions about the content of the token. In particular,
81+
the should not assume that it is a timestamp.
82+
83+
Query commands send a request-token to the daemon and it responds with
84+
a summary of the changes that have occurred since that token was
85+
created. The daemon also returns a response-token that the client can
86+
use in a future query.
87+
88+
For more information see the "File System Monitor" section in
89+
linkgit:git-update-index[1].
90+
91+
CAVEATS
92+
-------
93+
94+
The fsmonitor daemon does not currently know about submodules and does
95+
not know to filter out file system events that happen within a
96+
submodule. If fsmonitor daemon is watching a super repo and a file is
97+
modified within the working directory of a submodule, it will report
98+
the change (as happening against the super repo). However, the client
99+
should properly ignore these extra events, so performance may be affected
100+
but it should not cause an incorrect result.
101+
102+
GIT
103+
---
104+
Part of the linkgit:git[1] suite

Documentation/git-update-index.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,9 @@ FILE SYSTEM MONITOR
498498
This feature is intended to speed up git operations for repos that have
499499
large working directories.
500500

501-
It enables git to work together with a file system monitor (see the
501+
It enables git to work together with a file system monitor (see
502+
linkgit:git-fsmonitor--daemon[1]
503+
and the
502504
"fsmonitor-watchman" section of linkgit:githooks[5]) that can
503505
inform it as to what files have been modified. This enables git to avoid
504506
having to lstat() every file to find modified files.

Documentation/githooks.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,8 @@ fsmonitor-watchman
593593

594594
This hook is invoked when the configuration option `core.fsmonitor` is
595595
set to `.git/hooks/fsmonitor-watchman` or `.git/hooks/fsmonitor-watchmanv2`
596-
depending on the version of the hook to use.
596+
depending on the version of the hook to use, unless overridden via
597+
`core.useBuiltinFSMonitor` (see linkgit:git-config[1]).
597598

598599
Version 1 takes two arguments, a version (1) and the time in elapsed
599600
nanoseconds since midnight, January 1, 1970.

0 commit comments

Comments
 (0)