]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
11 months agotest-lib: GIT_TEST_SANITIZE_LEAK_LOG enabled by default
Rubén Justo [Thu, 11 Jul 2024 14:10:51 +0000 (23:10 +0900)] 
test-lib: GIT_TEST_SANITIZE_LEAK_LOG enabled by default

As we currently describe in t/README, it can happen that:

    Some tests run "git" (or "test-tool" etc.) without properly checking
    the exit code, or git will invoke itself and fail to ferry the
    abort() exit code to the original caller.

Therefore, GIT_TEST_SANITIZE_LEAK_LOG=true is needed to be set to
capture all memory leaks triggered by our tests.

It seems unnecessary to force users to remember this option, as
forgetting it could lead to missed memory leaks.

We could solve the problem by making it "true" by default, but that
might suggest we think "false" makes sense, which isn't the case.

Therefore, the best approach is to remove the option entirely while
maintaining the capability to detect memory leaks in blind spots of our
tests.

Signed-off-by: Rubén Justo <rjusto@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agotest-lib: fix GIT_TEST_SANITIZE_LEAK_LOG
Rubén Justo [Sun, 30 Jun 2024 06:42:06 +0000 (08:42 +0200)] 
test-lib: fix GIT_TEST_SANITIZE_LEAK_LOG

When a test that leaks runs with GIT_TEST_SANITIZE_LEAK_LOG=true,
the test returns zero, which is not what we want.

In the if-else's chain we have in "check_test_results_san_file_", we
consider three variables: $passes_sanitize_leak, $sanitize_leak_check
and, implicitly, GIT_TEST_SANITIZE_LEAK_LOG (always set to "true" at
that point).

For the first two variables we have different considerations depending
on the value of $test_failure, which makes sense.  However, for the
third, GIT_TEST_SANITIZE_LEAK_LOG, we don't;  regardless of
$test_failure, we use "invert_exit_code=t" to produce a non-zero
return value.

That assumes "$test_failure" is always zero at that point.  But it
may not be:

   $ git checkout v2.40.1
   $ make test SANITIZE=leak T=t3200-branch.sh # this fails
   $ make test SANITIZE=leak GIT_TEST_SANITIZE_LEAK_LOG=true T=t3200-branch.sh # this succeeds
   [...]
   With GIT_TEST_SANITIZE_LEAK_LOG=true, our logs revealed a memory leak, exiting with a non-zero status!
   # faked up failures as TODO & now exiting with 0 due to --invert-exit-code

We need to use "invert_exit_code=t" only when "$test_failure" is zero.

Let's add the missing conditions in the if-else's chain to make it work
as expected.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Rubén Justo <rjusto@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoMore post 2.45.2 updates from the 'master' front
Junio C Hamano [Fri, 28 Jun 2024 22:09:40 +0000 (15:09 -0700)] 
More post 2.45.2 updates from the 'master' front

Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoMerge branch 'ds/ahead-behind-fix' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:19 +0000 (15:53 -0700)] 
Merge branch 'ds/ahead-behind-fix' into maint-2.45

Fix for a progress bar.

* ds/ahead-behind-fix:
  commit-graph: increment progress indicator

11 months agoMerge branch 'ds/doc-add-interactive-singlekey' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:18 +0000 (15:53 -0700)] 
Merge branch 'ds/doc-add-interactive-singlekey' into maint-2.45

Doc update.

* ds/doc-add-interactive-singlekey:
  doc: interactive.singleKey is disabled by default

11 months agoMerge branch 'jc/varargs-attributes' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:18 +0000 (15:53 -0700)] 
Merge branch 'jc/varargs-attributes' into maint-2.45

Varargs functions that are unannotated as printf-like or execl-like
have been annotated as such.

* jc/varargs-attributes:
  __attribute__: add a few missing format attributes
  __attribute__: mark some functions with LAST_ARG_MUST_BE_NULL
  __attribute__: remove redundant attribute declaration for git_die_config()
  __attribute__: trace2_region_enter_printf() is like "printf"

11 months agoMerge branch 'ps/ci-fix-detection-of-ubuntu-20' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:17 +0000 (15:53 -0700)] 
Merge branch 'ps/ci-fix-detection-of-ubuntu-20' into maint-2.45

Fix for an embarrassing typo that prevented Python2 tests from running
anywhere.

* ps/ci-fix-detection-of-ubuntu-20:
  ci: fix check for Ubuntu 20.04

11 months agoMerge branch 'jk/cap-exclude-file-size' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:17 +0000 (15:53 -0700)] 
Merge branch 'jk/cap-exclude-file-size' into maint-2.45

An overly large ".gitignore" files are now rejected silently.

* jk/cap-exclude-file-size:
  dir.c: reduce max pattern file size to 100MB
  dir.c: skip .gitignore, etc larger than INT_MAX

11 months agoMerge branch 'jc/safe-directory-leading-path' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:16 +0000 (15:53 -0700)] 
Merge branch 'jc/safe-directory-leading-path' into maint-2.45

The safe.directory configuration knob has been updated to
optionally allow leading path matches.

* jc/safe-directory-leading-path:
  safe.directory: allow "lead/ing/path/*" match

11 months agoMerge branch 'rs/difftool-env-simplify' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:16 +0000 (15:53 -0700)] 
Merge branch 'rs/difftool-env-simplify' into maint-2.45

Code simplification.

* rs/difftool-env-simplify:
  difftool: add env vars directly in run_file_diff()

11 months agoMerge branch 'ps/fix-reinit-includeif-onbranch' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:15 +0000 (15:53 -0700)] 
Merge branch 'ps/fix-reinit-includeif-onbranch' into maint-2.45

"git init" in an already created directory, when the user
configuration has includeif.onbranch, started to fail recently,
which has been corrected.

* ps/fix-reinit-includeif-onbranch:
  setup: fix bug with "includeIf.onbranch" when initializing dir

11 months agoMerge branch 'es/chainlint-ncores-fix' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:15 +0000 (15:53 -0700)] 
Merge branch 'es/chainlint-ncores-fix' into maint-2.45

The chainlint script (invoked during "make test") did nothing when
it failed to detect the number of available CPUs.  It now falls
back to 1 CPU to avoid the problem.

* es/chainlint-ncores-fix:
  chainlint.pl: latch CPU count directly reported by /proc/cpuinfo
  chainlint.pl: fix incorrect CPU count on Linux SPARC
  chainlint.pl: make CPU count computation more robust

11 months agoMerge branch 'jc/rev-parse-fatal-doc' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:14 +0000 (15:53 -0700)] 
Merge branch 'jc/rev-parse-fatal-doc' into maint-2.45

Doc update.

* jc/rev-parse-fatal-doc:
  rev-parse: document how --is-* options work outside a repository

11 months agoMerge branch 'jc/doc-diff-name-only' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:14 +0000 (15:53 -0700)] 
Merge branch 'jc/doc-diff-name-only' into maint-2.45

The documentation for "git diff --name-only" has been clarified
that it is about showing the names in the post-image tree.

* jc/doc-diff-name-only:
  diff: document what --name-only shows

11 months agoMerge branch 'mt/t0211-typofix' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:13 +0000 (15:53 -0700)] 
Merge branch 'mt/t0211-typofix' into maint-2.45

Test fix.

