Commit Graph

98762 Commits

Author SHA1 Message Date
Johannes Schindelin
a28b2de982 Merge branch 'close-graph-everywhere'
This topic branch is a backport of
https://github.com/gitgitgadget/git/pull/208, which avoids a lock
contention in `git gc --auto` where the `git gc` process holds a read
lock to the `commit-graph` file (if `core.commitgraph=true`) and the
spawned `git commit-graph write` (if `gc.writecommitgraph=true`) tries
to overwrite it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-19 16:47:32 +02:00
Derrick Stolee
c5007fc487 packfile: close_all_packs to close_object_store
The close_all_packs() method is now responsible for more than just pack-files.
It also closes the commit-graph and the multi-pack-index. Rename the function
to be more descriptive of its larger role. The name also fits because the
input parameter is a raw_object_store.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
2019-05-19 16:47:22 +02:00
Derrick Stolee
bdf80cb75e packfile: close commit-graph in close_all_packs
The close_all_packs() method is used to close all read handles to
pack-files and the multi-pack-index before running 'git gc --auto'.
This is particularly important on the Windows platform, where read
handles block any writes to those files. Replacing one of these
files with a rename() will fail in this situation.

The commit-graph also performs a rename, so is susceptable to this
problem. We are careful to close the commit-graph before writing,
but that doesn't work when a 'git fetch' (or similar) process runs
'git gc --auto' which may write a commit-graph.

Here, close the commit-graph as part of close_all_packs().

Reported-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
2019-05-19 16:45:56 +02:00
Derrick Stolee
46cecd986f commit-graph: use raw_object_store when closing
The close_commit_graph() method took a repository struct, but then
only uses the raw_object_store within. Change the function prototype
to make the method more flexible.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
2019-05-19 16:45:56 +02:00
Johannes Schindelin
5b8ef3292e fixup! tests: add a special setup where stash.useBuiltin is off
For some reason, this double-mention of the GIT_TEST_STASH_BUILTIN
variable crept in... Let's revert it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-14 15:25:23 +02:00
Johannes Schindelin
a56176a372 fixup! mingw: add a Makefile target to copy test artifacts
We no longer "build" `git-remote-testgit` as a non-test artifact, so
there is no need to copy it (and attempting to copy it will actually
fail).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
v2.22.0-rc0.windows.1
2019-05-14 09:30:56 +02:00
Johannes Schindelin
03dbcd76d0 parse-options: adjust parse_opt_unknown_cb()s declared return type
In f41179f16b (parse-options: avoid magic return codes, 2019-01-27),
the signature of the low-level parse-opt callback function was changed
to return an `enum`.

And while the implementations were changed, one declaration was left
unchanged, still claiming to return `int`.

This can potentially lead to problems, as compilers are free to choose
any integral type for an `enum` as long as it can represent all declared
values.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-14 00:02:00 +02:00
Johannes Schindelin
ac89ed362b pkt-line: fix declaration of set_packet_header()
When this function was changed in a97d00799a (remote-curl: use
post_rpc() for protocol v2 also, 2019-02-21) from file-local to global,
the declaration was incorrectly missing the `const` qualifier.

Let's fix that.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 23:39:02 +02:00
Johannes Schindelin
35a89663a8 Merge 'readme' into HEAD
Add a README.md for GitHub goodness.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 23:28:08 +02:00
Johannes Schindelin
dac39504bc Merge pull request #1354 from dscho/phase-out-show-ignored-directory-gracefully
Phase out `--show-ignored-directory` gracefully
2019-05-13 23:28:08 +02:00
Johannes Schindelin
fa04a89f4c Merge branch 'status-no-lock-index'
This branch allows third-party tools to call `git status
--no-lock-index` to avoid lock contention with the interactive Git usage
of the actual human user.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 23:28:08 +02:00
Johannes Schindelin
b6316fc47f Merge pull request #2149 from dscho/gcc-8-gfw
Make Git for Windows compile with GCC 8.x
2019-05-13 23:28:08 +02:00
Johannes Schindelin
5c9e421917 Merge branch 'fix-terminal-prompt'
This fixes the issue identified in

	https://github.com/git-for-windows/git/issues/1498

where Git would not fall back to reading credentials from a Win32
Console when the credentials could not be read from the terminal via the
Bash hack (that is necessary to support running in a MinTTY).

Tested in a Powershell window.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 23:28:06 +02:00
Johannes Schindelin
9828eb5088 kwset: allow building with GCC 8
The kwset functionality makes use of the obstack code, which expects to
be handed a function that can allocate large chunks of data. It expects
that function to accept a `size` parameter of type `long`.

