]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
2 months agomerge-ort: add a new mergeability_only option
Elijah Newren [Fri, 16 May 2025 20:04:17 +0000 (20:04 +0000)] 
merge-ort: add a new mergeability_only option

Git Forges may be interested in whether two branches can be merged while
not being interested in what the resulting merge tree is nor which files
conflicted.  For such cases, add a new mergeability_only option.  This
option allows the merge machinery to, in the "outer layer" of the merge:
  * exit upon first[-ish] conflict
  * avoid (not prevent) writing merged blobs/trees to the object store

I have a number of qualifiers there, so let me explain each:

"outer layer":

Note that since the recursive merge of merge bases (corresponding to
call_depth > 0) can conflict without the outer final merge
(corresponding to call_depth == 0) conflicting, we can't short-circuit
nor avoid writing merged blobs/trees to the object store during those
inner merges.

"first-ish conflict":

The current patch only exits early from process_entries() on the first
conflict it detects, but conflicts could have been detected in a
previous function call, namely detect_and_process_renames().  However:
  * conflicts detected by detect_and_process_renames() are quite rare
    conflict types
  * the detection would still come after regular rename detection
    (which is the expensive part of detect_and_process_renames()), so
    it is not saving us much in computation time given that
    process_entries() directly follows detect_and_process_renames()
  * [this overlaps with the next bullet point] process_entries() is the
    place where virtually all object writing occurs (object writing is
    sometimes more of a concern for Forges than computation time), so
    exiting early here isn't saving us much in object writes either
  * the code changes needed to handle an earlier exit are slightly
    more invasive in detect_and_process_renames() than for
    process_entries().
Given the rareness of the even earlier conflicts, the limited savings
we'd get from exiting even earlier, and in an attempt to keep this
patch simpler, we don't guarantee that we actually exit on the first
conflict detected.  We can always revisit this decision later if we
decide that a further micro-optimization to exit slightly earlier in
rare cases is worthwhile.

"avoid (not prevent) writing objects":

The detect_and_process_renames() call can also write objects to the
object store, when rename/rename conflicts involve one (or more) files
that have also been modified on both sides.  Because of this alternate
call path leading to handle_content_merges(), our "early exit" does not
prevent writing objects entirely, even within the "outer layer"
(i.e. even within call_depth == 0).  I figure that's fine though, since
we're already writing objects for the inner merges (i.e. for call_depth
> 0), which are likely going to represent vastly more objects than files
involved in rename/rename+modify/modify cases in the outer merge, on
average.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agoMerge branch 'master' of https://github.com/j6t/gitk
Junio C Hamano [Fri, 9 May 2025 20:16:51 +0000 (13:16 -0700)] 
Merge branch 'master' of https://github.com/j6t/gitk

* 'master' of https://github.com/j6t/gitk:
  gitk: add Tamil translation
  gitk: limit PATH search to bare executable names
  gitk: _search_exe is no longer needed
  gitk: override $PATH search only on Windows
  gitk: adjust indentation to match the style used in this script

3 months agoMerge branch 'master' of https://github.com/j6t/git-gui
Junio C Hamano [Fri, 9 May 2025 20:14:36 +0000 (13:14 -0700)] 
Merge branch 'master' of https://github.com/j6t/git-gui

* 'master' of https://github.com/j6t/git-gui:
  git-gui: treat the message template file as a built file
  git-gui: heed core.commentChar/commentString
  git-gui: po/README: update repository location and maintainer

3 months agoMerge branch 'js/po-update-workflow'
Johannes Sixt [Fri, 9 May 2025 17:16:41 +0000 (19:16 +0200)] 
Merge branch 'js/po-update-workflow'

* js/po-update-workflow:
  git-gui: treat the message template file as a built file
  git-gui: po/README: update repository location and maintainer

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
3 months agoMerge branch 'at/translation-tamil'
Johannes Sixt [Fri, 9 May 2025 16:01:02 +0000 (18:01 +0200)] 
Merge branch 'at/translation-tamil'

* at/translation-tamil:
  gitk: add Tamil translation

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
3 months agoThe twelfth batch
Junio C Hamano [Thu, 8 May 2025 18:12:02 +0000 (11:12 -0700)] 
The twelfth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agoMerge branch 'js/diff-codeql-false-positive-workaround'
Junio C Hamano [Thu, 8 May 2025 19:36:32 +0000 (12:36 -0700)] 
Merge branch 'js/diff-codeql-false-positive-workaround'

Work around false positive given by CodeQL.

* js/diff-codeql-false-positive-workaround:
  diff: check range before dereferencing an array element

3 months agoMerge branch 'ps/mv-contradiction-fix'
Junio C Hamano [Thu, 8 May 2025 19:36:31 +0000 (12:36 -0700)] 
Merge branch 'ps/mv-contradiction-fix'

"git mv a a/b dst" would ask to move the directory 'a' itself, as
well as its contents, in a single destination directory, which is
a contradicting request that is impossible to satisfy. This case is
now detected and the command errors out.

* ps/mv-contradiction-fix:
  builtin/mv: convert assert(3p) into `BUG()`
  builtin/mv: bail out when trying to move child and its parent

3 months agoMerge branch 'en/hashmap-clear-fix'
Junio C Hamano [Thu, 8 May 2025 19:36:31 +0000 (12:36 -0700)] 
Merge branch 'en/hashmap-clear-fix'

hashmap API clean-up to ensure hashmap_clear() leaves a cleared map
in a reusable state.

* en/hashmap-clear-fix:
  hashmap: ensure hashmaps are reusable after hashmap_clear()

3 months agogit-gui: treat the message template file as a built file
Johannes Sixt [Tue, 24 Dec 2024 13:47:08 +0000 (14:47 +0100)] 
git-gui: treat the message template file as a built file

