Commit Graph

97113 Commits

Author SHA1 Message Date
Johannes Schindelin
f2175ea5c1 Merge 'fix-externals' into HEAD 2019-05-13 22:36:54 +02:00
Johannes Schindelin
37cf2e633a Merge 'remote-hg-prerequisites' into HEAD
These fixes were necessary for Sverre Rabbelier's remote-hg to work,
but for some magic reason they are not necessary for the current
remote-hg. Makes you wonder how that one gets away with it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 22:36:54 +02:00
Johannes Schindelin
1550ae7d2f Merge branch 'cvsexportcommit-crlf'
This used to be "Merge pull request #938 from virtuald/patch-1"

git-cvsexportcommit.perl: Force crlf translation

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 22:36:54 +02:00
Johannes Schindelin
fec3185956 Merge branch 'reset-stdin'
This topic branch adds the (experimental) --stdin/-z options to `git
reset`. Those patches are still under review in the upstream Git project,
but are already merged in their experimental form into Git for Windows'
`master` branch, in preparation for a MinGit-only release.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 22:36:54 +02:00
Johannes Schindelin
7bdc9ab8f9 Merge branch 'unhidden-git'
It has been reported that core.hideDotFiles=false stopped working...
This topic branch fixes it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 22:36:53 +02:00
Adam Roben
ea5d335e86 Make non-.exe externals work again
7ebac8cb94 made launching of .exe
externals work when installed in Unicode paths. But it broke launching
of non-.exe externals, no matter where they were installed. We now
correctly maintain the UTF-8 and UTF-16 paths in tandem in lookup_prog.

This fixes t5526, among others.

Signed-off-by: Adam Roben <adam@roben.org>
2019-05-13 22:36:37 +02:00
Johannes Schindelin
016d49a575 Always auto-gc after calling a fast-import transport
After importing anything with fast-import, we should always let the
garbage collector do its job, since the objects are written to disk
inefficiently.

This brings down an initial import of http://selenic.com/hg from about
230 megabytes to about 14.

In the future, we may want to make this configurable on a per-remote
basis, or maybe teach fast-import about it in the first place.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 22:36:37 +02:00
Dustin Spicuzza
272fdca194 cvsexportcommit: force crlf translation
When using cvsnt + msys + git, it seems like the output of cvs status
had \r\n in it, and caused the command to fail.

This fixes that.

Signed-off-by: Dustin Spicuzza <dustin@virtualroadside.com>
2019-05-13 22:36:37 +02:00
Johannes Schindelin
8e4e4135cb reset: support the experimental --stdin option
Just like with other Git commands, this option makes it read the paths
from the standard input. It comes in handy when resetting many, many
paths at once and wildcards are not an option (e.g. when the paths are
generated by a tool).

Note: we first parse the entire list and perform the actual reset action
only in a second phase. Not only does this make things simpler, it also
helps performance, as do_diff_cache() traverses the index and the
(sorted) pathspecs in simultaneously to avoid unnecessary lookups.

This feature is marked experimental because it is still under review in
the upstream Git project.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 22:36:37 +02:00
Johannes Schindelin
16c441f3c7 mingw: respect core.hidedotfiles = false in git-init again
This is a brown paper bag. When adding the tests, we actually failed
to verify that the config variable is heeded in git-init at all. And
when changing the original patch that marked the .git/ directory as
hidden after reading the config, it was lost on this developer that
the new code would use the hide_dotfiles variable before the config
was read.

The fix is obvious: read the (limited, pre-init) config *before*
creating the .git/ directory.

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 22:36:37 +02:00
Adam Roben
2e2b40d0d6 Fix launching of externals from Unicode paths
If Git were installed in a path containing non-ASCII characters,
commands such as git-am and git-submodule, which are implemented as
externals, would fail to launch with the following error:

> fatal: 'am' appears to be a git command, but we were not
> able to execute it. Maybe git-am is broken?

This was due to lookup_prog not being Unicode-aware. It was somehow
missed in 2ee5a1a14a.

