git
4 years agofetch: default to protocol version 2
Jonathan Nieder [Tue, 24 Dec 2019 01:04:15 +0000 (17:04 -0800)] 
fetch: default to protocol version 2

The Git users at $DAYJOB have been using protocol v2 as a default for
~1.5 years now and others have been also reporting good experiences
with it, so it seems like a good time to bump the default version.  It
produces a significant performance improvement when fetching from
repositories with many refs, such as
https://chromium.googlesource.com/chromium/src.

This only affects the client, not the server.  (The server already
defaults to supporting protocol v2.)  The protocol change is backward
compatible, so this should produce no significant effect when
contacting servers that only speak protocol v0.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoprotocol test: let protocol.version override GIT_TEST_PROTOCOL_VERSION
Jonathan Nieder [Tue, 24 Dec 2019 01:02:28 +0000 (17:02 -0800)] 
protocol test: let protocol.version override GIT_TEST_PROTOCOL_VERSION

The GIT_TEST_PROTOCOL_VERSION environment variable can be used to
upgrade the version of Git protocol used in tests.  If both
GIT_TEST_PROTOCOL_VERSION and 'protocol.version' are set, the higher
value wins.

For usage within tests, these semantics are too complex.  Instead,
always use the value from protocol.version configuration when it is
set, falling back to GIT_TEST_PROTOCOL_VERSION.  This way, the envvar
provides a reliable preview of what will happen if the default
protocol version is changed.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agotest: request GIT_TEST_PROTOCOL_VERSION=0 when appropriate
Jonathan Nieder [Tue, 24 Dec 2019 01:01:10 +0000 (17:01 -0800)] 
test: request GIT_TEST_PROTOCOL_VERSION=0 when appropriate

Since 8cbeba0632 (tests: define GIT_TEST_PROTOCOL_VERSION,
2019-02-25), it has been possible to run tests with a newer protocol
version by setting the GIT_TEST_PROTOCOL_VERSION envvar to a version
number.  Tests that assume protocol v0 handle this by explicitly
setting

GIT_TEST_PROTOCOL_VERSION=

or similar constructs like 'test -z "$GIT_TEST_PROTOCOL_VERSION" ||
return 0' to declare that they only handle the default (v0) protocol.

The emphasis there is a bit off: it would be clearer to specify
GIT_TEST_PROTOCOL_VERSION=0 to inform the reader that these tests are
specifically testing and relying on details of protocol v0.  Do so.

This way, a reader does not need to know what the default protocol
version is, and the tests can continue to work when the default
protocol version used by Git advances past v0.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoconfig doc: protocol.version is not experimental
Jonathan Nieder [Tue, 24 Dec 2019 01:00:00 +0000 (17:00 -0800)] 
config doc: protocol.version is not experimental

Git's protocol version 2 has been working well in production for over
a year.  Simplify documentation by no longer referring to it as
experimental.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agofetch test: use more robust test for filtered objects
Jonathan Nieder [Tue, 24 Dec 2019 00:59:07 +0000 (16:59 -0800)] 
fetch test: use more robust test for filtered objects

"git cat-file -e" uses has_object_file, which can fetch from promisor
remotes when an object is missing.  These tests end up checking that
that fetch fails instead of for the object being missing.

By luck, the tests pass anyway:

- in one of these tests ("filtering by size"), the fetch fails because
  (in protocol v0) the server does not support fetches by SHA-1

- in the second, the object is present but the test could pass even if
  it weren't if the fetch succeeds

- in the third, the test sets extensions.partialClone to "arbitrary
  string" so that when it tries to fetch, it looks up the "arbitrary
  string" remote which does not exist

Use "git rev-list --objects --missing=allow-any", so that the tests
pass for the right reason.

Noticed while testing with protocol v2, which allows fetching by sha1
by default, causing the first fetch to succeed and the test to fail.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agofetch test: mark test of "skipping" haves as v0-only
Jonathan Nieder [Thu, 26 Dec 2019 23:12:51 +0000 (15:12 -0800)] 
fetch test: mark test of "skipping" haves as v0-only

Since 633a53179e (fetch test: avoid use of "VAR= cmd" with a shell
function, 2019-12-26), t5552.5 (do not send "have" with ancestors of
commits that server ACKed) fails when run with
GIT_TEST_PROTOCOL_VERSION=2.

The cause:

The progression of "have"s sent in negotiation depends on whether we
are using a stateless RPC based transport or a stateful bidirectional
one (see for example 44d8dc54e7, "Fix potential local deadlock during
fetch-pack", 2011-03-29).  In protocol v2, all transports are
stateless transports, while in protocol v0, transports such as local
access and ssh are stateful.

In stateful transports, the number of "have"s to send multiplies by
two each round until we reach PIPESAFE_FLUSH (that is, 32), and then
it increases by PIPESAFE_FLUSH each round.  In stateless transport,
the count multiplies by two each round until we reach LARGE_FLUSH
(which is 16384) and then multiplies by 1.1 each round after that.

Moreover, in stateful transports, as fetch-pack.c explains:

We keep one window "ahead" of the other side, and will wait
for an ACK only on the next one.

This affects t5552.5 because it looks for "have"s from the negotiator
that appear in that second window.  With protocol version 2, the
second window never arrives, and the test fails.

Until 633a53179e (2019-12-26), a previous test in the same file
contained

GIT_TEST_PROTOCOL_VERSION= trace_fetch client origin to_fetch

In many common shells (e.g. bash when run as "sh"), the setting of
GIT_TEST_PROTOCOL_VERSION to the empty string lasts beyond the
intended duration of the trace_fetch invocation.  This causes it to
override the GIT_TEST_PROTOCOL_VERSION setting that was passed in to
the test during the remainder of the test script, so t5552.5 never got
run using protocol v2 on those shells, regardless of the
GIT_TEST_PROTOCOL_VERSION setting from the environment.  633a53179e
fixed that, revealing the failing test.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot/check-non-portable-shell: detect "FOO= shell_func", too
Jonathan Nieder [Thu, 26 Dec 2019 19:57:47 +0000 (11:57 -0800)] 
t/check-non-portable-shell: detect "FOO= shell_func", too

Just like assigning a nonempty value, assigning an empty value to a
shell variable when calling a function produces non-portable behavior:
in some shells, the assignment lasts for the duration of the function
invocation, and in others, it persists after the function returns.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agofetch test: avoid use of "VAR= cmd" with a shell function
Jonathan Nieder [Thu, 26 Dec 2019 19:55:10 +0000 (11:55 -0800)] 
fetch test: avoid use of "VAR= cmd" with a shell function

Just like assigning a nonempty value, assigning an empty value to a
shell variable when calling a function produces non-portable behavior:
in some shells, the assignment lasts for the duration of the function
invocation, and in others, it persists after the function returns.

Use an explicit subshell with the envvar exported to make the behavior
consistent across shells and crystal clear.

All previous instances of this pattern used "VAR=value" (with nonempty
`value`), which is already diagnosed automatically by "make test-lint"
since a0a630192d (t/check-non-portable-shell: detect "FOO=bar
shell_func", 2018-07-13).

Noticed using an improved "make test-lint".

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoMerge branch 'am/pathspec-from-file'
Junio C Hamano [Tue, 10 Dec 2019 21:11:40 +0000 (13:11 -0800)] 
Merge branch 'am/pathspec-from-file'

A few commands learned to take the pathspec from the
standard input or a named file, instead of taking it as the command
line arguments.

* am/pathspec-from-file:
  commit: support the --pathspec-from-file option
  doc: commit: synchronize <pathspec> description
  reset: support the `--pathspec-from-file` option
  doc: reset: synchronize <pathspec> description
  pathspec: add new function to parse file
  parse-options.h: add new options `--pathspec-from-file`, `--pathspec-file-nul`

4 years agoSync with Git 2.24.1
Junio C Hamano [Tue, 10 Dec 2019 06:17:55 +0000 (22:17 -0800)] 
Sync with Git 2.24.1

4 years agoThe fourth batch
Junio C Hamano [Fri, 6 Dec 2019 23:10:00 +0000 (15:10 -0800)] 
The fourth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoMerge branch 'dl/lore-is-the-archive'
Junio C Hamano [Fri, 6 Dec 2019 23:09:24 +0000 (15:09 -0800)] 
Merge branch 'dl/lore-is-the-archive'

Publicize lore.kernel.org mailing list archive and use URLs
pointing into it to refer to notable messages in the documentation.

* dl/lore-is-the-archive:
  doc: replace LKML link with lore.kernel.org
  RelNotes: replace Gmane with real Message-IDs
  doc: replace MARC links with lore.kernel.org

4 years agoMerge branch 'jk/lore-is-the-archive'
Junio C Hamano [Fri, 6 Dec 2019 23:09:23 +0000 (15:09 -0800)] 
Merge branch 'jk/lore-is-the-archive'

Doc update for the mailing list archiving and nntp service.

* jk/lore-is-the-archive:
  doc: replace public-inbox links with lore.kernel.org
  doc: recommend lore.kernel.org over public-inbox.org

4 years agoMerge branch 'tg/perf-remove-stale-result'
Junio C Hamano [Fri, 6 Dec 2019 23:09:23 +0000 (15:09 -0800)] 
Merge branch 'tg/perf-remove-stale-result'

PerfTest fix to avoid stale result mixed up with the latest round
of test results.

* tg/perf-remove-stale-result:
  perf-lib: use a single filename for all measurement types

4 years agoMerge branch 'jk/send-pack-check-negative-with-quick'
Junio C Hamano [Fri, 6 Dec 2019 23:09:22 +0000 (15:09 -0800)] 
Merge branch 'jk/send-pack-check-negative-with-quick'

Performance tweak on "git push" into a repository with many refs
that point at objects we have never heard of.

* jk/send-pack-check-negative-with-quick:
  send-pack: use OBJECT_INFO_QUICK to check negative objects

4 years agoMerge branch 'hi/grep-do-not-return-void'
Junio C Hamano [Fri, 6 Dec 2019 23:09:22 +0000 (15:09 -0800)] 
Merge branch 'hi/grep-do-not-return-void'

Code cleanup.

* hi/grep-do-not-return-void:
  grep: don't return an expression from pcre2_free()

4 years agoMerge branch 'rs/use-skip-prefix-more'
Junio C Hamano [Fri, 6 Dec 2019 23:09:22 +0000 (15:09 -0800)] 
Merge branch 'rs/use-skip-prefix-more'

Code cleanup.

* rs/use-skip-prefix-more:
  name-rev: use skip_prefix() instead of starts_with()
  push: use skip_prefix() instead of starts_with()
  shell: use skip_prefix() instead of starts_with()
  fmt-merge-msg: use skip_prefix() instead of starts_with()
  fetch: use skip_prefix() instead of starts_with()

4 years agoMerge branch 'rs/simplify-prepare-cmd'
Junio C Hamano [Fri, 6 Dec 2019 23:09:22 +0000 (15:09 -0800)] 
Merge branch 'rs/simplify-prepare-cmd'

Code cleanup.

* rs/simplify-prepare-cmd:
  run-command: use prepare_git_cmd() in prepare_cmd()

4 years agoMerge branch 'rs/test-cleanup'
Junio C Hamano [Fri, 6 Dec 2019 23:09:22 +0000 (15:09 -0800)] 
Merge branch 'rs/test-cleanup'

Test cleanup.

* rs/test-cleanup:
  t7811: don't create unused file
  t9300: don't create unused file
  test: use test_must_be_empty F instead of test_cmp empty F
  test: use test_must_be_empty F instead of test -z $(cat F)
  t1400: use test_must_be_empty
  t1410: use test_line_count
  t1512: use test_line_count

4 years agoMerge branch 'sg/assume-no-todo-update-in-cherry-pick'
Junio C Hamano [Fri, 6 Dec 2019 23:09:21 +0000 (15:09 -0800)] 
Merge branch 'sg/assume-no-todo-update-in-cherry-pick'

While running "revert" or "cherry-pick --edit" for multiple
commits, a recent regression incorrectly detected "nothing to
commit, working tree clean", instead of replaying the commits,
which has been corrected.

* sg/assume-no-todo-update-in-cherry-pick:
  sequencer: don't re-read todo for revert and cherry-pick

4 years agoMerge branch 'sg/osx-force-gcc-9'
Junio C Hamano [Fri, 6 Dec 2019 23:09:21 +0000 (15:09 -0800)] 
Merge branch 'sg/osx-force-gcc-9'

TravisCI update.

* sg/osx-force-gcc-9:
  ci: build Git with GCC 9 in the 'osx-gcc' build job

4 years agoGit 2.24.1 v2.24.1
Johannes Schindelin [Wed, 4 Dec 2019 22:10:12 +0000 (23:10 +0100)] 
Git 2.24.1

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agoSync with 2.23.1
Johannes Schindelin [Wed, 4 Dec 2019 22:09:11 +0000 (23:09 +0100)] 
Sync with 2.23.1

* maint-2.23: (44 commits)
  Git 2.23.1
  Git 2.22.2
  Git 2.21.1
  mingw: sh arguments need quoting in more circumstances
  mingw: fix quoting of empty arguments for `sh`
  mingw: use MSYS2 quoting even when spawning shell scripts
  mingw: detect when MSYS2's sh is to be spawned more robustly
  t7415: drop v2.20.x-specific work-around
  Git 2.20.2
  t7415: adjust test for dubiously-nested submodule gitdirs for v2.20.x
  Git 2.19.3
  Git 2.18.2
  Git 2.17.3
  Git 2.16.6
  test-drop-caches: use `has_dos_drive_prefix()`
  Git 2.15.4
  Git 2.14.6
  mingw: handle `subst`-ed "DOS drives"
  mingw: refuse to access paths with trailing spaces or periods
  mingw: refuse to access paths with illegal characters
  ...

4 years agoGit 2.23.1 v2.23.1
Johannes Schindelin [Wed, 4 Dec 2019 22:07:46 +0000 (23:07 +0100)] 
Git 2.23.1

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agoSync with 2.22.2
Johannes Schindelin [Wed, 4 Dec 2019 22:06:31 +0000 (23:06 +0100)] 
Sync with 2.22.2

* maint-2.22: (43 commits)
  Git 2.22.2
  Git 2.21.1
  mingw: sh arguments need quoting in more circumstances
  mingw: fix quoting of empty arguments for `sh`
  mingw: use MSYS2 quoting even when spawning shell scripts
  mingw: detect when MSYS2's sh is to be spawned more robustly
  t7415: drop v2.20.x-specific work-around
  Git 2.20.2
  t7415: adjust test for dubiously-nested submodule gitdirs for v2.20.x
  Git 2.19.3
  Git 2.18.2
  Git 2.17.3
  Git 2.16.6
  test-drop-caches: use `has_dos_drive_prefix()`
  Git 2.15.4
  Git 2.14.6
  mingw: handle `subst`-ed "DOS drives"
  mingw: refuse to access paths with trailing spaces or periods
  mingw: refuse to access paths with illegal characters
  unpack-trees: let merged_entry() pass through do_add_entry()'s errors
  ...

4 years agoGit 2.22.2 v2.22.2
Johannes Schindelin [Wed, 4 Dec 2019 22:05:10 +0000 (23:05 +0100)] 
Git 2.22.2

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agoSync with 2.21.1
Johannes Schindelin [Wed, 4 Dec 2019 22:03:16 +0000 (23:03 +0100)] 
Sync with 2.21.1

* maint-2.21: (42 commits)
  Git 2.21.1
  mingw: sh arguments need quoting in more circumstances
  mingw: fix quoting of empty arguments for `sh`
  mingw: use MSYS2 quoting even when spawning shell scripts
  mingw: detect when MSYS2's sh is to be spawned more robustly
  t7415: drop v2.20.x-specific work-around
  Git 2.20.2
  t7415: adjust test for dubiously-nested submodule gitdirs for v2.20.x
  Git 2.19.3
  Git 2.18.2
  Git 2.17.3
  Git 2.16.6
  test-drop-caches: use `has_dos_drive_prefix()`
  Git 2.15.4
  Git 2.14.6
  mingw: handle `subst`-ed "DOS drives"
  mingw: refuse to access paths with trailing spaces or periods
  mingw: refuse to access paths with illegal characters
  unpack-trees: let merged_entry() pass through do_add_entry()'s errors
  quote-stress-test: offer to test quoting arguments for MSYS2 sh
  ...

4 years agoGit 2.21.1 v2.21.1
Johannes Schindelin [Wed, 4 Dec 2019 22:01:50 +0000 (23:01 +0100)] 
Git 2.21.1

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agoMerge branch 'fix-msys2-quoting-bugs'
Johannes Schindelin [Mon, 16 Sep 2019 11:26:40 +0000 (13:26 +0200)] 
Merge branch 'fix-msys2-quoting-bugs'

These patches fix several bugs in quoting arguments when spawning shell
scripts on Windows.

Note: these bugs are Windows-only, as we have to construct a command
line for the process-to-spawn, unlike Linux/macOS, where `execv()`
accepts an already-split command line.

Furthermore, these fixes were not included in the CVE-2019-1350 part of
v2.14.6 because the Windows-specific quoting when spawning shell scripts
was contributed from Git for Windows into Git only in the v2.21.x era.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agomingw: sh arguments need quoting in more circumstances
Johannes Schindelin [Thu, 19 Sep 2019 21:43:03 +0000 (23:43 +0200)] 
mingw: sh arguments need quoting in more circumstances

Previously, we failed to quote characters such as '*', '(' and the
likes. Let's fix this.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agot7415: drop v2.20.x-specific work-around
Johannes Schindelin [Wed, 4 Dec 2019 21:47:25 +0000 (22:47 +0100)] 
t7415: drop v2.20.x-specific work-around

This reverts the work-around that was introduced just for the v2.20.x
release train in "t7415: adjust test for dubiously-nested submodule
gitdirs for v2.20.x"; It is not necessary for v2.21.x.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agomingw: fix quoting of empty arguments for `sh`
Johannes Schindelin [Thu, 19 Sep 2019 21:38:33 +0000 (23:38 +0200)] 
mingw: fix quoting of empty arguments for `sh`

When constructing command-lines to spawn processes, it is an unfortunate
but necessary decision to quote arguments differently: MSYS2 has
different dequoting rules (inherited from Cygwin) than the rest of
Windows.

To accommodate that, Git's Windows compatibility layer has two separate
quoting helpers, one for MSYS2 (which it uses exclusively when spawning
`sh`) and the other for regular Windows executables.

The MSYS2 one had an unfortunate bug where a `,` somehow slipped in,
instead of the `;`. As a consequence, empty arguments would not be
enclosed in a pair of double quotes, but the closing double quote was
skipped.

Let's fix this.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agomingw: use MSYS2 quoting even when spawning shell scripts
Johannes Schindelin [Thu, 19 Sep 2019 15:05:45 +0000 (17:05 +0200)] 
mingw: use MSYS2 quoting even when spawning shell scripts

At the point where `mingw_spawn_fd()` is called, we already have a full
path to the script interpreter in that scenario, and we pass it in as
the executable to run, while the `argv` reflect what the script should
receive as command-line.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agomingw: detect when MSYS2's sh is to be spawned more robustly
Johannes Schindelin [Thu, 19 Sep 2019 15:05:21 +0000 (17:05 +0200)] 
mingw: detect when MSYS2's sh is to be spawned more robustly

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agoSync with 2.20.2
Johannes Schindelin [Wed, 4 Dec 2019 21:46:37 +0000 (22:46 +0100)] 
Sync with 2.20.2

* maint-2.20: (36 commits)
  Git 2.20.2
  t7415: adjust test for dubiously-nested submodule gitdirs for v2.20.x
  Git 2.19.3
  Git 2.18.2
  Git 2.17.3
  Git 2.16.6
  test-drop-caches: use `has_dos_drive_prefix()`
  Git 2.15.4
  Git 2.14.6
  mingw: handle `subst`-ed "DOS drives"
  mingw: refuse to access paths with trailing spaces or periods
  mingw: refuse to access paths with illegal characters
  unpack-trees: let merged_entry() pass through do_add_entry()'s errors
  quote-stress-test: offer to test quoting arguments for MSYS2 sh
  t6130/t9350: prepare for stringent Win32 path validation
  quote-stress-test: allow skipping some trials
  quote-stress-test: accept arguments to test via the command-line
  tests: add a helper to stress test argument quoting
  mingw: fix quoting of arguments
  Disallow dubiously-nested submodule git directories
  ...

4 years agoGit 2.20.2 v2.20.2
Johannes Schindelin [Wed, 4 Dec 2019 21:33:15 +0000 (22:33 +0100)] 
Git 2.20.2

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agosubmodule: defend against submodule.update = !command in .gitmodules
Jonathan Nieder [Thu, 5 Dec 2019 09:28:28 +0000 (01:28 -0800)] 
submodule: defend against submodule.update = !command in .gitmodules

In v2.15.4, we started to reject `submodule.update` settings in
`.gitmodules`. Let's raise a BUG if it somehow still made it through
from anywhere but the Git config.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
4 years agot7415: adjust test for dubiously-nested submodule gitdirs for v2.20.x
Johannes Schindelin [Wed, 4 Dec 2019 09:06:08 +0000 (10:06 +0100)] 
t7415: adjust test for dubiously-nested submodule gitdirs for v2.20.x

In v2.20.x, Git clones submodules recursively by first creating the
submodules' gitdirs and _then_ "updating" the submodules. This can lead
to the situation where the clone path is taken because the directory
(while it exists already) is not a git directory, but then the clone
fails because that gitdir is unexpectedly already a directory.

This _also_ works around the vulnerability that was fixed in "Disallow
dubiously-nested submodule git directories", but it produces a different
error message than the one expected by the test case, therefore we
adjust the test case accordingly.

Note: as the two submodules "race each other", there are actually two
possible error messages, therefore we have to teach the test case to
expect _two_ possible (and good) outcomes in addition to the one it
expected before.

Note: this workaround is only necessary for the v2.20.x release train;
The behavior changed again in v2.21.x so that the original test case's
expectations are met again.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agoSync with 2.19.3
Johannes Schindelin [Wed, 4 Dec 2019 21:31:10 +0000 (22:31 +0100)] 
Sync with 2.19.3

* maint-2.19: (34 commits)
  Git 2.19.3
  Git 2.18.2
  Git 2.17.3
  Git 2.16.6
  test-drop-caches: use `has_dos_drive_prefix()`
  Git 2.15.4
  Git 2.14.6
  mingw: handle `subst`-ed "DOS drives"
  mingw: refuse to access paths with trailing spaces or periods
  mingw: refuse to access paths with illegal characters
  unpack-trees: let merged_entry() pass through do_add_entry()'s errors
  quote-stress-test: offer to test quoting arguments for MSYS2 sh
  t6130/t9350: prepare for stringent Win32 path validation
  quote-stress-test: allow skipping some trials
  quote-stress-test: accept arguments to test via the command-line
  tests: add a helper to stress test argument quoting
  mingw: fix quoting of arguments
  Disallow dubiously-nested submodule git directories
  protect_ntfs: turn on NTFS protection by default
  path: also guard `.gitmodules` against NTFS Alternate Data Streams
  ...

4 years agoGit 2.19.3 v2.19.3
Johannes Schindelin [Wed, 4 Dec 2019 21:29:33 +0000 (22:29 +0100)] 
Git 2.19.3

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agoSync with 2.18.2
Johannes Schindelin [Wed, 4 Dec 2019 21:27:04 +0000 (22:27 +0100)] 
Sync with 2.18.2

* maint-2.18: (33 commits)
  Git 2.18.2
  Git 2.17.3
  Git 2.16.6
  test-drop-caches: use `has_dos_drive_prefix()`
  Git 2.15.4
  Git 2.14.6
  mingw: handle `subst`-ed "DOS drives"
  mingw: refuse to access paths with trailing spaces or periods
  mingw: refuse to access paths with illegal characters
  unpack-trees: let merged_entry() pass through do_add_entry()'s errors
  quote-stress-test: offer to test quoting arguments for MSYS2 sh
  t6130/t9350: prepare for stringent Win32 path validation
  quote-stress-test: allow skipping some trials
  quote-stress-test: accept arguments to test via the command-line
  tests: add a helper to stress test argument quoting
  mingw: fix quoting of arguments
  Disallow dubiously-nested submodule git directories
  protect_ntfs: turn on NTFS protection by default
  path: also guard `.gitmodules` against NTFS Alternate Data Streams
  is_ntfs_dotgit(): speed it up
  ...

4 years agoGit 2.18.2 v2.18.2
Johannes Schindelin [Wed, 4 Dec 2019 21:22:52 +0000 (22:22 +0100)] 
Git 2.18.2

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agoSync with 2.17.3
Johannes Schindelin [Wed, 4 Dec 2019 21:21:20 +0000 (22:21 +0100)] 
Sync with 2.17.3

* maint-2.17: (32 commits)
  Git 2.17.3
  Git 2.16.6
  test-drop-caches: use `has_dos_drive_prefix()`
  Git 2.15.4
  Git 2.14.6
  mingw: handle `subst`-ed "DOS drives"
  mingw: refuse to access paths with trailing spaces or periods
  mingw: refuse to access paths with illegal characters
  unpack-trees: let merged_entry() pass through do_add_entry()'s errors
  quote-stress-test: offer to test quoting arguments for MSYS2 sh
  t6130/t9350: prepare for stringent Win32 path validation
  quote-stress-test: allow skipping some trials
  quote-stress-test: accept arguments to test via the command-line
  tests: add a helper to stress test argument quoting
  mingw: fix quoting of arguments
  Disallow dubiously-nested submodule git directories
  protect_ntfs: turn on NTFS protection by default
  path: also guard `.gitmodules` against NTFS Alternate Data Streams
  is_ntfs_dotgit(): speed it up
  mingw: disallow backslash characters in tree objects' file names
  ...

4 years agoGit 2.17.3 v2.17.3
Johannes Schindelin [Wed, 4 Dec 2019 21:13:04 +0000 (22:13 +0100)] 
Git 2.17.3

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agofsck: reject submodule.update = !command in .gitmodules
Jonathan Nieder [Thu, 5 Dec 2019 09:30:43 +0000 (01:30 -0800)] 
fsck: reject submodule.update = !command in .gitmodules

This allows hosting providers to detect whether they are being used
to attack users using malicious 'update = !command' settings in
.gitmodules.

Since ac1fbbda2013 (submodule: do not copy unknown update mode from
.gitmodules, 2013-12-02), in normal cases such settings have been
treated as 'update = none', so forbidding them should not produce any
collateral damage to legitimate uses.  A quick search does not reveal
any repositories making use of this construct, either.

Reported-by: Joern Schneeweisz <jschneeweisz@gitlab.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agoSync with 2.16.6
Johannes Schindelin [Wed, 4 Dec 2019 20:52:10 +0000 (21:52 +0100)] 
Sync with 2.16.6

* maint-2.16: (31 commits)
  Git 2.16.6
  test-drop-caches: use `has_dos_drive_prefix()`
  Git 2.15.4
  Git 2.14.6
  mingw: handle `subst`-ed "DOS drives"
  mingw: refuse to access paths with trailing spaces or periods
  mingw: refuse to access paths with illegal characters
  unpack-trees: let merged_entry() pass through do_add_entry()'s errors
  quote-stress-test: offer to test quoting arguments for MSYS2 sh
  t6130/t9350: prepare for stringent Win32 path validation
  quote-stress-test: allow skipping some trials
  quote-stress-test: accept arguments to test via the command-line
  tests: add a helper to stress test argument quoting
  mingw: fix quoting of arguments
  Disallow dubiously-nested submodule git directories
  protect_ntfs: turn on NTFS protection by default
  path: also guard `.gitmodules` against NTFS Alternate Data Streams
  is_ntfs_dotgit(): speed it up
  mingw: disallow backslash characters in tree objects' file names
  path: safeguard `.git` against NTFS Alternate Streams Accesses
  ...

4 years agoGit 2.16.6 v2.16.6
Johannes Schindelin [Wed, 4 Dec 2019 20:45:07 +0000 (21:45 +0100)] 
Git 2.16.6

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agotest-drop-caches: use `has_dos_drive_prefix()`
Johannes Schindelin [Wed, 4 Dec 2019 20:40:01 +0000 (21:40 +0100)] 
test-drop-caches: use `has_dos_drive_prefix()`

This is a companion patch to 'mingw: handle `subst`-ed "DOS drives"':
use the DOS drive prefix handling that is already provided by
`compat/mingw.c` (and which just learned to handle non-alphabetical
"drive letters").

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agoSync with 2.15.4
Johannes Schindelin [Wed, 4 Dec 2019 20:38:25 +0000 (21:38 +0100)] 
Sync with 2.15.4

* maint-2.15: (29 commits)
  Git 2.15.4
  Git 2.14.6
  mingw: handle `subst`-ed "DOS drives"
  mingw: refuse to access paths with trailing spaces or periods
  mingw: refuse to access paths with illegal characters
  unpack-trees: let merged_entry() pass through do_add_entry()'s errors
  quote-stress-test: offer to test quoting arguments for MSYS2 sh
  t6130/t9350: prepare for stringent Win32 path validation
  quote-stress-test: allow skipping some trials
  quote-stress-test: accept arguments to test via the command-line
  tests: add a helper to stress test argument quoting
  mingw: fix quoting of arguments
  Disallow dubiously-nested submodule git directories
  protect_ntfs: turn on NTFS protection by default
  path: also guard `.gitmodules` against NTFS Alternate Data Streams
  is_ntfs_dotgit(): speed it up
  mingw: disallow backslash characters in tree objects' file names
  path: safeguard `.git` against NTFS Alternate Streams Accesses
  clone --recurse-submodules: prevent name squatting on Windows
  is_ntfs_dotgit(): only verify the leading segment
  ...

4 years agoGit 2.15.4 v2.15.4
Johannes Schindelin [Wed, 4 Dec 2019 20:33:29 +0000 (21:33 +0100)] 
Git 2.15.4

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agosubmodule: reject submodule.update = !command in .gitmodules
Jonathan Nieder [Thu, 5 Dec 2019 09:28:28 +0000 (01:28 -0800)] 
submodule: reject submodule.update = !command in .gitmodules

Since ac1fbbda2013 (submodule: do not copy unknown update mode from
.gitmodules, 2013-12-02), Git has been careful to avoid copying

[submodule "foo"]
update = !run an arbitrary scary command

from .gitmodules to a repository's local config, copying in the
setting 'update = none' instead.  The gitmodules(5) manpage documents
the intention:

The !command form is intentionally ignored here for security
reasons

Unfortunately, starting with v2.20.0-rc0 (which integrated ee69b2a9
(submodule--helper: introduce new update-module-mode helper,
2018-08-13, first released in v2.20.0-rc0)), there are scenarios where
we *don't* ignore it: if the config store contains no
submodule.foo.update setting, the submodule-config API falls back to
reading .gitmodules and the repository-supplied !command gets run
after all.

This was part of a general change over time in submodule support to
read more directly from .gitmodules, since unlike .git/config it
allows a project to change values between branches and over time
(while still allowing .git/config to override things).  But it was
never intended to apply to this kind of dangerous configuration.

The behavior change was not advertised in ee69b2a9's commit message
and was missed in review.

Let's take the opportunity to make the protection more robust, even in
Git versions that are technically not affected: instead of quietly
converting 'update = !command' to 'update = none', noisily treat it as
an error.  Allowing the setting but treating it as meaning something
else was just confusing; users are better served by seeing the error
sooner.  Forbidding the construct makes the semantics simpler and
means we can check for it in fsck (in a separate patch).

As a result, the submodule-config API cannot read this value from
.gitmodules under any circumstance, and we can declare with confidence

For security reasons, the '!command' form is not accepted
here.

Reported-by: Joern Schneeweisz <jschneeweisz@gitlab.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
4 years agoSync with 2.14.6
Johannes Schindelin [Wed, 4 Dec 2019 20:26:31 +0000 (21:26 +0100)] 
Sync with 2.14.6

* maint-2.14: (28 commits)
  Git 2.14.6
  mingw: handle `subst`-ed "DOS drives"
  mingw: refuse to access paths with trailing spaces or periods
  mingw: refuse to access paths with illegal characters
  unpack-trees: let merged_entry() pass through do_add_entry()'s errors
  quote-stress-test: offer to test quoting arguments for MSYS2 sh
  t6130/t9350: prepare for stringent Win32 path validation
  quote-stress-test: allow skipping some trials
  quote-stress-test: accept arguments to test via the command-line
  tests: add a helper to stress test argument quoting
  mingw: fix quoting of arguments
  Disallow dubiously-nested submodule git directories
  protect_ntfs: turn on NTFS protection by default
  path: also guard `.gitmodules` against NTFS Alternate Data Streams
  is_ntfs_dotgit(): speed it up
  mingw: disallow backslash characters in tree objects' file names
  path: safeguard `.git` against NTFS Alternate Streams Accesses
  clone --recurse-submodules: prevent name squatting on Windows
  is_ntfs_dotgit(): only verify the leading segment
  test-path-utils: offer to run a protectNTFS/protectHFS benchmark
  ...

4 years agoGit 2.14.6 v2.14.6
Johannes Schindelin [Wed, 4 Dec 2019 18:58:46 +0000 (19:58 +0100)] 
Git 2.14.6

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agoThe third batch
Junio C Hamano [Thu, 5 Dec 2019 20:43:59 +0000 (12:43 -0800)] 
The third batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoMerge branch 'js/pkt-line-h-typofix'
Junio C Hamano [Thu, 5 Dec 2019 20:52:49 +0000 (12:52 -0800)] 
Merge branch 'js/pkt-line-h-typofix'

Typofix.

* js/pkt-line-h-typofix:
  pkt-line: fix a typo

4 years agoMerge branch 'us/unpack-trees-fsmonitor'
Junio C Hamano [Thu, 5 Dec 2019 20:52:48 +0000 (12:52 -0800)] 
Merge branch 'us/unpack-trees-fsmonitor'

Users of oneway_merge() (like "reset --hard") learned to take
advantage of fsmonitor to avoid unnecessary lstat(2) calls.

* us/unpack-trees-fsmonitor:
  unpack-trees: skip stat on fsmonitor-valid files

4 years agoMerge branch 'sg/test-bool-env'
Junio C Hamano [Thu, 5 Dec 2019 20:52:48 +0000 (12:52 -0800)] 
Merge branch 'sg/test-bool-env'

Recently we have declared that GIT_TEST_* variables take the
usual boolean values (it used to be that some used "non-empty
means true" and taking GIT_TEST_VAR=YesPlease as true); make
sure we notice and fail when non-bool strings are given to
these variables.

* sg/test-bool-env:
  t5608-clone-2gb.sh: turn GIT_TEST_CLONE_2GB into a bool
  tests: add 'test_bool_env' to catch non-bool GIT_TEST_* values

4 years agoMerge branch 'mh/clear-topo-walk-upon-reset'
Junio C Hamano [Thu, 5 Dec 2019 20:52:48 +0000 (12:52 -0800)] 
Merge branch 'mh/clear-topo-walk-upon-reset'

The revision walking machinery uses resources like per-object flag
bits that need to be reset before a new iteration of walking
begins, but the resources related to topological walk were not
cleared correctly, which has been corrected.

* mh/clear-topo-walk-upon-reset:
  revision: free topo_walk_info before creating a new one in init_topo_walk
  revision: clear the topo-walk flags in reset_revision_walk

4 years agoMerge branch 'hv/assume-priumax-is-available-anywhere'
Junio C Hamano [Thu, 5 Dec 2019 20:52:47 +0000 (12:52 -0800)] 
Merge branch 'hv/assume-priumax-is-available-anywhere'

We have had compatibility fallback macro definitions for "PRIuMAX",
"PRIu32", etc. but did not for "PRIdMAX", while the code used the
last one apparently without any hiccup reported recently.  The
fallback macro definitions for these <inttypes.h> macros that must
appear in C99 systems have been removed.

* hv/assume-priumax-is-available-anywhere:
  git-compat-util.h: drop the `PRIuMAX` and other fallback definitions

4 years agoMerge branch 'mg/submodule-status-from-a-subdirectory'
Junio C Hamano [Thu, 5 Dec 2019 20:52:47 +0000 (12:52 -0800)] 
Merge branch 'mg/submodule-status-from-a-subdirectory'

"git submodule status" that is run from a subdirectory of the
superproject did not work well, which has been corrected.

* mg/submodule-status-from-a-subdirectory:
  submodule: fix 'submodule status' when called from a subdirectory

4 years agoMerge branch 'dl/t5520-cleanup'
Junio C Hamano [Thu, 5 Dec 2019 20:52:47 +0000 (12:52 -0800)] 
Merge branch 'dl/t5520-cleanup'

Test cleanup.

* dl/t5520-cleanup:
  t5520: replace `! git` with `test_must_fail git`
  t5520: remove redundant lines in test cases
  t5520: replace $(cat ...) comparison with test_cmp
  t5520: don't put git in upstream of pipe
  t5520: test single-line files by git with test_cmp
  t5520: use test_cmp_rev where possible
  t5520: replace test -{n,z} with test-lib functions
  t5520: use test_line_count where possible
  t5520: remove spaces after redirect operator
  t5520: replace test -f with test-lib functions
  t5520: let sed open its own input
  t5520: use sq for test case names
  t5520: improve test style
  t: teach test_cmp_rev to accept ! for not-equals
  t0000: test multiple local assignment

4 years agoMerge branch 'nl/reset-patch-takes-a-tree'
Junio C Hamano [Thu, 5 Dec 2019 20:52:47 +0000 (12:52 -0800)] 
Merge branch 'nl/reset-patch-takes-a-tree'

"git reset --patch $object" without any pathspec should allow a
tree object to be given, but incorrectly required a committish,
which has been corrected.

* nl/reset-patch-takes-a-tree:
  reset: parse rev as tree-ish in patch mode

4 years agoMerge branch 'mg/doc-submodule-status-cached'
Junio C Hamano [Thu, 5 Dec 2019 20:52:47 +0000 (12:52 -0800)] 
Merge branch 'mg/doc-submodule-status-cached'

"git submodule status" and "git submodule status --cached" show
different things, but the documentation did not cover them
correctly, which has been corrected.

* mg/doc-submodule-status-cached:
  doc: document 'git submodule status --cached'

4 years agoMerge branch 'js/git-svn-use-rebase-merges'
Junio C Hamano [Thu, 5 Dec 2019 20:52:46 +0000 (12:52 -0800)] 
Merge branch 'js/git-svn-use-rebase-merges'

Prepare further for "rebase --preserve-merges" deprecation.

* js/git-svn-use-rebase-merges:
  git svn: stop using `rebase --preserve-merges`

4 years agoMerge branch 'hi/gpg-optional-pkfp-fix'
Junio C Hamano [Thu, 5 Dec 2019 20:52:46 +0000 (12:52 -0800)] 
Merge branch 'hi/gpg-optional-pkfp-fix'

The code to parse GPG output used to assume incorrectly that the
finterprint for the primary key would always be present for a valid
signature, which has been corrected.

* hi/gpg-optional-pkfp-fix:
  gpg-interface: limit search for primary key fingerprint
  gpg-interface: refactor the free-and-xmemdupz pattern

4 years agoMerge branch 'pw/sequencer-compare-with-right-parent-to-check-empty-commits'
Junio C Hamano [Thu, 5 Dec 2019 20:52:46 +0000 (12:52 -0800)] 
Merge branch 'pw/sequencer-compare-with-right-parent-to-check-empty-commits'

The sequencer machinery compared the HEAD and the state it is
attempting to commit to decide if the result would be a no-op
commit, even when amending a commit, which was incorrect, and
has been corrected.

* pw/sequencer-compare-with-right-parent-to-check-empty-commits:
  sequencer: fix empty commit check when amending

4 years agoMerge branch 'jk/fail-show-toplevel-outside-working-tree'
Junio C Hamano [Thu, 5 Dec 2019 20:52:45 +0000 (12:52 -0800)] 
Merge branch 'jk/fail-show-toplevel-outside-working-tree'

"git rev-parse --show-toplevel" run outside of any working tree did
not error out, which has been corrected.

* jk/fail-show-toplevel-outside-working-tree:
  rev-parse: make --show-toplevel without a worktree an error

4 years agoMerge branch 'sg/unpack-progress-throughput'
Junio C Hamano [Thu, 5 Dec 2019 20:52:45 +0000 (12:52 -0800)] 
Merge branch 'sg/unpack-progress-throughput'

"git unpack-objects" used to show progress based only on the number
of received and unpacked objects, which stalled when it has to
handle an unusually large object.  It now shows the throughput as
well.

* sg/unpack-progress-throughput:
  builtin/unpack-objects.c: show throughput progress

4 years agoMerge branch 'pb/submodule-update-fetches'
Junio C Hamano [Thu, 5 Dec 2019 20:52:45 +0000 (12:52 -0800)] 
Merge branch 'pb/submodule-update-fetches'

Doc update.

* pb/submodule-update-fetches:
  doc: mention that 'git submodule update' fetches missing commits

4 years agoMerge branch 'jc/azure-ci-osx-fix-fix'
Junio C Hamano [Thu, 5 Dec 2019 20:52:44 +0000 (12:52 -0800)] 
Merge branch 'jc/azure-ci-osx-fix-fix'

CI jobs for macOS has been made less chatty when updating perforce
package used during testing.

* jc/azure-ci-osx-fix-fix:
  ci(osx): update homebrew-cask repository with less noise

4 years agoMerge branch 'dl/range-diff-with-notes'
Junio C Hamano [Thu, 5 Dec 2019 20:52:44 +0000 (12:52 -0800)] 
Merge branch 'dl/range-diff-with-notes'

"git range-diff" learned to take the "--notes=<ref>" and the
"--no-notes" options to control the commit notes included in the
log message that gets compared.

* dl/range-diff-with-notes:
  format-patch: pass notes configuration to range-diff
  range-diff: pass through --notes to `git log`
  range-diff: output `## Notes ##` header
  t3206: range-diff compares logs with commit notes
  t3206: s/expected/expect/
  t3206: disable parameter substitution in heredoc
  t3206: remove spaces after redirect operators
  pretty-options.txt: --notes accepts a ref instead of treeish
  rev-list-options.txt: remove reference to --show-notes
  argv-array: add space after `while`

4 years agoMerge branch 'jh/userdiff-python-async'
Junio C Hamano [Thu, 5 Dec 2019 20:52:44 +0000 (12:52 -0800)] 
Merge branch 'jh/userdiff-python-async'

The userdiff machinery has been taught that "async def" is another
way to begin a "function" in Python.

* jh/userdiff-python-async:
  userdiff: support Python async functions

4 years agoMerge branch 'ec/fetch-mark-common-refs-trace2'
Junio C Hamano [Thu, 5 Dec 2019 20:52:43 +0000 (12:52 -0800)] 
Merge branch 'ec/fetch-mark-common-refs-trace2'

Trace2 annotation.

* ec/fetch-mark-common-refs-trace2:
  fetch: add trace2 instrumentation

4 years agoMerge branch 'dd/rebase-merge-reserves-onto-label'
Junio C Hamano [Thu, 5 Dec 2019 20:52:43 +0000 (12:52 -0800)] 
Merge branch 'dd/rebase-merge-reserves-onto-label'

The logic to avoid duplicate label names generated by "git rebase
--rebase-merges" forgot that the machinery itself uses "onto" as a
label name, which must be avoided by auto-generated labels, which
has been corrected.

* dd/rebase-merge-reserves-onto-label:
  sequencer: handle rebase-merges for "onto" message

4 years agoMerge branch 'js/builtin-add-i'
Junio C Hamano [Thu, 5 Dec 2019 20:52:43 +0000 (12:52 -0800)] 
Merge branch 'js/builtin-add-i'

The beginning of rewriting "git add -i" in C.

* js/builtin-add-i:
  built-in add -i: implement the `help` command
  built-in add -i: use color in the main loop
  built-in add -i: support `?` (prompt help)
  built-in add -i: show unique prefixes of the commands
  built-in add -i: implement the main loop
  built-in add -i: color the header in the `status` command
  built-in add -i: implement the `status` command
  diff: export diffstat interface
  Start to implement a built-in version of `git add --interactive`

4 years agoMerge branch 'js/rebase-r-safer-label'
Junio C Hamano [Thu, 5 Dec 2019 20:52:43 +0000 (12:52 -0800)] 
Merge branch 'js/rebase-r-safer-label'

A label used in the todo list that are generated by "git rebase
--rebase-merges" is used as a part of a refname; the logic to come
up with the label has been tightened to avoid names that cannot be
used as such.

* js/rebase-r-safer-label:
  rebase -r: let `label` generate safer labels
  rebase-merges: move labels' whitespace mangling into `label_oid()`

4 years agoMerge branch 'ep/guard-kset-tar-headers'
Junio C Hamano [Thu, 5 Dec 2019 20:52:43 +0000 (12:52 -0800)] 
Merge branch 'ep/guard-kset-tar-headers'

Code clean-up.

* ep/guard-kset-tar-headers:
  kset.h, tar.h: add missing header guard to prevent multiple inclusion

4 years agoMerge branch 'win32-accommodate-funny-drive-names'
Johannes Schindelin [Mon, 16 Sep 2019 11:26:40 +0000 (13:26 +0200)] 
Merge branch 'win32-accommodate-funny-drive-names'

While the only permitted drive letters for physical drives on Windows
are letters of the US-English alphabet, this restriction does not apply
to virtual drives assigned via `subst <letter>: <path>`.

To prevent targeted attacks against systems where "funny" drive letters
such as `1` or `!` are assigned, let's handle them as regular drive
letters on Windows.

This fixes CVE-2019-1351.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agoMerge branch 'win32-filenames-cannot-have-trailing-spaces-or-periods'
Johannes Schindelin [Mon, 16 Sep 2019 11:26:40 +0000 (13:26 +0200)] 
Merge branch 'win32-filenames-cannot-have-trailing-spaces-or-periods'

On Windows, filenames cannot have trailing spaces or periods, when
opening such paths, they are stripped automatically. Read: you can open
the file `README` via the file name `README . . .`. This ambiguity can
be used in combination with other security bugs to cause e.g. remote
code execution during recursive clones. This patch series fixes that.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agoMerge branch 'fix-mingw-quoting-bug'
Johannes Schindelin [Mon, 16 Sep 2019 11:26:40 +0000 (13:26 +0200)] 
Merge branch 'fix-mingw-quoting-bug'

This patch fixes a vulnerability in the Windows-specific code where a
submodule names ending in a backslash were quoted incorrectly, and that
bug could be abused to insert command-line parameters e.g. to `ssh` in a
recursive clone.

Note: this bug is Windows-only, as we have to construct a command line
for the process-to-spawn, unlike Linux/macOS, where `execv()` accepts an
already-split command line.

While at it, other quoting issues are fixed as well.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agoMerge branch 'dubiously-nested-submodules'
Johannes Schindelin [Wed, 2 Oct 2019 11:08:45 +0000 (13:08 +0200)] 
Merge branch 'dubiously-nested-submodules'

Recursive clones are currently affected by a vulnerability that is
caused by too-lax validation of submodule names.

This topic branch fixes that.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agoMerge branch 'turn-on-protectntfs-by-default'
Johannes Schindelin [Mon, 16 Sep 2019 11:26:40 +0000 (13:26 +0200)] 
Merge branch 'turn-on-protectntfs-by-default'

This patch series makes it safe to use Git on Windows drives, even if
running on a mounted network share or within the Windows Subsystem for
Linux (WSL).

This topic branch addresses CVE-2019-1353.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agomingw: handle `subst`-ed "DOS drives"
Johannes Schindelin [Thu, 5 Sep 2019 22:09:10 +0000 (00:09 +0200)] 
mingw: handle `subst`-ed "DOS drives"

Over a decade ago, in 25fe217b86c (Windows: Treat Windows style path
names., 2008-03-05), Git was taught to handle absolute Windows paths,
i.e. paths that start with a drive letter and a colon.

Unbeknownst to us, while drive letters of physical drives are limited to
letters of the English alphabet, there is a way to assign virtual drive
letters to arbitrary directories, via the `subst` command, which is
_not_ limited to English letters.

It is therefore possible to have absolute Windows paths of the form
`1:\what\the\hex.txt`. Even "better": pretty much arbitrary Unicode
letters can also be used, e.g. `ä:\tschibät.sch`.

While it can be sensibly argued that users who set up such funny drive
letters really seek adverse consequences, the Windows Operating System
is known to be a platform where many users are at the mercy of
administrators who have their very own idea of what constitutes a
reasonable setup.

Therefore, let's just make sure that such funny paths are still
considered absolute paths by Git, on Windows.

In addition to Unicode characters, pretty much any character is a valid
drive letter, as far as `subst` is concerned, even `:` and `"` or even a
space character. While it is probably the opposite of smart to use them,
let's safeguard `is_dos_drive_prefix()` against all of them.

Note: `[::1]:repo` is a valid URL, but not a valid path on Windows.
As `[` is now considered a valid drive letter, we need to be very
careful to avoid misinterpreting such a string as valid local path in
`url_is_local_not_ssh()`. To do that, we use the just-introduced
function `is_valid_path()` (which will label the string as invalid file
name because of the colon characters).

This fixes CVE-2019-1351.

Reported-by: Nicolas Joly <Nicolas.Joly@microsoft.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agoMerge branch 'disallow-dotgit-via-ntfs-alternate-data-streams'
Johannes Schindelin [Mon, 16 Sep 2019 11:26:40 +0000 (13:26 +0200)] 
Merge branch 'disallow-dotgit-via-ntfs-alternate-data-streams'

This patch series plugs an attack vector we had overlooked in our
December 2014 work on `core.protectNTFS`.

Essentially, the path `.git::$INDEX_ALLOCATION/config` is interpreted as
`.git/config` when NTFS Alternate Data Streams are available (which they
are on Windows, and at least on network shares that are SMB-mounted on
macOS).

Needless to say: we don't want that.

In fact, we want to stay on the very safe side and not even special-case
the `$INDEX_ALLOCATION` stream type: let's just prevent Git from
touching _any_ explicitly specified Alternate Data Stream of `.git`.

In essence, we'll prevent Git from tracking, or writing to, any path
with a segment of the form `.git:<anything>`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agomingw: refuse to access paths with trailing spaces or periods
Johannes Schindelin [Thu, 5 Sep 2019 11:27:53 +0000 (13:27 +0200)] 
mingw: refuse to access paths with trailing spaces or periods

When creating a directory on Windows whose path ends in a space or a
period (or chains thereof), the Win32 API "helpfully" trims those. For
example, `mkdir("abc ");` will return success, but actually create a
directory called `abc` instead.

This stems back to the DOS days, when all file names had exactly 8
characters plus exactly 3 characters for the file extension, and the
only way to have shorter names was by padding with spaces.

Sadly, this "helpful" behavior is a bit inconsistent: after a successful
`mkdir("abc ");`, a `mkdir("abc /def")` will actually _fail_ (because
the directory `abc ` does not actually exist).

Even if it would work, we now have a serious problem because a Git
repository could contain directories `abc` and `abc `, and on Windows,
they would be "merged" unintentionally.

As these paths are illegal on Windows, anyway, let's disallow any
accesses to such paths on that Operating System.

For practical reasons, this behavior is still guarded by the
config setting `core.protectNTFS`: it is possible (and at least two
regression tests make use of it) to create commits without involving the
worktree. In such a scenario, it is of course possible -- even on
Windows -- to create such file names.

Among other consequences, this patch disallows submodules' paths to end
in spaces on Windows (which would formerly have confused Git enough to
try to write into incorrect paths, anyway).

While this patch does not fix a vulnerability on its own, it prevents an
attack vector that was exploited in demonstrations of a number of
recently-fixed security bugs.

The regression test added to `t/t7417-submodule-path-url.sh` reflects
that attack vector.

Note that we have to adjust the test case "prevent git~1 squatting on
Windows" in `t/t7415-submodule-names.sh` because of a very subtle issue.
It tries to clone two submodules whose names differ only in a trailing
period character, and as a consequence their git directories differ in
the same way. Previously, when Git tried to clone the second submodule,
it thought that the git directory already existed (because on Windows,
when you create a directory with the name `b.` it actually creates `b`),
but with this patch, the first submodule's clone will fail because of
the illegal name of the git directory. Therefore, when cloning the
second submodule, Git will take a different code path: a fresh clone
(without an existing git directory). Both code paths fail to clone the
second submodule, both because the the corresponding worktree directory
exists and is not empty, but the error messages are worded differently.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agoquote-stress-test: offer to test quoting arguments for MSYS2 sh
Johannes Schindelin [Thu, 19 Sep 2019 22:12:37 +0000 (00:12 +0200)] 
quote-stress-test: offer to test quoting arguments for MSYS2 sh

It is unfortunate that we need to quote arguments differently on
Windows, depending whether we build a command-line for MSYS2's `sh` or
for other Windows executables.

We already have a test helper to verify the latter, with this patch we
can also verify the former.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agomingw: refuse to access paths with illegal characters
Johannes Schindelin [Thu, 5 Sep 2019 11:44:21 +0000 (13:44 +0200)] 
mingw: refuse to access paths with illegal characters

Certain characters are not admissible in file names on Windows, even if
Cygwin/MSYS2 (and therefore, Git for Windows' Bash) pretend that they
are, e.g. `:`, `<`, `>`, etc

Let's disallow those characters explicitly in Windows builds of Git.

Note: just like trailing spaces or periods, it _is_ possible on Windows
to create commits adding files with such illegal characters, as long as
the operation leaves the worktree untouched. To allow for that, we
continue to guard `is_valid_win32_path()` behind the config setting
`core.protectNTFS`, so that users _can_ continue to do that, as long as
they turn the protections off via that config setting.

Among other problems, this prevents Git from trying to write to an "NTFS
Alternate Data Stream" (which refers to metadata stored alongside a
file, under a special name: "<filename>:<stream-name>"). This fix
therefore also prevents an attack vector that was exploited in
demonstrations of a number of recently-fixed security bugs.

Further reading on illegal characters in Win32 filenames:
https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agounpack-trees: let merged_entry() pass through do_add_entry()'s errors
Johannes Schindelin [Mon, 9 Sep 2019 11:56:15 +0000 (13:56 +0200)] 
unpack-trees: let merged_entry() pass through do_add_entry()'s errors

A `git clone` will end with exit code 0 when `merged_entry()` returns a
positive value during a call of `unpack_trees()` to `traverse_trees()`.
The reason is that `unpack_trees()` will interpret a positive value not
to be an error.

The problem is, however, that `add_index_entry()` (which is called by
`merged_entry()` can report an error, and we really should fail the
entire clone in such a case.

Let's fix this problem, in preparation for a Windows-specific patch
disallowing `mkdir()` with directory names that contain a trailing space
(which is illegal on NTFS): we want `git clone` to abort when a path
cannot be checked out due to that condition.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agoquote-stress-test: allow skipping some trials
Johannes Schindelin [Thu, 19 Sep 2019 21:46:31 +0000 (23:46 +0200)] 
quote-stress-test: allow skipping some trials

When the, say, 93rd trial run fails, it is a good idea to have a way to
skip the first 92 trials and dig directly into the 93rd in a debugger.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agot6130/t9350: prepare for stringent Win32 path validation
Johannes Schindelin [Mon, 9 Sep 2019 13:43:35 +0000 (15:43 +0200)] 
t6130/t9350: prepare for stringent Win32 path validation

On Windows, file names cannot contain asterisks nor newline characters.
In an upcoming commit, we will make this limitation explicit,
disallowing even the creation of commits that introduce such file names.

However, in the test scripts touched by this patch, we _know_ that those
paths won't be checked out, so we _want_ to allow such file names.

Happily, the stringent path validation will be guarded via the
`core.protectNTFS` flag, so all we need to do is to force that flag off
temporarily.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agoquote-stress-test: accept arguments to test via the command-line
Johannes Schindelin [Fri, 20 Sep 2019 17:09:39 +0000 (19:09 +0200)] 
quote-stress-test: accept arguments to test via the command-line

When the stress test reported a problem with quoting certain arguments,
it is helpful to have a facility to play with those arguments in order
to find out whether variations of those arguments are affected, too.

Let's allow `test-run-command quote-stress-test -- <args>` to be used
for that purpose.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agotests: add a helper to stress test argument quoting
Garima Singh [Wed, 18 Sep 2019 20:03:59 +0000 (16:03 -0400)] 
tests: add a helper to stress test argument quoting

On Windows, we have to do all the command-line argument quoting
ourselves. Worse: we have to have two versions of said quoting, one for
MSYS2 programs (which have their own dequoting rules) and the rest.

We care mostly about the rest, and to make sure that that works, let's
have a stress test that comes up with all kinds of awkward arguments,
verifying that a spawned sub-process receives those unharmed.

Signed-off-by: Garima Singh <garima.singh@microsoft.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agoDisallow dubiously-nested submodule git directories
Johannes Schindelin [Tue, 1 Oct 2019 21:27:18 +0000 (23:27 +0200)] 
Disallow dubiously-nested submodule git directories

Currently it is technically possible to let a submodule's git
directory point right into the git dir of a sibling submodule.

Example: the git directories of two submodules with the names `hippo`
and `hippo/hooks` would be `.git/modules/hippo/` and
`.git/modules/hippo/hooks/`, respectively, but the latter is already
intended to house the former's hooks.

In most cases, this is just confusing, but there is also a (quite
contrived) attack vector where Git can be fooled into mistaking remote
content for file contents it wrote itself during a recursive clone.

Let's plug this bug.

To do so, we introduce the new function `validate_submodule_git_dir()`
which simply verifies that no git dir exists for any leading directories
of the submodule name (if there are any).

Note: this patch specifically continues to allow sibling modules names
of the form `core/lib`, `core/doc`, etc, as long as `core` is not a
submodule name.

This fixes CVE-2019-1387.

Reported-by: Nicolas Joly <Nicolas.Joly@microsoft.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agoprotect_ntfs: turn on NTFS protection by default
Johannes Schindelin [Mon, 9 Sep 2019 19:04:41 +0000 (21:04 +0200)] 
protect_ntfs: turn on NTFS protection by default

Back in the DOS days, in the FAT file system, file names always
consisted of a base name of length 8 plus a file extension of length 3.
Shorter file names were simply padded with spaces to the full 8.3
format.

Later, the FAT file system was taught to support _also_ longer names,
with an 8.3 "short name" as primary file name. While at it, the same
facility allowed formerly illegal file names, such as `.git` (empty base
names were not allowed), which would have the "short name" `git~1`
associated with it.

For backwards-compatibility, NTFS supports alternative 8.3 short
filenames, too, even if starting with Windows Vista, they are only
generated on the system drive by default.

We addressed the problem that the `.git/` directory can _also_ be
accessed via `git~1/` (when short names are enabled) in 2b4c6efc821
(read-cache: optionally disallow NTFS .git variants, 2014-12-16), i.e.
since Git v1.9.5, by introducing the config setting `core.protectNTFS`
and enabling it by default on Windows.

In the meantime, Windows 10 introduced the "Windows Subsystem for Linux"
(short: WSL), i.e. a way to run Linux applications/distributions in a
thinly-isolated subsystem on Windows (giving rise to many a "2016 is the
Year of Linux on the Desktop" jokes). WSL is getting increasingly
popular, also due to the painless way Linux application can operate
directly ("natively") on files on Windows' file system: the Windows
drives are mounted automatically (e.g. `C:` as `/mnt/c/`).

Taken together, this means that we now have to enable the safe-guards of
Git v1.9.5 also in WSL: it is possible to access a `.git` directory
inside `/mnt/c/` via the 8.3 name `git~1` (unless short name generation
was disabled manually). Since regular Linux distributions run in WSL,
this means we have to enable `core.protectNTFS` at least on Linux, too.

To enable Services for Macintosh in Windows NT to store so-called
resource forks, NTFS introduced "Alternate Data Streams". Essentially,
these constitute additional metadata that are connected to (and copied
with) their associated files, and they are accessed via pseudo file
names of the form `filename:<stream-name>:<stream-type>`.

In a recent patch, we extended `core.protectNTFS` to also protect
against accesses via NTFS Alternate Data Streams, e.g. to prevent
contents of the `.git/` directory to be "tracked" via yet another
alternative file name.

While it is not possible (at least by default) to access files via NTFS
Alternate Data Streams from within WSL, the defaults on macOS when
mounting network shares via SMB _do_ allow accessing files and
directories in that way. Therefore, we need to enable `core.protectNTFS`
on macOS by default, too, and really, on any Operating System that can
mount network shares via SMB/CIFS.

A couple of approaches were considered for fixing this:

1. We could perform a dynamic NTFS check similar to the `core.symlinks`
   check in `init`/`clone`: instead of trying to create a symbolic link
   in the `.git/` directory, we could create a test file and try to
   access `.git/config` via 8.3 name and/or Alternate Data Stream.

2. We could simply "flip the switch" on `core.protectNTFS`, to make it
   "on by default".

The obvious downside of 1. is that it won't protect worktrees that were
clone with a vulnerable Git version already. We considered patching code
paths that check out files to check whether we're running on an NTFS
system dynamically and persist the result in the repository-local config
setting `core.protectNTFS`, but in the end decided that this solution
would be too fragile, and too involved.

The obvious downside of 2. is that everybody will have to "suffer" the
performance penalty incurred from calling `is_ntfs_dotgit()` on every
path, even in setups where.

After the recent work to accelerate `is_ntfs_dotgit()` in most cases,
it looks as if the time spent on validating ten million random
file names increases only negligibly (less than 20ms, well within the
standard deviation of ~50ms). Therefore the benefits outweigh the cost.

Another downside of this is that paths that might have been acceptable
previously now will be forbidden. Realistically, though, this is an
improvement because public Git hosters already would reject any `git
push` that contains such file names.

Note: There might be a similar problem mounting HFS+ on Linux. However,
this scenario has been considered unlikely and in light of the cost (in
the aforementioned benchmark, `core.protectHFS = true` increased the
time from ~440ms to ~610ms), it was decided _not_ to touch the default
of `core.protectHFS`.

This change addresses CVE-2019-1353.

Reported-by: Nicolas Joly <Nicolas.Joly@microsoft.com>
Helped-by: Garima Singh <garima.singh@microsoft.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agopath: also guard `.gitmodules` against NTFS Alternate Data Streams
Johannes Schindelin [Wed, 28 Aug 2019 10:22:17 +0000 (12:22 +0200)] 
path: also guard `.gitmodules` against NTFS Alternate Data Streams

We just safe-guarded `.git` against NTFS Alternate Data Stream-related
attack vectors, and now it is time to do the same for `.gitmodules`.

Note: In the added regression test, we refrain from verifying all kinds
of variations between short names and NTFS Alternate Data Streams: as
the new code disallows _all_ Alternate Data Streams of `.gitmodules`, it
is enough to test one in order to know that all of them are guarded
against.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agomingw: fix quoting of arguments
Johannes Schindelin [Fri, 13 Sep 2019 14:32:43 +0000 (16:32 +0200)] 
mingw: fix quoting of arguments

We need to be careful to follow proper quoting rules. For example, if an
argument contains spaces, we have to quote them. Double-quotes need to
be escaped. Backslashes need to be escaped, but only if they are
followed by a double-quote character.

We need to be _extra_ careful to consider the case where an argument
ends in a backslash _and_ needs to be quoted: in this case, we append a
double-quote character, i.e. the backslash now has to be escaped!

The current code, however, fails to recognize that, and therefore can
turn an argument that ends in a single backslash into a quoted argument
that now ends in an escaped double-quote character. This allows
subsequent command-line parameters to be split and part of them being
mistaken for command-line options, e.g. through a maliciously-crafted
submodule URL during a recursive clone.

Technically, we would not need to quote _all_ arguments which end in a
backslash _unless_ the argument needs to be quoted anyway. For example,
`test\` would not need to be quoted, while `test \` would need to be.

To keep the code simple, however, and therefore easier to reason about
and ensure its correctness, we now _always_ quote an argument that ends
in a backslash.

This addresses CVE-2019-1350.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agois_ntfs_dotgit(): speed it up
Johannes Schindelin [Fri, 6 Sep 2019 19:09:35 +0000 (21:09 +0200)] 
is_ntfs_dotgit(): speed it up

Previously, this function was written without focusing on speed,
intending to make reviewing the code as easy as possible, to avoid any
bugs in this critical code.

Turns out: we can do much better on both accounts. With this patch, we
make it as fast as this developer can make it go:

- We avoid the call to `is_dir_sep()` and make all the character
  comparisons explicit.

- We avoid the cost of calling `strncasecmp()` and unroll the test for
  `.git` and `git~1`, not even using `tolower()` because it is faster to
  compare against two constant values.

- We look for `.git` and `.git~1` first thing, and return early if not
  found.

- We also avoid calling a separate function for detecting chains of
  spaces and periods.

Each of these improvements has a noticeable impact on the speed of
`is_ntfs_dotgit()`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agopath: safeguard `.git` against NTFS Alternate Streams Accesses
Johannes Schindelin [Wed, 28 Aug 2019 10:22:17 +0000 (12:22 +0200)] 
path: safeguard `.git` against NTFS Alternate Streams Accesses

Probably inspired by HFS' resource streams, NTFS supports "Alternate
Data Streams": by appending `:<stream-name>` to the file name,
information in addition to the file contents can be written and read,
information that is copied together with the file (unless copied to a
non-NTFS location).

These Alternate Data Streams are typically used for things like marking
an executable as having just been downloaded from the internet (and
hence not necessarily being trustworthy).

In addition to a stream name, a stream type can be appended, like so:
`:<stream-name>:<stream-type>`. Unless specified, the default stream
type is `$DATA` for files and `$INDEX_ALLOCATION` for directories. In
other words, `.git::$INDEX_ALLOCATION` is a valid way to reference the
`.git` directory!

In our work in Git v2.2.1 to protect Git on NTFS drives under
`core.protectNTFS`, we focused exclusively on NTFS short names, unaware
of the fact that NTFS Alternate Data Streams offer a similar attack
vector.

Let's fix this.

Seeing as it is better to be safe than sorry, we simply disallow paths
referring to *any* NTFS Alternate Data Stream of `.git`, not just
`::$INDEX_ALLOCATION`. This also simplifies the implementation.

This closes CVE-2019-1352.

Further reading about NTFS Alternate Data Streams:
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/c54dec26-1551-4d3a-a0ea-4fa40f848eb3

Reported-by: Nicolas Joly <Nicolas.Joly@microsoft.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agois_ntfs_dotgit(): only verify the leading segment
Johannes Schindelin [Mon, 23 Sep 2019 06:58:11 +0000 (08:58 +0200)] 
is_ntfs_dotgit(): only verify the leading segment

The config setting `core.protectNTFS` is specifically designed to work
not only on Windows, but anywhere, to allow for repositories hosted on,
say, Linux servers to be protected against NTFS-specific attack vectors.

As a consequence, `is_ntfs_dotgit()` manually splits backslash-separated
paths (but does not do the same for paths separated by forward slashes),
under the assumption that the backslash might not be a valid directory
separator on the _current_ Operating System.

However, the two callers, `verify_path()` and `fsck_tree()`, are
supposed to feed only individual path segments to the `is_ntfs_dotgit()`
function.

This causes a lot of duplicate scanning (and very inefficient scanning,
too, as the inner loop of `is_ntfs_dotgit()` was optimized for
readability rather than for speed.

Let's simplify the design of `is_ntfs_dotgit()` by putting the burden of
splitting the paths by backslashes as directory separators on the
callers of said function.

Consequently, the `verify_path()` function, which already splits the
path by directory separators, now treats backslashes as directory
separators _explicitly_ when `core.protectNTFS` is turned on, even on
platforms where the backslash is _not_ a directory separator.

Note that we have to repeat some code in `verify_path()`: if the
backslash is not a directory separator on the current Operating System,
we want to allow file names like `\`, but we _do_ want to disallow paths
that are clearly intended to cause harm when the repository is cloned on
Windows.

The `fsck_tree()` function (the other caller of `is_ntfs_dotgit()`) now
needs to look for backslashes in tree entries' names specifically when
`core.protectNTFS` is turned on. While it would be tempting to
completely disallow backslashes in that case (much like `fsck` reports
names containing forward slashes as "full paths"), this would be
overzealous: when `core.protectNTFS` is turned on in a non-Windows
setup, backslashes are perfectly valid characters in file names while we
_still_ want to disallow tree entries that are clearly designed to
exploit NTFS-specific behavior.

This simplification will make subsequent changes easier to implement,
such as turning `core.protectNTFS` on by default (not only on Windows)
or protecting against attack vectors involving NTFS Alternate Data
Streams.

Incidentally, this change allows for catching malicious repositories
that contain tree entries of the form `dir\.gitmodules` already on the
server side rather than only on the client side (and previously only on
Windows): in contrast to `is_ntfs_dotgit()`, the
`is_ntfs_dotgitmodules()` function already expects the caller to split
the paths by directory separators.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
4 years agotest-path-utils: offer to run a protectNTFS/protectHFS benchmark
Garima Singh [Wed, 4 Sep 2019 17:36:39 +0000 (13:36 -0400)] 
test-path-utils: offer to run a protectNTFS/protectHFS benchmark

In preparation to flipping the default on `core.protectNTFS`, let's have
some way to measure the speed impact of this config setting reliably
(and for comparison, the `core.protectHFS` config setting).

For now, this is a manual performance benchmark:

./t/helper/test-path-utils protect_ntfs_hfs [arguments...]

where the arguments are an optional number of file names to test with,
optionally followed by minimum and maximum length of the random file
names. The default values are one million, 3 and 20, respectively.

Just like `sqrti()` in `bisect.c`, we introduce a very simple function
to approximation the square root of a given value, in order to avoid
having to introduce the first user of `<math.h>` in Git's source code.

Note: this is _not_ implemented as a Unix shell script in t/perf/
because we really care about _very_ precise timings here, and Unix shell
scripts are simply unsuited for precise and consistent benchmarking.

Signed-off-by: Garima Singh <garima.singh@microsoft.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>