Follow the lead of 5377abc0c9d5 ("po/git.pot: don't check in result
of "make pot"", 2022-05-26) in the Git repository and do not track
git-gui.pot anymore.

Instead, translators are expected to integrate an up-to-date version
from the master branch into their translation file using

   make ALL_POFILES=po/xx.po update-po

Update README to describe the new process. It is now understood that
different translations need not be based on the same message template
file, but rather individual translators should base their translation
on the most up-to-date code. Remove the section that addresses the
i18n coordinator as it does not apply when no common base is required
among translators.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
3 months agogitk: add Tamil translation
தமிழ் நேரம் [Wed, 7 May 2025 15:54:35 +0000 (21:24 +0530)] 
gitk: add Tamil translation

Signed-off-by: தமிழ் நேரம் <anishprabu.t@gmail.com>
3 months agoThe eleventh batch
Junio C Hamano [Mon, 5 May 2025 21:55:57 +0000 (14:55 -0700)] 
The eleventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agoMerge branch 'kn/meson-hdr-check'
Junio C Hamano [Mon, 5 May 2025 21:56:25 +0000 (14:56 -0700)] 
Merge branch 'kn/meson-hdr-check'

Add an equivalent to "make hdr-check" target to meson based builds.

* kn/meson-hdr-check:
  makefile/meson: add 'check-headers' as alias for 'hdr-check'
  meson: add support for 'hdr-check'
  meson: rename 'third_party_sources' to 'third_party_excludes'
  meson: move headers definition from 'contrib/coccinelle'
  coccinelle: meson: rename variables to be more specific
  ci/github: install git before checking out the repository

3 months agoMerge branch 'es/meson-cleanup'
Junio C Hamano [Mon, 5 May 2025 21:56:25 +0000 (14:56 -0700)] 
Merge branch 'es/meson-cleanup'

Code clean-up for meson-based build infrastructure.

* es/meson-cleanup:
  meson: only check for missing networking syms on non-Windows; add compat impls
  meson: fix typo in function check that prevented checking for hstrerror
  meson: add a couple missing networking dependencies
  meson: do a full usage-based compile check for sysinfo
  meson: check for getpagesize before using it
  meson: simplify and parameterize various standard function checks

3 months agoMerge branch 'ps/meson-build-perf-bench'
Junio C Hamano [Mon, 5 May 2025 21:56:24 +0000 (14:56 -0700)] 
Merge branch 'ps/meson-build-perf-bench'

The build procedure based on Meson learned to drive the
benchmarking tests.

* ps/meson-build-perf-bench:
  meson: wire up benchmarking options
  meson: wire up benchmarks
  t/perf: fix benchmarks with out-of-tree builds
  t/perf: use configured PERL_PATH
  t/perf: fix benchmarks with alternate repo formats

3 months agoMerge branch 'js/windows-arm64'
Junio C Hamano [Mon, 5 May 2025 21:56:24 +0000 (14:56 -0700)] 
Merge branch 'js/windows-arm64'

Update to arm64 Windows port.

* js/windows-arm64:
  max_tree_depth: lower it for clangarm64 on Windows
  mingw(arm64): do move the `/etc/git*` location
  msvc: do handle builds on Windows/ARM64
  mingw: do not use nedmalloc on Windows/ARM64
  config.mak.uname: add support for clangarm64
  bswap.h: add support for built-in bswap functions

3 months agobuiltin/mv: convert assert(3p) into `BUG()`
Patrick Steinhardt [Wed, 30 Apr 2025 12:44:58 +0000 (14:44 +0200)] 
builtin/mv: convert assert(3p) into `BUG()`

The use of asserts is discouraged in our codebase because they lead to
different behaviour depending on how Git is built. When being unsure
enough whether a condition always holds so that one adds the assert,
then the assert should probably trigger regardless of how Git is being
built.

Drop the call to assert(3p) in git-mv(1) and instead use `BUG()`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agobuiltin/mv: bail out when trying to move child and its parent
Patrick Steinhardt [Wed, 30 Apr 2025 12:44:57 +0000 (14:44 +0200)] 
builtin/mv: bail out when trying to move child and its parent

We have a known issue in git-mv(1) where moving both a child and any of
its parents causes an assert to trigger because the child cannot be
found anymore in the index. We have added a test for this in commit
0fcd473fdd3 (t7001: add failure test which triggers assertion,
2024-10-22) without addressing the issue, which is why the test itself
is marked as `test_expect_failure`.

The behaviour of that test relies on a call to assert(3p) though, which
may or may not be compiled into the resulting binary depending on
whether or not we pass `-DNDEBUG`. When these asserts are compiled into
Git this may cause our CI to hang on Windows though, because asserts may
cause a modal window to be shown.

While we could work around the issue by converting this into a call to
`BUG()`, let's rather address the root cause of the issue by bailing out
in case we see that both a child and any of its parents are being moved
in the same command.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agoThe tenth batch
Junio C Hamano [Tue, 29 Apr 2025 21:07:22 +0000 (14:07 -0700)] 
The tenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agoMerge branch 'ps/ci-resurrect-p4-on-github'
Junio C Hamano [Tue, 29 Apr 2025 21:21:33 +0000 (14:21 -0700)] 
Merge branch 'ps/ci-resurrect-p4-on-github'

CI fix.

* ps/ci-resurrect-p4-on-github:
  ci: fix p4d executable not being found on GitHub Actions

3 months agoMerge branch 'ps/install-bash-completion'
Junio C Hamano [Tue, 29 Apr 2025 21:21:32 +0000 (14:21 -0700)] 
Merge branch 'ps/install-bash-completion'

Build update to install bash (but not zsh) completion script.

* ps/install-bash-completion:
  contrib/completion: install Bash completion

3 months agoMerge branch 'jk/p5332-testfix'
Junio C Hamano [Tue, 29 Apr 2025 21:21:32 +0000 (14:21 -0700)] 
Merge branch 'jk/p5332-testfix'

A test fix.

* jk/p5332-testfix:
  p5332: drop "+" from --stdin-packs input

3 months agoMerge branch 'lo/remove-log-reencode-from-rev-info'
Junio C Hamano [Tue, 29 Apr 2025 21:21:31 +0000 (14:21 -0700)] 
Merge branch 'lo/remove-log-reencode-from-rev-info'

Code clean-up.

* lo/remove-log-reencode-from-rev-info:
  revision: remove log_reencode field from rev_info

3 months agoMerge branch 'ps/fewer-perl'
Junio C Hamano [Tue, 29 Apr 2025 21:21:30 +0000 (14:21 -0700)] 
Merge branch 'ps/fewer-perl'

Reduce requirement for Perl in our documentation build and a few
scripts.

* ps/fewer-perl:
  Documentation: stop depending on Perl to generate command list
  Documentation: stop depending on Perl to massage user manual
  request-pull: stop depending on Perl
  filter-branch: stop depending on Perl

3 months agoMerge branch 'ps/reftable-api-revamp'
Junio C Hamano [Tue, 29 Apr 2025 21:21:29 +0000 (14:21 -0700)] 
Merge branch 'ps/reftable-api-revamp'

Overhaul of the reftable API.

* ps/reftable-api-revamp:
  reftable/table: move printing logic into test helper
  reftable/constants: make block types part of the public interface
  reftable/table: introduce iterator for table blocks
  reftable/table: add `reftable_table` to the public interface
  reftable/block: expose a generic iterator over reftable records
  reftable/block: make block iterators reseekable
  reftable/block: store block pointer in the block iterator
  reftable/block: create public interface for reading blocks
  git-zlib: use `struct z_stream_s` instead of typedef
  reftable/block: rename `block_reader` to `reftable_block`
  reftable/block: rename `block` to `block_data`
  reftable/table: move reading block into block reader
  reftable/block: simplify how we track restart points
  reftable/blocksource: consolidate code into a single file
  reftable/reader: rename data structure to "table"
  reftable: fix formatting of the license header

3 months agoMerge branch 'jh/gc-launchctl-schedule-fix'
Junio C Hamano [Tue, 29 Apr 2025 21:21:28 +0000 (14:21 -0700)] 
Merge branch 'jh/gc-launchctl-schedule-fix'

Fix for scheduled maintenance tasks on platforms using launchctl.

* jh/gc-launchctl-schedule-fix:
  maintenance: fix launchctl calendar intervals

3 months agoMerge branch 'az/tighten-string-array-constness'
Junio C Hamano [Tue, 29 Apr 2025 21:21:28 +0000 (14:21 -0700)] 
Merge branch 'az/tighten-string-array-constness'

Code clean-up.

* az/tighten-string-array-constness:
  global: mark usage strings and string tables const

3 months agoMerge branch 'as/typofix-in-env-h-header'
Junio C Hamano [Tue, 29 Apr 2025 21:21:27 +0000 (14:21 -0700)] 
Merge branch 'as/typofix-in-env-h-header'

Typofix.

* as/typofix-in-env-h-header:
  environment: fix typo: 'setup_git_directory_gently'

3 months agoMerge branch 'ua/call-repo-config-with-possibly-null-repository'
Junio C Hamano [Tue, 29 Apr 2025 21:21:27 +0000 (14:21 -0700)] 
Merge branch 'ua/call-repo-config-with-possibly-null-repository'

Since a call to repo_config() can be called with repo set to NULL
these days, a command that is marked as RUN_SETUP in the builtin
command table does not have to check repo with NULL before making
the call.

* ua/call-repo-config-with-possibly-null-repository:
  builtin/difftool: remove unnecessary if statement
  builtin/add: remove unnecessary if statement

3 months agoMerge branch 'js/git-perf-env-override'
Junio C Hamano [Tue, 29 Apr 2025 21:21:26 +0000 (14:21 -0700)] 
Merge branch 'js/git-perf-env-override'

Developer support fix..

* js/git-perf-env-override:
  perf: do allow `GIT_PERF_*` to be overridden again

3 months agodiff: check range before dereferencing an array element
Johannes Schindelin [Tue, 29 Apr 2025 11:37:58 +0000 (11:37 +0000)] 
diff: check range before dereferencing an array element

Before accessing an array element at a given index, it should be
verified that the index is within the desired bounds, not afterwards,
otherwise it may not make sense to even access the array element in the
first place. This is the point of CodeQL's
`cpp/offset-use-before-range-check` rule.

This CodeQL rule unfortunately is also triggered by the
`fill_es_indent_data()` code, even though the condition `off < len - 1`
does not even need to guarantee that the offset is in bounds (`s` points
to a NUL-terminated string, for which `s[off] == '\r'` would fail before
running out of bounds).

Let's work around this rare false positive to help us use an otherwise
mostly useful tool is a worthy thing to do.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agohashmap: ensure hashmaps are reusable after hashmap_clear()
Elijah Newren [Tue, 29 Apr 2025 15:47:43 +0000 (15:47 +0000)] 
hashmap: ensure hashmaps are reusable after hashmap_clear()

In the series merged at bf0a430f70b5 (Merge branch 'en/strmap',
2020-11-21), strmap was built on top of hashmap and hashmap was extended
in a few ways to support strmap and be more generally useful.  One of
the extensions was that hashmap_partial_clear() was introduced to allow
reuse of the hashmap without freeing the table.  Peff believed that it
also made sense to introduce a hashmap_clear() which freed everything
while allowing reuse.

I added hashmap_clear(), but in doing so, overlooked the fact that for
a hashmap to be reusable, it needs a defined cmpfn and data (the
HASHMAP_INIT macro requires these fields as parameters, for example).
So, if we want the hashmap to be reusable, we shouldn't zero out those
fields.  We probably also shouldn't zero out do_count_items.  (We could
zero out grow_at and shrink_at, but whether we zero those or not is
irrelevant as they'll be automatically updated whenever a new entry is
inserted.)