* mt/t0211-typofix:
  t/t0211-trace2-perf.sh: fix typo patern -> pattern

11 months agoMerge branch 'dg/fetch-pack-code-cleanup' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:13 +0000 (15:53 -0700)] 
Merge branch 'dg/fetch-pack-code-cleanup' into maint-2.45

Code clean-up to remove an unused struct definition.

* dg/fetch-pack-code-cleanup:
  fetch-pack: remove unused 'struct loose_object_iter'

11 months agoMerge branch 'dm/update-index-doc-fix' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:12 +0000 (15:53 -0700)] 
Merge branch 'dm/update-index-doc-fix' into maint-2.45

Doc fix.

* dm/update-index-doc-fix:
  documentation: git-update-index: add --show-index-version to synopsis

11 months agoMerge branch 'ds/scalar-reconfigure-all-fix' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:12 +0000 (15:53 -0700)] 
Merge branch 'ds/scalar-reconfigure-all-fix' into maint-2.45

Scalar fix.

* ds/scalar-reconfigure-all-fix:
  scalar: avoid segfault in reconfigure --all

11 months agoMerge branch 'vd/doc-merge-tree-x-option' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:11 +0000 (15:53 -0700)] 
Merge branch 'vd/doc-merge-tree-x-option' into maint-2.45

Doc update.

* vd/doc-merge-tree-x-option:
  Documentation/git-merge-tree.txt: document -X

11 months agoMerge branch 'fa/p4-error' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:10 +0000 (15:53 -0700)] 
Merge branch 'fa/p4-error' into maint-2.45

P4 update.

* fa/p4-error:
  git-p4: show Perforce error to the user

11 months agoMerge branch 'tb/attr-limits' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:10 +0000 (15:53 -0700)] 
Merge branch 'tb/attr-limits' into maint-2.45

The maximum size of attribute files is enforced more consistently.

* tb/attr-limits:
  attr.c: move ATTR_MAX_FILE_SIZE check into read_attr_from_buf()

11 months agoMerge branch 'rs/diff-parseopts-cleanup' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:09 +0000 (15:53 -0700)] 
Merge branch 'rs/diff-parseopts-cleanup' into maint-2.45

Code clean-up to remove code that is now a noop.

* rs/diff-parseopts-cleanup:
  diff-lib: stop calling diff_setup_done() in do_diff_cache()

11 months agoMerge branch 'dk/zsh-git-repo-path-fix' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:09 +0000 (15:53 -0700)] 
Merge branch 'dk/zsh-git-repo-path-fix' into maint-2.45

Command line completion support for zsh (in contrib/) has been
updated to stop exposing internal state to end-user shell
interaction.

* dk/zsh-git-repo-path-fix:
  completion: zsh: stop leaking local cache variable

11 months agoMerge branch 'bc/zsh-compatibility' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:08 +0000 (15:53 -0700)] 
Merge branch 'bc/zsh-compatibility' into maint-2.45

zsh can pretend to be a normal shell pretty well except for some
glitches that we tickle in some of our scripts. Work them around
so that "vimdiff" and our test suite works well enough with it.

* bc/zsh-compatibility:
  vimdiff: make script and tests work with zsh
  t4046: avoid continue in &&-chain for zsh

11 months agoMerge branch 'js/for-each-repo-keep-going' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:08 +0000 (15:53 -0700)] 
Merge branch 'js/for-each-repo-keep-going' into maint-2.45

A scheduled "git maintenance" job is expected to work on all
repositories it knows about, but it stopped at the first one that
errored out.  Now it keeps going.

* js/for-each-repo-keep-going:
  maintenance: running maintenance should not stop on errors
  for-each-repo: optionally keep going on an error

11 months agoMerge branch 'aj/stash-staged-fix' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:07 +0000 (15:53 -0700)] 
Merge branch 'aj/stash-staged-fix' into maint-2.45

"git stash -S" did not handle binary files correctly, which has
been corrected.

* aj/stash-staged-fix:
  stash: fix "--staged" with binary files

11 months agoMerge branch 'xx/disable-replace-when-building-midx' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:06 +0000 (15:53 -0700)] 
Merge branch 'xx/disable-replace-when-building-midx' into maint-2.45

The procedure to build multi-pack-index got confused by the
replace-refs mechanism, which has been corrected by disabling the
latter.

* xx/disable-replace-when-building-midx:
  midx: disable replace objects

11 months agoMerge branch 'pw/rebase-m-signoff-fix' into maint-2.45
Junio C Hamano [Fri, 28 Jun 2024 22:53:06 +0000 (15:53 -0700)] 
Merge branch 'pw/rebase-m-signoff-fix' into maint-2.45

"git rebase --signoff" used to forget that it needs to add a
sign-off to the resulting commit when told to continue after a
conflict stops its operation.

* pw/rebase-m-signoff-fix:
  rebase -m: fix --signoff with conflicts
  sequencer: store commit message in private context
  sequencer: move current fixups to private context
  sequencer: start removing private fields from public API
  sequencer: always free "struct replay_opts"

12 months agocommit-graph: increment progress indicator
Derrick Stolee [Tue, 11 Jun 2024 15:09:15 +0000 (15:09 +0000)] 
commit-graph: increment progress indicator

This fixes a bug that was introduced by 368d19b0b7 (commit-graph:
refactor compute_topological_levels(), 2023-03-20): Previously, the
progress indicator was updated from `i + 1` where `i` is the loop
variable of the enclosing `for` loop. After this patch, the update used
`info->progress_cnt + 1` instead, however, unlike `i`, the
`progress_cnt` attribute was not incremented. Let's increment it.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
[jc: squashed in a test update from Patrick Steinhardt]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months ago__attribute__: add a few missing format attributes
Junio C Hamano [Sat, 8 Jun 2024 18:37:47 +0000 (11:37 -0700)] 
__attribute__: add a few missing format attributes

A public function mem_pool_strfmt() takes printf like parameters,
but is not given an attribute as such.  Also a few file-scope static
functions were missing their format attribute.

Add them.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months ago__attribute__: mark some functions with LAST_ARG_MUST_BE_NULL
Junio C Hamano [Sat, 8 Jun 2024 18:37:46 +0000 (11:37 -0700)] 
__attribute__: mark some functions with LAST_ARG_MUST_BE_NULL

Some varargs functions that use NULL-terminated parameter list were
missing __attributes__ ((sentinel)) aka LAST_ARG_MUST_BE_NULL.

Add them.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months ago__attribute__: remove redundant attribute declaration for git_die_config()
Junio C Hamano [Sat, 8 Jun 2024 18:37:45 +0000 (11:37 -0700)] 
__attribute__: remove redundant attribute declaration for git_die_config()

The convention is to declare the function attribute to an extern
function together with its declaration in the header file, without
repeating the attribute declaration with its definition in the .c
source file (a file-scope static function declares its attribute
together with its definition in the .c file it is defined, as there
is no other place to do so).

The definition of git_die_config() in config.c did not follow the
convention and had its attribute declared with both its declaration
in the header and its definition in the .c source file.

Remove the one in the config.c to match everybody else.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months ago__attribute__: trace2_region_enter_printf() is like "printf"
Junio C Hamano [Sat, 8 Jun 2024 18:37:44 +0000 (11:37 -0700)] 
__attribute__: trace2_region_enter_printf() is like "printf"

