]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
4 years agonotes: create init_display_notes() helper
Denton Liu [Mon, 9 Dec 2019 13:10:41 +0000 (05:10 -0800)] 
notes: create init_display_notes() helper

We currently open code the initialization for revs->notes_opt. Abstract
this away into a helper function so that the logic can be reused in a
future commit.

This is slightly wasteful as we memset the struct twice but this is only
run once so it shouldn't have any major effect.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agonotes: rename to load_display_notes()
Denton Liu [Mon, 9 Dec 2019 13:10:39 +0000 (05:10 -0800)] 
notes: rename to load_display_notes()

According to the function comment, init_display_notes() was supposed to
"Load the notes machinery for displaying several notes trees." Rename
this function to load_display_notes() so that its use is more accurately
represented.

This is done because, in a future commit, we will reuse the name
init_display_notes().

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoname-rev: cleanup name_ref()
SZEDER Gábor [Mon, 9 Dec 2019 11:52:58 +0000 (12:52 +0100)] 
name-rev: cleanup name_ref()

Earlier patches in this series moved a couple of conditions from the
recursive name_rev() function into its caller name_ref(), for no other
reason than to make eliminating the recursion a bit easier to follow.

Since the previous patch name_rev() is not recursive anymore, so let's
move all those conditions back into name_rev().

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoname-rev: eliminate recursion in name_rev()
SZEDER Gábor [Mon, 9 Dec 2019 11:52:57 +0000 (12:52 +0100)] 
name-rev: eliminate recursion in name_rev()

The name_rev() function calls itself recursively for each interesting
parent of the commit it got as parameter, and, consequently, it can
segfault when processing a deep history if it exhausts the available
stack space.  E.g. running 'git name-rev --all' and 'git name-rev
HEAD~100000' in the gcc, gecko-dev, llvm, and WebKit repositories
results in segfaults on my machine ('ulimit -s' reports 8192kB of
stack size limit), and nowadays the former segfaults in the Linux repo
as well (it reached the necessasry depth sometime between v5.3-rc4 and
-rc5).

Eliminate the recursion by inserting the interesting parents into a
LIFO 'prio_queue' [1] and iterating until the queue becomes empty.

Note that the parent commits must be added in reverse order to the
LIFO 'prio_queue', so their relative order is preserved during
processing, i.e. the first parent should come out first from the
queue, because otherwise performance greatly suffers on mergy
histories [2].

The stacksize-limited test 'name-rev works in a deep repo' in
't6120-describe.sh' demonstrated this issue and expected failure.  Now
the recursion is gone, so flip it to expect success.  Also gone are
the dmesg entries logging the segfault of that segfaulting 'git
name-rev' process on every execution of the test suite.

Note that this slightly changes the order of lines in the output of
'git name-rev --all', usually swapping two lines every 35 lines in
git.git or every 150 lines in linux.git.  This shouldn't matter in
practice, because the output has always been unordered anyway.

This patch is best viewed with '--ignore-all-space'.

[1] Early versions of this patch used a 'commit_list', resulting in
    ~15% performance penalty for 'git name-rev --all' in 'linux.git',
    presumably because of the memory allocation and release for each
    insertion and removal. Using a LIFO 'prio_queue' has basically no
    effect on performance.

[2] We prefer shorter names, i.e. 'v0.1~234' is preferred over
    'v0.1^2~5', meaning that usually following the first parent of a
    merge results in the best name for its ancestors.  So when later
    we follow the remaining parent(s) of a merge, and reach an already
    named commit, then we usually find that we can't give that commit
    a better name, and thus we don't have to visit any of its
    ancestors again.

    OTOH, if we were to follow the Nth parent of the merge first, then
    the name of all its ancestors would include a corresponding '^N'.
    Those are not the best names for those commits, so when later we
    reach an already named commit following the first parent of that
    merge, then we would have to update the name of that commit and
    the names of all of its ancestors as well.  Consequently, we would
    have to visit many commits several times, resulting in a
    significant slowdown.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoname-rev: use 'name->tip_name' instead of 'tip_name'
