Commit Graph

107386 Commits

Author SHA1 Message Date
Johannes Schindelin
cc1416aae4 Merge pull request #994 from jeffhostetler/jeffhostetler/fscache_nfd
fscache: add not-found directory cache to fscache
2020-03-06 08:03:38 +01:00
Johannes Schindelin
73e5b50f42 Merge branch 'fscache' 2020-03-06 08:03:37 +01:00
Johannes Schindelin
b271bec90b Merge 'add-p-many-files'
This topic branch allows `add -p` and `add -i` with a large number of
files. It is kind of a hack that was never really meant to be
upstreamed. Let's see if we can do better in the built-in `add -p`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 08:03:37 +01:00
Johannes Schindelin
8e764e9ac6 Merge branch 'gitk-and-git-gui-patches'
These are Git for Windows' Git GUI and gitk patches. We will have to
decide at some point what to do about them, but that's a little lower
priority (as Git GUI seems to be unmaintained for the time being, and
the gitk maintainer keeps a very low profile on the Git mailing list,
too).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 08:03:36 +01:00
Johannes Schindelin
c64d5d3338 Merge branch 'ready-for-upstream'
This is the branch thicket of patches in Git for Windows that are
considered ready for upstream. To keep them in a ready-to-submit shape,
they are kept as close to the beginning of the branch thicket as
possible.
2020-03-06 08:03:35 +01:00
Johannes Schindelin
9c1191524d fscache: add a test for the dir-not-found optimization
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 08:03:13 +01:00
Karsten Blees
0b069e0074 fscache: load directories only once
If multiple threads access a directory that is not yet in the cache, the
directory will be loaded by each thread. Only one of the results is added
to the cache, all others are leaked. This wastes performance and memory.

On cache miss, add a future object to the cache to indicate that the
directory is currently being loaded. Subsequent threads register themselves
with the future object and wait. When the first thread has loaded the
directory, it replaces the future object with the result and notifies
waiting threads.

Signed-off-by: Karsten Blees <blees@dcon.de>
2020-03-06 08:03:13 +01:00
Jeff Hostetler
23c3e57816 fscache: remember not-found directories
Teach FSCACHE to remember "not found" directories.

This is a performance optimization.

FSCACHE is a performance optimization available for Windows.  It
intercepts Posix-style lstat() calls into an in-memory directory
using FindFirst/FindNext.  It improves performance on Windows by
catching the first lstat() call in a directory, using FindFirst/
FindNext to read the list of files (and attribute data) for the
entire directory into the cache, and short-cut subsequent lstat()
calls in the same directory.  This gives a major performance
boost on Windows.

However, it does not remember "not found" directories.  When STATUS
runs and there are missing directories, the lstat() interception
fails to find the parent directory and simply return ENOENT for the
file -- it does not remember that the FindFirst on the directory
failed. Thus subsequent lstat() calls in the same directory, each
re-attempt the FindFirst.  This completely defeats any performance
gains.

This can be seen by doing a sparse-checkout on a large repo and
then doing a read-tree to reset the skip-worktree bits and then
running status.

This change reduced status times for my very large repo by 60%.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 08:03:13 +01:00
Karsten Blees
58faee0a91 mingw: add a cache below mingw's lstat and dirent implementations
Checking the work tree status is quite slow on Windows, due to slow
`lstat()` emulation (git calls `lstat()` once for each file in the
index). Windows operating system APIs seem to be much better at scanning
the status of entire directories than checking single files.

Add an `lstat()` implementation that uses a cache for lstat data. Cache
misses read the entire parent directory and add it to the cache.
Subsequent `lstat()` calls for the same directory are served directly
from the cache.

Also implement `opendir()`/`readdir()`/`closedir()` so that they create
and use directory listings in the cache.

The cache doesn't track file system changes and doesn't plug into any
modifying file APIs, so it has to be explicitly enabled for git functions
that don't modify the working copy.

Note: in an earlier version of this patch, the cache was always active and
tracked file system changes via ReadDirectoryChangesW. However, this was
much more complex and had negative impact on the performance of modifying
git commands such as 'git checkout'.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 08:03:13 +01:00
Jeff Hostetler
b59d2a5aed fscache: add key for GIT_TRACE_FSCACHE
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 08:03:13 +01:00
Karsten Blees
c6eccfc2c2 add infrastructure for read-only file system level caches
Add a macro to mark code sections that only read from the file system,
along with a config option and documentation.