Since clearing is associated with freeing map->table, and the only thing
required for consistency after freeing map->table is zeroing tablesize
and private_size, let's only zero those fields out.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agomeson: wire up benchmarking options
Patrick Steinhardt [Mon, 28 Apr 2025 07:30:50 +0000 (09:30 +0200)] 
meson: wire up benchmarking options

Wire up a couple of benchmarking options that we end up writing into our
"GIT-BUILD-OPTIONS" file. These options allow users to control how
exactly benchmarks are executed.

Note that neither `GIT_PERF_MAKE_COMMAND` nor `GIT_PERF_MAKE_OPTS` are
exposed as a build option. Those options are used by "t/perf/run", which
is not used by Meson.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agomeson: wire up benchmarks
Patrick Steinhardt [Mon, 28 Apr 2025 07:30:49 +0000 (09:30 +0200)] 
meson: wire up benchmarks

Wire up benchmarks in Meson. The setup is mostly the same as how we wire
up our tests. The only difference is that benchmarks get wired up via
the `benchmark()` option instead of via `test()`, which gives them a bit
of special treatment:

  - Benchmarks never run in parallel.

  - Benchmarks aren't run by default when tests are executed.

  - Meson does not inject the `MALLOC_PERTURB` environment variable.

Using benchmarks is quite simple:

    ```
    $ meson setup build
    # Run all benchmarks.
    $ meson test -C build --benchmark
    # Run a specific benchmark.
    $ meson test -C build --benchmark p0000-*
    ```

Other than that the usual command line arguments accepted when running
tests are also accepted when running benchmarks.

Note that the benchmarking target is somewhat limited because it will
only run benchmarks for the current build. Other use cases, like running
benchmarks against multiple different versions of Git, are not currently
supported. Users should continue to use "t/perf/run" for those use
cases. The script should get extended at one point in time to support
Meson, but this is outside of the scope of this series.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agot/perf: fix benchmarks with out-of-tree builds
Patrick Steinhardt [Mon, 28 Apr 2025 07:30:48 +0000 (09:30 +0200)] 
t/perf: fix benchmarks with out-of-tree builds

The "perf-lib.sh" script is sourced by all of our benchmarking suites to
make available common infrastructure. The script assumes that build and
source directory are the same, which works for our Makefile. But the
assumption breaks with both CMake and Meson, where the build directory
can be located in an arbitrary place.

Adapt the script so that it works with out-of-tree builds. Most
importantly, this requires us to figure out the location of the build
directory:

  - When running benchmarks via our Makefile the build directory is the
    same as the source directory. We already know to derive the test
    directory ("t/") via `$(pwd)/..`, which works because we chdir into
    "t/perf" before executing benchmarks. We can thus derive the build
    directory by appending another "/.." to that path.

  - When running benchmarks via Meson the build directory is located at
    an arbitrary location. The build system thus has to make the path
    known by exporting the `GIT_BUILD_DIR` environment variable.

This change prepares us for wiring up benchmarks in Meson.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agot/perf: use configured PERL_PATH
Patrick Steinhardt [Mon, 28 Apr 2025 07:30:47 +0000 (09:30 +0200)] 
t/perf: use configured PERL_PATH

Our benchmarks use a couple of Perl scripts to compute results. These
Perl scripts get executed directly, and as the shebang is hardcoded to
"/usr/bin/perl" this will fail on any system where the Perl interpreter
is located in a different path.

Our build infrastructure already lets users configure the location of
Perl, which ultimately gets written into the GIT-BUILD-OPTIONS file.
This file is being sourced by "test-lib.sh", and consequently we already
have the "PERL_PATH" variable available that contains its configured
location.

Use "PERL_PATH" to execute Perl scripts, which makes them work on more
esoteric systems like NixOS. Furthermore, adapt the shebang to use
env(1) to execute Perl so that users who have Perl in PATH, but in a
non-standard location can execute the script directly.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agot/perf: fix benchmarks with alternate repo formats
Patrick Steinhardt [Mon, 28 Apr 2025 07:30:46 +0000 (09:30 +0200)] 
t/perf: fix benchmarks with alternate repo formats

Many of our benchmarks operate on a user-defined repository that we copy
over before running the benchmarked logic. To keep unintentional side
effects caused by on-disk state at bay we skip copying some files. This
includes for example hooks, but also the repo's configuration.

It is quite sensible to not copy over the configuration, as it is quite
easy to inadvertently carry over configuration that may significantly
impact the performance measurements. But we cannot fully ignore the
configuration either, as it may contain information about the repository
format. This will cause failures when for example using a repository
with SHA256 object format or the reftable ref format.

Fix the issue by parsing the reference and object formats from the
source repository and passing them to git-init(1).

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agomeson: only check for missing networking syms on non-Windows; add compat impls
Eli Schwartz [Fri, 25 Apr 2025 05:25:45 +0000 (01:25 -0400)] 
meson: only check for missing networking syms on non-Windows; add compat impls

These are added in the Makefile, but not in meson. They probably won't
work well on systems without them.

CMake adds them, but only on non-Windows. Actually, it only performs
compiler checks for hstrerror, but excludes that check on Windows with
the note that it is "incompatible with the Windows build". This seems to
be misleading -- it is not incompatible, it simply doesn't exist. Still,
the compat version should not be used.

I interpret this cmake logic to mean we shouldn't even be checking for
symbol availability on Windows. In addition to making it simple to add
compat definitions, this also probably shaves off a second or two of
configure time on Windows as no compiler check needs to be performed.

Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agomeson: fix typo in function check that prevented checking for hstrerror
Eli Schwartz [Fri, 25 Apr 2025 05:25:44 +0000 (01:25 -0400)] 
meson: fix typo in function check that prevented checking for hstrerror

Nowhere in the codebase do we otherwise check for strerror. Nowhere in
the codebase do we make use of -DNO_STRERROR. `strerror` is not a
networking function at all.

We do utilize `hstrerror` though, which is a networking function we
should have been checking here.

Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agomeson: add a couple missing networking dependencies
Eli Schwartz [Fri, 25 Apr 2025 05:25:43 +0000 (01:25 -0400)] 
meson: add a couple missing networking dependencies

As evidenced in config.mak.uname and configure.ac, there are various
possible scenarios where these libraries are default-enabled in the
build, which mainly boils down to: SunOS. -lresolv is simply not the
only library that, when it exists, probably needs to be linked to for
networking.