SZEDER Gábor [Mon, 9 Dec 2019 11:52:56 +0000 (12:52 +0100)] 
name-rev: use 'name->tip_name' instead of 'tip_name'

Following the previous patches in this series we can get the value of
'name_rev()'s 'tip_name' parameter from the 'struct rev_name'
associated with the commit as well.

So let's use 'name->tip_name' instead, which makes the patch
eliminating the recursion of name_rev() a bit easier to follow.

Note that at this point we could drop the 'tip_name' parameter as
well, but that parameter will be necessary later, after the recursion
is eliminated.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoarchive-zip: use enum for compression method
René Scharfe [Sat, 7 Dec 2019 12:20:33 +0000 (13:20 +0100)] 
archive-zip: use enum for compression method

Add an enumeration to assign names to the magic values that determine
the ZIP compression method to use.  Use those names to improve code
readability.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agogit gui: fix branch name encoding error
Kazuhiro Kato [Sat, 7 Dec 2019 00:29:09 +0000 (00:29 +0000)] 
git gui: fix branch name encoding error

After "git checkout -b '漢字'" to create a branch with UTF-8 character
in it, "git gui" shows the branch name incorrectly, as it forgets to
turn the bytes read from the "git for-each-ref" and read from "HEAD"
file into Unicode characters.

Signed-off-by: Kazuhiro Kato <kato-k@ksysllc.co.jp>
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
4 years agol10n: minor case fix in 'git branch' '--unset-upstream' description
Dimitriy Ryazantcev [Sun, 8 Dec 2019 09:26:47 +0000 (11:26 +0200)] 
l10n: minor case fix in 'git branch' '--unset-upstream' description

Signed-off-by: Dimitriy Ryazantcev <dimitriy.ryazantcev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot3404: fix indentation
Johannes Schindelin [Sat, 7 Dec 2019 22:22:44 +0000 (22:22 +0000)] 
t3404: fix indentation

This test case was added in 66ae9a57b88 (t3404: rebase -i: demonstrate
short SHA-1 collision, 2013-08-23), and it is not indented in the way we
usually indent sub-shell code in our test cases these days.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agopatch-id: use oid_to_hex() to print multiple object IDs
René Scharfe [Sat, 7 Dec 2019 19:16:51 +0000 (20:16 +0100)] 
patch-id: use oid_to_hex() to print multiple object IDs

