git
2 years agodoc: refactor common asciidoc dependencies
Felipe Contreras [Fri, 21 May 2021 22:29:37 +0000 (17:29 -0500)] 
doc: refactor common asciidoc dependencies

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoGit 2.32-rc1 v2.32.0-rc1
Junio C Hamano [Sat, 22 May 2021 09:27:45 +0000 (18:27 +0900)] 
Git 2.32-rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'dl/stash-show-untracked-fixup'
Junio C Hamano [Sat, 22 May 2021 09:29:01 +0000 (18:29 +0900)] 
Merge branch 'dl/stash-show-untracked-fixup'

Another brown paper bag inconsistency fix for a new feature
introduced during this cycle.

* dl/stash-show-untracked-fixup:
  stash show: use stash.showIncludeUntracked even when diff options given

2 years agoMerge branch 'jh/simple-ipc-sans-pthread'
Junio C Hamano [Sat, 22 May 2021 09:29:01 +0000 (18:29 +0900)] 
Merge branch 'jh/simple-ipc-sans-pthread'

The "simple-ipc" did not compile without pthreads support, but the
build procedure was not properly account for it.

* jh/simple-ipc-sans-pthread:
  simple-ipc: correct ifdefs when NO_PTHREADS is defined

2 years agoMerge branch 'wm/rev-parse-path-format-wo-arg'
Junio C Hamano [Sat, 22 May 2021 09:29:00 +0000 (18:29 +0900)] 
Merge branch 'wm/rev-parse-path-format-wo-arg'

The "rev-parse" command did not diagnose the lack of argument to
"--path-format" option, which was introduced in v2.31 era, which
has been corrected.

* wm/rev-parse-path-format-wo-arg:
  rev-parse: fix segfault with missing --path-format argument

2 years agostash show: use stash.showIncludeUntracked even when diff options given
Denton Liu [Fri, 21 May 2021 10:37:47 +0000 (03:37 -0700)] 
stash show: use stash.showIncludeUntracked even when diff options given

If options pertaining to how the diff is displayed is provided to
`git stash show`, the command will ignore the stash.showIncludeUntracked
configuration variable, defaulting to not showing any untracked files.
This is unintuitive behaviour since the format of the diff output and
whether or not to display untracked files are orthogonal.

Use stash.showIncludeUntracked even when diff options are given. Of
course, this is still overridable via the command-line options.

Update the documentation to explicitly say which configuration variables
will be overridden when a diff options are given.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agosimple-ipc: correct ifdefs when NO_PTHREADS is defined
Jeff Hostetler [Thu, 20 May 2021 18:28:10 +0000 (18:28 +0000)] 
simple-ipc: correct ifdefs when NO_PTHREADS is defined

Simple IPC always requires threads (in addition to various
platform-specific IPC support).  Fix the ifdefs in the Makefile
to define SUPPORTS_SIMPLE_IPC when appropriate.

Previously, the Unix version of the code would only verify that
Unix domain sockets were available.

This problem was reported here:
https://lore.kernel.org/git/YKN5lXs4AoK%2FJFTO@coredump.intra.peff.net/T/#m08be8f1942ea8a2c36cfee0e51cdf06489fdeafc

Reported-by: Randall S. Becker <rsbecker@nexbridge.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'ds/sparse-index-protections'
Junio C Hamano [Thu, 20 May 2021 20:50:38 +0000 (05:50 +0900)] 
Merge branch 'ds/sparse-index-protections'

Fix access to uninitialized piece of memory, introduced during this
cycle.

* ds/sparse-index-protections:
  sparse-index: fix uninitialized jump

2 years agoMerge branch 'tz/c-locale-output-is-no-more'
Junio C Hamano [Thu, 20 May 2021 20:50:32 +0000 (05:50 +0900)] 
Merge branch 'tz/c-locale-output-is-no-more'

Test update.

* tz/c-locale-output-is-no-more:
  t7500: remove non-existant C_LOCALE_OUTPUT prereq

2 years agoMerge branch 'cs/http-use-basic-after-failed-negotiate'
Junio C Hamano [Thu, 20 May 2021 20:48:25 +0000 (05:48 +0900)] 
Merge branch 'cs/http-use-basic-after-failed-negotiate'

Regression fix for a change made during this cycle.

* cs/http-use-basic-after-failed-negotiate:
  Revert "remote-curl: fall back to basic auth if Negotiate fails"
  t5551: test http interaction with credential helpers

2 years agoA handful more topics before -rc1
Junio C Hamano [Wed, 19 May 2021 23:43:22 +0000 (08:43 +0900)] 
A handful more topics before -rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'jk/test-chainlint-softer'
Junio C Hamano [Wed, 19 May 2021 23:55:00 +0000 (08:55 +0900)] 
Merge branch 'jk/test-chainlint-softer'

The "chainlint" feature in the test framework is a handy way to
catch common mistakes in writing new tests, but tends to get
expensive.  An knob to selectively disable it has been introduced
to help running tests that the developer has not modified.

* jk/test-chainlint-softer:
  t: avoid sed-based chain-linting in some expensive cases

2 years agoMerge branch 'en/prompt-under-set-u'
Junio C Hamano [Wed, 19 May 2021 23:55:00 +0000 (08:55 +0900)] 
Merge branch 'en/prompt-under-set-u'

The bash prompt script (in contrib/) did not work under "set -u".

* en/prompt-under-set-u:
  git-prompt: work under set -u

2 years agoMerge branch 'zh/ref-filter-push-remote-fix'
Junio C Hamano [Wed, 19 May 2021 23:55:00 +0000 (08:55 +0900)] 
Merge branch 'zh/ref-filter-push-remote-fix'

The handling of "%(push)" formatting element of "for-each-ref" and
friends was broken when the same codepath started handling
"%(push:<what>)", which has been corrected.

* zh/ref-filter-push-remote-fix:
  ref-filter: fix read invalid union member bug

2 years agoMerge branch 'ew/sha256-clone-remote-curl-fix'
Junio C Hamano [Wed, 19 May 2021 23:54:59 +0000 (08:54 +0900)] 
Merge branch 'ew/sha256-clone-remote-curl-fix'

"git clone" from SHA256 repository by Git built with SHA-1 as the
default hash algorithm over the dumb HTTP protocol did not
correctly set up the resulting repository, which has been corrected.

* ew/sha256-clone-remote-curl-fix:
  remote-curl: fix clone on sha256 repos

2 years agoMerge branch 'en/dir-traversal'
Junio C Hamano [Wed, 19 May 2021 23:54:58 +0000 (08:54 +0900)] 
Merge branch 'en/dir-traversal'

"git clean" and "git ls-files -i" had confusion around working on
or showing ignored paths inside an ignored directory, which has
been corrected.

* en/dir-traversal:
  dir: introduce readdir_skip_dot_and_dotdot() helper
  dir: update stale description of treat_directory()
  dir: traverse into untracked directories if they may have ignored subfiles
  dir: avoid unnecessary traversal into ignored directory
  t3001, t7300: add testcase showcasing missed directory traversal
  t7300: add testcase showing unnecessary traversal into ignored directory
  ls-files: error out on -i unless -o or -c are specified
  dir: report number of visited directories and paths with trace2
  dir: convert trace calls to trace2 equivalents

2 years agoMerge branch 'ab/perl-makefile-cleanup'
Junio C Hamano [Wed, 19 May 2021 23:54:58 +0000 (08:54 +0900)] 
Merge branch 'ab/perl-makefile-cleanup'

Build procedure clean-up.

