Commit Graph

122562 Commits

Author SHA1 Message Date
Johannes Schindelin
ba452fa475 Start the merging-rebase to v2.33.0-rc1
This commit starts the rebase of ba2c6c3d88 to ca63a8f183b
2021-08-07 11:52:08 +02:00
Junio C Hamano
2d755dfac9 Git 2.33-rc1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-08-06 12:53:06 -07:00
Junio C Hamano
aa7d2fe355 Merge branch 'cb/t7508-regexp-fix'
* cb/t7508-regexp-fix:
  t7508: avoid non POSIX BRE
2021-08-06 12:52:22 -07:00
Junio C Hamano
55194925e6 Merge branch 'ab/pickaxe-pcre2'
* ab/pickaxe-pcre2:
  diff: --pickaxe-all typofix
2021-08-06 12:52:15 -07:00
Junio C Hamano
c87977a0c5 Merge branch 'fc/disable-checkwinsize'
* fc/disable-checkwinsize:
  test: fix for COLUMNS and bash 5
2021-08-06 12:50:26 -07:00
Felipe Contreras
390b44eb2b test: fix for COLUMNS and bash 5
Since c49a177bec (test-lib.sh: set COLUMNS=80 for --verbose
repeatability, 2021-06-29) multiple tests have been failing when using
bash 5 because checkwinsize is enabled by default, therefore COLUMNS is
reset using TIOCGWINSZ even for non-interactive shells.

It's debatable whether or not bash should even be doing that, but for
now we can avoid this undesirable behavior by disabling this option.