This upsets GCC 8 on Windows, because `long` does not have the same
bit size as `size_t` there.

Now, the proper thing to do would be to switch to `size_t`. But this
would make us deviate from the "upstream" code even further, making it
hard to synchronize with newer versions, and also it would be quite
involved because that `long` type is so invasive in that code.

Let's punt, and instead provide a super small wrapper around
`xmalloc()`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 23:28:06 +02:00
Johannes Schindelin
4baae73952 mingw: allow compiling with GCC 8 and DEVELOPER=1
The return type of the `GetProcAddress()` function is `FARPROC` which
evaluates to `long long int (*)()`, i.e. it cannot be cast to the
correct function signature by GCC 8.

To work around that, we first cast to `void *` and go on with our merry
lives.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 23:28:06 +02:00
Johannes Schindelin
e1f7f4ae1e Merge pull request #1170 from dscho/mingw-kill-process
Handle Ctrl+C in Git Bash nicely

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 23:28:05 +02:00
Johannes Schindelin
2a314d3182 Merge pull request #1937 from benpeart/fscache-NtQueryDirectoryFile-gfw
fscache: teach fscache to use NtQueryDirectoryFile
2019-05-13 23:28:05 +02:00
Johannes Schindelin
cabbe2edec Merge pull request #1934 from benpeart/fscache-thread-safe-enable-gfw
fscache: make fscache_enable() thread safe
2019-05-13 23:28:05 +02:00
Johannes Schindelin
807ea1e3aa Merge remote-tracking branch 'benpeart/fscache-per-thread-gfw'
This brings substantial wins in performance because the FSCache is now
per-thread, being merged to the primary thread only at the end, so we do
not have to lock (except while merging).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 23:28:04 +02:00
Johannes Schindelin
33ab45067d Merge pull request #1910 from benpeart/fscache_statistics-gfw
fscache: add fscache hit statistics
2019-05-13 23:28:04 +02:00
Johannes Schindelin
c98d387b1d Merge pull request #1914 from benpeart/free-fscache-after-add-gfw
At the end of the add command, disable and free the fscache
2019-05-13 23:28:03 +02:00
Johannes Schindelin
7adcd2b4d5 Merge pull request #1911 from benpeart/git_test_fscache-gfw
fscache: add GIT_TEST_FSCACHE support
2019-05-13 23:28:03 +02:00
Johannes Schindelin
aae28686d2 Merge pull request #1909 from benpeart/free-fscache-after-status-gfw
status: disable and free fscache at the end of the status command
2019-05-13 23:28:03 +02:00
Johannes Schindelin
f7dfd91fa4 Merge pull request #1908 from benpeart/FindFirstFileEx-gfw
fscache: use FindFirstFileExW to avoid retrieving the short name
2019-05-13 23:28:03 +02:00
Johannes Schindelin
a8359b8e5f Merge pull request #1827 from benpeart/fscache_refresh_index
Enable the filesystem cache (fscache) in refresh_index().
2019-05-13 23:28:02 +02:00
Johannes Schindelin
7764deebf8 Merge pull request #1468 from atetubou/fscache_checkout_flush
checkout.c: enable fscache for checkout again

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 23:28:02 +02:00
Johannes Schindelin
b7c47a1e20 Merge pull request #1426 from atetubou/fetch_pack
fetch-pack.c: enable fscache for stats under .git/objects
2019-05-13 23:28:02 +02:00
Johannes Schindelin
70aae0aa41 Merge pull request #1344 from jeffhostetler/perf_add_excludes_with_fscache
dir.c: make add_excludes aware of fscache during status
2019-05-13 23:28:02 +02:00
Johannes Schindelin
95f9beaf05 Merge pull request #971 from jeffhostetler/jeffhostetler/add_preload_fscache
add: use preload-index and fscache for performance
2019-05-13 23:28:02 +02:00
Johannes Schindelin
b6ac7dc76b Merge pull request #994 from jeffhostetler/jeffhostetler/fscache_nfd
fscache: add not-found directory cache to fscache
2019-05-13 23:28:01 +02:00
Johannes Schindelin
b927c96303 Merge pull request #305 from dscho/msysgit_issues_182
Allow `add -p` and `add -i` with a large number of files
2019-05-13 23:28:01 +02:00
Johannes Schindelin
4363b83669 Merge pull request #2091 from dscho/symlink-attr-extra
Touch up symlink .gitattributes support
2019-05-13 23:28:01 +02:00
Johannes Schindelin
196192a921 Merge pull request #1897 from piscisaureus/symlink-attr
Specify symlink type in .gitattributes
2019-05-13 23:28:01 +02:00
Johannes Schindelin
2ca334661d Merge 'docker-volumes-are-no-symlinks'
This was pull request #1645 from ZCube/master