Check for and add -lnsl -lsocket as well.

Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agomeson: do a full usage-based compile check for sysinfo
Eli Schwartz [Fri, 25 Apr 2025 05:25:42 +0000 (01:25 -0400)] 
meson: do a full usage-based compile check for sysinfo

On Solaris, sys/sysinfo.h is a completely different file and doesn't
resemble the linux file at all. There is also a sysinfo() function, but
it takes a totally different call signature, which asks for:

- the field you wish to receive
- a `char *buf` to copy the data to

and is very useful IFF you want to know, say, the hardware provider. Or,
get *specific* fields from uname(2).

https://docs.oracle.com/cd/E86824_01/html/E54765/sysinfo-2.html

It is surely possible to do this manually via `sysconf(3)` without the
nice API. I can't find anything more direct. Either way, I'm not very
attached to Solaris, so someone who cares can add it. Either way, it's
wrong to assume that sysinfo.h contains what we are looking for.

Check that sysinfo.h defines the struct we actually utilize in
builtins/gc.c, which will correctly fail on systems that don't have it.

Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agomeson: check for getpagesize before using it
Eli Schwartz [Fri, 25 Apr 2025 05:25:41 +0000 (01:25 -0400)] 
meson: check for getpagesize before using it

It is deprecated and removed in SUS v3 / POSIX 2001, so various systems
may not include it. Solaris, in particular, carefully refrains from
defining it except inside of a maze of `#ifdef` to make sure you have
kept your nose clean and only used it in code that *targets* SUS v2 or
earlier.

config.mak.uname defines this automatically, though only for QNX.

Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agomeson: simplify and parameterize various standard function checks
Eli Schwartz [Fri, 25 Apr 2025 05:25:40 +0000 (01:25 -0400)] 
meson: simplify and parameterize various standard function checks

This is repetitive logic. We either want to use some -lc function, or if
it is not available we define it as -DNO_XXX and usually (but not
always) provide some custom compatibility impl instead.

Checking the intent of each block when reading through the file is slow
and not very DRY. Switch to taking an array of checkable functions
instead.

Not all functions are straightforward to move, since different macro
prefixes are used.

Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agoThe ninth batch
Junio C Hamano [Fri, 25 Apr 2025 00:27:03 +0000 (17:27 -0700)] 
The ninth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agoSync with 'maint'
Junio C Hamano [Fri, 25 Apr 2025 00:26:33 +0000 (17:26 -0700)] 
Sync with 'maint'

3 months agoMerge branch 'rj/build-tweaks'
Junio C Hamano [Fri, 25 Apr 2025 00:25:34 +0000 (17:25 -0700)] 
Merge branch 'rj/build-tweaks'

Various build tweaks, including CSPRNG selection on some platforms.

* rj/build-tweaks:
  config.mak.uname: set CSPRNG_METHOD to getrandom on Linux
  config.mak.uname: add arc4random to the cygwin build
  config.mak.uname: add sysinfo() configuration for cygwin
  builtin/gc.c: correct RAM calculation when using sysinfo
  config.mak.uname: add clock_gettime() to the cygwin build
  config.mak.uname: add HAVE_GETDELIM to the cygwin section
  config.mak.uname: only set NO_REGEX on cygwin for v1.7
  config.mak.uname: add a note about NO_STRLCPY for Linux
  Makefile: remove NEEDS_LIBRT build variable
  meson.build: set default help format to html on windows
  meson.build: only set build variables for non-default values
  Makefile: only set some BASIC_CFLAGS when RUNTIME_PREFIX is set
  meson.build: remove -DCURL_DISABLE_TYPECHECK

3 months agoMerge branch 'ps/parse-options-integers'
Junio C Hamano [Fri, 25 Apr 2025 00:25:33 +0000 (17:25 -0700)] 
Merge branch 'ps/parse-options-integers'

Update parse-options API to catch mistakes to pass address of an
integral variable of a wrong type/size.

* ps/parse-options-integers:
  parse-options: detect mismatches in integer signedness
  parse-options: introduce precision handling for `OPTION_UNSIGNED`
  parse-options: introduce precision handling for `OPTION_INTEGER`
  parse-options: rename `OPT_MAGNITUDE()` to `OPT_UNSIGNED()`
  parse-options: support unit factors in `OPT_INTEGER()`
  global: use designated initializers for options
  parse: fix off-by-one for minimum signed values

3 months agoMerge branch 'ds/doc-disable-hooks'
Junio C Hamano [Fri, 25 Apr 2025 00:25:33 +0000 (17:25 -0700)] 
Merge branch 'ds/doc-disable-hooks'

Document the convention to disable hooks altogether by setting the
hooksPath configuration variable to /dev/nulll

* ds/doc-disable-hooks:
  docs: document core.hooksPath=/dev/null

3 months agoMerge branch 'ps/object-file-cleanup'
Junio C Hamano [Fri, 25 Apr 2025 00:25:33 +0000 (17:25 -0700)] 
Merge branch 'ps/object-file-cleanup'

Code clean-up.

* ps/object-file-cleanup:
  object-store: merge "object-store-ll.h" and "object-store.h"
  object-store: remove global array of cached objects
  object: split out functions relating to object store subsystem
  object-file: drop `index_blob_stream()`
  object-file: split up concerns of `HASH_*` flags
  object-file: split out functions relating to object store subsystem
  object-file: move `xmmap()` into "wrapper.c"
  object-file: move `git_open_cloexec()` to "compat/open.c"
  object-file: move `safe_create_leading_directories()` into "path.c"
  object-file: move `mkdir_in_gitdir()` into "path.c"

3 months agoMerge branch 'aw/t9811-modernize'
Junio C Hamano [Fri, 25 Apr 2025 00:25:32 +0000 (17:25 -0700)] 
Merge branch 'aw/t9811-modernize'

Test updates.

* aw/t9811-modernize:
  t9811: fix misconversion of tests
  t9811: be more precise to check importing of tags

3 months agoMerge branch 'jc/ci-skip-unavailable-external-software'
Junio C Hamano [Fri, 25 Apr 2025 00:25:31 +0000 (17:25 -0700)] 
Merge branch 'jc/ci-skip-unavailable-external-software'

Make sure outage of third-party sites that supply P4, Git-LFS, and
JGit we use for testing would not prevent our CI jobs from running
at all.

* jc/ci-skip-unavailable-external-software:
  ci: skip unavailable external software

3 months agoCI updates
Junio C Hamano [Fri, 25 Apr 2025 00:14:14 +0000 (17:14 -0700)] 
CI updates

Ever since we issued 2.49, external forces broke our CI jobs in
various ways, and we had to adjust our code to work them around.
Backmerge them from the 'master' front to make it easier to test
real changes to the maintenance track.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agoMerge branch 'jc/ci-skip-unavailable-external-software' into maint-2.49
Junio C Hamano [Fri, 25 Apr 2025 00:13:31 +0000 (17:13 -0700)] 
Merge branch 'jc/ci-skip-unavailable-external-software' into maint-2.49

Make sure outage of third-party sites that supply P4, Git-LFS, and
JGit we use for testing would not prevent our CI jobs from running
at all.

* jc/ci-skip-unavailable-external-software:
  ci: skip unavailable external software

3 months agoMerge branch 'js/ci-fedora-gawk' into maint-2.49
Junio C Hamano [Fri, 25 Apr 2025 00:13:30 +0000 (17:13 -0700)] 
Merge branch 'js/ci-fedora-gawk' into maint-2.49

Work around CI breakage due to fedora base image getting updated.

* js/ci-fedora-gawk:
  ci(pedantic): ensure that awk is installed

3 months agoMerge branch 'js/ci-github-update-ubuntu' into maint-2.49
Junio C Hamano [Fri, 25 Apr 2025 00:13:30 +0000 (17:13 -0700)] 
Merge branch 'js/ci-github-update-ubuntu' into maint-2.49

Adjust to the deprecation of use of Ubuntu 20.04 GitHub Actions CI.

* js/ci-github-update-ubuntu:
  ci: upgrade `sparse` to supported build agents