Note that the only problem in this function was calling
GetFileAttributes instead of GetFileAttributesW. The calls to access()
were fine because access() is a macro which resolves to mingw_access,
which already handles Unicode correctly. But I changed lookup_prog to
use _waccess directly so that we only convert the path to UTF-16 once.

Signed-off-by: Adam Roben <adam@roben.org>
2019-05-13 22:36:37 +02:00
Sverre Rabbelier
a05b703cb2 remote-helper: check helper status after import/export
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
2019-05-13 22:36:37 +02:00
Sverre Rabbelier
abc5547ab5 transport-helper: add trailing --
[PT: ensure we add an additional element to the argv array]
2019-05-13 22:36:37 +02:00
Sverre Rabbelier
63461b00cd t9350: point out that refs are not updated correctly
This happens only when the corresponding commits are not exported in
the current fast-export run. This can happen either when the relevant
commit is already marked, or when the commit is explicitly marked
as UNINTERESTING with a negative ref by another argument.

This breaks fast-export basec remote helpers.

Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
2019-05-13 22:36:37 +02:00
Johannes Schindelin
08f5629871 Start the merging-rebase to 7dcd3d86d4
In preparation for v2.22.0-rc0, we rearrange quite a few topics in this
branch thicket.

Apart from a reworded comment, this does not introduce any new change.

This commit starts the rebase of 7dcd3d86d4 to 7dcd3d86d4

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 21:22:22 +02:00
Johannes Schindelin
d4e5e1ea92 Merge pull request #2191 from dscho/add-p-fixups
A couple of fixups for add-i-in-c-status-and-help
2019-05-13 19:33:22 +02:00
Johannes Schindelin
c6746a4f41 fixup! Add a function to determine unique prefixes for a list of strings
Let's not walk off the end of the array. Also, avoid an early `malloc()`
in `add_prefix_entry()` (avoiding reuse of the same data structure for
lookup as for adding a new item), and strengthen the condition for the
bug condition.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 14:56:18 +02:00
Johannes Schindelin
f159d0dd18 fixup! built-in add -i: implement the main loop
Clarify the role of the "magic" `-1` and `-2` return values of the
`list_and_choose()` function.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-13 14:56:12 +02:00
Johannes Schindelin
e3538d8eb3 Merge pull request #2185 from dscho/fix-status-with-rebase-ir
Fix `git status`' display of `git rebase -ir`'s `label` commands
2019-05-10 22:55:48 +02:00
Johannes Schindelin
ec9eed5c88 status: fix display of rebase -ir's label command
The argument of a `label` command does *not* want to be turned into an
abbreviated SHA-1.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-10 21:32:17 +02:00
Johannes Schindelin
81a060a4d1 Merge pull request #2127 from dscho/fix-fsmonitor
Do query the fsmonitor again after the index has been discarded
2019-05-09 23:04:27 +02:00
Johannes Schindelin
912cfd3f9e fsmonitor: force a refresh after the index was discarded
With this change, the `index_state` struct becomes the new home for the
flag that says whether the fsmonitor hook has been run, i.e. it is now
per-index.

It also gets re-set when the index is discarded, fixing the bug
demonstrated by the "test_expect_failure" test added in the preceding
commit. In that case fsmonitor-enabled Git would miss updates under
certain circumstances, see that preceding commit for details.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-09 21:04:25 +02:00
Johannes Schindelin
328b4a2b06 fsmonitor: demonstrate that it is not refreshed after discard_index()
This one is tricky.

When `core.fsmonitor` is set, a `refresh_index()` will not perform a
full scan of files that might be modified, but will query the fsmonitor
and refresh only the ones that have been actually touched.

Due to implementation details, the fsmonitor is queried in
`refresh_cache_ent()`, but of course it only has to be queried once, so
we set a flag when we did that. But when the index was discarded, we did
not re-set that flag.

So far, this is only covered by our test suite when running with
GIT_TEST_FSMONITOR=$PWD/t7519/fsmonitor-all, and only due to the way the
built-in stash interacts with the recursive merge machinery.

Let's introduce a straight-forward regression test for this.

We simply extend the "read & discard index" loop in `test-tool
read-cache` to optionally refresh the index, report on a given file's
status, and then modify that file. Due to the bug described above, only
the first refresh will actually query the fsmonitor; subsequent loop
iterations will not.