The last part of the parameter list the function takes is like
parameters to printf.  Mark it as such.

An existing call that formats a value of type size_t using "%d" was
found by the compiler with the help with this annotation; fix it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agodoc: interactive.singleKey is disabled by default
Dragan Simic [Fri, 7 Jun 2024 22:27:17 +0000 (15:27 -0700)] 
doc: interactive.singleKey is disabled by default

Make it clear that the interactive.singleKey configuration option is
disabled by default, using rather subtle wording that avoids an
emphasis on the actual default value.  This should eliminate any
associated doubts.

While there, touch up the remaining wording of the description a bit.

Signed-off-by: Dragan Simic <dsimic@manjaro.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoci: fix check for Ubuntu 20.04
Patrick Steinhardt [Thu, 6 Jun 2024 09:31:40 +0000 (11:31 +0200)] 
ci: fix check for Ubuntu 20.04

In 5ca0c455f1 (ci: fix Python dependency on Ubuntu 24.04, 2024-05-06),
we made the use of Python 2 conditional on whether or not the CI job
runs Ubuntu 20.04. There was a brown-paper-bag-style bug though, where
the condition forgot to invoke the `test` builtin. The result of it is
that the check always fails, and thus all of our jobs run with Python 3
by accident.

Fix this.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agodir.c: reduce max pattern file size to 100MB
Jeff King [Wed, 5 Jun 2024 08:03:08 +0000 (04:03 -0400)] 
dir.c: reduce max pattern file size to 100MB

In a2bc523e1e (dir.c: skip .gitignore, etc larger than INT_MAX,
2024-05-31) we put capped the size of some files whose parsing code and
data structures used ints. Setting the limit to INT_MAX was a natural
spot, since we know the parsing code would misbehave above that.

But it also leaves the possibility of overflow errors when we multiply
that limit to allocate memory. For instance, a file consisting only of
"a\na\n..." could have INT_MAX/2 entries. Allocating an array of
pointers for each would need INT_MAX*4 bytes on a 64-bit system, enough
to overflow a 32-bit int.

So let's give ourselves a bit more safety margin by giving a much
smaller limit. The size 100MB is somewhat arbitrary, but is based on the
similar value for attribute files added by 3c50032ff5 (attr: ignore
overly large gitattributes files, 2022-12-01).

There's no particular reason these have to be the same, but the idea is
that they are in the ballpark of "so huge that nobody would care, but
small enough to avoid malicious overflow". So lacking a better guess, it
makes sense to use the same value. The implementation here doesn't share
the same constant, but we could change that later (or even give it a
runtime config knob, though nobody has complained yet about the
attribute limit).

And likewise, let's add a few tests that exercise the limits, based on
the attr ones. In this case, though, we never read .gitignore from the
index; the blob code is exercised only for sparse filters. So we'll
trigger it that way.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agodir.c: skip .gitignore, etc larger than INT_MAX
Jeff King [Fri, 31 May 2024 12:00:34 +0000 (08:00 -0400)] 
dir.c: skip .gitignore, etc larger than INT_MAX

We use add_patterns() to read .gitignore, .git/info/exclude, etc, as
well as other pattern-like files like sparse-checkout. The parser for
these uses an "int" as an index, meaning that files over 2GB will
generally cause signed integer overflow and out-of-bounds access.

This is unlikely to happen in any real files, but we do read .gitignore
files from the tree. A malicious tree could cause an out-of-bounds read
and segfault (we also write NULs over newlines, so in theory it could be
an out-of-bounds write, too, but as we go char-by-char, the first thing
that happens is trying to read a negative 2GB offset).

We could fix the most obvious issue by replacing one "int" with a
"size_t". But there are tons of "int" sprinkled throughout this code for
things like pattern lengths, number of patterns, and so on. Since nobody
would actually want a 2GB .gitignore file, an easy defensive measure is
to just refuse to parse them.

The "int" in question is in add_patterns_from_buffer(), so we could
catch it there. But by putting the checks in its two callers, we can
produce more useful error messages.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoPost 2.45.2 updates
Junio C Hamano [Fri, 31 May 2024 20:51:15 +0000 (13:51 -0700)] 
Post 2.45.2 updates

Merge down a handful of topics to adjust tests and CI to make them
work better, without changing Git itself, and a bit of developer
docs update:

 * Tests that try to corrupt in-repository files in chunked format did
   not work well on macOS due to its broken "mv", which has been
   worked around.

 * Unbreak CI jobs so that we do not attempt to use Python 2 that has
   been removed from the platform.

 * Git 2.43 started using the tree of HEAD as the source of attributes
   in a bare repository, which has severe performance implications.
   For now, revert the change, without ripping out a more explicit
   support for the attr.tree configuration variable.

 * Windows CI running in GitHub Actions started complaining about the
   order of arguments given to calloc(); the imported regex code uses
   the wrong order almost consistently, which has been corrected.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'jk/ci-macos-gcc13-fix' into maint-2.45
Junio C Hamano [Fri, 31 May 2024 22:28:21 +0000 (15:28 -0700)] 
Merge branch 'jk/ci-macos-gcc13-fix' into maint-2.45

CI fix.

* jk/ci-macos-gcc13-fix:
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable

12 months agoMerge branch 'ma/win32-unix-domain-socket' into maint-2.45
Junio C Hamano [Fri, 31 May 2024 22:28:21 +0000 (15:28 -0700)] 
Merge branch 'ma/win32-unix-domain-socket' into maint-2.45

Build fix.

* ma/win32-unix-domain-socket:
  win32: fix building with NO_UNIX_SOCKETS

12 months agoMerge branch 'jt/doc-submitting-rerolled-series' into maint-2.45
Junio C Hamano [Fri, 31 May 2024 22:28:20 +0000 (15:28 -0700)] 
Merge branch 'jt/doc-submitting-rerolled-series' into maint-2.45

Developer doc update.

* jt/doc-submitting-rerolled-series:
  doc: clarify practices for submitting updated patch versions

12 months agoMerge branch 'jc/doc-manpages-l10n' into maint-2.45
Junio C Hamano [Fri, 31 May 2024 22:28:20 +0000 (15:28 -0700)] 
Merge branch 'jc/doc-manpages-l10n' into maint-2.45

The SubmittingPatches document now refers folks to manpages
translation project.

* jc/doc-manpages-l10n:
  SubmittingPatches: advertise git-manpages-l10n project a bit

12 months agoMerge branch 'jc/compat-regex-calloc-fix' into maint-2.45
Junio C Hamano [Fri, 31 May 2024 22:28:19 +0000 (15:28 -0700)] 
Merge branch 'jc/compat-regex-calloc-fix' into maint-2.45

Windows CI running in GitHub Actions started complaining about the
order of arguments given to calloc(); the imported regex code uses
the wrong order almost consistently, which has been corrected.

* jc/compat-regex-calloc-fix:
  compat/regex: fix argument order to calloc(3)

12 months agoMerge branch 'jc/no-default-attr-tree-in-bare' into maint-2.45
Junio C Hamano [Fri, 31 May 2024 22:28:19 +0000 (15:28 -0700)] 
Merge branch 'jc/no-default-attr-tree-in-bare' into maint-2.45