3 months agoMerge branch 'dd/sparse-glibc-workaround' into maint-2.49
Junio C Hamano [Fri, 25 Apr 2025 00:13:29 +0000 (17:13 -0700)] 
Merge branch 'dd/sparse-glibc-workaround' into maint-2.49

Squelch false-positive from sparse.

* dd/sparse-glibc-workaround:
  sparse: ignore warning from new glibc headers

3 months agoci: skip unavailable external software
Junio C Hamano [Thu, 24 Apr 2025 23:10:47 +0000 (16:10 -0700)] 
ci: skip unavailable external software

The ci/install-dependencies.sh script used in a very early phase of
our CI jobs downloads Perforce, Git-LFS, and JGit, used for running
the test scripts.  The test framework is prepared to properly skip
the tests that depend on these external software, but the CI script
is unnecessarily strict (due to its use of "set -e" in ci/lib.sh)
and fails the entire CI run before even starting to test the rest of
the system.

Notice a failure to download to any of these external software, but
keep going.  We need to be careful about cleaning after a failed
wget, as a later part of the script that does:

        if type jgit >/dev/null 2>&1
        then
                echo "$(tput setaf 6)JGit Version$(tput sgr0)"
                jgit version
        else
                echo >&2 "WARNING: JGit wasn't installed, see above for clues why"
        fi

will (surprise!) succeed running "type jgit", and then fail with
"jgit version", taking the whole thing down due to "set -e".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agoThe eighth batch
Junio C Hamano [Wed, 23 Apr 2025 20:08:58 +0000 (13:08 -0700)] 
The eighth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agoMerge branch 'mh/left-right-limited'
Junio C Hamano [Wed, 23 Apr 2025 20:58:51 +0000 (13:58 -0700)] 
Merge branch 'mh/left-right-limited'

"git log --{left,right}-only A...B", when A and B does not share
any common ancestor, now behaves as expected.

* mh/left-right-limited:
  revision: fix --left/right-only use with unrelated histories

3 months agoMerge branch 'js/range-check-codeql-workaround'
Junio C Hamano [Wed, 23 Apr 2025 20:58:51 +0000 (13:58 -0700)] 
Merge branch 'js/range-check-codeql-workaround'

Work around false positive from CodeQL checker.

* js/range-check-codeql-workaround:
  read-cache: check range before dereferencing an array element

3 months agoMerge branch 'ja/doc-reset-mv-rm-markup-updates'
Junio C Hamano [Wed, 23 Apr 2025 20:58:50 +0000 (13:58 -0700)] 
Merge branch 'ja/doc-reset-mv-rm-markup-updates'

Doc mark-up updates.

* ja/doc-reset-mv-rm-markup-updates:
  doc: add markup for characters in Guidelines
  doc: fix asciidoctor synopsis processing of triple-dots
  doc: convert git-mv to new documentation format
  doc: move synopsis git-mv commands in the synopsis section
  doc: convert git-rm to new documentation format
  doc: fix synopsis analysis logic
  doc: convert git-reset to new documentation format

3 months agoMerge branch 'kn/bundle-dedup-optim'
Junio C Hamano [Wed, 23 Apr 2025 20:58:50 +0000 (13:58 -0700)] 
Merge branch 'kn/bundle-dedup-optim'

Optimize the code to dedup references recorded in a bundle file.

* kn/bundle-dedup-optim:
  bundle: fix non-linear performance scaling with refs
  t6020: test for duplicate refnames in bundle creation

3 months agoMerge branch 'pb/perf-test-fixes'
Junio C Hamano [Wed, 23 Apr 2025 20:58:50 +0000 (13:58 -0700)] 
Merge branch 'pb/perf-test-fixes'

"make perf" fixes.

* pb/perf-test-fixes:
  p7821: fix instructions for testing with threads
  p9210: fix 'scalar clone' when running from a detached HEAD
  p7821: fix test_perf invocation for prereqs

3 months agomaintenance: fix launchctl calendar intervals
Josh Heinrichs [Mon, 21 Apr 2025 05:46:33 +0000 (23:46 -0600)] 
maintenance: fix launchctl calendar intervals

When using the launchctl scheduler, the weekly job runs daily, and the
daily job runs on the first six days of each month. This appears to be
due to specifying "Day" in the calendar intervals, which according to
launchd.plist(5) is for specifying days of the month rather than days of
the week. The behaviour of running a job on the 0th day is undocumented,
but in my testing appears to be the same as not specifying "Day" in the
calendar interval, in which case the job will run daily.

Use "Weekday" in the calendar intervals, which is the correct way to
schedule jobs to run on specific days of the week.

Signed-off-by: Josh Heinrichs <joshiheinrichs@gmail.com>
Acked-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agomakefile/meson: add 'check-headers' as alias for 'hdr-check'
Karthik Nayak [Wed, 23 Apr 2025 08:15:39 +0000 (10:15 +0200)] 
makefile/meson: add 'check-headers' as alias for 'hdr-check'

The 'hdr-check' target in Meson and makefile is used to check if headers
can be compiled individually. The naming however isn't readable as 'hdr'
is not a common shortforme for 'header', neither is it an abbreviation.

Let's introduce 'check-headers' as an alternative target for 'hdr-check'
and add a `TODO` to deprecate the latter after 2 releases. Since this
is an internal tool, we can use a shorter deprecation cycle.

Change existing usage of 'hdr-check' in 'ci/run-static-analysis.sh' to
also use 'check-headers'.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agomeson: add support for 'hdr-check'
Karthik Nayak [Wed, 23 Apr 2025 08:15:38 +0000 (10:15 +0200)] 
meson: add support for 'hdr-check'

The Makefile supports a target called 'hdr-check', which checks if
individual header files can be independently compiled. Let's port this
functionality to Meson, our new build system too. The implementation
resembles that of the Makefile and provides the same check.

Since meson builds are out-of-tree, header dependencies are not
automatically met. So unlike the Makefile version, we also need to add
the required dependencies.

Also add the 'xdiff/' dir to the list of 'third_party_sources' as those
headers must be skipped from the checks too. This also skips the folder
from the 'coccinelle' checks, this is okay, since this code is an
external dependency.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agomeson: rename 'third_party_sources' to 'third_party_excludes'
Karthik Nayak [Wed, 23 Apr 2025 08:15:37 +0000 (10:15 +0200)] 
meson: rename 'third_party_sources' to 'third_party_excludes'

The 'third_party_sources' variable was moved to the root 'meson.build'
file in the previous commit. The variable is actually used to exclude
third party sources, so rename it accordingly to 'third_party_excludes'
to avoid confusion. While here, remove a duplicate from the list.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agomeson: move headers definition from 'contrib/coccinelle'
Karthik Nayak [Wed, 23 Apr 2025 08:15:36 +0000 (10:15 +0200)] 
meson: move headers definition from 'contrib/coccinelle'

The Meson build for coccinelle static analysis lists all headers to
analyse. Due to the way Meson exports variables between subdirs, this
variable is also available in the root Meson build.

An upcoming commit, will add a new check complimenting 'hdr-check' in
the Makefile. This would require the list of headers. So move the
'coccinelle_headers' to the root Meson build and rename it to 'headers',
remove the root path being appended to each header and retain that in
the coccinelle Meson build since it is specific to the coccinelle build.

Also move the 'third_party_sources' variable to the root Meson build
since it is also a dependency for the 'headers' variable. This also
makes it easier to understand as the variable is now propagated from the
top level to the bottom.

While 'headers_to_check' is only computed when we have a repository and
the 'git' executable is present, the variable itself is exposed as an
empty array. This allows dependencies in upcoming commits to simply
check for length of the array and not worry about dependencies required
to actually populate the array.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agococcinelle: meson: rename variables to be more specific
Karthik Nayak [Wed, 23 Apr 2025 08:15:35 +0000 (10:15 +0200)] 
coccinelle: meson: rename variables to be more specific

In Meson, included subdirs export their variables to top level Meson
builds. In 'contrib/coccinelle/meson.build', we define two such
variables `sources` and `headers`. While these variables are specific to
the checks in the 'contrib/coccinelle/' directory, they also pollute the
top level 'meson.build'.