Support windows container.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 23:28:00 +02:00
Johannes Schindelin
20f3e6b6f1 Merge branch 'kblees/kb/symlinks' 2019-05-13 23:28:00 +02:00
Johannes Schindelin
100c277a33 Merge branch 'msys2' 2019-05-13 23:28:00 +02:00
Johannes Schindelin
7d3fc1d254 Merge branch 'core-longpaths-everywhere'
Git for Windows supports the core.longPaths config setting to allow
writing/reading long paths via the \\?\ trick for a long time now.

However, for that support to work, it is absolutely necessary that
git_default_config() is given a chance to parse the config. Otherwise
Git will be non the wiser.

So let's make sure that as many commands that previously failed to
parse the core.* settings now do that, implicitly enabling long path
support in a lot more places.

Note: this is not a perfect solution, and it cannot be, as there is
a chicken-and-egg problem in reading the config itself...

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 23:28:00 +02:00
Johannes Schindelin
d5c0446beb mingw (git_terminal_prompt): do fall back to CONIN$/CONOUT$ method
To support Git Bash running in a MinTTY, we use a dirty trick to access
the MSYS2 pseudo terminal: we execute a Bash snippet that accesses
/dev/tty.

The idea was to fall back to writing to/reading from CONOUT$/CONIN$ if
that Bash call failed because Bash was not found.

However, we should fall back even in other error conditions, because we
have not successfully read the user input. Let's make it so.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 23:27:59 +02:00
Johannes Schindelin
0eb9e3558b mingw: really handle SIGINT
Previously, we did not install any handler for Ctrl+C, but now we really
want to because the MSYS2 runtime learned the trick to call the
ConsoleCtrlHandler when Ctrl+C was pressed.

With this, hitting Ctrl+C while `git log` is running will only terminate
the Git process, but not the pager. This finally matches the behavior on
Linux and on macOS.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 23:27:59 +02:00
Johannes Schindelin
3fe8d9b896 Merge branch 'long-paths' 2019-05-13 23:27:59 +02:00
Ben Peart
9af0c76ab9 fscache: teach fscache to use NtQueryDirectoryFile
Using FindFirstFileExW() requires the OS to allocate a 64K buffer for each
directory and then free it when we call FindClose().  Update fscache to call
the underlying kernel API NtQueryDirectoryFile so that we can do the buffer
management ourselves.  That allows us to allocate a single buffer for the
lifetime of the cache and reuse it for each directory.

This change improves performance of 'git status' by 18% in a repo with ~200K
files and 30k folders.

Documentation for NtQueryDirectoryFile can be found at:

https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/ntifs/nf-ntifs-ntquerydirectoryfile
https://docs.microsoft.com/en-us/windows/desktop/FileIO/file-attribute-constants
https://docs.microsoft.com/en-us/windows/desktop/fileio/reparse-point-tags

To determine if the specified directory is a symbolic link, inspect the
FileAttributes member to see if the FILE_ATTRIBUTE_REPARSE_POINT flag is
set. If so, EaSize will contain the reparse tag (this is a so far
undocumented feature, but confirmed by the NTFS developers). To
determine if the reparse point is a symbolic link (and not some other
form of reparse point), test whether the tag value equals the value
IO_REPARSE_TAG_SYMLINK.

The NtQueryDirectoryFile() call works best (and on Windows 8.1 and
earlier, it works *only*) with buffer sizes up to 64kB. Which is 32k
wide characters, so let's use that as our buffer size.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 23:27:58 +02:00
Ben Peart
d395e4f7c1 fscache: make fscache_enable() thread safe
The recent change to make fscache thread specific relied on fscache_enable()
being called first from the primary thread before being called in parallel
from worker threads.  Make that more robust and protect it with a critical
section to avoid any issues.

Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Ben Peart <benpeart@microsoft.com>
2019-05-13 23:27:58 +02:00
Johannes Schindelin
bb04fe312f mingw: kill child processes in a gentler way
The TerminateProcess() function does not actually leave the child
processes any chance to perform any cleanup operations. This is bad
insofar as Git itself expects its signal handlers to run.

A symptom is e.g. a left-behind .lock file that would not be left behind
if the same operation was run, say, on Linux.

To remedy this situation, we use an obscure trick: we inject a thread
into the process that needs to be killed and to let that thread run the
ExitProcess() function with the desired exit status. Thanks J Wyman for
describing this trick.

The advantage is that the ExitProcess() function lets the atexit
handlers run. While this is still different from what Git expects (i.e.
running a signal handler), in practice Git sets up signal handlers and
atexit handlers that call the same code to clean up after itself.