* ab/perl-makefile-cleanup:
  Makefile: make PERL_DEFINES recursively expanded
  perl: use mock i18n functions under NO_GETTEXT=Y
  Makefile: regenerate *.pm on NO_PERL_CPAN_FALLBACKS change
  Makefile: regenerate perl/build/* if GIT-PERL-DEFINES changes
  Makefile: don't re-define PERL_DEFINES

2 years agoRevert "remote-curl: fall back to basic auth if Negotiate fails"
Jeff King [Tue, 18 May 2021 06:27:42 +0000 (02:27 -0400)] 
Revert "remote-curl: fall back to basic auth if Negotiate fails"

This reverts commit 1b0d9545bb85912a16b367229d414f55d140d3be.

That commit does fix the situation it intended to (avoiding Negotiate
even when the credentials were provided in the URL), but it creates a
more serious regression: we now never hit the conditional for "we had a
username and password, tried them, but the server still gave us a 401".
That has two bad effects:

 1. we never call credential_reject(), and thus a bogus credential
    stored by a helper will live on forever

 2. we never return HTTP_NOAUTH, so the error message the user gets is
    "The requested URL returned error: 401", instead of "Authentication
    failed".

Doing this correctly seems non-trivial, as we don't know whether the
Negotiate auth was a problem. Since this is a regression in the upcoming
v2.23.0 release (for which we're in -rc0), let's revert for now and work
on a fix separately.

(Note that this isn't a pure revert; the previous commit added a test
showing the regression, so we can now flip it to expect_success).

Reported-by: Ben Humphreys <behumphreys@atlassian.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot5551: test http interaction with credential helpers
Jeff King [Tue, 18 May 2021 06:27:36 +0000 (02:27 -0400)] 
t5551: test http interaction with credential helpers

We test authentication with http, and we independently test that
credential helpers work, but we don't have any tests that cover the
two features working together. Let's add two:

  1. Make sure that a successful request asks the helper to save the
     credential. This works as expected.

  2. Make sure that a failed request asks the helper to forget the
     credential. This is marked as expect_failure, as it was recently
     regressed by 1b0d9545bb (remote-curl: fall back to basic auth if
     Negotiate fails, 2021-03-22). The symptom here is that the second
     request should prompt the user, but doesn't.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agosparse-index: fix uninitialized jump
Derrick Stolee [Mon, 17 May 2021 12:22:17 +0000 (12:22 +0000)] 
sparse-index: fix uninitialized jump

While testing the sparse-index, I verified a test with --valgrind and it
complained about an uninitialized value being used in a jump in the
path_matches_pattern_list() method. The line was this one:

if (*dtype == DT_UNKNOWN)

In the call stack, the culprit was the initialization of the dtype
variable in convert_to_sparse_rec().

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot7500: remove non-existant C_LOCALE_OUTPUT prereq
Todd Zullinger [Mon, 17 May 2021 15:12:22 +0000 (11:12 -0400)] 
t7500: remove non-existant C_LOCALE_OUTPUT prereq

The C_LOCALE_OUTPUT prerequisite was removed in b1e079807b (tests:
remove last uses of C_LOCALE_OUTPUT, 2021-02-11), where Ævar noted:

    I'm not leaving the prerequisite itself in place for in-flight changes
    as there currently are none that introduce new tests that rely on it,
    and because C_LOCALE_OUTPUT is currently a noop on the master branch
    we likely won't have any new submissions that use it.

One more use of C_LOCALE_OUTPUT did creep in with 3d1bda6b5b (t7500: add
tests for --fixup=[amend|reword] options, 2021-03-15).  This causes a
number of the tests to be skipped by default:

    ok 35 # SKIP --fixup=reword: incompatible with --all (missing C_LOCALE_OUTPUT)
    ok 36 # SKIP --fixup=reword: incompatible with --include (missing C_LOCALE_OUTPUT)
    ok 37 # SKIP --fixup=reword: incompatible with --only (missing C_LOCALE_OUTPUT)
    ok 38 # SKIP --fixup=reword: incompatible with --interactive (missing C_LOCALE_OUTPUT)
    ok 39 # SKIP --fixup=reword: incompatible with --patch (missing C_LOCALE_OUTPUT)

Remove the C_LOCALE_OUTPUT prerequisite from these tests so they are
not skipped.

Signed-off-by: Todd Zullinger <tmz@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agorev-parse: fix segfault with missing --path-format argument
Wolfgang Müller [Mon, 17 May 2021 08:02:42 +0000 (10:02 +0200)] 
rev-parse: fix segfault with missing --path-format argument

Calling "git rev-parse --path-format" without an argument segfaults
instead of giving an error message. Commit fac60b8925 (rev-parse: add
option for absolute or relative path formatting, 2020-12-13) added the
argument parsing code but forgot to handle NULL.

Returning an error makes sense here because there is no default value we
could use. Add a test case to verify.

Signed-off-by: Wolfgang Müller <wolf@oriole.systems>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoGit 2.32-rc0 v2.32.0-rc0
Junio C Hamano [Sun, 16 May 2021 12:04:46 +0000 (21:04 +0900)] 
Git 2.32-rc0

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'ls/typofix'
Junio C Hamano [Sun, 16 May 2021 12:05:24 +0000 (21:05 +0900)] 
Merge branch 'ls/typofix'

* ls/typofix:
  pretty: fix a typo in the documentation for %(trailers)

2 years agoMerge branch 'dl/stash-show-untracked-fixup'
Junio C Hamano [Sun, 16 May 2021 12:05:24 +0000 (21:05 +0900)] 
Merge branch 'dl/stash-show-untracked-fixup'

The code to handle options recently added to "git stash show"
around untracked part of the stash segfaulted when these options
were used on a stash entry that does not record untracked part.

* dl/stash-show-untracked-fixup:
  stash show: fix segfault with --{include,only}-untracked
  t3905: correct test title

2 years agoMerge branch 'wc/packed-ref-removal-cleanup'
Junio C Hamano [Sun, 16 May 2021 12:05:24 +0000 (21:05 +0900)] 
Merge branch 'wc/packed-ref-removal-cleanup'

When "git update-ref -d" removes a ref that is packed, it left
empty directories under $GIT_DIR/refs/ for

* wc/packed-ref-removal-cleanup:
  refs: cleanup directories when deleting packed ref

2 years agoMerge branch 'lh/maintenance-leakfix'
Junio C Hamano [Sun, 16 May 2021 12:05:24 +0000 (21:05 +0900)] 
Merge branch 'lh/maintenance-leakfix'

* lh/maintenance-leakfix:
  maintenance: fix two memory leaks

2 years agoMerge branch 'ma/typofixes'
Junio C Hamano [Sun, 16 May 2021 12:05:23 +0000 (21:05 +0900)] 
Merge branch 'ma/typofixes'

A couple of trivial typofixes.

* ma/typofixes:
  pretty-formats.txt: add missing space
  git-repack.txt: remove spurious ")"

2 years agoMerge branch 'ah/merge-ort-i18n'
Junio C Hamano [Sun, 16 May 2021 12:05:23 +0000 (21:05 +0900)] 
Merge branch 'ah/merge-ort-i18n'

An i18n fix.

* ah/merge-ort-i18n:
  merge-ort: split "distinct types" message into two translatable messages

2 years agoMerge branch 'dd/mailinfo-quoted-cr'
Junio C Hamano [Sun, 16 May 2021 12:05:23 +0000 (21:05 +0900)] 
Merge branch 'dd/mailinfo-quoted-cr'

"git mailinfo" (hence "git am") learned the "--quoted-cr" option to
control how lines ending with CRLF wrapped in base64 or qp are
handled.

* dd/mailinfo-quoted-cr:
  am: learn to process quoted lines that ends with CRLF
  mailinfo: allow stripping quoted CR without warning
  mailinfo: allow squelching quoted CRLF warning
  mailinfo: warn if CRLF found in decoded base64/QP email
  mailinfo: stop parsing options manually
  mailinfo: load default metainfo_charset lazily

2 years agoMerge branch 'ab/sparse-index-cleanup'
Junio C Hamano [Sun, 16 May 2021 12:05:23 +0000 (21:05 +0900)] 
Merge branch 'ab/sparse-index-cleanup'

Code clean-up.

* ab/sparse-index-cleanup:
  sparse-index.c: remove set_index_sparse_config()

2 years agoMerge branch 'ab/streaming-simplify'
Junio C Hamano [Sun, 16 May 2021 12:05:23 +0000 (21:05 +0900)] 
Merge branch 'ab/streaming-simplify'

Code clean-up.

* ab/streaming-simplify:
  streaming.c: move {open,close,read} from vtable to "struct git_istream"
  streaming.c: stop passing around "object_info *" to open()
  streaming.c: remove {open,close,read}_method_decl() macros
  streaming.c: remove enum/function/vtbl indirection
  streaming.c: avoid forward declarations

2 years agoMerge branch 'mt/parallel-checkout-part-3'
Junio C Hamano [Sun, 16 May 2021 12:05:23 +0000 (21:05 +0900)] 
Merge branch 'mt/parallel-checkout-part-3'

The final part of "parallel checkout".

* mt/parallel-checkout-part-3:
  ci: run test round with parallel-checkout enabled
  parallel-checkout: add tests related to .gitattributes
  t0028: extract encoding helpers to lib-encoding.sh
  parallel-checkout: add tests related to path collisions
  parallel-checkout: add tests for basic operations
  checkout-index: add parallel checkout support
  builtin/checkout.c: complete parallel checkout support
  make_transient_cache_entry(): optionally alloc from mem_pool

2 years agoMerge branch 'jt/push-negotiation'
Junio C Hamano [Sun, 16 May 2021 12:05:22 +0000 (21:05 +0900)] 
Merge branch 'jt/push-negotiation'

"git push" learns to discover common ancestor with the receiving
end over protocol v2.

* jt/push-negotiation:
  send-pack: support push negotiation
  fetch: teach independent negotiation (no packfile)
  fetch-pack: refactor command and capability write
  fetch-pack: refactor add_haves()
  fetch-pack: refactor process_acks()

2 years agoThe seventeenth batch
Junio C Hamano [Thu, 13 May 2021 23:25:42 +0000 (08:25 +0900)] 
The seventeenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMerge branch 'mt/clean-clean'
Junio C Hamano [Thu, 13 May 2021 23:26:10 +0000 (08:26 +0900)] 
Merge branch 'mt/clean-clean'

Code clean-up.

* mt/clean-clean:
  clean: remove unnecessary variable

2 years agoMerge branch 'ow/no-dryrun-in-add-i'
Junio C Hamano [Thu, 13 May 2021 23:26:09 +0000 (08:26 +0900)] 
Merge branch 'ow/no-dryrun-in-add-i'

"git add -i --dry-run" does not dry-run, which was surprising.  The
combination of options has taught to error out.

* ow/no-dryrun-in-add-i:
  add: die if both --dry-run and --interactive are given

2 years agoMerge branch 'jk/p4-locate-branch-point-optim'
Junio C Hamano [Thu, 13 May 2021 23:26:08 +0000 (08:26 +0900)] 
Merge branch 'jk/p4-locate-branch-point-optim'

"git p4" learned to find branch points more efficiently.

* jk/p4-locate-branch-point-optim:
  git-p4: speed up search for branch parent
  git-p4: ensure complex branches are cloned correctly

2 years agoMerge branch 'ba/object-info'
Junio C Hamano [Thu, 13 May 2021 23:26:08 +0000 (08:26 +0900)] 
Merge branch 'ba/object-info'

Over-the-wire protocol learns a new request type to ask for object
sizes given a list of object names.

* ba/object-info:
  object-info: support for retrieving object info

2 years agoMerge branch 'pw/patience-diff-clean-up'
Junio C Hamano [Thu, 13 May 2021 23:26:07 +0000 (08:26 +0900)] 
Merge branch 'pw/patience-diff-clean-up'

Code clean-up.

* pw/patience-diff-clean-up:
  patience diff: remove unused variable
  patience diff: remove unnecessary string comparisons

2 years agoMerge branch 'pw/word-diff-zero-width-matches'
Junio C Hamano [Thu, 13 May 2021 23:26:06 +0000 (08:26 +0900)] 
Merge branch 'pw/word-diff-zero-width-matches'

The word-diff mode has been taught to work better with a word
regexp that can match an empty string.

* pw/word-diff-zero-width-matches:
  word diff: handle zero length matches

2 years agot: avoid sed-based chain-linting in some expensive cases
Jeff King [Thu, 13 May 2021 06:25:53 +0000 (02:25 -0400)] 
t: avoid sed-based chain-linting in some expensive cases

Commit 878f988350 (t/test-lib: teach --chain-lint to detect broken
&&-chains in subshells, 2018-07-11) introduced additional chain-lint
tests which add an extra "sed" pipeline to each test we run. This has a
measurable impact on runtime. Here are timings with and without a new
environment variable (added by this patch) that lets you disable just
the additional sed-based chain-lint tests:

  Benchmark #1: GIT_TEST_CHAIN_LINT_HARDER=1 make test
    Time (mean ± σ):     64.202 s ±  1.030 s    [User: 622.469 s, System: 301.402 s]
    Range (min … max):   61.571 s … 65.662 s    10 runs

  Benchmark #2: GIT_TEST_CHAIN_LINT_HARDER=0 make test
    Time (mean ± σ):     57.591 s ±  0.333 s    [User: 529.368 s, System: 270.618 s]
    Range (min … max):   57.143 s … 58.309 s    10 runs

  Summary
    'GIT_TEST_CHAIN_LINT_HARDER=0 make test' ran
      1.11 ± 0.02 times faster than 'GIT_TEST_CHAIN_LINT_HARDER=1 make test'

Of course those extra lint checks are doing something useful, so paying
a few extra seconds (at least on Linux) isn't so bad (though note the
CPU time; we're bounded in our parallel run here by the slowest test, so
it really is ~120s of CPU improvement).

But we can observe that there are some test scripts where they produce a
much stronger effect, and provide less value. In t0027 and t3070 we run
a very large number of small tests, all driven by a series of
functions/loops which are filling in the test bodies. There we get much
less bang for our buck in terms of bug-finding versus CPU cost.

This patch introduces a mechanism for controlling when those extra
lint checks are run, at two levels:

  - a user can ask to disable or to force-enable the checks by setting
    GIT_TEST_CHAIN_LINT_HARDER

  - if the user hasn't specified a preference, individual scripts can
    disable the checks by setting GIT_TEST_CHAIN_LINT_HARDER_DEFAULT;
    scripts which don't set that get the current behavior of enabling
    them.

In addition, this patch flips the default for t0027 and t3070's
mass-generated sections to disable the extra checks. Here are the timing
results for t0027:

  Benchmark #1: GIT_TEST_CHAIN_LINT_HARDER=1 ./t0027-auto-crlf.sh
    Time (mean ± σ):     17.078 s ±  0.848 s    [User: 14.878 s, System: 7.075 s]
    Range (min … max):   15.952 s … 18.421 s    10 runs

  Benchmark #2: GIT_TEST_CHAIN_LINT_HARDER=0 ./t0027-auto-crlf.sh
    Time (mean ± σ):      9.063 s ±  0.759 s    [User: 7.890 s, System: 3.362 s]
    Range (min … max):    7.747 s … 10.619 s    10 runs

  Benchmark #3: ./t0027-auto-crlf.sh
    Time (mean ± σ):      9.186 s ±  0.881 s    [User: 7.957 s, System: 3.427 s]
    Range (min … max):    7.796 s … 10.498 s    10 runs

  Summary
    'GIT_TEST_CHAIN_LINT_HARDER=0 ./t0027-auto-crlf.sh' ran
      1.01 ± 0.13 times faster than './t0027-auto-crlf.sh'
      1.88 ± 0.18 times faster than 'GIT_TEST_CHAIN_LINT_HARDER=1 ./t0027-auto-crlf.sh'

We can see that disabling the checks for the whole script buys us an
almost 2x speedup. But the new default behavior, disabling them only for
the mass-generated part, gets us most of that speedup (but still leaves
the checks on for further manual tests people might write).

  As a side note, I'd caution about comparing runtimes and CPU seconds
  between this timing and the earlier "make test" one. In "make test",
  we're running a lot of scripts in parallel, so the CPU is throttling
  down (and thus a CPU second saved here would count for more during a
  parallel run; the same work takes more CPU seconds there).

We get similar results for t3070:

  Benchmark #1: GIT_TEST_CHAIN_LINT_HARDER=1 ./t3070-wildmatch.sh
    Time (mean ± σ):     20.054 s ±  3.967 s    [User: 16.003 s, System: 8.286 s]
    Range (min … max):   11.891 s … 23.671 s    10 runs

  Benchmark #2: GIT_TEST_CHAIN_LINT_HARDER=0 ./t3070-wildmatch.sh
    Time (mean ± σ):     12.399 s ±  2.256 s    [User: 7.542 s, System: 5.342 s]
    Range (min … max):    9.606 s … 15.727 s    10 runs

  Benchmark #3: ./t3070-wildmatch.sh
    Time (mean ± σ):     10.726 s ±  3.476 s    [User: 6.790 s, System: 4.365 s]
    Range (min … max):    5.444 s … 15.376 s    10 runs

  Summary
    './t3070-wildmatch.sh' ran
      1.16 ± 0.43 times faster than 'GIT_TEST_CHAIN_LINT_HARDER=0 ./t3070-wildmatch.sh'
      1.87 ± 0.71 times faster than 'GIT_TEST_CHAIN_LINT_HARDER=1 ./t3070-wildmatch.sh'

Again, we get almost a 2x speedup disabling these. In this case, there
are no tests not covered by the script's "default to disable" behavior,
so the second two benchmarks should be the same (and while they do
differ, you can see the variance is quite high but they're within one
standard deviation).

So it seems like for these two scripts, at least, disabling the extra
checks is a reasonable tradeoff. Sadly, the overall runtime of "make
test" on my system doesn't get much faster. But that's because we're
mostly limited by the cost of the single biggest test. Here are the
top-5 tests by wall-clock time from a parallel run, before my patch:

  57.9192368984222 t9001-send-email.sh
  45.6329638957977 t0027-auto-crlf.sh
  32.5278220176697 t3070-wildmatch.sh
  22.2701289653778 t7610-mergetool.sh
  20.8635759353638 t1701-racy-split-index.sh

And after:

  57.1476998329163 t9001-send-email.sh
  33.776211977005 t0027-auto-crlf.sh
  21.3116669654846 t7610-mergetool.sh
  20.7748689651489 t1701-racy-split-index.sh
  19.6957249641418 t7112-reset-submodule.sh

We dropped 12s from t0027, and t3070 dropped off our list entirely at
around 16s. In both cases we're bound by t9001, but its slowness is
due to the actual tests, so we'll have to deal with it in a different
way. But this reduces overall CPU, and means that dealing with t9001 (by
improving the speed of send-email or splitting it apart) will let us
reduce our overall runtime even on multi-core machines.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agogit-prompt: work under set -u
Elijah Newren [Thu, 13 May 2021 06:22:36 +0000 (06:22 +0000)] 
git-prompt: work under set -u

Commit afda36dbf3 ("git-prompt: include sparsity state as well",
2020-06-21) added the use of some variables to control how to show
sparsity state in the git prompt, but implicitly assumed that undefined
variables would be treated as the empty string.  This breaks users who
run under 'set -u'; fix the code to be more explicit.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agostash show: fix segfault with --{include,only}-untracked
Denton Liu [Wed, 12 May 2021 20:16:13 +0000 (13:16 -0700)] 
stash show: fix segfault with --{include,only}-untracked

When `git stash show --include-untracked` or
`git stash show --only-untracked` is run on a stash that doesn't include
an untracked entry, a segfault occurs. This happens because we do not
check whether the untracked entry is actually present and just attempt
to blindly dereference it.

Ensure that the untracked entry is present before actually attempting to
dereference it.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot3905: correct test title
Denton Liu [Wed, 12 May 2021 20:16:12 +0000 (13:16 -0700)] 
t3905: correct test title

We reference the non-existent option `git stash show --show-untracked`
when we really meant `--only-untracked`. Correct the test title
accordingly.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agodir: introduce readdir_skip_dot_and_dotdot() helper
Elijah Newren [Wed, 12 May 2021 17:28:22 +0000 (17:28 +0000)] 
dir: introduce readdir_skip_dot_and_dotdot() helper

Many places in the code were doing
    while ((d = readdir(dir)) != NULL) {
        if (is_dot_or_dotdot(d->d_name))
            continue;
        ...process d...
    }
Introduce a readdir_skip_dot_and_dotdot() helper to make that a one-liner:
    while ((d = readdir_skip_dot_and_dotdot(dir)) != NULL) {
        ...process d...
    }

This helper particularly simplifies checks for empty directories.

Also use this helper in read_cached_dir() so that our statistics are
consistent across platforms.  (In other words, read_cached_dir() should
have been using is_dot_or_dotdot() and skipping such entries, but did
not and left it to treat_path() to detect and mark such entries as
path_none.)

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agodir: update stale description of treat_directory()
Derrick Stolee [Wed, 12 May 2021 17:28:21 +0000 (17:28 +0000)] 
dir: update stale description of treat_directory()

The documentation comment for treat_directory() was originally written
in 095952 (Teach directory traversal about subprojects, 2007-04-11)
which was before the 'struct dir_struct' split its bitfield of named
options into a 'flags' enum in 7c4c97c0 (Turn the flags in struct
dir_struct into a single variable, 2009-02-16). When those flags
changed, the comment became stale, since members like
'show_other_directories' transitioned into flags like
DIR_SHOW_OTHER_DIRECTORIES.

Update the comments for treat_directory() to use these flag names rather
than the old member names.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agodir: traverse into untracked directories if they may have ignored subfiles
Elijah Newren [Wed, 12 May 2021 17:28:20 +0000 (17:28 +0000)] 
dir: traverse into untracked directories if they may have ignored subfiles

A directory that is untracked does not imply that all files under it
should be categorized as untracked; in particular, if the caller is
interested in ignored files, many files or directories underneath the
untracked directory may be ignored.  We previously partially handled
this right with DIR_SHOW_IGNORED_TOO, but missed DIR_SHOW_IGNORED.  It
was not obvious, though, because the logic for untracked and excluded
files had been fused together making it harder to reason about.  The
previous commit split that logic out, making it easier to notice that
DIR_SHOW_IGNORED was missing.  Add it.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agodir: avoid unnecessary traversal into ignored directory
Elijah Newren [Wed, 12 May 2021 17:28:19 +0000 (17:28 +0000)] 
dir: avoid unnecessary traversal into ignored directory

The show_other_directories case in treat_directory() tried to handle
both excludes and untracked files with the same logic, and mishandled
both the excludes and the untracked files in the process, in different
ways.  Split that logic apart, and then focus on the logic for the
excludes; a subsequent commit will address the logic for untracked
files.

For show_other_directories, an excluded directory means that
every path underneath that directory will also be excluded.  Given that
the calling code requested to just show directories when everything
under a directory had the same state (that's what the
"DIR_SHOW_OTHER_DIRECTORIES" flag means), we generally do not need to
traverse into such directories and can just immediately mark them as
ignored (i.e. as path_excluded).  The only reason we cannot just
immediately return path_excluded is the DIR_HIDE_EMPTY_DIRECTORIES flag
and the possibility that the ignored directory is an empty directory.
The code previously treated DIR_SHOW_IGNORED_TOO in most cases as an
exception as well, which was wrong.  It can sometimes reduce the number
of cases where we need to recurse (namely if
DIR_SHOW_IGNORED_TOO_MODE_MATCHING is also set), but should not be able
to increase the number of cases where we need to recurse.  Fix the logic
accordingly.

Some sidenotes about possible confusion with dir.c:

* "ignored" often refers to an untracked ignore", i.e. a file which is
  not tracked which matches one of the ignore/exclusion rules.  But you
  can also have a "tracked ignore", a tracked file that happens to match
  one of the ignore/exclusion rules and which dir.c has to worry about
  since "git ls-files -c -i" is supposed to list them.

* The dir code often uses "ignored" and "excluded" interchangeably,
  which you need to keep in mind while reading the code.

* "exclude" is used multiple ways in the code:

  * As noted above, "exclude" is often a synonym for "ignored".

  * The logic for parsing .gitignore files was re-used in
    .git/info/sparse-checkout, except there it is used to mark paths that
    the user wants to *keep*.  This was mostly addressed by commit
    65edd96aec ("treewide: rename 'exclude' methods to 'pattern'",
    2019-09-03), but every once in a while you'll find a comment about
    "exclude" referring to these patterns that might in fact be in use
    by the sparse-checkout machinery for inclusion rules.

  * The word "EXCLUDE" is also used for pathspec negation, as in
      (pathspec->items[3].magic & PATHSPEC_EXCLUDE)
    Thus if a user had a .gitignore file containing
      *~
      *.log
      !settings.log
    And then ran
      git add -- 'settings.*' ':^settings.log'
    Then :^settings.log is a pathspec negation making settings.log not
    be requested to be added even though all other settings.* files are
    being added.  Also, !settings.log in the gitignore file is a negative
    exclude pattern meaning that settings.log is normally a file we
    want to track even though all other *.log files are ignored.

Sometimes it feels like dir.c needs its own glossary with its many
definitions, including the multiply-defined terms.

Reported-by: Jason Gore <Jason.Gore@microsoft.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot3001, t7300: add testcase showcasing missed directory traversal
Elijah Newren [Wed, 12 May 2021 17:28:18 +0000 (17:28 +0000)] 
t3001, t7300: add testcase showcasing missed directory traversal

In the last commit, we added a testcase showing that the directory
traversal machinery sometimes traverses into directories unnecessarily.
Here we show that there are cases where it does the opposite: it does
not traverse into directories, despite those directories having
important files that need to be flagged.

Add a testcase showing that `git ls-files -o -i --directory` can omit
some of the files it should be listing, and another showing that `git
clean -fX` can fail to clean out some of the expected files.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agot7300: add testcase showing unnecessary traversal into ignored directory
Elijah Newren [Wed, 12 May 2021 17:28:17 +0000 (17:28 +0000)] 
t7300: add testcase showing unnecessary traversal into ignored directory

The PNPM package manager is apparently creating deeply nested (but
ignored) directory structures; traversing them is costly
performance-wise, unnecessary, and in some cases is even throwing
warnings/errors because the paths are too long to handle on various
platforms.  Add a testcase that checks for such unnecessary directory
traversal.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agols-files: error out on -i unless -o or -c are specified
Elijah Newren [Wed, 12 May 2021 17:28:16 +0000 (17:28 +0000)] 
ls-files: error out on -i unless -o or -c are specified

ls-files --ignored can be used together with either --others or
--cached.  After being perplexed for a bit and digging in to the code, I
assumed that ls-files -i was just broken and not printing anything and
I had a nice patch ready to submit when I finally realized that -i can be
used with --cached to find tracked ignores.

While that was a mistake on my part, and a careful reading of the
documentation could have made this more clear, I suspect this is an
error others are likely to make as well.  In fact, of two uses in our
testsuite, I believe one of the two did make this error.  In t1306.13,
there are NO tracked files, and all the excludes built up and used in
that test and in previous tests thus have to be about untracked files.
However, since they were looking for an empty result, the mistake went
unnoticed as their erroneous command also just happened to give an empty
answer.

-i will most the time be used with -o, which would suggest we could just
make -i imply -o in the absence of either a -o or -c, but that would be
a backward incompatible break.  Instead, let's just flag -i without
either a -o or -c as an error, and update the two relevant testcases to
specify their intent.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agodir: report number of visited directories and paths with trace2
Elijah Newren [Wed, 12 May 2021 17:28:15 +0000 (17:28 +0000)] 
dir: report number of visited directories and paths with trace2

Provide more statistics in trace2 output that include the number of
directories and total paths visited by the directory traversal logic.
Subsequent patches will take advantage of this to ensure we do not
unnecessarily traverse into ignored directories.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agodir: convert trace calls to trace2 equivalents
Elijah Newren [Wed, 12 May 2021 17:28:14 +0000 (17:28 +0000)] 
dir: convert trace calls to trace2 equivalents

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agopretty: fix a typo in the documentation for %(trailers)
Louis Sautier [Wed, 12 May 2021 11:18:02 +0000 (11:18 +0000)] 
pretty: fix a typo in the documentation for %(trailers)

Signed-off-by: Louis Sautier <sautier.louis@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoMakefile: make PERL_DEFINES recursively expanded
Ævar Arnfjörð Bjarmason [Wed, 12 May 2021 09:49:44 +0000 (11:49 +0200)] 
Makefile: make PERL_DEFINES recursively expanded

Since 07d90eadb50 (Makefile: add Perl runtime prefix support,
2018-04-10) PERL_DEFINES has been a simply-expanded variable, let's
make it recursively expanded instead.

This change doesn't matter for the correctness of the logic. Whether
we used simply-expanded or recursively expanded didn't change what we
wrote out in GIT-PERL-DEFINES, but being consistent with other rules
makes this easier to understand.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoremote-curl: fix clone on sha256 repos
Eric Wong [Tue, 11 May 2021 10:37:30 +0000 (10:37 +0000)] 
remote-curl: fix clone on sha256 repos

The remote-https process needs to update it's own instance of
`the_repository' when it sees an HTTP(S) remote is using sha256.
Without this, parse_oid_hex() fails to handle sha256 OIDs when
it's eventually called by parse_fetch().

Tested with:

git clone https://yhbt.net/sha256test.git
GIT_SMART_HTTP=0 git clone https://yhbt.net/sha256test.git
(plain http:// also works)

Cloning the URL via git:// required no changes

Signed-off-by: Eric Wong <e@80x24.org>
Acked-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agoref-filter: fix read invalid union member bug
ZheNing Hu [Tue, 11 May 2021 15:35:20 +0000 (15:35 +0000)] 
ref-filter: fix read invalid union member bug

used_atom.u is an union, and it has different members depending on
what atom the auxiliary data the union part of the "struct
used_atom" wants to record. At most only one of the members can be
valid at any one time. Since the code checks u.remote_ref without
even making sure if the atom is "push" or "push:" (which are only
two cases that u.remote_ref.push becomes valid), but u.remote_ref
shares the same storage for other members of the union, the check
was reading from an invalid member, which was the bug.

Modify the condition here to check whether the atom name
equals to "push" or starts with "push:", to avoid reading the
value of invalid member of the union.

Signed-off-by: ZheNing Hu <adlternative@gmail.com>
[jc: further test fixes]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 years agomaintenance: fix two memory leaks
Lénaïc Huard [Mon, 10 May 2021 19:59:09 +0000 (21:59 +0200)] 
maintenance: fix two memory leaks

Fixes two memory leaks when running `git maintenance start` or `git
maintenance stop` in `update_background_schedule`:

$ valgrind --leak-check=full ~/git/bin/git maintenance start
==76584== Memcheck, a memory error detector
==76584== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==76584== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==76584== Command: /home/lenaic/git/bin/git maintenance start
==76584==
==76584==
==76584== HEAP SUMMARY:
==76584==     in use at exit: 34,880 bytes in 252 blocks
==76584==   total heap usage: 820 allocs, 568 frees, 146,414 bytes allocated
==76584==
==76584== 65 bytes in 1 blocks are definitely lost in loss record 17 of 39
==76584==    at 0x483E6AF: malloc (vg_replace_malloc.c:306)
==76584==    by 0x3DC39C: xrealloc (wrapper.c:126)
==76584==    by 0x3992CC: strbuf_grow (strbuf.c:98)
==76584==    by 0x39A473: strbuf_vaddf (strbuf.c:392)
==76584==    by 0x39BC54: xstrvfmt (strbuf.c:979)
==76584==    by 0x39BD2C: xstrfmt (strbuf.c:989)
==76584==    by 0x18451B: update_background_schedule (gc.c:1977)
==76584==    by 0x1846F6: maintenance_start (gc.c:2011)
==76584==    by 0x1847B4: cmd_maintenance (gc.c:2030)
==76584==    by 0x127A2E: run_builtin (git.c:453)
==76584==    by 0x127E81: handle_builtin (git.c:704)
==76584==    by 0x128142: run_argv (git.c:771)
==76584==
==76584== 240 bytes in 1 blocks are definitely lost in loss record 29 of 39
==76584==    at 0x4840D7B: realloc (vg_replace_malloc.c:834)
==76584==    by 0x491CE5D: getdelim (in /usr/lib/libc-2.33.so)
==76584==    by 0x39ADD7: strbuf_getwholeline (strbuf.c:635)
==76584==    by 0x39AF31: strbuf_getdelim (strbuf.c:706)
==76584==    by 0x39B064: strbuf_getline_lf (strbuf.c:727)
==76584==    by 0x184273: crontab_update_schedule (gc.c:1919)
==76584==    by 0x184678: update_background_schedule (gc.c:1997)
==76584==    by 0x1846F6: maintenance_start (gc.c:2011)
==76584==    by 0x1847B4: cmd_maintenance (gc.c:2030)
==76584==    by 0x127A2E: run_builtin (git.c:453)
==76584==    by 0x127E81: handle_builtin (git.c:704)
==76584==    by 0x128142: run_argv (git.c:771)
==76584==
==76584== LEAK SUMMARY:
==76584==    definitely lost: 305 bytes in 2 blocks
==76584==    indirectly lost: 0 bytes in 0 blocks
==76584==      possibly lost: 0 bytes in 0 blocks
==76584==    still reachable: 34,575 bytes in 250 blocks
==76584==         suppressed: 0 bytes in 0 blocks
==76584== Reachable blocks (those to which a pointer was found) are not shown.
==76584== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==76584==
==76584== For lists of detected and suppressed errors, rerun with: -s
==76584== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)

Signed-off-by: Lénaïc Huard <lenaic@lhuard.fr>
Acked-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoThe sixteenth batch
Junio C Hamano [Tue, 11 May 2021 06:26:42 +0000 (15:26 +0900)] 
The sixteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'zh/trailer-cmd'
Junio C Hamano [Tue, 11 May 2021 06:27:23 +0000 (15:27 +0900)] 
Merge branch 'zh/trailer-cmd'

The way the command line specified by the trailer.<token>.command
configuration variable receives the end-user supplied value was
both error prone and misleading.  An alternative to achieve the
same goal in a safer and more intuitive way has been added, as
the trailer.<token>.cmd configuration variable, to replace it.

* zh/trailer-cmd:
  trailer: add new .cmd config option
  docs: correct descript of trailer.<token>.command

3 years agoMerge branch 'jk/symlinked-dotgitx-cleanup'
Junio C Hamano [Tue, 11 May 2021 06:27:23 +0000 (15:27 +0900)] 
Merge branch 'jk/symlinked-dotgitx-cleanup'

Various test and documentation updates about .gitsomething paths
that are symlinks.

* jk/symlinked-dotgitx-cleanup:
  docs: document symlink restrictions for dot-files
  fsck: warn about symlinked dotfiles we'll open with O_NOFOLLOW
  t0060: test ntfs/hfs-obscured dotfiles
  t7450: test .gitmodules symlink matching against obscured names
  t7450: test verify_path() handling of gitmodules
  t7415: rename to expand scope
  fsck_tree(): wrap some long lines
  fsck_tree(): fix shadowed variable
  t7415: remove out-dated comment about translation

3 years agoMerge branch 'jk/pack-objects-negative-options-fix'
Junio C Hamano [Tue, 11 May 2021 06:27:23 +0000 (15:27 +0900)] 
Merge branch 'jk/pack-objects-negative-options-fix'

Options to "git pack-objects" that take numeric values like
--window and --depth should not accept negative values; the input
validation has been tightened.

* jk/pack-objects-negative-options-fix:
  pack-objects: clamp negative depth to 0
  t5316: check behavior of pack-objects --depth=0
  pack-objects: clamp negative window size to 0
  t5300: check that we produced expected number of deltas
  t5300: modernize basic tests

3 years agoMerge branch 'jk/doc-format-patch-skips-merges'
Junio C Hamano [Tue, 11 May 2021 06:27:22 +0000 (15:27 +0900)] 
Merge branch 'jk/doc-format-patch-skips-merges'

Document that "format-patch" skips merges.

* jk/doc-format-patch-skips-merges:
  docs/format-patch: mention handling of merges

3 years agoMerge branch 'jc/test-allows-local'
Junio C Hamano [Tue, 11 May 2021 06:27:22 +0000 (15:27 +0900)] 
Merge branch 'jc/test-allows-local'

Document that our test can use "local" keyword.

* jc/test-allows-local:
  CodingGuidelines: explicitly allow "local" for test scripts

3 years agoMerge branch 'nc/submodule-update-quiet'
Junio C Hamano [Tue, 11 May 2021 06:27:22 +0000 (15:27 +0900)] 
Merge branch 'nc/submodule-update-quiet'

"git submodule update --quiet" did not propagate the quiet option
down to underlying "git fetch", which has been corrected.

* nc/submodule-update-quiet:
  submodule update: silence underlying fetch with "--quiet"

3 years agoMerge branch 'js/merge-already-up-to-date-message-reword'
Junio C Hamano [Tue, 11 May 2021 06:27:22 +0000 (15:27 +0900)] 
Merge branch 'js/merge-already-up-to-date-message-reword'

A few variants of informational message "Already up-to-date" has
been rephrased.

* js/merge-already-up-to-date-message-reword:
  merge: fix swapped "up to date" message components
  merge(s): apply consistent punctuation to "up to date" messages

3 years agoMerge branch 'rj/bisect-skip-honor-terms'
Junio C Hamano [Tue, 11 May 2021 06:27:21 +0000 (15:27 +0900)] 
Merge branch 'rj/bisect-skip-honor-terms'

"git bisect skip" when custom words are used for new/old did not
work, which has been corrected.

* rj/bisect-skip-honor-terms:
  bisect--helper: use BISECT_TERMS in 'bisect skip' command

3 years agorefs: cleanup directories when deleting packed ref
Will Chandler [Sat, 8 May 2021 05:00:43 +0000 (01:00 -0400)] 
refs: cleanup directories when deleting packed ref

When deleting a packed ref via 'update-ref -d', a lockfile is made in
the directory that would contain the loose copy of that ref, creating
any directories in the ref's path that do not exist. When the
transaction completes, the lockfile is deleted, but any empty parent
directories made when creating the lockfile are left in place.  These
empty directories are not removed by 'pack-refs' or other housekeeping
tasks and will accumulate over time.

When deleting a loose ref, we remove all empty parent directories at the
end of the transaction.

This commit applies the parent directory cleanup logic used when
deleting loose refs to packed refs as well.

Signed-off-by: Will Chandler <wfc@wfchandler.org>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomerge-ort: split "distinct types" message into two translatable messages
Alex Henrie [Sun, 9 May 2021 21:52:50 +0000 (15:52 -0600)] 
merge-ort: split "distinct types" message into two translatable messages

The word "renamed" has two possible translations in many European
languages depending on whether one thing was renamed or two things were
renamed. Give translators freedom to alter any part of the message to
make it sound right in their language.

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Acked-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoThe fifteenth batch
Junio C Hamano [Mon, 10 May 2021 07:58:04 +0000 (16:58 +0900)] 
The fifteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'rs/repack-without-loosening-promised-objects'
Junio C Hamano [Mon, 10 May 2021 07:59:47 +0000 (16:59 +0900)] 
Merge branch 'rs/repack-without-loosening-promised-objects'

"git repack -A -d" in a partial clone unnecessarily loosened
objects in promisor pack.

* rs/repack-without-loosening-promised-objects:
  repack: avoid loosening promisor objects in partial clones

3 years agoMerge branch 'ls/subtree'
Junio C Hamano [Mon, 10 May 2021 07:59:47 +0000 (16:59 +0900)] 
Merge branch 'ls/subtree'

"git subtree" updates.

* ls/subtree: (30 commits)
  subtree: be stricter about validating flags
  subtree: push: allow specifying a local rev other than HEAD
  subtree: allow 'split' flags to be passed to 'push'
  subtree: allow --squash to be used with --rejoin
  subtree: give the docs a once-over
  subtree: have $indent actually affect indentation
  subtree: don't let debug and progress output clash
  subtree: add comments and sanity checks
  subtree: remove duplicate check
  subtree: parse revs in individual cmd_ functions
  subtree: use "^{commit}" instead of "^0"
  subtree: don't fuss with PATH
  subtree: use "$*" instead of "$@" as appropriate
  subtree: use more explicit variable names for cmdline args
  subtree: use git-sh-setup's `say`
  subtree: use `git merge-base --is-ancestor`
  subtree: drop support for git < 1.7
  subtree: more consistent error propagation
  subtree: don't have loose code outside of a function
  subtree: t7900: add porcelain tests for 'pull' and 'push'
  ...

3 years agoMerge branch 'bc/hash-transition-interop-part-1'
Junio C Hamano [Mon, 10 May 2021 07:59:46 +0000 (16:59 +0900)] 
Merge branch 'bc/hash-transition-interop-part-1'

SHA-256 transition.

* bc/hash-transition-interop-part-1:
  hex: print objects using the hash algorithm member
  hex: default to the_hash_algo on zero algorithm value
  builtin/pack-objects: avoid using struct object_id for pack hash
  commit-graph: don't store file hashes as struct object_id
  builtin/show-index: set the algorithm for object IDs
  hash: provide per-algorithm null OIDs
  hash: set, copy, and use algo field in struct object_id
  builtin/pack-redundant: avoid casting buffers to struct object_id
  Use the final_oid_fn to finalize hashing of object IDs
  hash: add a function to finalize object IDs
  http-push: set algorithm when reading object ID
  Always use oidread to read into struct object_id
  hash: add an algo member to struct object_id

3 years agoam: learn to process quoted lines that ends with CRLF
Đoàn Trần Công Danh [Sun, 9 May 2021 17:12:13 +0000 (00:12 +0700)] 
am: learn to process quoted lines that ends with CRLF

In previous changes, mailinfo has learnt to process lines that decoded
from base64 or quoted-printable, and ends with CRLF.

Let's teach "am" that new trick, too.

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomailinfo: allow stripping quoted CR without warning
Đoàn Trần Công Danh [Sun, 9 May 2021 17:12:12 +0000 (00:12 +0700)] 
mailinfo: allow stripping quoted CR without warning

In previous changes, we've turned on warning for quoted CR in base64 or
quoted-printable email messages. Some projects see those quoted CR a lot,
they know that it happens most of the time, and they find it's desirable
to always strip those CR.

Those projects in question usually fall back to use other tools to handle
patches when receive such patches.

Let's help those projects handle those patches by stripping those
excessive CR.

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomailinfo: allow squelching quoted CRLF warning
Đoàn Trần Công Danh [Sun, 9 May 2021 17:12:11 +0000 (00:12 +0700)] 
mailinfo: allow squelching quoted CRLF warning

In previous change, Git starts to warn for quoted CRLF in decoded
base64/QP email. Despite those warnings are usually helpful,
quoted CRLF could be part of some users' workflow.

Let's give them an option to turn off the warning completely.

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomailinfo: warn if CRLF found in decoded base64/QP email
Đoàn Trần Công Danh [Sun, 9 May 2021 17:12:10 +0000 (00:12 +0700)] 
mailinfo: warn if CRLF found in decoded base64/QP email

When SMTP servers receive 8-bit email messages, possibly with only
LF as line ending, some of them decide to change said LF to CRLF.

Some mailing list softwares, when receive 8-bit email messages,
decide to encode those messages in base64 or quoted-printable.

If an email is transfered through above mail servers, then distributed
by such mailing list softwares, the recipients will receive an email
contains a patch mungled with CRLF encoded inside another encoding.

Thus, such CR (in CRLF) couldn't be dropped by "mailsplit".
Hence, the mailed patch couldn't be applied cleanly.
Such accidents have been observed in the wild [1].

Instead of silently rejecting those messages, let's give our users
some warnings if such CR (as part of CRLF) is found.

[1]: https://nmbug.notmuchmail.org/nmweb/show/m2lf9ejegj.fsf%40guru.guru-group.fi

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agopretty-formats.txt: add missing space
Martin Ågren [Sun, 9 May 2021 09:10:00 +0000 (11:10 +0200)] 
pretty-formats.txt: add missing space

The description of "%ch" is missing a space after "human style", before
the parenthetical remark. This description was introduced in b722d4560e
("pretty: provide human date format", 2021-04-25). That commit also
added "%ah", which does have the space already.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogit-repack.txt: remove spurious ")"
Martin Ågren [Sun, 9 May 2021 09:09:59 +0000 (11:09 +0200)] 
git-repack.txt: remove spurious ")"

Drop the ")" at the end of this paragraph. There's a parenthetical
remark in this paragraph, but it's been closed on the line above.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoThe fourteenth batch
Junio C Hamano [Fri, 7 May 2021 03:35:33 +0000 (12:35 +0900)] 
The fourteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'll/clone-reject-shallow'
Junio C Hamano [Fri, 7 May 2021 03:47:42 +0000 (12:47 +0900)] 
Merge branch 'll/clone-reject-shallow'

Fix tests when forced to use v0 protocol.

* ll/clone-reject-shallow:
  t5601: mark protocol v2-only test

3 years agoMerge branch 'si/zsh-complete-comment-fix'
Junio C Hamano [Fri, 7 May 2021 03:47:42 +0000 (12:47 +0900)] 
Merge branch 'si/zsh-complete-comment-fix'

Portability fix for command line completion script (in contrib/).

* si/zsh-complete-comment-fix:
  work around zsh comment in __git_complete_worktree_paths

3 years agoMerge branch 'dl/complete-stash-updates'
Junio C Hamano [Fri, 7 May 2021 03:47:41 +0000 (12:47 +0900)] 
Merge branch 'dl/complete-stash-updates'

Further update the command line completion (in contrib/) for "git
stash".

* dl/complete-stash-updates:
  git-completion.bash: consolidate cases in _git_stash()
  git-completion.bash: use $__git_cmd_idx in more places
  git-completion.bash: rename to $__git_cmd_idx
  git-completion.bash: separate some commands onto their own line

3 years agoMerge branch 'dl/complete-stash'
Junio C Hamano [Fri, 7 May 2021 03:47:41 +0000 (12:47 +0900)] 
Merge branch 'dl/complete-stash'

The command line completion (in contrib/) for "git stash" has been
updated.

* dl/complete-stash:
  git-completion.bash: use __gitcomp_builtin() in _git_stash()
  git-completion.bash: extract from else in _git_stash()
  git-completion.bash: pass $__git_subcommand_idx from __git_main()

3 years agoMerge branch 'ah/plugleaks'
Junio C Hamano [Fri, 7 May 2021 03:47:41 +0000 (12:47 +0900)] 
Merge branch 'ah/plugleaks'

Plug various leans reported by LSAN.

* ah/plugleaks:
  builtin/rm: avoid leaking pathspec and seen
  builtin/rebase: release git_format_patch_opt too
  builtin/for-each-ref: free filter and UNLEAK sorting.
  mailinfo: also free strbuf lists when clearing mailinfo
  builtin/checkout: clear pending objects after diffing
  builtin/check-ignore: clear_pathspec before returning
  builtin/bugreport: don't leak prefixed filename
  branch: FREE_AND_NULL instead of NULL'ing real_ref
  bloom: clear each bloom_key after use
  ls-files: free max_prefix when done
  wt-status: fix multiple small leaks
  revision: free remainder of old commit list in limit_list

3 years agoMerge branch 'ps/rev-list-object-type-filter'
Junio C Hamano [Fri, 7 May 2021 03:47:40 +0000 (12:47 +0900)] 
Merge branch 'ps/rev-list-object-type-filter'

"git rev-list" learns the "--filter=object:type=<type>" option,
which can be used to exclude objects of the given kind from the
packfile generated by pack-objects.

* ps/rev-list-object-type-filter:
  rev-list: allow filtering of provided items
  pack-bitmap: implement combined filter
  pack-bitmap: implement object type filter
  list-objects: implement object type filter
  list-objects: support filtering by tag and commit
  list-objects: move tag processing into its own function
  revision: mark commit parents as NOT_USER_GIVEN
  uploadpack.txt: document implication of `uploadpackfilter.allow`

3 years agoMerge branch 'ab/svn-tests-set-e-fix'
Junio C Hamano [Fri, 7 May 2021 03:47:40 +0000 (12:47 +0900)] 
Merge branch 'ab/svn-tests-set-e-fix'

Test clean-up.

* ab/svn-tests-set-e-fix:
  svn tests: refactor away a "set -e" in test body
  svn tests: remove legacy re-setup from init-clone test

3 years agoMerge branch 'ab/rebase-no-reschedule-failed-exec'
Junio C Hamano [Fri, 7 May 2021 03:47:40 +0000 (12:47 +0900)] 
Merge branch 'ab/rebase-no-reschedule-failed-exec'

"git rebase --[no-]reschedule-failed-exec" did not work well with
its configuration variable, which has been corrected.

* ab/rebase-no-reschedule-failed-exec:
  rebase: don't override --no-reschedule-failed-exec with config
  rebase tests: camel-case rebase.rescheduleFailedExec consistently

3 years agoMerge branch 'ab/doc-lint'
Junio C Hamano [Fri, 7 May 2021 03:47:40 +0000 (12:47 +0900)] 
Merge branch 'ab/doc-lint'

Dev support.

* ab/doc-lint:
  docs: fix linting issues due to incorrect relative section order
  doc lint: lint relative section order
  doc lint: lint and fix missing "GIT" end sections
  doc lint: fix bugs in, simplify and improve lint script
  doc lint: Perl "strict" and "warnings" in lint-gitlink.perl
  Documentation/Makefile: make doc.dep dependencies a variable again
  Documentation/Makefile: make $(wildcard howto/*.txt) a var

3 years agoMerge branch 'mt/add-rm-in-sparse-checkout'
Junio C Hamano [Fri, 7 May 2021 03:47:39 +0000 (12:47 +0900)] 
Merge branch 'mt/add-rm-in-sparse-checkout'

"git add" and "git rm" learned not to touch those paths that are
outside of sparse checkout.

* mt/add-rm-in-sparse-checkout:
  rm: honor sparse checkout patterns
  add: warn when asked to update SKIP_WORKTREE entries
  refresh_index(): add flag to ignore SKIP_WORKTREE entries
  pathspec: allow to ignore SKIP_WORKTREE entries on index matching
  add: make --chmod and --renormalize honor sparse checkouts
  t3705: add tests for `git add` in sparse checkouts
  add: include magic part of pathspec on --refresh error

3 years agoMerge branch 'ps/config-global-override'
Junio C Hamano [Fri, 7 May 2021 03:47:39 +0000 (12:47 +0900)] 
Merge branch 'ps/config-global-override'

Replace GIT_CONFIG_NOSYSTEM mechanism to decline from reading the
system-wide configuration file with GIT_CONFIG_SYSTEM that lets
users specify from which file to read the system-wide configuration
(setting it to an empty file would essentially be the same as
setting NOSYSTEM), and introduce GIT_CONFIG_GLOBAL to override the
per-user configuration in $HOME/.gitconfig.

* ps/config-global-override:
  t1300: fix unset of GIT_CONFIG_NOSYSTEM leaking into subsequent tests
  config: allow overriding of global and system configuration
  config: unify code paths to get global config paths
  config: rename `git_etc_config()`

3 years agoMerge branch 'zh/pretty-date-human'
Junio C Hamano [Fri, 7 May 2021 03:47:39 +0000 (12:47 +0900)] 
Merge branch 'zh/pretty-date-human'

"git log --format=..." placeholders learned %ah/%ch placeholders to
request the --date=human output.

* zh/pretty-date-human:
  pretty: provide human date format

3 years agoMerge branch 'zh/format-ref-array-optim'
Junio C Hamano [Fri, 7 May 2021 03:47:39 +0000 (12:47 +0900)] 
Merge branch 'zh/format-ref-array-optim'

"git (branch|tag) --format=..." has been micro-optimized.

* zh/format-ref-array-optim:
  ref-filter: reuse output buffer
  ref-filter: get rid of show_ref_array_item

3 years agoMerge branch 'ad/cygwin-no-backslashes-in-paths'
Junio C Hamano [Fri, 7 May 2021 03:47:39 +0000 (12:47 +0900)] 
Merge branch 'ad/cygwin-no-backslashes-in-paths'

Cygwin pathname handling fix.

* ad/cygwin-no-backslashes-in-paths:
  cygwin: disallow backslashes in file names

3 years agoMerge branch 'jz/apply-3way-first-message-fix'
Junio C Hamano [Fri, 7 May 2021 03:47:38 +0000 (12:47 +0900)] 
Merge branch 'jz/apply-3way-first-message-fix'

When we swapped the order of --3way fallback, we forgot to adjust
the message we give when the first method fails and the second
method is attempted (which used to be "direct application failed
hence we try 3way", now it is the other way around).

* jz/apply-3way-first-message-fix:
  apply: adjust messages to account for --3way changes

3 years agoMerge branch 'jk/prune-with-bitmap-fix'
Junio C Hamano [Fri, 7 May 2021 03:47:38 +0000 (12:47 +0900)] 
Merge branch 'jk/prune-with-bitmap-fix'

When the reachability bitmap is in effect, the "do not lose
recently created objects and those that are reachable from them"
safety to protect us from races were disabled by mistake, which has
been corrected.

* jk/prune-with-bitmap-fix:
  prune: save reachable-from-recent objects with bitmaps
  pack-bitmap: clean up include_check after use

3 years agoMerge branch 'po/diff-patch-doc'
Junio C Hamano [Fri, 7 May 2021 03:47:38 +0000 (12:47 +0900)] 
Merge branch 'po/diff-patch-doc'

Doc update.

* po/diff-patch-doc:
  doc: point to diff attribute in patch format docs

3 years agoMerge branch 'hn/trace-reflog-expiry'
Junio C Hamano [Fri, 7 May 2021 03:47:38 +0000 (12:47 +0900)] 
Merge branch 'hn/trace-reflog-expiry'

The reflog expiry machinery has been taught to emit trace events.

* hn/trace-reflog-expiry:
  refs/debug: trace into reflog expiry too

3 years agoMerge branch 'ab/pretty-date-format-tests'
Junio C Hamano [Fri, 7 May 2021 03:47:37 +0000 (12:47 +0900)] 
Merge branch 'ab/pretty-date-format-tests'

Tweak a few tests for "log --format=..." that show timestamps in
various formats.

* ab/pretty-date-format-tests:
  pretty tests: give --date/format tests a better description
  pretty tests: simplify %aI/%cI date format test