Reported-by: Fabian Stelzer <fabian.stelzer@campoint.net>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
[jc: with SZEDER Gábor's suggestion to do this before setting COLUMNS]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-08-06 09:59:55 -07:00
Johannes Schindelin
5179b219d6 Merge pull request #3350 from dscho/trial-gfw-2.33.0.rc0-fsmonitor-pre-v4
Replace FSMonitor v2 with v4
2021-08-06 00:02:49 +02:00
Johannes Schindelin
56a0141587 fixup! mingw: support long paths
Let's re-apply the long-paths part of FSMonitor, after v4 was merged.

We also need to handle a new instance in `fsm-settings-win32.c` that
wasn't there in v2.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2021-08-05 22:41:45 +02:00
Jeff Hostetler
bcf4d40110 Merge feature.experimental markups for GFW preview 2021-08-05 21:26:21 +02:00
Johannes Schindelin
8a9b342c87 Enable the built-in FSMonitor as an experimental feature
If `feature.experimental` and `feature.manyFiles` are set, we now start
the built-in FSMonitor by default.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2021-08-05 21:26:21 +02:00
Jeff Hostetler
bc523846cd Merge branch 'builtin-fsmonitor' (preview of V4)
Left side is alternate version of v2.33.0-rc0.windows.1 with
the previous V2 version of FSMonitor removed.
2021-08-05 21:26:20 +02:00
Johannes Schindelin
e78851a724 fsmonitor: mark the built-in FSMonitor as experimental
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2021-08-05 21:26:20 +02:00
Johannes Schindelin
a0cc2340e5 fixup! Merge pull request #3234 from dscho/fsmonitor-v2
In preparation for taking FSMonitor v4, let's revert the merge of v2.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2021-08-05 21:23:51 +02:00
Johannes Schindelin
60b34f7570 fixup! mingw: support long paths
In preparation for merging FSMonitor v4, let's revert the FSMonitor part
of this patch.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2021-08-05 21:22:20 +02:00
Johannes Schindelin
d9811c094d fixup! Merge pull request #3236 from dscho/no-fsmonitor-in-bare-repos
In preparation for updating to FSMonitor v4, let's revert this.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2021-08-05 21:10:53 +02:00
Jeff Hostetler
12625c032a fsmonitor-settings: remote repos on Windows are incompatible with FSMonitor
Teach Git to detect remote working directories on Windows and mark them as
incompatible with FSMonitor.

With this `git fsmonitor--daemon run` will error out with a message like it
does for bare repos.

Client commands, such as `git status`, will not attempt to start the daemon.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:29 -04:00
Jeff Hostetler
2c799a2bfa fsmonitor-settings: remote repos on MacOS are incompatible with FSMonitor
Teach Git to detect remote working directories on MacOS and mark them as
incompatible with FSMonitor.

With this, `git fsmonitor--daemon run` will error out with a message
like it does for bare repos.

Client commands, like `git status`, will not attempt to start the daemon.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:29 -04:00
Jeff Hostetler
d78e5132ec fsmonitor-settings: stub in platform-specific incompatibility checking on MacOS
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:29 -04:00
Jeff Hostetler
cc72760a65 fsmonitor--daemon: background daemon must free the console on windows
Teach "git fsmonitor--daemon run" to call FreeConsole() when started
in the background by "git fsmonitor--daemon start" on Windows.

The background process was holding a handle to the inherited Win32
console despite being passed stdin/out/err set to /dev/null.  This
caused command prompts and powershell terminal windows to hang in
"exit" waiting for the last console handle to be released.

(This problem was not seen in git-bash type terminal windows because
they don't have a Win32 console attached to them.)

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:29 -04:00
Jeff Hostetler
d2ed07d07c fsmonitor-settings: virtual repos are incompatible with FSMonitor
Virtual repos, such as GVFS (aka VFS for Git), are incompatible
with FSMonitor.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:29 -04:00
Jeff Hostetler
ff00eee55f fsmonitor-settings: stub in platform-specific incompatibility checking
Extend generic incompatibility checkout with platform-specific
mechanism.  Stub in Win32 version.

In the existing fsmonitor-settings code we have a way to mark
types of repos as incompatible with fsmonitor (whether via the
hook and ipc APIs).  For example, we do this for bare repos,
since there are no files to watch.

Extend this exclusion mechanism for platfor-specific reasons.
This commit just creates the framework and adds a stub for Win32.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:29 -04:00
Jeff Hostetler
8956648b5d ipc-win32: add trace2 debugging
Create "ipc-debug" category events to log unexpected errors
when creating Simple-IPC connections.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:29 -04:00
Jeff Hostetler
e024c753c9 t/helper/fsmonitor-client: create stress test
Create a stress test to hammer on the fsmonitor daemon.
Create a client-side thread pool of n threads and have
each of them make m requests as fast as they can.

NEEDSWORK: This is just the client-side thread pool and
is useful for interactive testing and experimentation.
We need to add a script test to drive this.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:29 -04:00
Jeff Hostetler
e1055f3444 t7527: test builtin FSMonitor watching repos with unicode paths
Create some test repos with UTF8 pathnames and verify that
the builtin FSMonitor can watch them.  This test is mainly
for Windows where we need to avoid `*A()` routines.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:29 -04:00
Jeff Hostetler
67a44fb0ed t7527: test FS event reporing on MacOS WRT case and Unicode
Confirm that MacOS FS events are reported with a normalized spelling.

APFS (and/or HFS+) is case-insensitive.  This means that case-independent
lookups ( [ -d .git ] and [ -d .GIT ] ) should both succeed.  But that
doesn't tell us how FS events are reported if we try "rm -rf .git" versus
"rm -rf .GIT".  Are the events reported using the on-disk spelling of the
pathname or in the spelling used by the command.

NEEDSWORK: I was only able to test case.  It would be nice to add tests
that use different Unicode spellings/normalizations and understand the
differences between APFS and HFS+ in this area.  We should confirm that
the spelling of the workdir paths that the daemon sends to clients are
always properly normalized.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:29 -04:00
Jeff Hostetler
4005824c90 fsmonitor: handle shortname for .git
On Windows, teach FSMonitor to recognize the shortname of ".git"
as an alias for ".git".

Sometimes we receive FS events using the shortname, such as when
a CMD shell runs "RENAME GIT~1 FOO" or "RMDIR GIT~1".  The FS
notification arrives using whatever combination of long and
shortnames used by the other process.  (Shortnames do seem to
be case normalized, however.)

NEEDSWORK: This only addresses the case of removing or renaming
the ".git" directory using the shortname alias, so that the daemon
properly shuts down.  I'm leaving it a task for later to handle
the general case of shortnames and report them to the fsmonitor
client process.  This would include tracked and untracked paths
that just happen to have a shortname alias.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:29 -04:00
Jeff Hostetler
7adc66d9d3 t7527: test status with untracked-cache and fsmonitor--daemon
Create 2x2 test matrix with the untracked-cache and fsmonitor--daemon
features and a series of edits and verify that status output is
identical.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:28 -04:00
Jeff Hostetler
a7088d5ffb fsmonitor: force update index after large responses
Set the `FSMONITOR_CHANGED` bit on `istate->cache_changed` when
FSMonitor returns a very large repsonse to ensure that the index is
written to disk.

Normally, when the FSMonitor response includes a tracked file, the
index is always updated.  Similarly, the index might be updated when
the response alters the untracked-cache (when enabled).  However, in
cases where neither of those cause the index to be considered changed,
the FSMonitor response is wasted.  Subsequent Git commands will make
requests with the same token and receive the same response.

If that response is very large, performance may suffer.  It would be
more efficient to force update the index now (and the token in the
index extension) in order to reduce the size of the response received
by future commands.

This was observed on Windows after a large checkout.  On Windows, the
kernel emits events for the files that are changed as they are
changed.  However, it might delay events for the containing
directories until the system is more idle (or someone scans the
directory (so it seems)).  The first status following a checkout would
get the list of files.  The subsequent status commands would get the
list of directories as the events trickled out.  But they would never
catch up because the token was not advanced because the index wasn't
updated.

This list of directories caused `wt_status_collect_untracked()` to
unnecessarily spend time actually scanning them during each command.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:28 -04:00
Jeff Hostetler
1ec372a789 fsmonitor: enhance existing comments
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:28 -04:00
Jeff Hostetler
56056fc1f1 fsmonitor--daemon: use a cookie file to sync with file system
Teach fsmonitor--daemon client threads to create a cookie file
inside the .git directory and then wait until FS events for the
cookie are observed by the FS listener thread.

This helps address the racy nature of file system events by
blocking the client response until the kernel has drained any
event backlog.

This is especially important on MacOS where kernel events are
only issued with a limited frequency.  See the `latency` argument
of `FSeventStreamCreate()`.  The kernel only signals every `latency`
seconds, but does not guarantee that the kernel queue is completely
drained, so we may have to wait more than one interval.  If we
increase the frequency, the system is more likely to drop events.
We avoid these issues by having each client thread create a unique
cookie file and then wait until it is seen in the event stream.

Co-authored-by: Kevin Willford <Kevin.Willford@microsoft.com>
Co-authored-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:28 -04:00
Jeff Hostetler
87bf95d6e2 fsmonitor--daemon: periodically truncate list of modified files
Teach fsmonitor--daemon to periodically truncate the list of
modified files to save some memory.

Clients will ask for the set of changes relative to a token that they
found in the FSMN index extension in the index.  (This token is like a
point in time, but different).  Clients will then update the index to
contain the response token (so that subsequent commands will be
relative to this new token).

Therefore, the daemon can gradually truncate the in-memory list of
changed paths as they become obsolete (older than the previous token).
Since we may have multiple clients making concurrent requests with a
skew of tokens and clients may be racing to the talk to the daemon,
we lazily truncate the list.

We introduce a 5 minute delay and truncate batches 5 minutes after
they are considered obsolete.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:28 -04:00
Jeff Hostetler
b23d8be6b1 t7527: create test for fsmonitor--daemon
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:28 -04:00
Jeff Hostetler
4260225c2c t/perf/p7519: add fsmonitor--daemon test cases
Repeat all of the fsmonitor perf tests using `git fsmonitor--daemon` and
the "Simple IPC" interface.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:28 -04:00
Jeff Hostetler
e2756eed26 t/perf: avoid copying builtin fsmonitor files into test repo
Do not copy any of the various fsmonitor--daemon files from the .git
directory of the (GIT_PREF_REPO or GIT_PERF_LARGE_REPO) source repo
into the test's trash directory.

When perf tests start, they copy the contents of the source repo into
the test's trash directory.  If fsmonitor is running in the source repo,
there may be control files, such as the IPC socket and/or fsmonitor
cookie files.  These should not be copied into the test repo.

Unix domain sockets cannot be copied in the manner used by the test
setup, so if present, the test setup fails.

Cookie files are harmless, but we should avoid them.

The builtin fsmonitor keeps all such control files/sockets in
.git/fsmonitor--daemon*, so it is simple to exclude them.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:28 -04:00
Jeff Hostetler
15b84ce2c4 t/perf/p7519: speed up test on Windows
Change p7519 to use `test_seq` and `xargs` rather than a `for` loop
to touch thousands of files.  This takes minutes off of test runs
on Windows because of process creation overhead.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:28 -04:00
Jeff Hostetler
079e66ea82 t/helper/test-chmtime: skip directories on Windows
Teach `test-tool.exe chmtime` to ignore errors when setting the mtime
on a directory on Windows.

NEEDSWORK: The Windows version of `utime()` (aka `mingw_utime()`) does
not properly handle directories because it uses `_wopen()`.  It should
be converted to using `CreateFileW()` and backup semantics at a minimum.
Since I'm already in the middle of a large patch series, I did not want
to destabilize other callers of `utime()` right now.  The problem has
only been observed in the t/perf/p7519 test when the test repo contains
an empty directory on disk.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:28 -04:00
Jeff Hostetler
c7190622c7 fsmonitor--daemon: implement handle_client callback
Teach fsmonitor--daemon to respond to IPC requests from client
Git processes and respond with a list of modified pathnames
relative to the provided token.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:28 -04:00
Jeff Hostetler
f8ef89c867 fsm-listen-darwin: implement FSEvent listener on MacOS
Implement file system event listener on MacOS using FSEvent,
CoreFoundation, and CoreServices.

Co-authored-by: Kevin Willford <Kevin.Willford@microsoft.com>
Co-authored-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:28 -04:00
Jeff Hostetler
0cb240790a fsm-listen-darwin: add macos header files for FSEvent
Include MacOS system declarations to allow us to use FSEvent and
CoreFoundation APIs.  We need GCC and clang versions because of
compiler and header file conflicts.

While it is quite possible to #include Apple's CoreServices.h when
compiling C source code with clang, trying to build it with GCC
currently fails with this error:

In file included
   from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Security.framework/Headers/AuthSession.h:32,
   from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Security.framework/Headers/Security.h:42,
   from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/OSServices.framework/Headers/CSIdentity.h:43,
   from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/OSServices.framework/Headers/OSServices.h:29,
   from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Headers/IconsCore.h:23,
   from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Headers/LaunchServices.h:23,
   from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:45,
     /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Security.framework/Headers/Authorization.h:193:7: error: variably modified 'bytes' at file scope
       193 | char bytes[kAuthorizationExternalFormLength];
           |      ^~~~~

The underlying reason is that GCC (rightfully) objects that an `enum`
value such as `kAuthorizationExternalFormLength` is not a constant
(because it is not, the preprocessor has no knowledge of it, only the
actual C compiler does) and can therefore not be used to define the size
of a C array.

This is a known problem and tracked in GCC's bug tracker:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93082

In the meantime, let's not block things and go the slightly ugly route
of declaring/defining the FSEvents constants, data structures and
functions that we need, so that we can avoid above-mentioned issue.

Let's do this _only_ for GCC, though, so that the CI/PR builds (which
build both with clang and with GCC) can guarantee that we _are_ using
the correct data types.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:28 -04:00
Jeff Hostetler
95ec3cba77 fsm-listen-win32: implement FSMonitor backend on Windows
Teach the win32 backend to register a watch on the working tree
root directory (recursively).  Also watch the <gitdir> if it is
not inside the working tree.  And to collect path change notifications
into batches and publish.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:28 -04:00
Jeff Hostetler
30c5a1a8c2 fsmonitor--daemon: create token-based changed path cache
Teach fsmonitor--daemon to build a list of changed paths and associate
them with a token-id.  This will be used by the platform-specific
backends to accumulate changed paths in response to filesystem events.

The platform-specific file system listener thread receives file system
events containing one or more changed pathnames (with whatever bucketing
or grouping that is convenient for the file system).  These paths are
accumulated (without locking) by the file system layer into a `fsmonitor_batch`.

When the file system layer has drained the kernel event queue, it will
"publish" them to our token queue and make them visible to concurrent
client worker threads.  The token layer is free to combine and/or de-dup
paths within these batches for efficient presentation to clients.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:28 -04:00
Jeff Hostetler
89f8b1fa14 fsmonitor--daemon: define token-ids
Teach fsmonitor--daemon to create token-ids and define the
overall token naming scheme.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:28 -04:00
Jeff Hostetler
e43cdc6559 fsmonitor--daemon: add pathname classification
Teach fsmonitor--daemon to classify relative and absolute
pathnames and decide how they should be handled.  This will
be used by the platform-specific backend to respond to each
filesystem event.

When we register for filesystem notifications on a directory,
we get events for everything (recursively) in the directory.
We want to report to clients changes to tracked and untracked
paths within the working directory.  We do not want to report
changes within the .git directory, for example.

This classification will be used in a later commit by the
different backends to classify paths as events are received.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:28 -04:00
Jeff Hostetler
6e796211dc fsmonitor--daemon: do not try to operate on bare repos
Bare repos do not have a working directory, so there is no
directory for the daemon to register a watch upon.  And therefore
there are no files within the directory for it to actually watch.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:27 -04:00
Jeff Hostetler
f7a8c02b9a fsmonitor--daemon: implement 'start' command
Implement 'git fsmonitor--daemon start' command.  This command
tries to start a daemon in the background.  It creates a background
process to run the daemon.

The updated daemon does not actually do anything yet because the
platform backends are still just stubs.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:27 -04:00
Jeff Hostetler
7215c5ad3d fsmonitor--daemon: implement 'run' command
Implement `run` command to try to begin listening for file system events.

This version defines the thread structure with a single fsmonitor_fs_listen
thread to watch for file system events and a simple IPC thread pool to
watch for connection from Git clients over a well-known named pipe or
Unix domain socket.

This commit does not actually do anything yet because the platform
backends are still just stubs.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:27 -04:00
Jeff Hostetler
59bf746352 fsm-listen-darwin: stub in backend for Darwin
Stub in empty implementation of fsmonitor--daemon
backend for Darwin (aka MacOS).

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:27 -04:00
Jeff Hostetler
91b26cc298 fsm-listen-win32: stub in backend for Windows
Stub in empty filesystem listener backend for fsmonitor--daemon on Windows.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:27 -04:00
Jeff Hostetler
4e81f9bac1 t/helper/fsmonitor-client: create IPC client to talk to FSMonitor Daemon
Create an IPC client to send query and flush commands to the daemon.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:27 -04:00
Jeff Hostetler
b137b62500 fsmonitor--daemon: implement 'stop' and 'status' commands
Implement `stop` and `status` client commands to control and query the
status of a `fsmonitor--daemon` server process (and implicitly start a
server process if necessary).

Later commits will implement the actual server and monitor the file
system.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
2021-08-05 12:14:27 -04:00