In case that the gentle method to terminate the process failed, we still
fall back to calling TerminateProcess(), but in that case we now also
make sure that processes spawned by the spawned process are terminated;
TerminateProcess() does not give the spawned process a chance to do so
itself.

Please note that this change only affects how Git for Windows tries to
terminate processes spawned by Git's own executables. Third-party
software that *calls* Git and wants to terminate it *still* need to make
sure to imitate this gentle method, otherwise this patch will not have
any effect.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 23:27:58 +02:00
Johannes Schindelin
92544bd569 Merge branch 'docker-volumes-are-no-symlinks'
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 23:27:58 +02:00
Johannes Schindelin
bcd13ee006 Merge branch 'busybox-w32'
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 23:27:58 +02:00
Johannes Schindelin
456c281ce1 mingw: add a Makefile target to copy test artifacts
The Makefile target `install-mingit-test-artifacts` simply copies stuff
and things directly into a MinGit directory, including an init.bat
script to set everything up so that the tests can be run in a cmd
window.

Sadly, Git's test suite still relies on a Perl interpreter even if
compiled with NO_PERL=YesPlease. We punt for now, installing a small
script into /usr/bin/perl that hands off to an existing Perl of a Git
for Windows SDK.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 23:27:57 +02:00
Johannes Schindelin
504002f516 t9350: skip ISO-8859-1 test when the environment is always-UTF-8
In the BusyBox-w32 version that is currently under consideration for
MinGit for Windows (to reduce the .zip size, and to avoid problems with
the MSYS2 runtime), the UTF-16 environment present in Windows is
considered to be authoritative, and the 8-bit version is always in UTF-8
encoding.

As a consequence, the ISO-8859-1 test in t9350-fast-export (which tries
to set GIT_AUTHOR_NAME to a ISO-8859-1 encoded value) *must* fail in
that setup.

So let's detect when it would fail (due to an environment being purely
kept UTF-8 encoded), and skip that test in that case.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 23:27:57 +02:00
Johannes Schindelin
2865256c48 t9200: skip tests when $PWD contains a colon
On Windows, the current working directory is pretty much guaranteed to
contain a colon. If we feed that path to CVS, it mistakes it for a
separator between host and port, though.

This has not been a problem so far because Git for Windows uses MSYS2's
Bash using a POSIX emulation layer that also pretends that the current
directory is a Unix path (at least as long as we're in a shell script).

However, that is rather limiting, as Git for Windows also explores other
ports of other Unix shells. One of those is BusyBox-w32's ash, which is
a native port (i.e. *not* using any POSIX emulation layer, and certainly
not emulating Unix paths).

So let's just detect if there is a colon in $PWD and punt in that case.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 23:27:57 +02:00
Johannes Schindelin
01e671ca01 t7063: when running under BusyBox, avoid unsupported find option
BusyBox' find implementation does not understand the -ls option, so
let's not use it when we're running inside BusyBox.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 23:27:57 +02:00
Johannes Schindelin
f40ea0157e t5813: allow for $PWD to be a Windows path
Git for Windows uses MSYS2's Bash to run the test suite, which comes
with benefits but also at a heavy price: on the plus side, MSYS2's
POSIX emulation layer allows us to continue pretending that we are on a
Unix system, e.g. use Unix paths instead of Windows ones, yet this is
bought at a rather noticeable performance penalty.

There *are* some more native ports of Unix shells out there, though,
most notably BusyBox-w32's ash. These native ports do not use any POSIX
emulation layer (or at most a *very* thin one, choosing to avoid
features such as fork() that are expensive to emulate on Windows), and
they use native Windows paths (usually with forward slashes instead of
backslashes, which is perfectly legal in almost all use cases).

And here comes the problem: with a $PWD looking like, say,
C:/git-sdk-64/usr/src/git/t/trash directory.t5813-proto-disable-ssh
Git's test scripts get quite a bit confused, as their assumptions have
been shattered. Not only does this path contain a colon (oh no!), it
also does not start with a slash.

This is a problem e.g. when constructing a URL as t5813 does it:
ssh://remote$PWD. Not only is it impossible to separate the "host" from
the path with a $PWD as above, even prefixing $PWD by a slash won't
work, as /C:/git-sdk-64/... is not a valid path.

As a workaround, detect when $PWD does not start with a slash on
Windows, and simply strip the drive prefix, using an obscure feature of
Windows paths: if an absolute Windows path starts with a slash, it is
implicitly prefixed by the drive prefix of the current directory. As we
are talking about the current directory here, anyway, that strategy
works.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 23:27:56 +02:00