This problem was reported by Ævar Arnfjörð Bjarmason.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-09 21:04:20 +02:00
Johannes Schindelin
2ac5f424d8 Merge pull request #2184 from dscho/address-coverity-report
Fix some issues reported by Coverity
2019-05-09 16:31:19 +02:00
Johannes Schindelin
32b5d74642 Merge branch 'address-coverity-reports'
Coverity pointed out a couple of bugs, and here are fixes for some of
them.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-09 14:51:29 +02:00
Johannes Schindelin
52ac616bd3 fixup! fscache: teach fscache to use NtQueryDirectoryFile
The return value of that function is not actually we are currently able
to translate to an `errno`-style value easily. So let's just not.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-09 14:51:29 +02:00
Johannes Schindelin
2a85ba50fe fixup! fscache: update fscache to be thread specific instead of global
We do fall back to not enabling the FSCache when we're out of
Thread-Local indexes, but we failed to unlock the mutex.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-09 14:51:29 +02:00
Johannes Schindelin
0ccd8caa6a fixup! Introduce helper to create symlinks that knows about index_state
We do not actually need to test for `state != NULL`, as
`state->delayed_checkout` had already been accessed before this.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-09 14:51:28 +02:00
Johannes Schindelin
ea7a305a45 squash! ci: also test with MS Visual C on Azure Pipelines
We specifically reduce the number of parallel links for MSVC, as RAM
usage is an issue with MSVC's parallel mode, manifested in the symptom:

	fatal error LNK1318: Unexpected PDB error; OK (0) ''

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-09 14:51:28 +02:00
Johannes Schindelin
28f28c03fd fixup! built-in add -p: offer a helpful error message when hunk navigation failed
Just an obvious fix for an obvious varargs mistake.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-09 14:50:57 +02:00
Johannes Schindelin
2a2d648516 sequencer: check return value of get_oid()
Just a little defensive coding.

Found by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-09 14:44:14 +02:00
Johannes Schindelin
840b754ed4 bisect--helper: verify HEAD could be parsed before continuing
In 06f5608c14 (bisect--helper: `bisect_start` shell function partially
in C, 2019-01-02), we introduced a call to `get_oid()` and did not check
whether it succeeded before using its output.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-09 14:08:52 +02:00
Johannes Schindelin
d451e84f20 rebase -i: watch out for invalid upstream arguments
This was overlooked in 53bbcfbde7 (rebase -i: implement the main part
of interactive rebase as a builtin, 2018-09-27).

Found by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-09 12:26:46 +02:00
Johannes Schindelin
fd442be344 rebase: replace incorrect logical negation by correct bitwise one
In bff014dac7 (builtin rebase: support the `verbose` and `diffstat`
options, 2018-09-04), we added a line that wanted to remove the
`REBASE_DIFFSTAT` bit from the flags, but it used an incorrect negation.