This facilitates implementation of relatively simple file system level
caches without the need to synchronize with the file system.

Enable read-only sections for 'git status' and preload_index.

Signed-off-by: Karsten Blees <blees@dcon.de>
2020-03-06 08:03:12 +01:00
Karsten Blees
f10716000e Win32: make the lstat implementation pluggable
Emulating the POSIX lstat API on Windows via GetFileAttributes[Ex] is quite
slow. Windows operating system APIs seem to be much better at scanning the
status of entire directories than checking single files. A caching
implementation may improve performance by bulk-reading entire directories
or reusing data obtained via opendir / readdir.

Make the lstat implementation pluggable so that it can be switched at
runtime, e.g. based on a config option.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 08:03:12 +01:00
Karsten Blees
ae8ae3832c mingw: make the dirent implementation pluggable
Emulating the POSIX `dirent` API on Windows via
`FindFirstFile()`/`FindNextFile()` is pretty staightforward, however,
most of the information provided in the `WIN32_FIND_DATA` structure is
thrown away in the process. A more sophisticated implementation may
cache this data, e.g. for later reuse in calls to `lstat()`.

Make the `dirent` implementation pluggable so that it can be switched at
runtime, e.g. based on a config option.

Define a base DIR structure with pointers to `readdir()`/`closedir()`
that match the `opendir()` implementation (similar to vtable pointers in
Object-Oriented Programming). Define `readdir()`/`closedir()` so that
they call the function pointers in the `DIR` structure. This allows to
choose the `opendir()` implementation on a call-by-call basis.

Make the fixed-size `dirent.d_name` buffer a flex array, as `d_name` may
be implementation specific (e.g. a caching implementation may allocate a
`struct dirent` with _just_ the size needed to hold the `d_name` in
question).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 08:03:12 +01:00
Karsten Blees
d5f86f9feb Win32: dirent.c: Move opendir down
Move opendir down in preparation for the next patch.

Signed-off-by: Karsten Blees <blees@dcon.de>
2020-03-06 08:03:12 +01:00
Karsten Blees
5aadf8943e Win32: make FILETIME conversion functions public
We will use them in the upcoming "FSCache" patches (to accelerate
sequential lstat() calls).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 08:03:12 +01:00
Johannes Schindelin
d5be5ea7de t3701: verify that we can add *lots* of files interactively
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 08:03:11 +01:00
Kelly Heller
04c9ae6960 Allow add -p and add -i with a large number of files
This fixes https://github.com/msysgit/git/issues/182.

Inspired by Pull Request 218 using code from @PhilipDavis.

[jes: simplified code quite a bit]