Git 2.43 started using the tree of HEAD as the source of attributes
in a bare repository, which has severe performance implications.
For now, revert the change, without ripping out a more explicit
support for the attr.tree configuration variable.

* jc/no-default-attr-tree-in-bare:
  stop using HEAD for attributes in bare repository by default

12 months agoMerge branch 'ps/ci-python-2-deprecation' into maint-2.45
Junio C Hamano [Fri, 31 May 2024 22:28:18 +0000 (15:28 -0700)] 
Merge branch 'ps/ci-python-2-deprecation' into maint-2.45

Unbreak CI jobs so that we do not attempt to use Python 2 that has
been removed from the platform.

* ps/ci-python-2-deprecation:
  ci: fix Python dependency on Ubuntu 24.04

12 months agoMerge branch 'jc/test-workaround-broken-mv' into maint-2.45
Junio C Hamano [Fri, 31 May 2024 22:28:18 +0000 (15:28 -0700)] 
Merge branch 'jc/test-workaround-broken-mv' into maint-2.45

Tests that try to corrupt in-repository files in chunked format did
not work well on macOS due to its broken "mv", which has been
worked around.

* jc/test-workaround-broken-mv:
  t/lib-chunk: work around broken "mv" on some vintage of macOS

12 months agoMerge branch 'jc/git-gui-maintainer-update' into maint-2.45
Junio C Hamano [Fri, 31 May 2024 22:28:17 +0000 (15:28 -0700)] 
Merge branch 'jc/git-gui-maintainer-update' into maint-2.45

* jc/git-gui-maintainer-update:
  SubmittingPatches: welcome the new maintainer of git-gui part

12 months agoGit 2.45.2 v2.45.2
Junio C Hamano [Fri, 31 May 2024 00:18:43 +0000 (17:18 -0700)] 
Git 2.45.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'jc/fix-2.45.1-and-friends-for-maint' into maint-2.45
Junio C Hamano [Fri, 31 May 2024 00:17:21 +0000 (17:17 -0700)] 
Merge branch 'jc/fix-2.45.1-and-friends-for-maint' into maint-2.45

* jc/fix-2.45.1-and-friends-for-maint:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

12 months agoGit 2.44.2 v2.44.2
Junio C Hamano [Fri, 31 May 2024 00:13:43 +0000 (17:13 -0700)] 
Git 2.44.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'fixes/2.45.1/2.44' into maint-2.44
Junio C Hamano [Fri, 31 May 2024 00:11:02 +0000 (17:11 -0700)] 
Merge branch 'fixes/2.45.1/2.44' into maint-2.44

* fixes/2.45.1/2.44:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

12 months agoGit 2.43.5 v2.43.5
Junio C Hamano [Fri, 31 May 2024 00:06:24 +0000 (17:06 -0700)] 
Git 2.43.5

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'fixes/2.45.1/2.43' into maint-2.43
Junio C Hamano [Fri, 31 May 2024 00:04:37 +0000 (17:04 -0700)] 
Merge branch 'fixes/2.45.1/2.43' into maint-2.43

* fixes/2.45.1/2.43:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

12 months agoGit 2.42.3 v2.42.3
Junio C Hamano [Fri, 31 May 2024 00:03:31 +0000 (17:03 -0700)] 
Git 2.42.3

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'fixes/2.45.1/2.42' into maint-2.42
Junio C Hamano [Fri, 31 May 2024 00:00:57 +0000 (17:00 -0700)] 
Merge branch 'fixes/2.45.1/2.42' into maint-2.42

* fixes/2.45.1/2.42:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

12 months agoGit 2.41.2 v2.41.2
Junio C Hamano [Fri, 31 May 2024 00:00:29 +0000 (17:00 -0700)] 
Git 2.41.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'fixes/2.45.1/2.41' into maint-2.41
Junio C Hamano [Thu, 30 May 2024 23:58:12 +0000 (16:58 -0700)] 
Merge branch 'fixes/2.45.1/2.41' into maint-2.41

* fixes/2.45.1/2.41:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

12 months agoGit 2.40.3 v2.40.3
Junio C Hamano [Thu, 30 May 2024 23:57:31 +0000 (16:57 -0700)] 
Git 2.40.3

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agoMerge branch 'fixes/2.45.1/2.40' into maint-2.40
Junio C Hamano [Thu, 30 May 2024 23:54:42 +0000 (16:54 -0700)] 
Merge branch 'fixes/2.45.1/2.40' into maint-2.40

* fixes/2.45.1/2.40:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

12 months agoGit 2.39.5 v2.39.5
Junio C Hamano [Thu, 30 May 2024 23:52:52 +0000 (16:52 -0700)] 
Git 2.39.5

12 months agoMerge branch 'jc/fix-2.45.1-and-friends-for-2.39' into maint-2.39
Junio C Hamano [Thu, 30 May 2024 23:38:58 +0000 (16:38 -0700)] 
Merge branch 'jc/fix-2.45.1-and-friends-for-2.39' into maint-2.39

* jc/fix-2.45.1-and-friends-for-2.39:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

12 months agosafe.directory: allow "lead/ing/path/*" match
Junio C Hamano [Wed, 29 May 2024 16:02:16 +0000 (09:02 -0700)] 
safe.directory: allow "lead/ing/path/*" match

When safe.directory was introduced in v2.30.3 timeframe, 8959555c
(setup_git_directory(): add an owner check for the top-level
directory, 2022-03-02), it only allowed specific opt-out
directories.  Immediately after an embargoed release that included
the change, 0f85c4a3 (setup: opt-out of check with safe.directory=*,
2022-04-13) was done as a response to loosen the check so that a
single '*' can be used to say "I trust all repositories" for folks
who host too many repositories to list individually.

Let's further loosen the check to allow people to say "everything
under this hierarchy is deemed safe" by specifying such a leading
directory with "/*" appended to it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 months agodifftool: add env vars directly in run_file_diff()
René Scharfe [Sun, 26 May 2024 20:16:50 +0000 (22:16 +0200)] 
difftool: add env vars directly in run_file_diff()

Add the environment variables of the child process directly using
strvec_push() instead of building an array out of them and then adding
that using strvec_pushv().  The new code is shorter and avoids magic
array index values and fragile array padding.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoMerge branch 'fixes/2.45.1/2.44' into jc/fix-2.45.1-and-friends-for-maint
Junio C Hamano [Fri, 24 May 2024 23:59:12 +0000 (16:59 -0700)] 
Merge branch 'fixes/2.45.1/2.44' into jc/fix-2.45.1-and-friends-for-maint

* fixes/2.45.1/2.44:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

13 months agoMerge branch 'fixes/2.45.1/2.43' into fixes/2.45.1/2.44
Junio C Hamano [Fri, 24 May 2024 23:58:35 +0000 (16:58 -0700)] 
Merge branch 'fixes/2.45.1/2.43' into fixes/2.45.1/2.44

* fixes/2.45.1/2.43:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

13 months agoMerge branch 'fixes/2.45.1/2.42' into fixes/2.45.1/2.43
Junio C Hamano [Fri, 24 May 2024 23:58:11 +0000 (16:58 -0700)] 
Merge branch 'fixes/2.45.1/2.42' into fixes/2.45.1/2.43

* fixes/2.45.1/2.42:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