flush_current_id() prints the hexadecimal representation of two object
IDs.  When the code was added in f97672225b (Add "git-patch-id" program
to generate patch ID's., 2005-06-23), sha1_to_hex() had only a single
internal static buffer, so the result of one invocation had to be stored
in a local buffer.

Since dcb3450fd8 (sha1_to_hex() usage cleanup, 2006-05-03) it rotates
through four buffers, which allows to print up to four object IDs at the
same time.  1a876a69af6 (patch-id: convert to use struct object_id,
2015-03-13) replaced sha1_to_hex() with oid_to_hex(), which has the same
feature.  Use it to simplify the code.

Signed-off-by: René Scharfe <l.s.r@web.de>
Acked-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agocommit: use strbuf_add() to add a length-limited string
René Scharfe [Sat, 7 Dec 2019 11:16:04 +0000 (12:16 +0100)] 
commit: use strbuf_add() to add a length-limited string

This is shorter and simpler.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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 agoname-rev: drop name_rev()'s 'generation' and 'distance' parameters
SZEDER Gábor [Tue, 12 Nov 2019 10:38:19 +0000 (11:38 +0100)] 
name-rev: drop name_rev()'s 'generation' and 'distance' parameters

Following the previous patches in this series we can get the values of
name_rev()'s 'generation' and 'distance' parameters from the 'stuct
rev_name' associated with the commit as well.

Let's simplify the function's signature and remove these two
unnecessary parameters.

Note that at this point we could do the same with the 'tip_name',
'taggerdate' and 'from_tag' parameters as well, but those parameters
will be necessary later, after the recursion is eliminated.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoname-rev: restructure creating/updating 'struct rev_name' instances
SZEDER Gábor [Tue, 12 Nov 2019 10:38:18 +0000 (11:38 +0100)] 
name-rev: restructure creating/updating 'struct rev_name' instances

At the beginning of the recursive name_rev() function it creates a new
'struct rev_name' instance for each previously unvisited commit or, if
this visit results in better name for an already visited commit, then
updates the 'struct rev_name' instance attached to the commit, or
returns early.

Restructure this so it's caller creates or updates the 'struct
rev_name' instance associated with the commit to be passed as
parameter, i.e. both name_ref() before calling name_rev() and
name_rev() itself as it iterates over the parent commits.

This makes eliminating the recursion a bit easier to follow, and the
condition moved to name_ref() will be moved back to name_rev() after
the recursion is eliminated.

This change also plugs the memory leak that was temporarily unplugged
in the earlier "name-rev: pull out deref handling from the recursion"
patch in this series.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoname-rev: restructure parsing commits and applying date cutoff
SZEDER Gábor [Tue, 12 Nov 2019 10:38:17 +0000 (11:38 +0100)] 
name-rev: restructure parsing commits and applying date cutoff

At the beginning of the recursive name_rev() function it parses the
commit it got as parameter, and returns early if the commit is older
than a cutoff limit.

Restructure this so the caller parses the commit and checks its date,
and doesn't invoke name_rev() if the commit to be passed as parameter
is older than the cutoff, i.e. both name_ref() before calling
name_rev() and name_rev() itself as it iterates over the parent
commits.

This makes eliminating the recursion a bit easier to follow, and the
condition moved to name_ref() will be moved back to name_rev() after
the recursion is eliminated.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoname-rev: pull out deref handling from the recursion
SZEDER Gábor [Tue, 12 Nov 2019 10:38:16 +0000 (11:38 +0100)] 
name-rev: pull out deref handling from the recursion

The 'if (deref) { ... }' condition near the beginning of the recursive
name_rev() function can only ever be true in the first invocation,
because the 'deref' parameter is always 0 in the subsequent recursive
invocations.

Extract this condition from the recursion into name_rev()'s caller and
drop the function's 'deref' parameter.  This makes eliminating the
recursion a bit easier to follow, and it will be moved back into
name_rev() after the recursion is eliminated.

Furthermore, drop the condition that die()s when both 'deref' and
'generation' are non-null (which should have been a BUG() to begin
with).

Note that this change reintroduces the memory leak that was plugged in
in commit 5308224633 (name-rev: avoid leaking memory in the `deref`
case, 2017-05-04), but a later patch (name-rev: restructure
creating/updating 'struct rev_name' instances) in this series will
plug it in again.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoname-rev: extract creating/updating a 'struct name_rev' into a helper
SZEDER Gábor [Tue, 12 Nov 2019 10:38:15 +0000 (11:38 +0100)] 
name-rev: extract creating/updating a 'struct name_rev' into a helper

In a later patch in this series we'll want to do this in two places.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot6120: add a test to cover inner conditions in 'git name-rev's name_rev()
SZEDER Gábor [Tue, 12 Nov 2019 10:38:14 +0000 (11:38 +0100)] 
t6120: add a test to cover inner conditions in 'git name-rev's name_rev()

In 'builtin/name-rev.c' in the name_rev() function there is a loop
iterating over all parents of the given commit, and the loop body
looks like this:

  if (parent_number > 1) {
      if (generation > 0)
          // branch #1
          new_name = ...
      else
          // branch #2
          new_name = ...
      name_rev(parent, new_name, ...);
  } else {
      // branch #3
      name_rev(...);
  }

These conditions are not covered properly in the test suite.  As far
as purely test coverage goes, they are all executed several times over
in 't6120-describe.sh'.  However, they don't directly influence the
command's output, because the repository used in that test script
contains several branches and tags pointing somewhere into the middle
of the commit DAG, and thus result in a better name for the
to-be-named commit.  This can hide bugs: e.g. by replacing the
'new_name' parameter of the first recursive name_rev() call with
'tip_name' (effectively making both branch #1 and #2 a noop) 'git
name-rev --all' shows thousands of bogus names in the Git repository,
but the whole test suite still passes successfully.  In an early
version of a later patch in this series I managed to mess up all three
branches (at once!), but the test suite still passed.

So add a new test case that operates on the following history:

  A--------------master
   \            /
    \----------M2
     \        /
      \---M1-C
       \ /
        B

and names the commit 'B' to make sure that all three branches are
crucial to determine 'B's name:

  - There is only a single ref, so all names are based on 'master',
    without any undesired interference from other refs.

  - Each time name_rev() follows the second parent of a merge commit,
    it appends "^2" to the name.  Following 'master's second parent
    right at the start ensures that all commits on the ancestry path
    from 'master' to 'B' have a different base name from the original
    'tip_name' of the very first name_rev() invocation.  Currently,
    while name_rev() is recursive, it doesn't matter, but it will be
    necessary to properly cover all three branches after the recursion
    is eliminated later in this series.

  - Following 'M2's second parent makes sure that branch #2 (i.e. when
    'generation = 0') affects 'B's name.

  - Following the only parent of the non-merge commit 'C' ensures that
    branch #3 affects 'B's name, and that it increments 'generation'.

  - Coming from 'C' 'generation' is 1, thus following 'M1's second
    parent makes sure that branch #1 affects 'B's name.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoname-rev: use sizeof(*ptr) instead of sizeof(type) in allocation
SZEDER Gábor [Tue, 12 Nov 2019 10:38:13 +0000 (11:38 +0100)] 
name-rev: use sizeof(*ptr) instead of sizeof(type) in allocation

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoname-rev: avoid unnecessary cast in name_ref()
SZEDER Gábor [Tue, 12 Nov 2019 10:38:12 +0000 (11:38 +0100)] 
name-rev: avoid unnecessary cast in name_ref()

Casting a 'struct object' to 'struct commit' is unnecessary there,
because it's already available in the local 'commit' variable.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoname-rev: use strbuf_strip_suffix() in get_rev_name()
René Scharfe [Tue, 12 Nov 2019 10:38:11 +0000 (11:38 +0100)] 
name-rev: use strbuf_strip_suffix() in get_rev_name()

get_name_rev() basically open-codes strip_suffix() before adding a
string to a strbuf.

Let's use the strbuf right from the beginning, i.e. add the whole
string to the strbuf and then use strbuf_strip_suffix(), making the
code more idiomatic.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot6120-describe: modernize the 'check_describe' helper
SZEDER Gábor [Tue, 12 Nov 2019 10:38:10 +0000 (11:38 +0100)] 
t6120-describe: modernize the 'check_describe' helper

The 'check_describe' helper function runs 'git describe' outside of
'test_expect_success' blocks, with extra hand-rolled code to record
and examine its exit code.

Update this helper and move the 'git describe' invocation inside the
'test_expect_success' block.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agorange-diff: clear `other_arg` at end of function
Denton Liu [Fri, 6 Dec 2019 20:16:31 +0000 (12:16 -0800)] 
range-diff: clear `other_arg` at end of function

We were leaking memory by not clearing `other_arg` after we were done
using it. Clear it after we've finished using it.

Note that this isn't strictly necessary since the memory will be
reclaimed once the command exits. However, since we are releasing the
strbufs, we should also clear `other_arg` for consistency.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agorange-diff: mark pointers as const
Denton Liu [Fri, 6 Dec 2019 20:16:26 +0000 (12:16 -0800)] 
range-diff: mark pointers as const

The contents pointed to by `diffopt` and `other_arg` should not be
modified. Mark these as `const` to indicate this.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot3206: fix incorrect test name
Denton Liu [Fri, 6 Dec 2019 20:16:22 +0000 (12:16 -0800)] 
t3206: fix incorrect test name

The name of the test used to indicate that it was testing the `--notes`
option but it was really testing the `format.notes` configuration.
Correct the test name to reflect this.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot9300-fast-import: don't hang if background fast-import exits too early
SZEDER Gábor [Fri, 6 Dec 2019 19:03:31 +0000 (20:03 +0100)] 
t9300-fast-import: don't hang if background fast-import exits too early

The five tests checking 'git fast-import's checkpoint handling in
't9300-fast-import.sh', all with the prefix "V:" in their test
description, can hang indefinitely if 'git fast-import' unexpectedly
dies early in any of these tests.

These five tests run 'git fast-import' in the background, while
feeding instructions to its standard input through a fifo (fd 8) from
a background subshell, and reading and verifying its standard output
through another fifo (fd 9) in the test script's main shell process.
This "reading and verifying" is basically a 'while read ...' shell
loop iterating until 'git fast-import' outputs the expected line,
ignoring any other output.  This doesn't work very well when 'git
fast-import' dies before printing that particular line, because the
'read' builtin doesn't get EOF after the death of 'git fast-import',
as their input and output are not connected directly but through a
fifo.  Consequently, that 'read' hangs waiting for the next line from
the already dead 'git fast-import', leaving the test script and in
turn the whole test suite hanging.

Avoid this hang by checking whether the background 'git fast-import'
process exited unexpectedly early, and interrupt the 'while read' loop
if it did.  We have to jump through some hoops to achive that, though:

  - Start the background 'git fast-import' in another background
    subshell, which then:

      - prints the PID of that 'git fast-import' process to the fifo,
to be read by the main shell process, so it will know which
process to kill when the test is finished.

      - waits until that 'git fast-import' process exits.  If it does
exit, then report its exit code, and write a message to the
fifo used for 'git fast-import's standard output, thus
un-block the 'read' builtin in the main shell process.

  - Modify that 'while read' loop to break the loop upon seeing that
    message, and fail the test in the usual way.

  - Once the test is finished kill that background subshell as well,
    and do so before killing the background 'git fast-import'.
    Otherwise the background 'git fast-import' and subshell processes
    would die racily, and if 'git fast-import' were to die sooner,
    then we might get some undesired and potentially confusing
    messages in the test's output.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot9300-fast-import: store the PID in a variable instead of pidfile
SZEDER Gábor [Fri, 6 Dec 2019 19:03:30 +0000 (20:03 +0100)] 
t9300-fast-import: store the PID in a variable instead of pidfile

The five tests running 'git fast-import' in the background in
't9300-fast-import.sh' store the PID of that background process in a
pidfile, to be used to check whether that background process survived
each test and then to kill it in test_when_finished commands.  To
achieve this all these five tests run three $(cat <pidfile>) command
substitutions each.

Store the PID of the background 'git fast-import' in a variable to
avoid those extra processes.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agoapply --allow-overlap: fix a corner case
Johannes Schindelin [Fri, 6 Dec 2019 13:08:25 +0000 (13:08 +0000)] 
apply --allow-overlap: fix a corner case

Yes, yes, this is supposed to be only a band-aid option for `git add -p`
not Doing The Right Thing. But as long as we carry the `--allow-overlap`
option, we might just as well get it right.

This fixes the case where one hunk inserts a line before the first line,
and is followed by a hunk whose context overlaps with the first one's
and which appends a line at the end.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agogit add -p: use non-zero exit code when the diff generation failed
Johannes Schindelin [Fri, 6 Dec 2019 13:08:24 +0000 (13:08 +0000)] 
git add -p: use non-zero exit code when the diff generation failed

The first thing `git add -p` does is to generate a diff. If this diff
cannot be generated, `git add -p` should not continue as if nothing
happened, but instead fail.

What we *actually* do here is much broader: we now verify for *every*
`run_cmd_pipe()` call that the spawned process actually succeeded.

Note that we have to change two callers in this patch, as we need to
store the spawned process' output in a local variable, which means that
the callers can no longer decide whether to interpret the `return <$fh>`
in array or in scalar context.

This bug was noticed while writing a test case for the diff.algorithm
feature, and we let that test case double as a regression test for this
fixed bug, too.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot3701: verify that the diff.algorithm config setting is handled
Johannes Schindelin [Fri, 6 Dec 2019 13:08:23 +0000 (13:08 +0000)] 
t3701: verify that the diff.algorithm config setting is handled

Without this patch, there is actually no test in Git's test suite that
covers the diff.algorithm feature. Let's add one.

We do this by passing a bogus value and then expecting `git diff-files`
to produce the appropriate error message.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot3701: verify the shown messages when nothing can be added
Johannes Schindelin [Fri, 6 Dec 2019 13:08:22 +0000 (13:08 +0000)] 
t3701: verify the shown messages when nothing can be added

In preparation for re-implementing `git add -p` in pure C (where we will
purposefully keep the implementation of `git add -p` separate from the
implementation of `git add -i`), let's verify that the user is told the
same things as in the Perl version when the diff file is either empty or
contains only entries about binary files.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot3701: add a test for the different `add -p` prompts
Johannes Schindelin [Fri, 6 Dec 2019 13:08:21 +0000 (13:08 +0000)] 
t3701: add a test for the different `add -p` prompts

The `git add -p` command offers different prompts for regular diff hunks
vs mode change pseudo hunks vs diffs deleting files.

Let's cover this in the regresion test suite, in preparation for
re-implementing `git add -p` in C.

For the mode change prompt, we use a trick that lets this test case pass
even on systems without executable bit, i.e. where `core.filemode =
false` (such as Windows): we first add the file to the index with `git
add --chmod=+x`, and then call `git add -p` with `core.filemode` forced
to `true`. The file on disk has no executable bit set, therefore we will
see a mode change.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot3701: avoid depending on the TTY prerequisite
Johannes Schindelin [Fri, 6 Dec 2019 13:08:20 +0000 (13:08 +0000)] 
t3701: avoid depending on the TTY prerequisite

The TTY prerequisite is a rather heavy one: it not only requires Perl to
work, but also the IO/Pty.pm module (with native support, and it
requires pseudo terminals, too).

In particular, test cases marked with the TTY prerequisite would be
skipped in Git for Windows' SDK.

In the case of `git add -p`, we do not actually need that big a hammer,
as we do not want to test any functionality that requires a pseudo
terminal; all we want is for the interactive add command to use color,
even when being called from within the test suite.

And we found exactly such a trick earlier already: when we added a test
case to verify that the main loop of `git add -i` is colored
appropriately. Let's use that trick instead of the TTY prerequisite.

While at it, we avoid the pipes, as we do not want a SIGPIPE to break
the regression test cases (which will be much more likely when we do not
run everything through Perl because that is inherently slower).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 years agot3701: add a test for advanced split-hunk editing
Johannes Schindelin [Fri, 6 Dec 2019 13:08:19 +0000 (13:08 +0000)] 
t3701: add a test for advanced split-hunk editing

In this developer's workflows, it often happens that a hunk needs to be
edited in a way that adds lines, and sometimes even reduces the number
of context lines.

Let's add a regression test for this.

Note that just like the preceding test case, the new test case is *not*
handled gracefully by the current `git add -p`. It will be handled
correctly by the upcoming built-in `git add -p`, though.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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