Signed-off-by: Kelly Heller <kkheller@cedrus.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 08:03:11 +01:00
Johannes Schindelin
b469972d94 Merge pull request #2535 from dscho/schannel-revoke-best-effort
Introduce and use the new "best effort" strategy for Secure Channel revoke checking
2020-03-06 08:03:08 +01:00
Johannes Schindelin
ee83aaa5d1 Merge pull request #2516 from nyckyta/crlf-aware-git-credential
credential.c: fix credential reading with regards to CR/LF
2020-03-06 08:03:07 +01:00
Johannes Schindelin
22e5c4fc95 Merge pull request #2506 from dscho/issue-2283
Allow running Git directly from `C:\Program Files\Git\mingw64\bin\git.exe`
2020-03-06 08:03:06 +01:00
Johannes Schindelin
9753d533d2 Merge pull request #2504 from dscho/access-repo-via-junction
Handle `git add <file>` where <file> traverses an NTFS junction
2020-03-06 08:03:05 +01:00
Johannes Schindelin
91573cd503 Merge pull request #2501 from jeffhostetler/clink-debug-curl
clink.pl: fix MSVC compile script to handle libcurl-d.lib
2020-03-06 08:03:05 +01:00
Johannes Schindelin
edd36ae726 Merge pull request #2488 from bmueller84/master
mingw: fix fatal error working on mapped network drives on Windows
2020-03-06 08:03:04 +01:00
Johannes Schindelin
0229ef99a0 Merge pull request #2473 from dscho/com0-is-not-a-reserved-name
Do not mistake `COM0` for a reserved file name
2020-03-06 08:03:03 +01:00
Johannes Schindelin
bab7ffe864 Merge pull request #2449 from dscho/mingw-getcwd-and-symlinks
Do resolve symlinks in `getcwd()`
2020-03-06 08:03:02 +01:00
Johannes Schindelin
cd75e70023 Merge pull request #2405 from dscho/mingw-setsockopt
Make sure `errno` is set when socket operations fail
2020-03-06 08:03:02 +01:00
Johannes Schindelin
a232734cc5 Merge pull request #2375 from assarbad/reintroduce-sideband-config
Config option to disable side-band-64k for transport
2020-03-06 08:03:01 +01:00
Johannes Schindelin
68542ddf57 Merge branch 'msys2-python'
In MSYS2, we have two Python interpreters at our disposal, so we can
include the Python stuff in the build.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 08:03:01 +01:00
Johannes Schindelin
c6e18e46d1 Merge branch 'move-gfw-system-config-to-top-level'
Make `git config --system` work like you think it should on Windows: it
should edit the file that is located in `<Git>\etc\gitconfig`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 08:03:00 +01:00
Johannes Schindelin
5b5b923167 Merge pull request #2351 from PhilipOakley/vcpkg-tip
Vcpkg Install: detect lack of working Git, and note possible vcpkg time outs
2020-03-06 08:02:59 +01:00
Johannes Schindelin
27cebfc284 Merge pull request #2316 from carenas/win-pcre1-cleanup
config.mak.uname: PCRE1 cleanup
2020-03-06 08:02:58 +01:00
Johannes Schindelin
6a0d791402 Merge branch 'work-around-isilon'
It would appear that least the Isilon network filesystem (and possibly
other network filesystems, too), report non-standard error values when
trying to access a non-existing directory.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 08:02:58 +01:00
Johannes Schindelin
387af0860e Merge branch 'dont-clean-junctions'
This topic branch teaches `git clean` to respect NTFS junctions and Unix
bind mounts: it will now stop at those boundaries.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 08:02:57 +01:00
Johannes Schindelin
d781b4bec6 Merge branch 'msys2-strace'
Debugging support on MSYS2.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 08:02:56 +01:00
Johannes Schindelin
c3e7dc4630 Merge branch 'robustify-is-hidden-tests'
In Git for Windows, there is an option to mark the .git directory as
hidden. Our test cases verify this by using the system utility
`attrib.exe`.

This file name is unfortunately quite generic, and overlaps with a
Unix-y utility that might be hiding the system one in the `PATH`.

Let's specify explicitly which `attrib` to use.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 08:02:55 +01:00
Johannes Schindelin
dae0d80345 Merge branch 'fflush-in-git-clean'
After writing to `stdout` and before reading from `stdin`, it is a good
idea to flush the former.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 08:02:55 +01:00
Johannes Schindelin
13539237f5 Merge pull request #2170 from dscho/gitk-long-cmdline
Fix gitk (long cmdline)
2020-03-06 08:02:54 +01:00
Johannes Schindelin
50b6ea6d78 Merge branch 'fsync-object-files-always'
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 08:02:54 +01:00
Johannes Schindelin
40d496f4d3 Merge remote-tracking branch 'dscho/add-p' into add-p-g4w
Let's test this for a while.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 08:02:53 +01:00
Johannes Schindelin
bbf4fa574c Merge branch 'stash-p-corner-case'
This topic branch fixes a corner case that is amazingly common in this
developer's workflow: in a `git stash -p`, splitting a hunk and stashing
only part of it runs into a (known) bug where the partial hunk cannot be
applied in reverse.

It is one of those "good enough" fixes, not a full fix, though, as the
full fix would require a 3-way merge between `stash^` and the *worktree*
(not `HEAD`), with `stash` as merge base (i.e. a `git revert`, but on
top of the current worktree).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 08:02:45 +01:00
Johannes Schindelin
1def0ee711 stash -p: (partially) fix bug concerning split hunks
When trying to stash part of the worktree changes by splitting a hunk
and then only partially accepting the split bits and pieces, the user
is presented with a rather cryptic error:

	error: patch failed: <file>:<line>
	error: test: patch does not apply
	Cannot remove worktree changes

and the command would fail to stash the desired parts of the worktree
changes (even if the `stash` ref was actually updated correctly).

We even have a test case demonstrating that failure, carrying it for
four years already.