13 months agoMerge branch 'fixes/2.45.1/2.41' into fixes/2.45.1/2.42
Junio C Hamano [Fri, 24 May 2024 23:57:43 +0000 (16:57 -0700)] 
Merge branch 'fixes/2.45.1/2.41' into fixes/2.45.1/2.42

* fixes/2.45.1/2.41:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

13 months agoMerge branch 'fixes/2.45.1/2.40' into fixes/2.45.1/2.41
Junio C Hamano [Fri, 24 May 2024 23:57:01 +0000 (16:57 -0700)] 
Merge branch 'fixes/2.45.1/2.40' into fixes/2.45.1/2.41

* fixes/2.45.1/2.40:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

13 months agoMerge branch 'jc/fix-2.45.1-and-friends-for-2.39' into fixes/2.45.1/2.40
Junio C Hamano [Fri, 24 May 2024 19:29:35 +0000 (12:29 -0700)] 
Merge branch 'jc/fix-2.45.1-and-friends-for-2.39' into fixes/2.45.1/2.40

Revert overly aggressive "layered defence" that went into 2.45.1
and friends, which broke "git-lfs", "git-annex", and other use
cases, so that we can rebuild necessary counterparts in the open.

* jc/fix-2.45.1-and-friends-for-2.39:
  Revert "fsck: warn about symlink pointing inside a gitdir"
  Revert "Add a helper function to compare file contents"
  clone: drop the protections where hooks aren't run
  tests: verify that `clone -c core.hooksPath=/dev/null` works again
  Revert "core.hooksPath: add some protection while cloning"
  init: use the correct path of the templates directory again
  hook: plug a new memory leak
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable
  send-email: avoid creating more than one Term::ReadLine object
  send-email: drop FakeTerm hack

13 months agoRevert "fsck: warn about symlink pointing inside a gitdir"
Junio C Hamano [Thu, 23 May 2024 04:55:31 +0000 (21:55 -0700)] 
Revert "fsck: warn about symlink pointing inside a gitdir"

This reverts commit a33fea08 (fsck: warn about symlink pointing
inside a gitdir, 2024-04-10), which warns against symbolic links
commonly created by git-annex.

13 months agosetup: fix bug with "includeIf.onbranch" when initializing dir
Patrick Steinhardt [Wed, 22 May 2024 10:38:46 +0000 (12:38 +0200)] 
setup: fix bug with "includeIf.onbranch" when initializing dir

It was reported that git-init(1) can fail when initializing an existing
directory in case the config contains an "includeIf.onbranch:"
condition:

    $ mkdir repo
    $ git -c includeIf.onbranch:main.path=nonexistent init repo
    BUG: refs.c:2056: reference backend is unknown

The same error can also be triggered when re-initializing an already
existing repository.

The bug has been introduced in 173761e21b (setup: start tracking ref
storage format, 2023-12-29), which wired up the ref storage format. The
root cause is in `init_db()`, which tries to read the config before we
have initialized `the_repository` and most importantly its ref storage
format. We eventually end up calling `include_by_branch()` and execute
`refs_resolve_ref_unsafe()`, but because we have not initialized the ref
storage format yet this will trigger the above bug.

Interestingly, `include_by_branch()` has a mechanism that will only
cause us to resolve the ref when `the_repository->gitdir` is set. This
is also the reason why this only happens when we initialize an already
existing directory or repository: `gitdir` is set in those cases, but
not when creating a new directory.

Now there are two ways to address the issue:

  - We can adapt `include_by_branch()` to also make the code conditional
    on whether `the_repository->ref_storage_format` is set.

  - We can shift around code such that we initialize the repository
    format before we read the config.

While the first approach would be safe, it may also cause us to paper
over issues where a ref store should have been set up. In our case for
example, it may be reasonable to expect that re-initializing the repo
will cause the "onbranch:" condition to trigger, but we would not do
that if the ref storage format was not set up yet. This also used to
work before the above commit that introduced this bug.

Rearrange the code such that we set up the repository format before
reading the config. This fixes the bug and ensures that "onbranch:"
conditions can trigger.

Reported-by: Heghedus Razvan <heghedus.razvan@protonmail.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Tested-by: Heghedus Razvan <heghedus.razvan@protonmail.com>
[jc: fixed a test and backported to v2.44.0 codebase]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agochainlint.pl: latch CPU count directly reported by /proc/cpuinfo
Eric Sunshine [Mon, 20 May 2024 19:01:31 +0000 (15:01 -0400)] 
chainlint.pl: latch CPU count directly reported by /proc/cpuinfo

On Linux, ncores() computes the number of CPUs by counting the
"processor" or "CPU" lines emitted by /proc/cpuinfo. However, on some
platforms, /proc/cpuinfo does not enumerate the CPUs at all, but
instead merely mentions the total number of CPUs. In such cases, pluck
the CPU count directly from the /proc/cpuinfo line which reports the
number of active CPUs. (In particular, check for "cpus active: NN" and
"ncpus active: NN" since both variants have been seen in the
wild[1,2].)

[1]: https://lore.kernel.org/git/503a99f3511559722a3eeef15d31027dfe617fa1.camel@physik.fu-berlin.de/
[2]: https://lore.kernel.org/git/7acbd5c6c68bd7ba020e2d1cc457a8954fd6edf4.camel@physik.fu-berlin.de/

Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agochainlint.pl: fix incorrect CPU count on Linux SPARC
John Paul Adrian Glaubitz [Mon, 20 May 2024 19:01:30 +0000 (15:01 -0400)] 
chainlint.pl: fix incorrect CPU count on Linux SPARC

On SPARC systems running Linux, individual processors are denoted with
"CPUnn:" in /proc/cpuinfo instead of the usual "processor : NN". As a
result, the regexp in ncores() matches 0 times. Address this shortcoming
by extending the regexp to also match lines with "CPUnn:".

Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
[es: simplified regexp; tweaked commit message]
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoRevert "Add a helper function to compare file contents"
Johannes Schindelin [Mon, 20 May 2024 20:22:05 +0000 (20:22 +0000)] 
Revert "Add a helper function to compare file contents"

Now that during a `git clone`, the hooks' contents are no longer
compared to the templates' files', the caller for which the
`do_files_match()` function was introduced is gone, and therefore this
function can be retired, too.

This reverts commit 584de0b4c23 (Add a helper function to compare file
contents, 2024-03-30).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoclone: drop the protections where hooks aren't run
Johannes Schindelin [Mon, 20 May 2024 20:22:04 +0000 (20:22 +0000)] 
clone: drop the protections where hooks aren't run

As part of the security bug-fix releases v2.39.4, ..., v2.45.1, I
introduced logic to safeguard `git clone` from running hooks that were
installed _during_ the clone operation.

The rationale was that Git's CVE-2024-32002, CVE-2021-21300,
CVE-2019-1354, CVE-2019-1353, CVE-2019-1352, and CVE-2019-1349 should
have been low-severity vulnerabilities but were elevated to
critical/high severity by the attack vector that allows a weakness where
files inside `.git/` can be inadvertently written during a `git clone`
to escalate to a Remote Code Execution attack by virtue of installing a
malicious `post-checkout` hook that Git will then run at the end of the
operation without giving the user a chance to see what code is executed.

Unfortunately, Git LFS uses a similar strategy to install its own
`post-checkout` hook during a `git clone`; In fact, Git LFS is
installing four separate hooks while running the `smudge` filter.