Found by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-09 12:26:46 +02:00
Johannes Schindelin
65f1570624 Merge pull request #2175 from dscho/difftool-no-index
Allow `git difftool --no-index` to run outside of a worktree
2019-05-08 23:54:15 +02:00
Johannes Schindelin
a930c5a836 Merge pull request #2150 from dscho/add-p-gfw
Offer a built-in version of `git add -i` and `git add -p`
2019-05-08 21:30:53 +02:00
Johannes Schindelin
290a66692c Merge branch 'difftool-no-index-extra'
This patch addresses the segmentation faults in `git difftool --no-index
--dir-diff`: surprisingly, those two options don't make no sense
together.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-08 21:01:39 +02:00
Johannes Schindelin
860e6522f7 Merge branch 'difftool-no-index'
This fixes https://github.com/git-for-windows/git/issues/2123

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-08 21:01:38 +02:00
Johannes Schindelin
cac7f0a6c9 difftool --no-index: error out on --dir-diff (and don't crash)
In `--no-index` mode, we now no longer require a worktree nor a
repository. But some code paths in `difftool` expect those to be
present.

The most notable such code path is the `--dir-diff` one: we use the
existing checkout machinery to copy the files, and that machinery looks
up replacement refs, looks at alternate ODBs, wants to use the worktree
path, etc.

Rather than running into segmentation faults, let's die with an
informative error message.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-08 21:01:37 +02:00
Johannes Schindelin
89dfd5daf2 difftool: allow running outside Git worktrees with --no-index
As far as this developer can tell, the conversion from a Perl script to
a built-in caused the regression in the difftool that it no longer runs
outside of a Git worktree (with `--no-index`, of course).

It is a bit embarrassing that it took over two years after retiring the
Perl version to discover this regression, but at least we now know, and
can do something, about it.

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-08 21:01:37 +02:00
Johannes Schindelin
9732ed19da parse-options: make OPT_ARGUMENT() more useful
`OPT_ARGUMENT()` is intended to keep the specified long option in `argv`
and not to do anything else.

However, it would make a lot of sense for the caller to know whether
this option was seen at all or not. For example, we want to teach `git
difftool` to work outside of any Git worktree, but only when
`--no-index` was specified.

Note: nothing in Git uses OPT_ARGUMENT(). Even worse, looking through
the commit history, one can easily see that nothing even
ever used it, apart from the regression test.

So not only do we make `OPT_ARGUMENT()` more useful, we are also about
to introduce its first real user!

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-08 21:01:29 +02:00
Johannes Schindelin
ee7778868f Merge branch 'built-in-stash-and-add-p'
Now that we have a built-in `git add -p` and a built-in `git stash`,
make them play nicely together.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-08 16:20:22 +02:00
Johannes Schindelin
d8850d4e39 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>
2019-05-08 16:17:59 +02:00
Johannes Schindelin
b85a6f8009 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>
2019-05-08 16:17:58 +02:00
Johannes Schindelin
9c4ed70beb 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>
2019-05-08 16:17:58 +02:00
Johannes Schindelin
212565694d built-in stash: use the built-in git add -p if so configured
The scripted version of `git stash` called directly into the Perl script
`git-add--interactive.perl`, and this was faithfully converted to C.

However, we have a much better way to do this now: call `git add
--patch=<mode>`, which incidentally also respects the config setting
`add.interactive.useBuiltin`.

Let's do this.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-07 23:46:30 +02:00
Karsten Blees
954b915e0b mingw: Support git_terminal_prompt with more terminals
The `git_terminal_prompt()` function expects the terminal window to be
attached to a Win32 Console. However, this is not the case with terminal
windows other than `cmd.exe`'s, e.g. with MSys2's own `mintty`.

Non-cmd terminals such as `mintty` still have to have a Win32 Console
to be proper console programs, but have to hide the Win32 Console to
be able to provide more flexibility (such as being resizeable not only
vertically but also horizontally). By writing to that Win32 Console,
`git_terminal_prompt()` manages only to send the prompt to nowhere and
to wait for input from a Console to which the user has no access.

This commit introduces a function specifically to support `mintty` -- or
other terminals that are compatible with MSys2's `/dev/tty` emulation.

The most prominent user of `git_terminal_prompt()` is certainly
`git-remote-https.exe`. It is an interesting use case because both
`stdin` and `stdout` are redirected when Git calls said executable, yet
it still wants to access the terminal.

When running inside a `mintty`, the terminal is not accessible to the
`git-remote-https.exe` program, though, because it is a MinGW program
and the `mintty` terminal is not backed by a Win32 console.

To solve that problem, we simply call out to the shell -- which is an
*MSys2* program and can therefore access `/dev/tty`.

Helped-by: 마누엘 <nalla@hamal.uberspace.de>
Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-07 23:46:30 +02:00
Johannes Schindelin
36fd328ea7 re-revert tests: add a special setup where stash.useBuiltin is off
We temporarily reverted part of this commit to allow merging `add-p`
without conflicts. Now it is time to re-apply that part.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-07 23:25:09 +02:00
Johannes Schindelin
b6d244806d t3701: verify that we can add *lots* of files interactively
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-05-07 23:25:09 +02:00
Johannes Schindelin
b5af4f266b 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>
2019-05-07 23:25:09 +02:00