The explanation: when splitting a hunk, the changed lines are no longer
separated by more than 3 lines (which is the amount of context lines
Git's diffs use by default), but less than that. So when staging only
part of the diff hunk for stashing, the resulting diff that we want to
apply to the worktree in reverse will contain those changes to be
dropped surrounded by three context lines, but since the diff is
relative to HEAD rather than to the worktree, these context lines will
not match.

Example time. Let's assume that the file README contains these lines:

	We
	the
	people

and the worktree added some lines so that it contains these lines
instead:

	We
	are
	the
	kind
	people

and the user tries to stash the line containing "are", then the command
will internally stage this line to a temporary index file and try to
revert the diff between HEAD and that index file. The diff hunk that
`git stash` tries to revert will look somewhat like this:

	@@ -1776,3 +1776,4
	 We
	+are
	 the
	 people

It is obvious, now, that the trailing context lines overlap with the
part of the original diff hunk that the user did *not* want to stash.

Keeping in mind that context lines in diffs serve the primary purpose of
finding the exact location when the diff does not apply precisely (but
when the exact line number in the file to be patched differs from the
line number indicated in the diff), we work around this by reducing the
amount of context lines: the diff was just generated.

Note: this is not a *full* fix for the issue. Just as demonstrated in
t3701's 'add -p works with pathological context lines' test case, there
are ambiguities in the diff format. It is very rare in practice, of
course, to encounter such repeated lines.

The full solution for such cases would be to replace the approach of
generating a diff from the stash and then applying it in reverse by
emulating `git revert` (i.e. doing a 3-way merge). However, in `git
stash -p` it would not apply to `HEAD` but instead to the worktree,
which makes this non-trivial to implement as long as we also maintain a
scripted version of `add -i`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 08:02:44 +01:00
Johannes Schindelin
ddfd67b62e t3904: fix incorrect demonstration of a bug
In 7e9e048661 (stash -p: demonstrate failure of split with mixed y/n,
2015-04-16), a regression test for a known breakage that was added to
the test script `t3904-stash-patch.sh` that demonstrated that splitting
a hunk and trying to stash only part of that split hunk fails (but
shouldn't).

As expected, it still fails, but for the wrong reason: once the bug is
fixed, we would expect stderr to show nothing, yet the regression test
expects stderr to show something.

Let's fix that by telling that regression test case to expect nothing to
be printed to stderr.

While at it, also drop the obvious left-over from debugging where the
regression test did not mind `git stash -p` to return a non-zero exit
status.

Of course, the regression test still fails, but this time for the
correct reason.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 08:02:44 +01:00
Johannes Schindelin
0bd669d690 Merge 'gitk' into HEAD 2020-03-06 07:57:59 +01:00
Johannes Schindelin
c15efd18df Merge branch 'git-gui-askyesno'
These changes are necessary to support better Git for Windows' new
auto-update feature.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 07:57:58 +01:00
Johannes Schindelin
1bbdae5e64 Merge branch 'git-gui-hooks-path' of https://github.com/dscho/git-gui
Let's try to address #1755 this way.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 07:57:57 +01:00
Johannes Schindelin
023ab1e86c Merge 'git-gui' into HEAD 2020-03-06 07:57:57 +01:00
James J. Raden
b8728887cd gitk: make the "list references" default window width wider
When using remotes (with git-flow especially), the remote reference names
are almost always wordwrapped in the "list references" window because it's
somewhat narrow by default. It's possible to resize it with a mouse,
but it's annoying to have to do this every time, especially on Windows 10,
where the window border seems to be only one (1) pixel wide, thus making
the grabbing of the window border tricky.

Signed-off-by: James J. Raden <james.raden@gmail.com>
2020-03-06 07:57:56 +01:00
Johannes Schindelin
8936d4f05b gitk: fix arrow keys in input fields with Tcl/Tk >= 8.6
Tcl/Tk 8.6 introduced new events for the cursor left/right keys and
apparently changed the behavior of the previous event.

Let's work around that by using the new events when we are running with
Tcl/Tk 8.6 or later.

This fixes https://github.com/git-for-windows/git/issues/495

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 07:57:56 +01:00
Sebastian Schuberth
8fef396066 gitk: Use an external icon file on Windows
Git for Windows now ships with the new Git icon from git-scm.com. Use that
icon file if it exists instead of the old procedurally drawn one.

This patch was sent upstream but so far no decision on its inclusion was
made, so commit it to our fork.

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
2020-03-06 07:57:56 +01:00
Johannes Schindelin
e49b4ee6c2 git-gui--askyesno (mingw): use Git for Windows' icon, if available
For additional GUI goodness.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-03-06 07:57:55 +01:00