While this pattern is probably in want of being improved by introducing
better support in Git for Git LFS and other tools wishing to register
hooks to be run at various stages of Git's commands, let's undo the
clone protections to unbreak Git LFS-enabled clones.

This reverts commit 8db1e8743c0 (clone: prevent hooks from running
during a clone, 2024-03-28).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agotests: verify that `clone -c core.hooksPath=/dev/null` works again
Johannes Schindelin [Mon, 20 May 2024 20:22:03 +0000 (20:22 +0000)] 
tests: verify that `clone -c core.hooksPath=/dev/null` works again

As part of the protections added in Git v2.45.1 and friends,
repository-local `core.hooksPath` settings are no longer allowed, as a
defense-in-depth mechanism to prevent future Git vulnerabilities to
raise to critical level if those vulnerabilities inadvertently allow the
repository-local config to be written.

What the added protection did not anticipate is that such a
repository-local `core.hooksPath` can not only be used to point to
maliciously-placed scripts in the current worktree, but also to
_prevent_ hooks from being called altogether.

We just reverted the `core.hooksPath` protections, based on the Git
maintainer's recommendation in
https://lore.kernel.org/git/xmqq4jaxvm8z.fsf@gitster.g/ to address this
concern as well as related ones. Let's make sure that we won't regress
while trying to protect the clone operation further.

Reported-by: Brooke Kuhlmann <brooke@alchemists.io>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoRevert "core.hooksPath: add some protection while cloning"
Johannes Schindelin [Mon, 20 May 2024 20:22:02 +0000 (20:22 +0000)] 
Revert "core.hooksPath: add some protection while cloning"

This defense-in-depth was intended to protect the clone operation
against future escalations where bugs in `git clone` would allow
attackers to write arbitrary files in the `.git/` directory would allow
for Remote Code Execution attacks via maliciously-placed hooks.

However, it turns out that the `core.hooksPath` protection has
unintentional side effects so severe that they do not justify the
benefit of the protections. For example, it has been reported in
https://lore.kernel.org/git/FAFA34CB-9732-4A0A-87FB-BDB272E6AEE8@alchemists.io/
that the following invocation, which is intended to make `git clone`
safer, is itself broken by that protective measure:

git clone --config core.hooksPath=/dev/null <url>

Since it turns out that the benefit does not justify the cost, let's revert
20f3588efc6 (core.hooksPath: add some protection while cloning,
2024-03-30).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoinit: use the correct path of the templates directory again
Johannes Schindelin [Mon, 20 May 2024 20:22:01 +0000 (20:22 +0000)] 
init: use the correct path of the templates directory again

In df93e407f06 (init: refactor the template directory discovery into its
own function, 2024-03-29), I refactored the way the templates directory
is discovered.

The refactoring was faithful, but missed a reference in the `Makefile`
where the `DEFAULT_GIT_TEMPLATE_DIR` constant is defined. As a
consequence, Git v2.45.1 and friends will always use the hard-coded path
`/usr/share/git-core/templates`.

Let's fix that by defining the `DEFAULT_GIT_TEMPLATE_DIR` when building
`setup.o`, where that constant is actually used.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agohook: plug a new memory leak
Johannes Schindelin [Mon, 20 May 2024 20:22:00 +0000 (20:22 +0000)] 
hook: plug a new memory leak

In 8db1e8743c0 (clone: prevent hooks from running during a clone,
2024-03-28), I introduced an inadvertent memory leak that was
unfortunately not caught before v2.45.1 was released. Here is a fix.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoci: stop installing "gcc-13" for osx-gcc
Jeff King [Thu, 9 May 2024 16:25:44 +0000 (12:25 -0400)] 
ci: stop installing "gcc-13" for osx-gcc

Our osx-gcc job explicitly asks to install gcc-13. But since the GitHub
runner image already comes with gcc-13 installed, this is mostly doing
nothing (or in some cases it may install an incremental update over the
runner image). But worse, it recently started causing errors like:

    ==> Fetching gcc@13
    ==> Downloading https://ghcr.io/v2/homebrew/core/gcc/13/blobs/sha256:fb2403d97e2ce67eb441b54557cfb61980830f3ba26d4c5a1fe5ecd0c9730d1a
    ==> Pouring gcc@13--13.2.0.ventura.bottle.tar.gz
    Error: The `brew link` step did not complete successfully
    The formula built, but is not symlinked into /usr/local
    Could not symlink bin/c++-13
    Target /usr/local/bin/c++-13
    is a symlink belonging to gcc. You can unlink it:
      brew unlink gcc

which cause the whole CI job to bail.

I didn't track down the root cause, but I suspect it may be related to
homebrew recently switching the "gcc" default to gcc-14. And it may even
be fixed when a new runner image is released. But if we don't need to
run brew at all, it's one less thing for us to worry about.

[jc: cherry-picked from v2.45.0-3-g7df2405b38]

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoci: avoid bare "gcc" for osx-gcc job
Jeff King [Thu, 9 May 2024 16:24:15 +0000 (12:24 -0400)] 
ci: avoid bare "gcc" for osx-gcc job

On macOS, a bare "gcc" (without a version) will invoke a wrapper for
clang, not actual gcc. Even when gcc is installed via homebrew, that
only provides version-specific links in /usr/local/bin (like "gcc-13"),
and never a version-agnostic "gcc" wrapper.

As far as I can tell, this has been the case for a long time, and this
osx-gcc job has largely been doing nothing. We can point it at "gcc-13",
which will pick up the homebrew-installed version.

The fix here is specific to the github workflow file, as the gitlab one
does not have a matching job.

It's a little unfortunate that we cannot just ask for the latest version
of gcc which homebrew provides, but as far as I can tell there is no
easy alias (you'd have to find the highest number gcc-* in
/usr/local/bin yourself).

[jc: cherry-picked from v2.45.0-2-g11c7001e3d]

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoci: drop mention of BREW_INSTALL_PACKAGES variable
Jeff King [Thu, 9 May 2024 16:23:05 +0000 (12:23 -0400)] 
ci: drop mention of BREW_INSTALL_PACKAGES variable

The last user of this variable went away in 4a6e4b9602 (CI: remove
Travis CI support, 2021-11-23), so it's doing nothing except making it
more confusing to find out which packages _are_ installed.

[jc: cherry-picked from v2.45.0-1-g9d4453e8d6]

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agosend-email: avoid creating more than one Term::ReadLine object
Jeff King [Tue, 8 Aug 2023 18:15:31 +0000 (14:15 -0400)] 
send-email: avoid creating more than one Term::ReadLine object

Every time git-send-email calls its ask() function to prompt the user,
we call term(), which instantiates a new Term::ReadLine object. But in
v1.46 of Term::ReadLine::Gnu (which provides the Term::ReadLine
interface on some platforms), its constructor refuses to create a second
instance[1]. So on systems with that version of the module, most
git-send-email instances will fail (as we usually prompt for both "to"
and "in-reply-to" unless the user provided them on the command line).

We can fix this by keeping a single instance variable and returning it
for each call to term(). In perl 5.10 and up, we could do that with a
"state" variable. But since we only require 5.008, we'll do it the
old-fashioned way, with a lexical "my" in its own scope.

