Skip to content

Commit 9ba9d5d

Browse files
dschoGit for Windows Build Agent
authored andcommitted
Merge pull request #3234 from dscho/fsmonitor-v2
Replace the FSMonitor v1 patches with v2
2 parents a7e7aea + 994d0d8 commit 9ba9d5d

23 files changed

+914
-720
lines changed

Documentation/config/core.txt

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -62,47 +62,50 @@ core.protectNTFS::
6262
Defaults to `true` on Windows, and `false` elsewhere.
6363

6464
core.fsmonitor::
65-
If set, the value of this variable is used as a command which
66-
will identify all files that may have changed since the
67-
requested date/time. This information is used to speed up git by
68-
avoiding unnecessary processing of files that have not changed.
65+
If set, this variable contains the pathname of the "fsmonitor"
66+
hook command.
67+
+
68+
This hook command is used to identify all files that may have changed
69+
since the requested date/time. This information is used to speed up
70+
git by avoiding unnecessary scanning of files that have not changed.
6971
+
7072
See the "fsmonitor-watchman" section of linkgit:githooks[5].
7173
+
72-
Note: FSMonitor hooks (and this config setting) are ignored if the
73-
built-in FSMonitor is enabled (see `core.useBuiltinFSMonitor`).
74+
Note: The value of this config setting is ignored if the (experimental)
75+
built-in file system monitor is enabled (see `core.useBuiltinFSMonitor`).
7476

7577
core.fsmonitorHookVersion::
76-
Sets the version of hook that is to be used when calling the
77-
FSMonitor hook (as configured via `core.fsmonitor`).
78+
Sets the protocol version to be used when invoking the
79+
"fsmonitor" hook.
7880
+
7981
There are currently versions 1 and 2. When this is not set,
8082
version 2 will be tried first and if it fails then version 1
8183
will be tried. Version 1 uses a timestamp as input to determine
8284
which files have changes since that time but some monitors
83-
like watchman have race conditions when used with a timestamp.
85+
like Watchman have race conditions when used with a timestamp.
8486
Version 2 uses an opaque string so that the monitor can return
8587
something that can be used to determine what files have changed
8688
without race conditions.
8789
+
88-
Note: FSMonitor hooks (and this config setting) are ignored if the
89-
built-in FSMonitor is enabled (see `core.useBuiltinFSMonitor`).
90+
Note: The value of this config setting is ignored if the
91+
built-in file system monitor is enabled (see `core.useBuiltinFSMonitor`).
9092

9193
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+
(EXPERIMENTAL) If set to true, enable the built-in file system monitor
95+
daemon for this working directory (linkgit:git-fsmonitor--daemon[1]).
9496
+
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.
97+
Like hook-based file system monitors, the built-in file system monitor
98+
can speed up Git commands that need to refresh the Git index
99+
(e.g. `git status`) in a working directory with many files. The
100+
built-in monitor eliminates the need to install and maintain an
101+
external third-party tool.
99102
+
100-
The built-in FSMonitor is currently available only on a limited set of
101-
supported platforms.
103+
The built-in file system monitor is currently available only on a
104+
limited set of supported platforms. Currently, this includes Windows
105+
and MacOS.
102106
+
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.
107+
Note: if this config setting is set to `true`, the values of
108+
`core.fsmonitor` and `core.fsmonitorHookVersion` are ignored.
106109

107110
core.trustctime::
108111
If false, the ctime differences between the index and the

Documentation/git-fsmonitor--daemon.txt

Lines changed: 34 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,87 +3,61 @@ git-fsmonitor--daemon(1)
33

44
NAME
55
----
6-
git-fsmonitor--daemon - Builtin file system monitor daemon
6+
git-fsmonitor--daemon - (EXPERIMENTAL) A Built-in File System Monitor
77