Rename them to be more specific, this ensures that they aren't
mistakenly used in the upper levels and avoid variable name collisions.

While here, change the empty list denotation to be consistent with other
places.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agoci/github: install git before checking out the repository
Karthik Nayak [Wed, 23 Apr 2025 08:15:34 +0000 (10:15 +0200)] 
ci/github: install git before checking out the repository

The GitHub's CI workflow uses 'actions/checkout@v4' to checkout the
repository. This action defaults to using the GitHub REST API to obtain
the repository if the `git` executable isn't available.

The step to build Git in the GitHub workflow can be summarized as:

  ...
  - uses: actions/checkout@v4 #1
  - run: ci/install-dependencies.sh #2
  ...
  - run: sudo --preserve-env --set-home --user=builder ci/run-build-and-tests.sh #3
  ...

Step #1, clones the repository, since the `git` executable isn't present
at this step, it uses GitHub's REST API to obtain a tar of the
repository.

Step #2, installs all dependencies, which includes the `git` executable.

Step #3, sets up the build, which includes setting up meson in the meson
job. At this point the `git` executable is present.

This means while the `git` executable is present, the repository doesn't
contain the '.git' folder. To keep both the CI's (GitLab and GitHub)
behavior consistent and to ensure that the build is performed on a
real-world scenario, install `git` before the repository is checked out.
This ensures that 'actions/checkout@v4' will clone the repository
instead of using a tarball. We also update the package cache while
installing `git`, this is because some distros will fail to locate the
package without updating the cache.

Helped-by: Phillip Wood <phillip.wood123@gmail.com>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agomax_tree_depth: lower it for clangarm64 on Windows
Johannes Schindelin [Wed, 23 Apr 2025 08:01:48 +0000 (08:01 +0000)] 
max_tree_depth: lower it for clangarm64 on Windows

Just as in b64d78ad02ca (max_tree_depth: lower it for MSVC to avoid
stack overflows, 2023-11-01), I encountered the same problem with the
clang builds on Windows/ARM64.

The symptom is an exit code 127 when t6700 tries to verify that `git
archive big` fails.

This exit code is reserved on Unix/Linux to mean "command not found".
Unfortunately in this case, it is the fall-back chosen by
Cygwin's `pinfo::status_exit()` method when encountering
the NSTATUS `STATUS_STACK_OVERFLOW`, see
https://github.com/cygwin/cygwin/blob/cygwin-3.6.1/winsup/cygwin/pinfo.cc#L171

I verified manually that the stack overflow always happens somewhere
around tree depth 1403, therefore 1280 should be a safe bound in these
instances.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agomingw(arm64): do move the `/etc/git*` location
Johannes Schindelin [Wed, 23 Apr 2025 08:01:47 +0000 (08:01 +0000)] 
mingw(arm64): do move the `/etc/git*` location

In fb5e3378f8 (mingw: move Git for Windows' system config where users
expect it, 2021-06-22), I moved the location of Git for Windows' system
config and system Git attributes file to the top-level `/etc/` directory
(because it is a much more obvious location than, say, `/mingw64/etc/`).

The patch relied on a very specific scenario that the newly-supported
Windows/ARM64 builds of `git.exe` fails to fall into. So let's broaden
the condition a bit, so that Windows/ARM64 builds also use that location
(instead of the even more obscure `/clangarm64/etc/` directory).

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agomsvc: do handle builds on Windows/ARM64
Johannes Schindelin [Wed, 23 Apr 2025 08:01:46 +0000 (08:01 +0000)] 
msvc: do handle builds on Windows/ARM64

Git for Windows/ARM64 settled on using `clang` to compile `git.exe`, and
hence needs to run in a system where `MSYSTEM` is set to `CLANGARM64`
and the prefix to use is `/clangarm64`.

We already did that in the `MINGW` arm, i.e. for regular Git for Windows
builds using MINGW GCC (or `clang`'s shim pretending to be GCC), now it
is time to do the same in the MS Visual C part.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
[jc: adjust config.mak.uname for c18400c6]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agomingw: do not use nedmalloc on Windows/ARM64
Johannes Schindelin [Wed, 23 Apr 2025 08:01:45 +0000 (08:01 +0000)] 
mingw: do not use nedmalloc on Windows/ARM64

It does not compile there, and seeing as nedmalloc has been pretty much
unmaintained since at least November 2017, as per
https://github.com/ned14/nedmalloc/issues/20#issuecomment-343432314,
there is also no hope that any fixes will materialize there.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
[jc: adjust config.mak.uname for c18400c6]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agoconfig.mak.uname: add support for clangarm64
Dennis Ameling [Wed, 23 Apr 2025 08:01:44 +0000 (08:01 +0000)] 
config.mak.uname: add support for clangarm64

CLANGARM64 is a relatively new MSYSTEM added by the MSYS2 team. In order
to have Git build correctly for this platform, let's add some
configuration for it to config.mak.uname.

Signed-off-by: Dennis Ameling <dennis@dennisameling.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agobswap.h: add support for built-in bswap functions
Dennis Ameling [Wed, 23 Apr 2025 08:01:43 +0000 (08:01 +0000)] 
bswap.h: add support for built-in bswap functions

Newer compiler versions, like GCC 10 and Clang 12, have built-in
functions for bswap32 and bswap64. This comes in handy, for example,
when targeting CLANGARM64 on Windows, which would not be supported
without this logic.

Signed-off-by: Dennis Ameling <dennis@dennisameling.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agorevision: remove log_reencode field from rev_info
Lucas Seiki Oshiro [Tue, 22 Apr 2025 21:31:34 +0000 (18:31 -0300)] 
revision: remove log_reencode field from rev_info

Remove the log_reencode field from struct rev-info, as it is not used.
This field was introduced in 52883fb, but it hasn't been used since its
introduction.

Helped-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agop5332: drop "+" from --stdin-packs input
Jeff King [Tue, 22 Apr 2025 11:16:32 +0000 (07:16 -0400)] 
p5332: drop "+" from --stdin-packs input

This perf script creates a midx by running "git multi-pack-index write"
with the "--stdin-packs" option. We feed that stdin by running "find" on
.git/objects/pack, using sed to strip off everything but the basename.

But that sed invocation also does something peculiar: it adds a "+" to
the start of each pack name. This causes the multi-pack-index command to
barf. The modified name does not match any pack it knows about, so it
ends up with an empty list of packs to put in the midx. And thus nothing
matches the --preferred-pack option we pass, which causes it die().

The fix is to remove the extra "+" (which also lets us simplify the sed
invocation a bit, as it is now just stripping the leading directories).

But that leaves the mystery of why it was ever there in the first place.
The answer is that an earlier iteration of the patch series had a
concept of "disjoint" packs in the midx. And one of its patches here:

  https://lore.kernel.org/git/c52d7e7b27a9add4f58b8334db4fe4498af1c90f.1701198172.git.me@ttaylorr.com/

taught read_packs_from_stdin() to treat a leading "+" as marking a
disjoint pack. But in the second version of the series, which was
ultimately merged, that disjoint concept went away, and the code to
parse "+" did likewise. The regular regression tests were adjusted to
match, but this case in t/perf was forgotten.

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agocontrib/completion: install Bash completion
Patrick Steinhardt [Tue, 22 Apr 2025 08:36:11 +0000 (10:36 +0200)] 
contrib/completion: install Bash completion

The shell completion scripts in "contrib/completion" are being tested,
but none of our build systems support installing them. This is somewhat
confusing for Meson, where users can explicitly enable building these
scripts via `-Dcontrib=completion`. This option only controlls whether
the completions are built and tested against, where "building" is a bit
of an euphemism for "copying them into the build directory".

Teach both our Makefile and Meson to install our Bash completion script.
For now, this is the only completion script that we're installing given
that Bash completions "just work" with a canonical well-known location
nowadays. Other completion scripts, like for example the one for zsh,
don't have a well-known location and/or require extra steps by the user
to make them available. As such, we skip installing these scripts for
now, but we may do so in the future if we ever figure out a proper way
to do this.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agoci: fix p4d executable not being found on GitHub Actions
Patrick Steinhardt [Tue, 22 Apr 2025 05:47:27 +0000 (07:47 +0200)] 
ci: fix p4d executable not being found on GitHub Actions

Our tests for git-p4(1) depend on the p4d(1) and p4(1) executables to
exist. As we require specific versions of those binaries which typically
aren't available on common distributions, we install them manually via
"ci/install-dependencies.sh".

This script will put the binaries into "$CUSTOM_PATH", which gets
defined by "ci/lib.sh" -- if not explicitly overridden, its value will
be set to "$HOME/path". This causes issues though when running our tests
as unprivileged user, as we do both in GitLab CI and GitHub Actions,
because "$HOME" will be different when installing dependencies and when
running the tests. Consequently, the downloaded binaries will not be
found unless "$CUSTOM_PATH" is overridden to a common location.

We already do this for GitLab CI, where it points to "/custom". Let's do
the same for GitHub Actions so that Perforce-based tests are executed
again.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agoglobal: mark usage strings and string tables const
Ahelenia Ziemiańska [Mon, 21 Apr 2025 08:56:13 +0000 (10:56 +0200)] 
global: mark usage strings and string tables const

Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agobuiltin/difftool: remove unnecessary if statement
Usman Akinyemi [Sun, 20 Apr 2025 02:54:33 +0000 (08:24 +0530)] 
builtin/difftool: remove unnecessary if statement

Since we already teach the `repo_config()` in "f29f1990b5
(config: teach repo_config to allow `repo` to be NULL, 2025-03-08)"
to allow `repo` to be NULL, no need to check if `repo` is NULL
before calling `repo_config()`.

Suggested-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agobuiltin/add: remove unnecessary if statement
Usman Akinyemi [Sun, 20 Apr 2025 02:54:32 +0000 (08:24 +0530)] 
builtin/add: remove unnecessary if statement

Since we already teach the `repo_config()` in "f29f1990b5
(config: teach repo_config to allow `repo` to be NULL, 2025-03-08)"
to allow `repo` to be NULL, no need to check if `repo` is NULL
before calling `repo_config()`.

Suggested-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agoperf: do allow `GIT_PERF_*` to be overridden again
Johannes Schindelin [Fri, 4 Apr 2025 10:56:07 +0000 (10:56 +0000)] 
perf: do allow `GIT_PERF_*` to be overridden again

A common way to run Git's performance benchmarks on repositories other
than Git's own repository (which is not exactly large when compared to
actually large repositories) is to run them like this:

GIT_PERF_LARGE_REPO=/path/to/my/large/repo \
./p1234-*.sh -ivx

Contrary to developers' common expectations, this failed to work when
Git was built with a different `GIT_PERF_LARGE_REPO` value specified at
build time: That build-time option would have been written to the
`GIT-BUILD-OPTIONS` file, which in turn would have been sourced by
`test-lib.sh`, which in turn would have been sourced by `perf-lib.sh`,
which in turn would have been sourced by the perf test script,
_overriding_ the environment variable specified in the way illustrated
above.

Since perf tests are not run as part of the build, this most likely
unintended behavior was not caught and certainly not fixed, as the
`GIT_PERF_*` values would have been empty at build-time.

However, in 4638e8806e3a (Makefile: use common template for
GIT-BUILD-OPTIONS, 2024-12-06), a subtle change of behavior was
introduced: Whereas before, a couple of build-time options (the
`GIT_PERF_*` ones included) were written to `GIT-BUILD-OPTIONS` only
when their values were non-empty. With this commit, they are also
written when they are empty.

The consequence is that above-mentioned way to run the perf tests will
not only fail to pick up the desired `GIT_PERF_*` settings when they
were specified differently while building Git, instead the desired
settings will be only respected when specified _while building_ Git.

Let's work around the original issue, i.e. let `GIT_PERF_*` environment
variables override what is recorded in `GIT-BUILD-OPTIONS`.

Note that this is just the tip of the iceberg, there are a couple of
`GIT_TEST_*` options that may want a similar fix in `test-lib.sh`. Due
to time constraints on my side, this here patch focuses exclusively on
the `GIT_PERF_*` settings.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agoMerge branch 'ob/strip-comments-on-commit'
Johannes Sixt [Sun, 20 Apr 2025 07:27:22 +0000 (09:27 +0200)] 
Merge branch 'ob/strip-comments-on-commit'

* ob/strip-comments-on-commit:
  git-gui: heed core.commentChar/commentString

3 months agot9811: fix misconversion of tests
Junio C Hamano [Fri, 18 Apr 2025 17:54:59 +0000 (10:54 -0700)] 
t9811: fix misconversion of tests

The previous commit started to insist TAG_F1_ONLY to be missing,
which was not in the original.  Let's not be overly eager in the
conversion.

Also, the other hunk in the commit introduced a shell syntax error,
causing the test to fail.  Fix it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agoenvironment: fix typo: 'setup_git_directory_gently'
Abhijeet Sonar [Fri, 18 Apr 2025 18:58:48 +0000 (00:28 +0530)] 
environment: fix typo: 'setup_git_directory_gently'

Above the declaration of git_work_tree_cfg, we have:

  /* This is set by setup_git_dir_gently() and/or git_default_config() */
  char *git_work_tree_cfg;

It can be verified that there is no function called
'setup_git_dir_gently' by running grep on the codebase:

  $ grep -R setup_git_dir_gently .
  ./environment.c:/* This is set by setup_git_dir_gently() and/or git_default_config() */

The comment, introduced in e90fdc39b6 (Clean up work-tree handling), is
the only occurrence of the name 'setup_git_dir_gently'.

It probably meant 'setup_git_directory_gently' as that is a name of a
real function in setup.c. Correct it.

Signed-off-by: Abhijeet Sonar <abhijeet.nkt@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agoconfig.mak.uname: set CSPRNG_METHOD to getrandom on Linux
Ramsay Jones [Wed, 16 Apr 2025 23:18:34 +0000 (00:18 +0100)] 
config.mak.uname: set CSPRNG_METHOD to getrandom on Linux