Note that the tests in t9001 detect this problem as-is, since the
failure mode is for the program to die. But let's also beef up the
"Prompting works" test to check that it correctly handles multiple
inputs (if we had chosen to keep our FakeTerm hack in the previous
commit, then the failure mode would be incorrectly ignoring prompts
after the first).

[1] For discussion of why multiple instances are forbidden, see:
    https://github.com/hirooih/perl-trg/issues/16

[jc: cherry-picked from v2.42.0-rc2~6^2]

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agosend-email: drop FakeTerm hack
Jeff King [Tue, 8 Aug 2023 18:14:36 +0000 (14:14 -0400)] 
send-email: drop FakeTerm hack

Back in 280242d1cc (send-email: do not barf when Term::ReadLine does not
like your terminal, 2006-07-02), we added a fallback for when
Term::ReadLine's constructor failed: we'd have a FakeTerm object
instead, which would then die if anybody actually tried to call
readline() on it. Since we instantiated the $term variable at program
startup, we needed this workaround to let the program run in modes when
we did not prompt the user.

But later, in f4dc9432fd (send-email: lazily load modules for a big
speedup, 2021-05-28), we started loading Term::ReadLine lazily only when
ask() is called. So at that point we know we're trying to prompt the
user, and we can just die if ReadLine instantiation fails, rather than
making this fake object to lazily delay showing the error.