88
SYNOPSIS
99
--------
1010
[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
11+
'git fsmonitor--daemon' start
12+
'git fsmonitor--daemon' run
13+
'git fsmonitor--daemon' stop
14+
'git fsmonitor--daemon' status
1915

2016
DESCRIPTION
2117
-----------
2218

23-
Monitors files and directories in the working directory for changes using
24-
platform-specific file system notification facilities.
19+
NOTE! This command is still only an experiment, subject to change dramatically
20+
(or even to be abandoned).
2521

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.
22+
A daemon to watch the working directory for file and directory
23+
changes using platform-specific file system notification facilities.
24+
25+
This daemon communicates directly with commands like `git status`
26+
using the link:technical/api-simple-ipc.html[simple IPC] interface
27+
instead of the slower linkgit:githooks[5] interface.
28+
29+
This daemon is built into Git so that no third-party tools are
30+
required.
2931

3032
OPTIONS
3133
-------
3234

33-
--start::
34-
Starts the fsmonitor daemon in the background.
35+
start::
36+
Starts a daemon in the background.
3537

36-
--run::
37-
Runs the fsmonitor daemon in the foreground.
38+
run::
39+
Runs a daemon in the foreground.
3840

39-
--stop::
40-
Stops the fsmonitor daemon running for the current working
41+
stop::
42+
Stops the daemon running in the current working
4143
directory, if present.
4244

43-
--is-running::
44-
Exits with zero status if the fsmonitor daemon is watching the
45+
status::
46+
Exits with zero status if a daemon is watching the
4547
current working directory.
4648

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-
6749
REMARKS
6850
-------
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`.
7751

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.
52+
This daemon is a long running process used to watch a single working
53+
directory and maintain a list of the recently changed files and
54+
directories. Performance of commands such as `git status` can be
55+
increased if they just ask for a summary of changes to the working
56+
directory and can avoid scanning the disk.
8257

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.
58+
When `core.useBuiltinFSMonitor` is set to `true` (see
59+
linkgit:git-config[1]) commands, such as `git status`, will ask the
60+
daemon for changes and automatically start it (if necessary).
8761

8862
For more information see the "File System Monitor" section in
8963
linkgit:git-update-index[1].
@@ -96,8 +70,8 @@ not know to filter out file system events that happen within a
9670
submodule. If fsmonitor daemon is watching a super repo and a file is
9771
modified within the working directory of a submodule, it will report
9872
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.
73+
will properly ignore these extra events, so performance may be affected
74+
but it will not cause an incorrect result.
10175

10276
GIT
10377
---

Documentation/git-update-index.txt

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -510,17 +510,18 @@ performance by avoiding the cost of scanning the entire working directory
510510
looking for new files.
511511

512512
If you want to enable (or disable) this feature, it is easier to use
513-
the `core.fsmonitor` configuration variable (see
514-
linkgit:git-config[1]) than using the `--fsmonitor` option to
515-
`git update-index` in each repository, especially if you want to do so
516-
across all repositories you use, because you can set the configuration
517-
variable in your `$HOME/.gitconfig` just once and have it affect all
518-
repositories you touch.
519-
520-
When the `core.fsmonitor` configuration variable is changed, the
521-
file system monitor is added to or removed from the index the next time
522-
a command reads the index. When `--[no-]fsmonitor` are used, the file
523-
system monitor is immediately added to or removed from the index.
513+
the `core.fsmonitor` or `core.useBuiltinFSMonitor` configuration
514+
variable (see linkgit:git-config[1]) than using the `--fsmonitor`
515+
option to `git update-index` in each repository, especially if you
516+
want to do so across all repositories you use, because you can set the
517+
configuration variable in your `$HOME/.gitconfig` just once and have
518+
it affect all repositories you touch.
519+
520+
When the `core.fsmonitor` or `core.useBuiltinFSMonitor` configuration
521+
variable is changed, the file system monitor is added to or removed
522+
from the index the next time a command reads the index. When
523+
`--[no-]fsmonitor` are used, the file system monitor is immediately
524+
added to or removed from the index.
524525

525526
CONFIGURATION
526527
-------------

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,8 @@ all::
467467
# directory, and the JSON compilation database 'compile_commands.json' will be
468468
# created at the root of the repository.
469469
#
470-
# If your platform supports an built-in fsmonitor backend, set
471-
# FSMONITOR_DAEMON_BACKEND to the name of the corresponding
470+
# If your platform supports a built-in fsmonitor backend, set
471+
# FSMONITOR_DAEMON_BACKEND to the "<name>" of the corresponding
472472
# `compat/fsmonitor/fsmonitor-fs-listen-<name>.c` that implements the
473473
# `fsmonitor_fs_listen__*()` routines.
474474
#
@@ -715,6 +715,7 @@ TEST_BUILTINS_OBJS += test-dump-split-index.o
715715
TEST_BUILTINS_OBJS += test-dump-untracked-cache.o
716716
TEST_BUILTINS_OBJS += test-example-decorate.o
717717
TEST_BUILTINS_OBJS += test-fast-rebase.o
718+
TEST_BUILTINS_OBJS += test-fsmonitor-client.o
718719
TEST_BUILTINS_OBJS += test-genrandom.o
719720
TEST_BUILTINS_OBJS += test-genzeros.o
720721
TEST_BUILTINS_OBJS += test-hash-speed.o

0 commit comments

Comments
 (0)