Commit 05cd988dce ("wrapper: add a helper to generate numbers from a
CSPRNG", 2022-01-17) added a csprng_bytes() function which used one
of several interfaces to provide a source of cryptographically secure
pseudorandom numbers. The CSPRNG_METHOD make variable was provided to
determine the choice of available 'backends' for the source of random
bytes.

Commit 05cd988dce did not set CSPRNG_METHOD in the Linux section of
the config.mak.uname file, so it defaults to using '/dev/urandom' as
the source of random bytes. The 'backend' values which could be used
on Linux are 'arc4random', 'getrandom' or 'getentropy' ('openssl' is
an option, but seems to be discouraged).

The arc4random routines (arc4random_buf() is the one actually used) were
added to glibc in version 2.36, while both getrandom() and getentropy()
were included in 2.25. So, some of the more up-to-date distributions of
Linux (eg Debian 12, Ubuntu 24.04) would be able to use the 'arc4random'
setting. All currently supported distributions have glibc 2.25 or later
(RHEL 8 has v2.28) and, therefore, have support for the 'getrandom' and
'getentropy' settings.

The arc4random routines on the *BSDs (along with cygwin) implement the
ChaCha20 stream cipher algorithm (see RFC8439) in userspace, rather than
as a system call, and are thus somewhat faster (having avoided a context
switch to the kernel). In contrast, on Linux all three functions are
simple wrappers around the same kernel CSPRNG syscall.

If the meson build system is used on a newer platform, then they will be
configured to use 'arc4random', whereas the make build will currently
default to using '/dev/urandom' on Linux. Since there is no advantage,
in terms of performance, to the 'arc4random' setting, the 'getrandom'
setting should be preferred from an availability perspective. (Also, the
current uses of csprng_bytes() are not in any hot path).

In order to set an appropriate default, set the CSPRNG_METHOD build
variable to 'getrandom' in the Linux section of the 'config.mak.uname'
file.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agoThe seventh batch
Junio C Hamano [Thu, 17 Apr 2025 15:55:34 +0000 (08:55 -0700)] 
The seventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agoMerge branch 'ab/environment-clean-header'
Junio C Hamano [Thu, 17 Apr 2025 17:28:20 +0000 (10:28 -0700)] 
Merge branch 'ab/environment-clean-header'

Code clean-up.

* ab/environment-clean-header:
  environment.h: remove unused variables

3 months agoMerge branch 'ps/refname-avail-check-optim'
Junio C Hamano [Thu, 17 Apr 2025 17:28:19 +0000 (10:28 -0700)] 
Merge branch 'ps/refname-avail-check-optim'

Incorrect sorting of refs with bytes with high-bit set on platforms
with signed char led to a BUG, which has been corrected.

* ps/refname-avail-check-optim:
  refs/packed: fix BUG when seeking refs with UTF-8 characters

3 months agoMerge branch 'cj/refname-avail-check-optim-typofix'
Junio C Hamano [Thu, 17 Apr 2025 17:28:19 +0000 (10:28 -0700)] 
Merge branch 'cj/refname-avail-check-optim-typofix'

Comment fix.

* cj/refname-avail-check-optim-typofix:
  refs: fix duplicated word in comment

3 months agoMerge branch 'ua/update-update-server-info'
Junio C Hamano [Thu, 17 Apr 2025 17:28:18 +0000 (10:28 -0700)] 
Merge branch 'ua/update-update-server-info'

Code simplification.

* ua/update-update-server-info:
  builtin/update-server-info: remove unnecessary if statement

3 months agoMerge branch 'en/merge-recursive-debug'
Junio C Hamano [Thu, 17 Apr 2025 17:28:18 +0000 (10:28 -0700)] 
Merge branch 'en/merge-recursive-debug'

Remove remnants of the recursive merge strategy backend, which was
superseded by the ort merge strategy.

* en/merge-recursive-debug:
  builtin/{merge,rebase,revert}: remove GIT_TEST_MERGE_ALGORITHM
  tests: remove GIT_TEST_MERGE_ALGORITHM and test_expect_merge_algorithm
  merge-recursive.[ch]: thoroughly debug these
  merge, sequencer: switch recursive merges over to ort
  sequencer: switch non-recursive merges over to ort
  merge-ort: enable diff-algorithms other than histogram
  builtin/merge-recursive: switch to using merge_ort_generic()
  checkout: replace merge_trees() with merge_ort_nonrecursive()

3 months agoMerge branch 'kn/blame-porcelain-unblamable'
Junio C Hamano [Thu, 17 Apr 2025 17:28:17 +0000 (10:28 -0700)] 
Merge branch 'kn/blame-porcelain-unblamable'

"git blame --porcelain" mode now talks about unblamable lines and
lines that are blamed to an ignored commit.

* kn/blame-porcelain-unblamable:
  blame: print unblamable and ignored commits in porcelain mode

3 months agoMerge branch 'jk/fetch-follow-remote-head-fix'
Junio C Hamano [Thu, 17 Apr 2025 17:28:17 +0000 (10:28 -0700)] 
Merge branch 'jk/fetch-follow-remote-head-fix'

"git fetch [<remote>]" with only the configured fetch refspec
should be the only thing to update refs/remotes/<remote>/HEAD,
but the code was overly eager to do so in other cases.

* jk/fetch-follow-remote-head-fix:
  fetch: make set_head() call easier to read
  fetch: don't ask for remote HEAD if followRemoteHEAD is "never"
  fetch: only respect followRemoteHEAD with configured refspecs

3 months agoparse-options: detect mismatches in integer signedness
Patrick Steinhardt [Thu, 17 Apr 2025 10:49:42 +0000 (12:49 +0200)] 
parse-options: detect mismatches in integer signedness

It was reported that "t5620-backfill.sh" fails on s390x and sparc64 in a
test that exercises the "--min-batch-size" command line option. The
symptom was that the option didn't seem to have an effect: we didn't
fetch objects with a batch size of 20, but instead fetched all objects
at once.

As it turns out, the root cause is that `--min-batch-size` uses
`OPT_INTEGER()` to parse the command line option. While this macro
expects the caller to pass a pointer to an integer, we instead pass a
pointer to a `size_t`. This coincidentally works on most platforms, but
it breaks apart on the mentioned platforms because they are big endian.

This issue isn't specific to git-backfill(1): there are a couple of
other places where we have the same type confusion going on. This
indicates that the issue really is the interface that the parse-options
subsystem provides -- it is simply too easy to get this wrong as there
isn't any kind of compiler warning, and things just work on the most
common systems.

Address the systemic issue by introducing two new build asserts
`BARF_UNLESS_SIGNED()` and `BARF_UNLESS_UNSIGNED()`. As the names
already hint at, those macros will cause a compiler error when passed a
value that is not signed or unsigned, respectively.

Adapt `OPT_INTEGER()`, `OPT_UNSIGNED()` as well as `OPT_MAGNITUDE()` to
use those asserts. This uncovers a small set of sites where we indeed
have the same bug as in git-backfill(1). Adapt all of them to use the
correct option.

Reported-by: Todd Zullinger <tmz@pobox.com>
Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Helped-by: SZEDER Gábor <szeder.dev@gmail.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agoparse-options: introduce precision handling for `OPTION_UNSIGNED`
Patrick Steinhardt [Thu, 17 Apr 2025 10:49:41 +0000 (12:49 +0200)] 
parse-options: introduce precision handling for `OPTION_UNSIGNED`

This commit is the equivalent to the preceding commit, but instead of
introducing precision handling for `OPTION_INTEGER` we introduce it for
`OPTION_UNSIGNED`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agoparse-options: introduce precision handling for `OPTION_INTEGER`
Patrick Steinhardt [Thu, 17 Apr 2025 10:49:40 +0000 (12:49 +0200)] 
parse-options: introduce precision handling for `OPTION_INTEGER`

The `OPTION_INTEGER` option type accepts a signed integer. The type of
the underlying integer is a simple `int`, which restricts the range of
values accepted by such options. But there is a catch: because the
caller provides a pointer to the value via the `.value` field, which is
a simple void pointer. This has two consequences:

  - There is no check whether the passed value is sufficiently long to
    store the entire range of `int`. This can lead to integer wraparound
    in the best case and out-of-bounds writes in the worst case.

  - Even when a caller knows that they want to store a value larger than
    `INT_MAX` they don't have a way to do so.

In practice this doesn't tend to be a huge issue because users typically
don't end up passing huge values to most commands. But the parsing logic
is demonstrably broken, and it is too easy to get the calling convention
wrong.

Improve the situation by introducing a new `precision` field into the
structure. This field gets assigned automatically by `OPT_INTEGER_F()`
and tracks the size of the passed value. Like this it becomes possible
for the caller to pass arbitrarily-sized integers and the underlying
logic knows to handle it correctly by doing range checks. Furthermore,
convert the code to use `strtoimax()` intstead of `strtol()` so that we
can also parse values larger than `LONG_MAX`.

Note that we do not yet assert signedness of the passed variable, which
is another source of bugs. This will be handled in a subsequent commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agoparse-options: rename `OPT_MAGNITUDE()` to `OPT_UNSIGNED()`
Patrick Steinhardt [Thu, 17 Apr 2025 10:49:39 +0000 (12:49 +0200)] 
parse-options: rename `OPT_MAGNITUDE()` to `OPT_UNSIGNED()`

With the preceding commit, `OPT_INTEGER()` has learned to support unit
factors. Consequently, the major differencen between `OPT_INTEGER()` and
`OPT_MAGNITUDE()` isn't the support of unit factors anymore, as both of
them do support them now. Instead, the difference is that one handles
signed and the other handles unsigned integers.

Adapt the name of `OPT_MAGNITUDE()` accordingly by renaming it to
`OPT_UNSIGNED()`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>