This should be OK even if there is no tty (e.g., we're in a cron job),
because Term::ReadLine will return a stub object in that case whose "IN"
and "OUT" functions return undef. And since 5906f54e47 (send-email:
don't attempt to prompt if tty is closed, 2009-03-31), we check for that
case and skip prompting.

And we can be sure that FakeTerm was not kicking in for such a
situation, because it has actually been broken since that commit! It
does not define "IN" or "OUT" methods, so perl would barf with an error.
If FakeTerm was in use, we were neither honoring what 5906f54e47 tried
to do, nor producing the readable message that 280242d1cc intended.

So we're better off just dropping FakeTerm entirely, and letting the
error reported by constructing Term::ReadLine through.

[jc: cherry-picked from v2.42.0-rc2~6^2~1]

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agochainlint.pl: make CPU count computation more robust
Eric Sunshine [Mon, 20 May 2024 19:01:29 +0000 (15:01 -0400)] 
chainlint.pl: make CPU count computation more robust

There have been reports[1,2] of chainlint.pl failing to produce output
when output is expected. In fact, the underlying problem is more severe:
in these cases, it isn't doing any work at all, thus not checking Git
tests for semantic problems. In the reported cases, the problem was
tracked down to ncores() returning 0 for the CPU count, which resulted
in chainlint.pl not performing any work (since it thought it had no
cores on which to process).

In the reported cases, the reason for the failure was that the regular
expression counting the number of processors reported by /proc/cpuinfo
failed to find any matches, hence it counted 0 processors. Although
fixing each case as it is reported allows chaining.pl to work correctly
on that architecture, it does nothing to improve the overall robustness
of the core count computation which may still return 0 on some yet
untested architecture.

Address this shortcoming by ensuring that ncores() returns a sensible
fallback value in all cases.

[1]: https://lore.kernel.org/git/pull.1385.git.git.1669148861635.gitgitgadget@gmail.com/
[2]: https://lore.kernel.org/git/8baa12f8d044265f1ddeabd64209e7ac0d3700ae.camel@physik.fu-berlin.de/

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agodiff: document what --name-only shows
Junio C Hamano [Fri, 17 May 2024 17:14:46 +0000 (10:14 -0700)] 
diff: document what --name-only shows

The "--name-only" option is about showing the name of each file in
the post-image tree that got changed and nothing else (like "was it
created?").  Unlike the "--name-status" option that tells how the
change happened (e.g., renamed with similarity), it does not give
anything else, like the name of the corresponding file in the old
tree.

For example, if you start from a clean checkout that has a file
whose name is COPYING, here is what you would see:

    $ git mv COPYING RENAMING
    $ git diff -M --name-only HEAD
    RENAMING
    $ git diff -M --name-status HEAD
    R100 COPYING RENAMING

Lack of the description of this fact has confused readers in the
past.  Even back when dda2d79a ([PATCH] Clean up diff option
descriptions., 2005-07-13) documented "--name-only", "git diff"
already supported the renames, so in a sense, from day one, this
should have been documented more clearly but it wasn't.

Belatedly clarify it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoSubmittingPatches: advertise git-manpages-l10n project a bit
Junio C Hamano [Thu, 9 May 2024 17:32:09 +0000 (10:32 -0700)] 
SubmittingPatches: advertise git-manpages-l10n project a bit

The project takes our AsciiDoc sources of documentation and actively
maintains the translations to various languages.

Let's give them enhanced visibility to help those who want to
volunteer find them.

Acked-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agot/t0211-trace2-perf.sh: fix typo patern -> pattern
Marcel Telka [Thu, 16 May 2024 07:45:06 +0000 (09:45 +0200)] 
t/t0211-trace2-perf.sh: fix typo patern -> pattern

The bug went unnoticed because grep with null RE matches everything.

Signed-off-by: Marcel Telka <marcel@telka.sk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agodocumentation: git-update-index: add --show-index-version to synopsis
Dov Murik [Sun, 12 May 2024 03:14:00 +0000 (23:14 -0400)] 
documentation: git-update-index: add --show-index-version to synopsis

In 606e088d5d (update-index: add --show-index-version, 2023-09-12), we
added the new '--show-index-version' option to 'git-update-index' and
documented it, but forgot to add it to the synopsis section.

Add '--show-index-version' to the synopsis of 'git-update-index'.

Signed-off-by: Dov Murik <dov.murik@linux.dev>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agofetch-pack: remove unused 'struct loose_object_iter'
Dr. David Alan Gilbert [Sun, 12 May 2024 00:59:13 +0000 (01:59 +0100)] 
fetch-pack: remove unused 'struct loose_object_iter'

'struct loose_object_iter' in fetch-pack.c is unused since commit
97b2fa08 (fetch-pack: drop custom loose object cache, 2018-11-12).

Remove it.

Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agocompat/regex: fix argument order to calloc(3)
Junio C Hamano [Sun, 12 May 2024 06:25:04 +0000 (23:25 -0700)] 
compat/regex: fix argument order to calloc(3)

Windows compiler suddenly started complaining that calloc(3) takes
its arguments in <nmemb, size> order.  Indeed, there are many calls
that has their arguments in a _wrong_ order.

Fix them all.

A sample breakage can be seen at

  https://github.com/git/git/actions/runs/9046793153/job/24857988702#step:4:272

Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoSubmittingPatches: welcome the new maintainer of git-gui part
Junio C Hamano [Sat, 11 May 2024 18:15:58 +0000 (11:15 -0700)] 
SubmittingPatches: welcome the new maintainer of git-gui part

Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoci: stop installing "gcc-13" for osx-gcc
Jeff King [Thu, 9 May 2024 16:25:44 +0000 (12:25 -0400)] 
ci: stop installing "gcc-13" for osx-gcc

Our osx-gcc job explicitly asks to install gcc-13. But since the GitHub
runner image already comes with gcc-13 installed, this is mostly doing
nothing (or in some cases it may install an incremental update over the
runner image). But worse, it recently started causing errors like:

    ==> Fetching gcc@13
    ==> Downloading https://ghcr.io/v2/homebrew/core/gcc/13/blobs/sha256:fb2403d97e2ce67eb441b54557cfb61980830f3ba26d4c5a1fe5ecd0c9730d1a
    ==> Pouring gcc@13--13.2.0.ventura.bottle.tar.gz
    Error: The `brew link` step did not complete successfully
    The formula built, but is not symlinked into /usr/local
    Could not symlink bin/c++-13
    Target /usr/local/bin/c++-13
    is a symlink belonging to gcc. You can unlink it:
      brew unlink gcc

which cause the whole CI job to bail.

I didn't track down the root cause, but I suspect it may be related to
homebrew recently switching the "gcc" default to gcc-14. And it may even
be fixed when a new runner image is released. But if we don't need to
run brew at all, it's one less thing for us to worry about.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoci: avoid bare "gcc" for osx-gcc job
Jeff King [Thu, 9 May 2024 16:24:15 +0000 (12:24 -0400)] 
ci: avoid bare "gcc" for osx-gcc job

On macOS, a bare "gcc" (without a version) will invoke a wrapper for
clang, not actual gcc. Even when gcc is installed via homebrew, that
only provides version-specific links in /usr/local/bin (like "gcc-13"),
and never a version-agnostic "gcc" wrapper.

As far as I can tell, this has been the case for a long time, and this
osx-gcc job has largely been doing nothing. We can point it at "gcc-13",
which will pick up the homebrew-installed version.

The fix here is specific to the github workflow file, as the gitlab one
does not have a matching job.

It's a little unfortunate that we cannot just ask for the latest version
of gcc which homebrew provides, but as far as I can tell there is no
easy alias (you'd have to find the highest number gcc-* in
/usr/local/bin yourself).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoci: drop mention of BREW_INSTALL_PACKAGES variable
Jeff King [Thu, 9 May 2024 16:23:05 +0000 (12:23 -0400)] 
ci: drop mention of BREW_INSTALL_PACKAGES variable

The last user of this variable went away in 4a6e4b9602 (CI: remove
Travis CI support, 2021-11-23), so it's doing nothing except making it
more confusing to find out which packages _are_ installed.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agogit-p4: show Perforce error to the user
Fahad Alrashed [Wed, 8 May 2024 22:11:05 +0000 (22:11 +0000)] 
git-p4: show Perforce error to the user

During "git p4 clone" if p4 process returns an error from the server,
it will store the message in the 'err' variable. Then it will send a
text command "die-now" to git-fast-import. However, git-fast-import
raises an exception: "fatal: Unsupported command: die-now" and err is
never displayed. This patch ensures that err is shown to the end user.

Signed-off-by: Fahad Alrashed <fahad@keylock.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoscalar: avoid segfault in reconfigure --all
Derrick Stolee [Wed, 8 May 2024 00:05:49 +0000 (00:05 +0000)] 
scalar: avoid segfault in reconfigure --all

During the latest v2.45.0 update, 'scalar reconfigure --all' started to
segfault on my machine. Breaking it down via the debugger, it was
faulting on a NULL reference to the_hash_algo, which is a macro pointing
to the_repository->hash_algo.

In my case, this is due to one of my repositories having a detached HEAD,
which requires get_oid_hex() to parse that the HEAD reference is valid.
Another way to cause a failure is to use the "includeIf.onbranch" config
key, which will lead to a BUG() statement.

My first inclination was to try to refactor cmd_reconfigure() to execute
'git for-each-repo' instead of this loop. In addition to the difficulty
of executing 'scalar reconfigure' within 'git for-each-repo', it would
be difficult to perform the clean-up logic for non-existent repos if we
relied on that child process.

Instead, I chose to move the temporary repo to be within the loop and
reinstate the_repository to its old value after we are done performing
logic on the current array item.

Add tests to t9210-scalar.sh to test 'scalar reconfigure --all' with
multiple registered repos. There are two different ways that the old
use of the_repository could trigger bugs. These issues are being solved
independently to be more careful about the_repository being
uninitialized, but the change in this patch around the use of
the_repository is still a good safety precaution.

Co-authored-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoDocumentation/git-merge-tree.txt: document -X
Victoria Dye [Tue, 7 May 2024 21:36:29 +0000 (21:36 +0000)] 
Documentation/git-merge-tree.txt: document -X

Add an entry in the 'merge-tree' builtin documentation for
-X/--strategy-option (added in 6a4c9e7b32 (merge-tree: add -X strategy
option, 2023-09-24)). The same option is documented for 'merge', 'rebase',
'revert', etc. in their respective Documentation/ files, so let's do the
same for 'merge-tree'.

Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoci: fix Python dependency on Ubuntu 24.04
Patrick Steinhardt [Mon, 6 May 2024 05:35:17 +0000 (07:35 +0200)] 
ci: fix Python dependency on Ubuntu 24.04

Newer versions of Ubuntu have dropped Python 2 starting with Ubuntu
23.04. By default though, our CI setups will try to use that Python
version on all Ubuntu-based jobs except for the "linux-gcc" one.

We didn't notice this issue due to two reasons:

  - The "ubuntu:latest" tag always points to the latest LTS release.
    Until a few weeks ago this was Ubuntu 22.04, which still had Python
    2.

  - Our Docker-based CI jobs had their own script to install
    dependencies until 9cdeb34b96 (ci: merge scripts which install
    dependencies, 2024-04-12), where we didn't even try to install
    Python at all for many of them.

Since the CI refactorings have originally been implemented, Ubuntu
24.04 was released, and it being an LTS versions means that the "latest"
tag now points to that Python-2-less version. Consequently, those jobs
that use "ubuntu:latest" broke.

Address this by using Python 2 on Ubuntu 20.04, only, whereas we use
Python 3 on all other Ubuntu jobs. Eventually, we should think about
dropping support for Python 2 completely.

Reported-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 months agoattr.c: move ATTR_MAX_FILE_SIZE check into read_attr_from_buf()
Taylor Blau [Fri, 3 May 2024 19:12:36 +0000 (15:12 -0400)] 
attr.c: move ATTR_MAX_FILE_SIZE check into read_attr_from_buf()

Commit 3c50032ff52 (attr: ignore overly large gitattributes files,
2022-12-01) added a defense-in-depth check to ensure that .gitattributes
blobs read from the index do not exceed ATTR_MAX_FILE_SIZE (100 MB).

But there were two cases added shortly after 3c50032ff52 was written
which do not apply similar protections:

  - 47cfc9bd7d0 (attr: add flag `--source` to work with tree-ish,
    2023-01-14)

  - 4723ae1007f (attr.c: read attributes in a sparse directory,
    2023-08-11) added a similar

Ensure that we refuse to process a .gitattributes blob exceeding
ATTR_MAX_FILE_SIZE when reading from either an arbitrary tree object or
a sparse directory. This is done by pushing the ATTR_MAX_FILE_SIZE check
down into the low-level `read_attr_from_buf()`.

In doing so, plug a leak in `read_attr_from_index()` where we would
accidentally leak the large buffer upon detecting it is too large to
process.

(Since `read_attr_from_buf()` handles a NULL buffer input, we can remove
a NULL check before calling it in `read_attr_from_index()` as well).

Co-authored-by: Jeff King <peff@peff.net>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>