]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
2 months agoMerge branch 'ps/build-tweaks' into next
Junio C Hamano [Fri, 20 Mar 2026 21:49:12 +0000 (14:49 -0700)] 
Merge branch 'ps/build-tweaks' into next

Tweak the build infrastructure by moving tools around.

* ps/build-tweaks:
  meson: precompile "git-compat-util.h"
  meson: compile compatibility sources separately
  git-compat-util.h: move warning infra to prepare for PCHs
  builds: move build scripts into "tools/"
  contrib: move "update-unicode.sh" script into "tools/"
  contrib: move "coverage-diff.sh" script into "tools/"
  contrib: move "coccinelle/" directory into "tools/"
  Introduce new "tools/" directory

2 months agoMerge branch 'jk/diff-highlight-identical-pairs' into next
Junio C Hamano [Fri, 20 Mar 2026 21:49:12 +0000 (14:49 -0700)] 
Merge branch 'jk/diff-highlight-identical-pairs' into next

The handling of the incomplete lines at the end by "git
diff-highlight" has been fixed.

* jk/diff-highlight-identical-pairs:
  contrib/diff-highlight: do not highlight identical pairs

2 months agocontrib/diff-highlight: do not highlight identical pairs
Jeff King [Tue, 17 Mar 2026 23:02:23 +0000 (19:02 -0400)] 
contrib/diff-highlight: do not highlight identical pairs

We pair lines for highlighting based on their position in the hunk. So
we should never see two identical lines paired, like:

  -one
  -two
  +one
  +something else

which would pair -one/+one, because that implies that the diff could
easily be shrunk by turning line "one" into context.

But there is (at least) one exception: removing a newline at the end of
a file will produce a diff like:

  -foo
  +foo
  \No newline at end of file

And we will pair those two lines. As a result, we end up marking the
whole line, including the newline, as the shared prefix. And there's an
empty suffix.

The most obvious bug here is that when we try to print the highlighted
lines, we remove the trailing newline from the suffix, but do not bother
with the prefix (under the assumption that there had to be a difference
_somewhere_ in the line, and thus the prefix would not eat all the way
up to the newline). And so you get an extra line like:

  -foo

  +foo

  \No newline at end of file

This is obviously ugly, but also causes interactive.diffFilter to
(rightly) complain that the input and output do not match their lines
1-to-1.

This could easily be fixed by chomping the prefix, too, but I think the
problem is deeper. For one, I suspect some of the other logic gets
confused by forming an array with zero-indexed element "3" in a
3-element array. But more importantly, we try not to highlight whole
lines, as there's nothing interesting to show there. So let's catch this
early in is_pair_interesting() and bail to our usual passthrough
strategy.

Reported-by: Scott Baker <scott@perturb.org>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoSync with 'master'
Junio C Hamano [Thu, 19 Mar 2026 17:11:54 +0000 (10:11 -0700)] 
Sync with 'master'

2 months agoThe 18th batch
Junio C Hamano [Thu, 19 Mar 2026 16:54:41 +0000 (09:54 -0700)] 
The 18th batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoMerge branch 'ss/submodule--helper-use-xmalloc'
Junio C Hamano [Thu, 19 Mar 2026 16:54:56 +0000 (09:54 -0700)] 
Merge branch 'ss/submodule--helper-use-xmalloc'

Code clean-up.

* ss/submodule--helper-use-xmalloc:
  submodule--helper: replace malloc with xmalloc

2 months agoMerge branch 'ps/unit-test-c-escape-names.txt'
Junio C Hamano [Thu, 19 Mar 2026 16:54:56 +0000 (09:54 -0700)] 
Merge branch 'ps/unit-test-c-escape-names.txt'

The unit test helper function was taught to use backslash +
mnemonic notation for certain control characters like "\t", instead
of octal notation like "\011".

* ps/unit-test-c-escape-names.txt:
  test-lib: print escape sequence names

2 months agoMerge branch 'jc/doc-wholesale-replace-before-next'
Junio C Hamano [Thu, 19 Mar 2026 16:54:56 +0000 (09:54 -0700)] 
Merge branch 'jc/doc-wholesale-replace-before-next'

Doc update.

* jc/doc-wholesale-replace-before-next:
  SubmittingPatches: spell out "replace fully to pretend to be perfect"

2 months agoMerge branch 'lc/rebase-trailer'
Junio C Hamano [Thu, 19 Mar 2026 16:54:56 +0000 (09:54 -0700)] 
Merge branch 'lc/rebase-trailer'

"git rebase" learns "--trailer" command to drive the
interpret-trailers machinery.

* lc/rebase-trailer:
  rebase: support --trailer
  commit, tag: parse --trailer with OPT_STRVEC
  trailer: append trailers without fork/exec
  trailer: libify a couple of functions
  interpret-trailers: refactor create_in_place_tempfile()
  interpret-trailers: factor trailer rewriting

2 months agoMerge branch 'bk/run-command-wo-the-repository'
Junio C Hamano [Thu, 19 Mar 2026 16:54:55 +0000 (09:54 -0700)] 
Merge branch 'bk/run-command-wo-the-repository'

The run_command() API lost its implicit dependencyon the singleton
`the_repository` instance.

* bk/run-command-wo-the-repository:
  run-command: wean auto_maintenance() functions off the_repository
  run-command: wean start_command() off the_repository

2 months agoMerge branch 'ps/editorconfig-unanchor'
Junio C Hamano [Thu, 19 Mar 2026 16:54:55 +0000 (09:54 -0700)] 
Merge branch 'ps/editorconfig-unanchor'

Editorconfig filename patterns were specified incorrectly, making
many source files inside subdirectories unaffected, which has been
corrected.

* ps/editorconfig-unanchor:
  editorconfig: fix style not applying to subdirs anymore

2 months agoMerge branch 'ss/t3200-test-zero-oid'
Junio C Hamano [Thu, 19 Mar 2026 16:54:55 +0000 (09:54 -0700)] 
Merge branch 'ss/t3200-test-zero-oid'

A test now uses the symbolic constant $ZERO_OID instead of 40 "0" to
work better with SHA-256 as well as SHA-1.

* ss/t3200-test-zero-oid:
  t3200: replace hardcoded null OID with $ZERO_OID

2 months agoMerge branch 'dd/list-objects-filter-options-wo-strbuf-split'
Junio C Hamano [Thu, 19 Mar 2026 16:54:55 +0000 (09:54 -0700)] 
Merge branch 'dd/list-objects-filter-options-wo-strbuf-split'

The way combined list-object filter options are parsed has been
revamped.

* dd/list-objects-filter-options-wo-strbuf-split:
  list-objects-filter-options: avoid strbuf_split_str()
  worktree: do not pass strbuf by value

2 months agoMerge branch 'ps/t9200-test-path-is-helpers'
Junio C Hamano [Thu, 19 Mar 2026 16:54:54 +0000 (09:54 -0700)] 
Merge branch 'ps/t9200-test-path-is-helpers'

Test update.

* ps/t9200-test-path-is-helpers:
  t9200: replace test -f with modern path helper
  t9200: handle missing CVS with skip_all

2 months agomeson: precompile "git-compat-util.h"
Patrick Steinhardt [Thu, 19 Mar 2026 05:33:27 +0000 (06:33 +0100)] 
meson: precompile "git-compat-util.h"

Every compilation unit in Git is expected to include "git-compat-util.h"
first, either directly or indirectly via "builtin.h". This header papers
over differences between platforms so that we can expect the typical
POSIX functions to exist. Furthermore, it provides functionality that we
end up using everywhere.

This header is thus quite heavy as a consequence. Preprocessing it as a
standalone unit via `clang -E git-compat-util.h` yields over 23,000
lines of code overall. Naturally, it takes quite some time to compile
all of this.

Luckily, this is exactly the kind of use case that precompiled headers
aim to solve: instead of recompiling it every single time, we compile it
once and then link the result into the executable. If include guards are
set up properly it means that the file won't need to be reprocessed.

Set up such a precompiled header for "git-compat-util.h" and wire it up
via Meson. This causes Meson to implicitly include the precompiled
header in all compilation units. With GCC and Clang for example this is
done via the "-include" statement [1].

This leads to a significant speedup when performing full builds:

  Benchmark 1: ninja (rev = HEAD~)
  Time (mean ± σ):     14.467 s ±  0.126 s    [User: 248.133 s, System: 31.298 s]
  Range (min … max):   14.195 s … 14.633 s    10 runs

  Benchmark 2: ninja (rev = HEAD)
    Time (mean ± σ):     10.307 s ±  0.111 s    [User: 173.290 s, System: 23.998 s]
    Range (min … max):   10.030 s … 10.433 s    10 runs

  Summary
    ninja (rev = HEAD) ran
      1.40 ± 0.02 times faster than ninja (rev = HEAD~)

[1]: https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agomeson: compile compatibility sources separately
Patrick Steinhardt [Thu, 19 Mar 2026 05:33:26 +0000 (06:33 +0100)] 
meson: compile compatibility sources separately

In the next commit we're about to introduce a precompiled header for
"git-compat-util.h". The consequence of this change is that we'll
implicitly include that header for every compilation unit that uses the
precompiled headers.

This is okay for our "normal" library sources and our builtins. But some
of our compatibility sources do not include the header on purpose, and
doing so would cause compilation errors.

Prepare for this change by splitting out compatibility sources into
their static library. Like this, we can selectively enable precompiled
headers for the library sources.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agogit-compat-util.h: move warning infra to prepare for PCHs
Patrick Steinhardt [Thu, 19 Mar 2026 05:33:25 +0000 (06:33 +0100)] 
git-compat-util.h: move warning infra to prepare for PCHs

The "git-compat-util.h" header is supposed to be the first header
included by every code compilation unit. As such, a subsequent commit
will start to precompile this header to speed up compilation of Git.

This will cause an issue though with the way that we have set up the
"-Wsign-compare" warnings. It is expected that any compilation unit that
fails with that compiler warning sets `DISABLE_SIGN_COMPARE_WARNINGS`
before including "git-compat-util.h". If so, we'll disable the warning
right away via a compiler pragma.

But with precompiled headers we do not know ahead of time whether the
code unit wants to disable those warnings, and thus we'll have to
precompile the header without defining `DISABLE_SIGN_COMPARE_WARNINGS`.
But as the pragma statement is wrapped by our include guards, the second
include of that file will not have the desired effect of disabling the
warnings anymore.

We could fix this issue by declaring a new macro that compilation units
are expected to invoke after having included the file. In retrospect,
that would have been the better way to handle this as it allows for
more flexibility: we could for example toggle the warning for specific
code blocks, only. But changing this now would require a bunch of
changes, and the churn feels excessive for what we gain.

Instead, prepare for the precompiled headers by moving the code outside
of the include guards.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agobuilds: move build scripts into "tools/"
Patrick Steinhardt [Thu, 19 Mar 2026 05:33:24 +0000 (06:33 +0100)] 
builds: move build scripts into "tools/"

We have a bunch of scripts used by our different build systems that are
all located in the top-level directory. Now that we have introduced the
new "tools/" directory though we have a better home for them.

Move the scripts into the "tools/" directory.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agocontrib: move "update-unicode.sh" script into "tools/"
Patrick Steinhardt [Thu, 19 Mar 2026 05:33:23 +0000 (06:33 +0100)] 
contrib: move "update-unicode.sh" script into "tools/"

The "update-unicode.sh" script is used to update the unicode data
compiled into Git whenever a new version of the Unicode standard has
been released. As such, it is a natural part of our developer-facing
tooling, and its presence in "contrib/" is misleading.

Promote the script into the new "tools/" directory.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agocontrib: move "coverage-diff.sh" script into "tools/"
Patrick Steinhardt [Thu, 19 Mar 2026 05:33:22 +0000 (06:33 +0100)] 
contrib: move "coverage-diff.sh" script into "tools/"

The "coverage-diff.sh" script can be used to get information about test
coverage fro the Git codebase. It is thus rather specific to our build
and test infrastructure and part of the developer-facing tooling. The
fact that this script is part of "contrib/" is thus rather misleading
and a historic wart.

Promote the tool into the new "tools/" directory.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agocontrib: move "coccinelle/" directory into "tools/"
Patrick Steinhardt [Thu, 19 Mar 2026 05:33:21 +0000 (06:33 +0100)] 
contrib: move "coccinelle/" directory into "tools/"

The Coccinelle tool is an ingrained part of our build infrastructure. It
is executed by our CI to detect antipatterns and is used to detect
misuses of certain interfaces. It's presence in "contrib/" is thus
rather misleading.

Promote the configuration into the new "tools/" directory.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoIntroduce new "tools/" directory
Patrick Steinhardt [Thu, 19 Mar 2026 05:33:20 +0000 (06:33 +0100)] 
Introduce new "tools/" directory

According to its readme, the "contrib/" directory's main intent is to
collect stuff that is not an official part of Git, either because it is
too specialized or because it is still considered experimental. The
reality tells a bit of a different story though: while it _does_ contain
such things, it also contains other things:

  - Our credential helpers, which are being distributed by many
    packagers nowadays and which can be considered "stable".

  - A bunch of tooling that relates to our build and test
    infrastructure.

Especially the second category is somewhat of a sore spot. You really
wouldn't expect build-related tooling to be considered an optional part
of Git. Quite the opposite.

Create a new top-level "tools/" directory to fix this discrepancy. This
directory will contain all kind of tools that are related to our build
infrastructure and that Git developers are likely to use day to day.

For now, this directory doesn't contain anything yet except for a
readme and a Meson skeleton. This will change in subsequent commits.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoMerge branch 'dd/cocci-do-not-pass-strbuf-by-value' into next
Junio C Hamano [Wed, 18 Mar 2026 19:23:44 +0000 (12:23 -0700)] 
Merge branch 'dd/cocci-do-not-pass-strbuf-by-value' into next

Add a coccinelle rule to break the build when "struct strbuf" gets
passed by value.

* dd/cocci-do-not-pass-strbuf-by-value:
  stash: do not pass strbuf by value
  coccinelle: detect struct strbuf passed by value

2 months agoMerge branch 'ty/doc-diff-u-wo-number' into next
Junio C Hamano [Wed, 18 Mar 2026 19:23:44 +0000 (12:23 -0700)] 
Merge branch 'ty/doc-diff-u-wo-number' into next

"git diff -U<num>" was too lenient in its command line parsing and
took an empty string as a valid <num>.

* ty/doc-diff-u-wo-number:
  diff: document -U without <n> as using default context

2 months agoMerge branch 'ps/upload-pack-buffer-more-writes' into next
Junio C Hamano [Wed, 18 Mar 2026 19:23:43 +0000 (12:23 -0700)] 
Merge branch 'ps/upload-pack-buffer-more-writes' into next

Reduce system overhead "git upload-pack" spends on relaying "git
pack-objects" output to the "git fetch" running on the other end of
the connection.

* ps/upload-pack-buffer-more-writes:
  builtin/pack-objects: reduce lock contention when writing packfile data
  csum-file: drop `hashfd_throughput()`
  csum-file: introduce `hashfd_ext()`
  sideband: use writev(3p) to send pktlines
  wrapper: introduce writev(3p) wrappers
  compat/posix: introduce writev(3p) wrapper
  upload-pack: reduce lock contention when writing packfile data
  upload-pack: prefer flushing data over sending keepalive
  upload-pack: adapt keepalives based on buffering
  upload-pack: fix debug statement when flushing packfile data

2 months agoMerge branch 'tb/incremental-midx-part-3.2' into next
Junio C Hamano [Wed, 18 Mar 2026 19:23:43 +0000 (12:23 -0700)] 
Merge branch 'tb/incremental-midx-part-3.2' into next

Further work on incremental repacking using MIDX/bitmap

* tb/incremental-midx-part-3.2:
  midx: enable reachability bitmaps during MIDX compaction
  midx: implement MIDX compaction
  t/helper/test-read-midx.c: plug memory leak when selecting layer
  midx-write.c: factor fanout layering from `compute_sorted_entries()`
  midx-write.c: enumerate `pack_int_id` values directly
  midx-write.c: extract `fill_pack_from_midx()`
  midx-write.c: introduce `midx_pack_perm()` helper
  midx: do not require packs to be sorted in lexicographic order
  midx-write.c: introduce `struct write_midx_opts`
  midx-write.c: don't use `pack_perm` when assigning `bitmap_pos`
  t/t5319-multi-pack-index.sh: fix copy-and-paste error in t5319.39
  git-multi-pack-index(1): align SYNOPSIS with 'git multi-pack-index -h'
  git-multi-pack-index(1): remove non-existent incompatibility
  builtin/multi-pack-index.c: make '--progress' a common option
  midx: introduce `midx_get_checksum_hex()`
  midx: rename `get_midx_checksum()` to `midx_get_checksum_hash()`
  midx: mark `get_midx_checksum()` arguments as const

2 months agoMerge branch 'yc/histogram-hunk-shift-fix' into next
Junio C Hamano [Wed, 18 Mar 2026 19:23:43 +0000 (12:23 -0700)] 
Merge branch 'yc/histogram-hunk-shift-fix' into next

The final clean-up phase of the diff output could turn the result of
histogram diff algorithm suboptimal, which has been corrected.

* yc/histogram-hunk-shift-fix:
  xdiff: re-diff shifted change groups when using histogram algorithm

2 months agoMerge branch 'mf/t0008-cleanup' into next
Junio C Hamano [Tue, 17 Mar 2026 18:32:44 +0000 (11:32 -0700)] 
Merge branch 'mf/t0008-cleanup' into next

Test clean-up.

* mf/t0008-cleanup:
  t0008: improve test cleanup to fix failing test

2 months agoMerge branch 'pb/t4200-test-path-is-helpers' into next
Junio C Hamano [Tue, 17 Mar 2026 18:32:44 +0000 (11:32 -0700)] 
Merge branch 'pb/t4200-test-path-is-helpers' into next

Test clean-up.

* pb/t4200-test-path-is-helpers:
  t4200: convert test -[df] checks to test_path_* helpers

2 months agoMerge branch 'jk/transport-color-leakfix' into next
Junio C Hamano [Tue, 17 Mar 2026 18:32:44 +0000 (11:32 -0700)] 
Merge branch 'jk/transport-color-leakfix' into next

Leakfix.

* jk/transport-color-leakfix:
  transport: plug leaks in transport_color_config()

2 months agoMerge branch 'rj/pack-refs-tests-path-is-helpers' into next
Junio C Hamano [Tue, 17 Mar 2026 18:32:43 +0000 (11:32 -0700)] 
Merge branch 'rj/pack-refs-tests-path-is-helpers' into next

Test updates.

* rj/pack-refs-tests-path-is-helpers:
  t/pack-refs-tests: use test_path_is_missing

2 months agoMerge branch 'ps/clar-wo-path-max' into next
Junio C Hamano [Tue, 17 Mar 2026 18:32:43 +0000 (11:32 -0700)] 
Merge branch 'ps/clar-wo-path-max' into next

Clar (unit testing framework) update from the upstream.

* ps/clar-wo-path-max:
  clar: update to fix compilation on platforms without PATH_MAX

2 months agoMerge branch 'gj/user-manual-fix-grep-example' into next
Junio C Hamano [Tue, 17 Mar 2026 18:32:43 +0000 (11:32 -0700)] 
Merge branch 'gj/user-manual-fix-grep-example' into next

Fix an example in the user-manual.

* gj/user-manual-fix-grep-example:
  doc: fix git grep args order in Quick Reference

2 months agoMerge branch 'ps/history-split' into next
Junio C Hamano [Tue, 17 Mar 2026 18:32:42 +0000 (11:32 -0700)] 
Merge branch 'ps/history-split' into next

"git history" learned the "split" subcommand.

* ps/history-split:
  builtin/history: implement "split" subcommand
  builtin/history: split out extended function to create commits
  cache-tree: allow writing in-memory index as tree
  add-patch: allow disabling editing of hunks
  add-patch: add support for in-memory index patching
  add-patch: remove dependency on "add-interactive" subsystem
  add-patch: split out `struct interactive_options`
  add-patch: split out header from "add-interactive.h"

2 months agoMerge branch 'ss/t0410-delete-object-cleanup' into next
Junio C Hamano [Tue, 17 Mar 2026 18:32:42 +0000 (11:32 -0700)] 
Merge branch 'ss/t0410-delete-object-cleanup' into next

Test clean-up.

* ss/t0410-delete-object-cleanup:
  t0410: modernize delete_object helper

2 months agoMerge branch 'jt/fast-import-sign-again' into next
Junio C Hamano [Tue, 17 Mar 2026 18:32:42 +0000 (11:32 -0700)] 
Merge branch 'jt/fast-import-sign-again' into next

"git fast-import" learned to optionally replace signature on
commits whose signatures get invalidated due to replaying by
signing afresh.

* jt/fast-import-sign-again:
  fast-import: add mode to sign commits with invalid signatures
  gpg-interface: allow sign_buffer() to use default signing key
  commit: remove unused forward declaration

2 months agoMerge branch 'ps/object-counting' into next
Junio C Hamano [Tue, 17 Mar 2026 18:32:40 +0000 (11:32 -0700)] 
Merge branch 'ps/object-counting' into next

The logic to count objects has been cleaned up.

* ps/object-counting:
  odb: introduce generic object counting
  odb/source: introduce generic object counting
  object-file: generalize counting objects
  object-file: extract logic to approximate object count
  packfile: extract logic to count number of objects
  odb: stop including "odb/source.h"

2 months agotransport: plug leaks in transport_color_config()
Jeff King [Sat, 14 Mar 2026 16:08:14 +0000 (12:08 -0400)] 
transport: plug leaks in transport_color_config()

We retrieve config values with repo_config_get_string(), which will
allocate a new copy of the string for us. But we don't hold on to those
strings, since they are just fed to git_config_colorbool() and
color_parse(). But nor do we free them, which means they leak.

We can fix this by using the "_tmp" form of repo_config_get_string(),
which just hands us a pointer directly to the internal storage. This is
OK for our purposes, since we don't need it to last for longer than our
parsing calls.

Two interesting side notes here:

  1. Many types already have a repo_config_get_X() variant that handles
     this for us (e.g., repo_config_get_bool()). But neither colorbools
     nor colors themselves have such helpers. We might think about
     adding them, but converting all callers is a larger task, and out
     of scope for this fix.

  2. As far as I can tell, this leak has been there since 960786e761
     (push: colorize errors, 2018-04-21), but wasn't detected by LSan in
     our test suite. It started triggering when we applied dd3693eb08
     (transport-helper, connect: use clean_on_exit to reap children on
     abnormal exit, 2026-03-12) which is mostly unrelated.

     Even weirder, it seems to trigger only with clang (and not gcc),
     and only with GIT_TEST_DEFAULT_REF_FORMAT=reftable. So I think this
     is another odd case where the pointers happened to be hanging
     around in stack memory, but changing the pattern of function calls
     in nearby code was enough for them to be incidentally overwritten.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot4200: convert test -[df] checks to test_path_* helpers
PRASHANT S BISHT [Mon, 16 Mar 2026 17:24:57 +0000 (22:54 +0530)] 
t4200: convert test -[df] checks to test_path_* helpers

Replace old-style path existence checks in t4200-rerere.sh with
the appropriate test_path_* helper functions. These helpers provide
clearer diagnostic messages on failure than the raw shell test
builtin.

Signed-off-by: Prashant S Bisht <prashantjee2025@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot0008: improve test cleanup to fix failing test
Mirko Faina [Mon, 16 Mar 2026 01:15:42 +0000 (02:15 +0100)] 
t0008: improve test cleanup to fix failing test

The "large exclude file ignored in tree" test fails. This is due to an
additional warning message that is generated in the test. "warning:
unable to access 'subdir/.gitignore': Too many levels of symbolic
links", the extra warning that is not supposed to be there, happens
because of some leftover files left by previous tests.

To fix this we improve cleanup on "symlinks not respected in-tree", and
because the tests in t0008 in general have poor cleanup, at the start of
"large exclude file ignored in tree" we search for any leftover
.gitignore and remove them before starting the test.

Improve post-test cleanup and add pre-test cleanup to make sure that we
have a workable environment for the test.

Signed-off-by: Mirko Faina <mroik@delayed.space>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoSync with 'master'
Junio C Hamano [Mon, 16 Mar 2026 17:51:25 +0000 (10:51 -0700)] 
Sync with 'master'

2 months agoMerge branch 'ty/mktree-wo-the-repository' into next
Junio C Hamano [Mon, 16 Mar 2026 17:50:38 +0000 (10:50 -0700)] 
Merge branch 'ty/mktree-wo-the-repository' into next

Code clean-up.

* ty/mktree-wo-the-repository:
  builtin/mktree: remove USE_THE_REPOSITORY_VARIABLE

2 months agoMerge branch 'bb/imap-send-openssl-4.0-prep' into next
Junio C Hamano [Mon, 16 Mar 2026 17:50:38 +0000 (10:50 -0700)] 
Merge branch 'bb/imap-send-openssl-4.0-prep' into next

"imap-send" used to use functions whose use is going to be removed
with OpenSSL 4.0; rewrite them using public API that has been
available since OpenSSL 1.1 since 2016 or so.

* bb/imap-send-openssl-4.0-prep:
  imap-send: move common code into function host_matches()
  imap-send: use the OpenSSL API to access the subject common name
  imap-send: use the OpenSSL API to access the subject alternative names

2 months agoMerge branch 'ac/help-sort-correctly' into next
Junio C Hamano [Mon, 16 Mar 2026 17:50:38 +0000 (10:50 -0700)] 
Merge branch 'ac/help-sort-correctly' into next

The code in "git help" that shows configuration items in sorted
order was awkwardly organized and prone to bugs.

* ac/help-sort-correctly:
  help: cleanup the contruction of keys_uniq

2 months agoMerge branch 'jc/test-allow-sed-with-ere' into next
Junio C Hamano [Mon, 16 Mar 2026 17:50:37 +0000 (10:50 -0700)] 
Merge branch 'jc/test-allow-sed-with-ere' into next

Adjust test-lint to allow "sed -E" to use ERE in the patterns.

* jc/test-allow-sed-with-ere:
  t: allow use of "sed -E"

2 months agoMerge branch 'ng/submodule-default-remote' into next
Junio C Hamano [Mon, 16 Mar 2026 17:50:37 +0000 (10:50 -0700)] 
Merge branch 'ng/submodule-default-remote' into next

Instead of hardcoded 'origin', use the configured default remote
when fetching from submodules.

* ng/submodule-default-remote:
  submodule: fetch missing objects from default remote

2 months agoMerge branch 'ms/t7605-test-path-is-helpers' into next
Junio C Hamano [Mon, 16 Mar 2026 17:50:37 +0000 (10:50 -0700)] 
Merge branch 'ms/t7605-test-path-is-helpers' into next

Test updates.

* ms/t7605-test-path-is-helpers:
  t7605: use test_path_is_file instead of test -f

2 months agoThe 17th batch
Junio C Hamano [Mon, 16 Mar 2026 17:48:02 +0000 (10:48 -0700)] 
The 17th batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoMerge branch 'ty/patch-ids-document-lazy-eval'
Junio C Hamano [Mon, 16 Mar 2026 17:48:15 +0000 (10:48 -0700)] 
Merge branch 'ty/patch-ids-document-lazy-eval'

In-code comment update to record a design decision to allow lazy
computation of patch IDs.

* ty/patch-ids-document-lazy-eval:
  patch-ids: document intentional const-casting in patch_id_neq()

2 months agoMerge branch 'rs/history-ergonomics-updates-fix'
Junio C Hamano [Mon, 16 Mar 2026 17:48:15 +0000 (10:48 -0700)] 
Merge branch 'rs/history-ergonomics-updates-fix'

Fix use of uninitialized variable.

* rs/history-ergonomics-updates-fix:
  history: initialize rev_info in cmd_history_reword()

2 months agoMerge branch 'jk/unleak-mmap'
Junio C Hamano [Mon, 16 Mar 2026 17:48:15 +0000 (10:48 -0700)] 
Merge branch 'jk/unleak-mmap'

Plug a few leaks where mmap'ed memory regions are not unmapped.

* jk/unleak-mmap:
  meson: turn on NO_MMAP when building with LSan
  Makefile: turn on NO_MMAP when building with LSan
  object-file: fix mmap() leak in odb_source_loose_read_object_stream()
  pack-revindex: avoid double-loading .rev files
  check_connected(): fix leak of pack-index mmap
  check_connected(): delay opening new_pack

2 months agoMerge branch 'ty/setup-error-tightening'
Junio C Hamano [Mon, 16 Mar 2026 17:48:14 +0000 (10:48 -0700)] 
Merge branch 'ty/setup-error-tightening'

While discovering a ".git" directory, the code treats any stat()
failure as a sign that a filesystem entity .git does not exist
there, and ignores ".git" that is not a "gitdir" file or a
directory.  The code has been tightened to notice and report
filesystem corruption better.

* ty/setup-error-tightening:
  setup: improve error diagnosis for invalid .git files

2 months agoMerge branch 'os/doc-git-custom-commands'
Junio C Hamano [Mon, 16 Mar 2026 17:48:14 +0000 (10:48 -0700)] 
Merge branch 'os/doc-git-custom-commands'

Doc update.

* os/doc-git-custom-commands:
  doc: make it easier to find custom command information

2 months agoMerge branch 'fp/t3310-unhide-git-failures'
Junio C Hamano [Mon, 16 Mar 2026 17:48:14 +0000 (10:48 -0700)] 
Merge branch 'fp/t3310-unhide-git-failures'

The construct 'test "$(command)" = expectation' loses the exit
status from the command, which has been fixed by breaking up the
statement into pieces.

* fp/t3310-unhide-git-failures:
  t3310: avoid hiding failures from rev-parse in command substitutions

2 months agoMerge branch 'jt/repo-structure-extrema'
Junio C Hamano [Mon, 16 Mar 2026 17:48:14 +0000 (10:48 -0700)] 
Merge branch 'jt/repo-structure-extrema'

"git repo structure" command learns to report maximum values on
various aspects of objects it inspects.

* jt/repo-structure-extrema:
  builtin/repo: find tree with most entries
  builtin/repo: find commit with most parents
  builtin/repo: add OID annotations to table output
  builtin/repo: collect largest inflated objects
  builtin/repo: add helper for printing keyvalue output
  builtin/repo: update stats for each object

2 months agoMerge branch 'sp/wt-status-wo-the-repository'
Junio C Hamano [Mon, 16 Mar 2026 17:48:13 +0000 (10:48 -0700)] 
Merge branch 'sp/wt-status-wo-the-repository'

Reduce dependence on the global the_hash_algo and the_repository
variables of wt-status code path.

* sp/wt-status-wo-the-repository:
  wt-status: use hash_algo from local repository instead of global the_hash_algo
  wt-status: replace uses of the_repository with local repository instances
  wt-status: pass struct repository through function parameters

2 months agodoc: fix git grep args order in Quick Reference
Guillaume Jacob [Mon, 16 Mar 2026 14:15:36 +0000 (14:15 +0000)] 
doc: fix git grep args order in Quick Reference

The example provided has its arguments in the wrong order. The revision
should follow the pattern, and not the other way around.

Signed-off-by: Guillaume Jacob <guillaume@absolut-sensing.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoclar: update to fix compilation on platforms without PATH_MAX
Patrick Steinhardt [Mon, 16 Mar 2026 07:50:43 +0000 (08:50 +0100)] 
clar: update to fix compilation on platforms without PATH_MAX

Update clar to e4172e3 (Merge pull request #134 from
clar-test/ethomson/const, 2026-01-10). Besides some changes to
"generate.py" which don't have any impact on us, this commit also fixes
compilation on platforms that don't have PATH_MAX, like for example
GNU/Hurd.

Reported-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agostash: do not pass strbuf by value
Deveshi Dwivedi [Sun, 15 Mar 2026 09:44:44 +0000 (09:44 +0000)] 
stash: do not pass strbuf by value

save_untracked_files() takes its 'files' parameter as struct strbuf
by value.  Passing a strbuf by value copies the struct but shares
the underlying buffer between caller and callee, risking a dangling
pointer and double-free if the callee reallocates.

The function needs both the buffer and its length for
pipe_command(), so a plain const char * is not sufficient here.
Switch the parameter to struct strbuf * and update the caller to
pass a pointer.

Signed-off-by: Deveshi Dwivedi <deveshigurgaon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agococcinelle: detect struct strbuf passed by value
Deveshi Dwivedi [Sun, 15 Mar 2026 09:44:43 +0000 (09:44 +0000)] 
coccinelle: detect struct strbuf passed by value

Passing a struct strbuf by value to a function copies the struct
but shares the underlying character array between caller and callee.
If the callee causes a reallocation, the caller's copy becomes a
dangling pointer, leading to a double-free when strbuf_release() is
called.  There is no coccinelle rule to catch this pattern.

Jeff King suggested adding one during review of the
write_worktree_linking_files() fix [1], and noted that a reporting
rule using coccinelle's Python scripting extensions could emit a
descriptive warning, but we do not currently require Python support
in coccinelle.

Add a transformation rule that rewrites a by-value strbuf parameter
to a pointer.  The detection is identical to what a Python-based
reporting rule would catch; only the presentation differs.  The
resulting diff will not produce compilable code on its own (callers
and the function body still need updating), but the spatch output
alerts the developer that the signature needs attention.  This is
consistent with the other rules in strbuf.cocci, which also rewrite
to the preferred form.

[1] https://lore.kernel.org/git/20260309192600.GC309867@coredump.intra.peff.net/

Signed-off-by: Deveshi Dwivedi <deveshigurgaon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoMerge branch 'dd/list-objects-filter-options-wo-strbuf-split' into dd/cocci-do-not...
Junio C Hamano [Sun, 15 Mar 2026 21:46:30 +0000 (14:46 -0700)] 
Merge branch 'dd/list-objects-filter-options-wo-strbuf-split' into dd/cocci-do-not-pass-strbuf-by-value

* dd/list-objects-filter-options-wo-strbuf-split:
  list-objects-filter-options: avoid strbuf_split_str()
  worktree: do not pass strbuf by value

2 months agot/pack-refs-tests: use test_path_is_missing
Ritesh Singh Jadoun [Sun, 15 Mar 2026 08:10:32 +0000 (13:40 +0530)] 
t/pack-refs-tests: use test_path_is_missing

The pack-refs tests previously used raw 'test -f' and 'test -e' checks
with negation. Update them to use Git's standard helper function
test_path_is_missing for consistency and clearer failure reporting.

As suggested in review, replaced the negated 'test_path_exists' with
test_path_is_missing to better reflect the expected absence of paths.

Signed-off-by: Ritesh Singh Jadoun <riteshjd75@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoSync with 'master'
Junio C Hamano [Fri, 13 Mar 2026 20:34:29 +0000 (13:34 -0700)] 
Sync with 'master'

2 months agoMerge branch 'ss/submodule--helper-use-xmalloc' into next
Junio C Hamano [Fri, 13 Mar 2026 20:34:22 +0000 (13:34 -0700)] 
Merge branch 'ss/submodule--helper-use-xmalloc' into next

Code clean-up.

* ss/submodule--helper-use-xmalloc:
  submodule--helper: replace malloc with xmalloc

2 months agoMerge branch 'ps/unit-test-c-escape-names.txt' into next
Junio C Hamano [Fri, 13 Mar 2026 20:34:21 +0000 (13:34 -0700)] 
Merge branch 'ps/unit-test-c-escape-names.txt' into next

The unit test helper function was taught to use backslash +
mneomnic notation for certain control characters like "\t", instead
of octal notation like "\011".

* ps/unit-test-c-escape-names.txt:
  test-lib: print escape sequence names

2 months agoMerge branch 'jc/doc-wholesale-replace-before-next' into next
Junio C Hamano [Fri, 13 Mar 2026 20:34:21 +0000 (13:34 -0700)] 
Merge branch 'jc/doc-wholesale-replace-before-next' into next

Doc update.

* jc/doc-wholesale-replace-before-next:
  SubmittingPatches: spell out "replace fully to pretend to be perfect"

2 months agoMerge branch 'cf/constness-fixes' into next
Junio C Hamano [Fri, 13 Mar 2026 20:34:21 +0000 (13:34 -0700)] 
Merge branch 'cf/constness-fixes' into next

Small code clean-up around constness area.

* cf/constness-fixes:
  dir: avoid -Wdiscarded-qualifiers in remove_path()
  bloom: remove a misleading const qualifier

2 months agoMerge branch 'lc/rebase-trailer' into next
Junio C Hamano [Fri, 13 Mar 2026 20:34:21 +0000 (13:34 -0700)] 
Merge branch 'lc/rebase-trailer' into next

"git rebase" learns "--trailer" command to drive the
interpret-trailers machinery.

* lc/rebase-trailer:
  rebase: support --trailer
  commit, tag: parse --trailer with OPT_STRVEC
  trailer: append trailers without fork/exec
  trailer: libify a couple of functions
  interpret-trailers: refactor create_in_place_tempfile()
  interpret-trailers: factor trailer rewriting

2 months agoMerge branch 'jc/neuter-sideband-fixup' into next
Junio C Hamano [Fri, 13 Mar 2026 20:34:20 +0000 (13:34 -0700)] 
Merge branch 'jc/neuter-sideband-fixup' into next

Try to resurrect and reboot a stalled "avoid sending risky escape
sequences taken from sideband to the terminal" topic by Dscho.  The
plan is to keep it in 'next' long enough to see if anybody screams
with the "everything dropped except for ANSI color escape sequence"
default.

* jc/neuter-sideband-fixup:
  sideband: drop 'default' configuration
  sideband: offer to configure sanitizing on a per-URL basis
  sideband: add options to allow more control sequences to be passed through
  sideband: do allow ANSI color sequences by default
  sideband: introduce an "escape hatch" to allow control characters
  sideband: mask control characters

2 months agobuiltin/pack-objects: reduce lock contention when writing packfile data
Patrick Steinhardt [Fri, 13 Mar 2026 06:45:21 +0000 (07:45 +0100)] 
builtin/pack-objects: reduce lock contention when writing packfile data

When running `git pack-objects --stdout` we feed the data through
`hashfd_ext()` with a progress meter and a smaller-than-usual buffer
length of 8kB so that we can track throughput more granularly. But as
packfiles tend to be on the larger side, this small buffer size may
cause a ton of write(3p) syscalls.

Originally, the buffer we used in `hashfd()` was 8kB for all use cases.
This was changed though in 2ca245f8be (csum-file.h: increase hashfile
buffer size, 2021-05-18) because we noticed that the number of writes
can have an impact on performance. So the buffer size was increased to
128kB, which improved performance a bit for some use cases.

But the commit didn't touch the buffer size for `hashd_throughput()`.
The reasoning here was that callers expect the progress indicator to
update frequently, and a larger buffer size would of course reduce the
update frequency especially on slow networks.

While that is of course true, there was (and still is, even though it's
now a call to `hashfd_ext()`) only a single caller of this function in
git-pack-objects(1). This command is responsible for writing packfiles,
and those packfiles are often on the bigger side. So arguably:

  - The user won't care about increments of 8kB when packfiles tend to
    be megabytes or even gigabytes in size.

  - Reducing the number of syscalls would be even more valuable here
    than it would be for multi-pack indices, which was the benchmark
    done in the mentioned commit, as MIDXs are typically significantly
    smaller than packfiles.

  - Nowadays, many internet connections should be able to transfer data
    at a rate significantly higher than 8kB per second.

Update the buffer to instead have a size of `LARGE_PACKET_DATA_MAX - 1`,
which translates to ~64kB. This limit was chosen because `git
pack-objects --stdout` is most often used when sending packfiles via
git-upload-pack(1), where packfile data is chunked into pktlines when
using the sideband. Furthermore, most internet connections should have a
bandwidth signifcantly higher than 64kB/s, so we'd still be able to
observe progress updates at a rate of at least once per second.

This change significantly reduces the number of write(3p) syscalls from
355,000 to 44,000 when packing the Linux repository. While this results
in a small performance improvement on an otherwise-unused system, this
improvement is mostly negligible. More importantly though, it will
reduce lock contention in the kernel on an extremely busy system where
we have many processes writing data at once.

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agocsum-file: drop `hashfd_throughput()`
Patrick Steinhardt [Fri, 13 Mar 2026 06:45:20 +0000 (07:45 +0100)] 
csum-file: drop `hashfd_throughput()`

The `hashfd_throughput()` function is used by a single callsite in
git-pack-objects(1). In contrast to `hashfd()`, this function uses a
progress meter to measure throughput and a smaller buffer length so that
the progress meter can provide more granular metrics.

We're going to change that caller in the next commit to be a bit more
specific to packing objects. As such, `hashfd_throughput()` will be a
somewhat unfitting mechanism for any potential new callers.

Drop the function and replace it with a call to `hashfd_ext()`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agocsum-file: introduce `hashfd_ext()`
Patrick Steinhardt [Fri, 13 Mar 2026 06:45:19 +0000 (07:45 +0100)] 
csum-file: introduce `hashfd_ext()`

Introduce a new `hashfd_ext()` function that takes an options structure.
This function will replace `hashd_throughput()` in the next commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agosideband: use writev(3p) to send pktlines
Patrick Steinhardt [Fri, 13 Mar 2026 06:45:18 +0000 (07:45 +0100)] 
sideband: use writev(3p) to send pktlines

Every pktline that we send out via `send_sideband()` currently requires
two syscalls: one to write the pktline's length, and one to send its
data. This typically isn't all that much of a problem, but under extreme
load the syscalls may cause contention in the kernel.

Refactor the code to instead use the newly introduced writev(3p) infra
so that we can send out the data with a single syscall. This reduces the
number of syscalls from around 133,000 calls to write(3p) to around
67,000 calls to writev(3p).

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agowrapper: introduce writev(3p) wrappers
Patrick Steinhardt [Fri, 13 Mar 2026 06:45:17 +0000 (07:45 +0100)] 
wrapper: introduce writev(3p) wrappers

In the preceding commit we have added a compatibility wrapper for the
writev(3p) syscall. Introduce some generic wrappers for this function
that we nowadays take for granted in the Git codebase.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agocompat/posix: introduce writev(3p) wrapper
Patrick Steinhardt [Fri, 13 Mar 2026 06:45:16 +0000 (07:45 +0100)] 
compat/posix: introduce writev(3p) wrapper

In a subsequent commit we're going to add the first caller to
writev(3p). Introduce a compatibility wrapper for this syscall that we
can use on systems that don't have this syscall.

The syscall exists on modern Unixes like Linux and macOS, and seemingly
even for NonStop according to [1]. It doesn't seem to exist on Windows
though.

[1]: http://nonstoptools.com/manuals/OSS-SystemCalls.pdf
[2]: https://www.gnu.org/software/gnulib/manual/html_node/writev.html

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoupload-pack: reduce lock contention when writing packfile data
Patrick Steinhardt [Fri, 13 Mar 2026 06:45:15 +0000 (07:45 +0100)] 
upload-pack: reduce lock contention when writing packfile data

In our production systems we have recently observed write contention in
git-upload-pack(1). The system in question was consistently streaming
packfiles at a rate of dozens of gigabits per second, but curiously the
system was neither bottlenecked on CPU, memory or IOPS.

We eventually discovered that Git was spending 80% of its time in
`pipe_write()`, out of which almost all of the time was spent in the
`ep_poll_callback` function in the kernel. Quoting the reporter:

  This infrastructure is part of an event notification queue designed to
  allow for multiple producers to emit events, but that concurrency
  safety is guarded by 3 layers of locking. The layer we're hitting
  contention in uses a simple reader/writer lock mode (a.k.a. shared
  versus exclusive mode), where producers need shared-mode (read mode),
  and various other actions use exclusive (write) mode.

The system in question generates workloads where we have hundreds of
git-upload-pack(1) processes active at the same point in time. These
processes end up contending around those locks, and the consequence is
that the Git processes stall.

Now git-upload-pack(1) already has the infrastructure in place to buffer
some of the data it reads from git-pack-objects(1) before actually
sending it out. We only use this infrastructure in very limited ways
though, so we generally end up matching one read(3p) call with one
write(3p) call. Even worse, when the sideband is enabled we end up
matching one read with _two_ writes: one for the pkt-line length, and
one for the packfile data.

Extend our use of the buffering infrastructure so that we soak up bytes
until the buffer is filled up at least 2/3rds of its capacity. The
change is relatively simple to implement as we already know to flush the
buffer in `create_pack_file()` after git-pack-objects(1) has finished.

This significantly reduces the number of write(3p) syscalls we need to
do. Before this change, cloning the Linux repository resulted in around
400,000 write(3p) syscalls. With the buffering in place we only do
around 130,000 syscalls.

Now we could of course go even further and make sure that we always fill
up the whole buffer. But this might cause an increase in read(3p)
syscalls, and some tests show that this only reduces the number of
write(3p) syscalls from 130,000 to 100,000. So overall this doesn't seem
worth it.

Note that the issue could also be fixed by adapting the write buffer
that we use in the downstream git-pack-objects(1) command, and such a
change would have roughly the same result. But the command that
generates the packfile data may not always be git-pack-objects(1) as it
can be changed via "uploadpack.packObjectsHook", so such a fix would
only help in _some_ cases. Regardless of that, we'll also adapt the
write buffer size of git-pack-objects(1) in a subsequent commit.

Helped-by: Matt Smiley <msmiley@gitlab.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoupload-pack: prefer flushing data over sending keepalive
Patrick Steinhardt [Fri, 13 Mar 2026 06:45:14 +0000 (07:45 +0100)] 
upload-pack: prefer flushing data over sending keepalive

When using the sideband in git-upload-pack(1) we know to send out
keepalive packets in case generating the pack takes too long. These
keepalives take the form of a simple empty pktline.

In the preceding commit we have adapted git-upload-pack(1) to buffer
data more aggressively before sending it to the client. This creates an
obvious optimization opportunity: when we hit the keepalive timeout
while we still hold on to some buffered data, then it makes more sense
to flush out the data instead of sending the empty keepalive packet.

This is overall not going to be a significant win. Most keepalives will
come before the pack data starts, and once pack-objects starts producing
data, it tends to do so pretty consistently. And of course we can't send
data before we see the PACK header, because the whole point is to buffer
the early bit waiting for packfile URIs. But the optimization is easy
enough to realize.

Do so and flush out data instead of sending an empty pktline.

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoupload-pack: adapt keepalives based on buffering
Patrick Steinhardt [Fri, 13 Mar 2026 06:45:13 +0000 (07:45 +0100)] 
upload-pack: adapt keepalives based on buffering

The function `create_pack_file()` is responsible for sending the
packfile data to the client of git-upload-pack(1). As generating the
bytes may take significant computing resources we also have a mechanism
in place that optionally sends keepalive pktlines in case we haven't
sent out any data.

The keepalive logic is purely based poll(3p): we pass a timeout to that
syscall, and if the call times out we send out the keepalive pktline.
While reasonable, this logic isn't entirely sufficient: even if the call
to poll(3p) ends because we have received data on any of the file
descriptors we may not necessarily send data to the client.

The most important edge case here happens in `relay_pack_data()`. When
we haven't seen the initial "PACK" signature from git-pack-objects(1)
yet we buffer incoming data. So in the worst case, if each of the bytes
of that signature arrive shortly before the configured keepalive
timeout, then we may not send out any data for a time period that is
(almost) four times as long as the configured timeout.

This edge case is rather unlikely to matter in practice. But in a
subsequent commit we're going to adapt our buffering mechanism to become
more aggressive, which makes it more likely that we don't send any data
for an extended amount of time.

Adapt the logic so that instead of using a fixed timeout on every call
to poll(3p), we instead figure out how much time has passed since the
last-sent data.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoupload-pack: fix debug statement when flushing packfile data
Patrick Steinhardt [Fri, 13 Mar 2026 06:45:12 +0000 (07:45 +0100)] 
upload-pack: fix debug statement when flushing packfile data

When git-upload-pack(1) writes packfile data to the client we have some
logic in place that buffers some partial lines. When that buffer still
contains data after git-pack-objects(1) has finished we flush the buffer
so that all remaining bytes are sent out.

Curiously, when we do so we also print the string "flushed." to stderr.
This statement has been introduced in b1c71b7281 (upload-pack: avoid
sending an incomplete pack upon failure, 2006-06-20), so quite a while
ago. What's interesting though is that stderr is typically spliced
through to the client-side, and consequently the client would see this
message. Munging the way how we do the caching indeed confirms this:

  $ git clone file:///home/pks/Development/linux/
  Cloning into bare repository 'linux.git'...
  remote: Enumerating objects: 12980346, done.
  remote: Counting objects: 100% (131820/131820), done.
  remote: Compressing objects: 100% (50290/50290), done.
  remote: Total 12980346 (delta 96319), reused 104500 (delta 81217), pack-reused 12848526 (from 1)
  Receiving objects: 100% (12980346/12980346), 3.23 GiB | 57.44 MiB/s, done.
  flushed.
  Resolving deltas: 100% (10676718/10676718), done.

It's quite clear that this string shouldn't ever be visible to the
client, so it rather feels like this is a left-over debug statement. The
menitoned commit doesn't mention this line, either.

Remove the debug output to prepare for a change in how we do the
buffering in the next commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot0410: modernize delete_object helper
Siddharth Shrimali [Fri, 13 Mar 2026 05:31:59 +0000 (11:01 +0530)] 
t0410: modernize delete_object helper

The delete_object helper currently relies on a manual sed command to
calculate object paths. This works, but it's a bit brittle and forces
us to maintain shell logic that Git's own test suite can already
handle more elegantly.

Switch to 'test_oid_to_path' to let Git handle the path logic. This
makes the helper hash independent, which is much cleaner than manual
string manipulation. While at it, use 'local' to declare helper-specific
variables and quote them to follow Git's coding style. This prevents
them from leaking into global shell scope and avoids potential naming
conflicts with other parts of the test suite.

Helped-by: Pushkar Singh <pushkarkumarsingh1970@gmail.com>
Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Siddharth Shrimali <r.siddharth.shrimali@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agofast-import: add mode to sign commits with invalid signatures
Justin Tobler [Fri, 13 Mar 2026 01:39:38 +0000 (20:39 -0500)] 
fast-import: add mode to sign commits with invalid signatures

With git-fast-import(1), handling of signed commits is controlled via
the `--signed-commits=<mode>` option. When an invalid signature is
encountered, a user may want the option to sign the commit again as
opposed to just stripping the signature. To facilitate this, introduce a
"sign-if-invalid" mode for the `--signed-commits` option. Optionally, a
key ID may be explicitly provided in the form
`sign-if-invalid[=<keyid>]` to specify which signing key should be used
when signing invalid commit signatures.

Note that to properly support interoperability mode when signing commit
signatures, the commit buffer must be created in both the repository and
compatability object formats to generate the appropriate signatures
accordingly. As currently implemented, the commit buffer for the
compatability object format is not reconstructed and thus signing
commits in interoperability mode is not yet supported. Support may be
added in the future.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agogpg-interface: allow sign_buffer() to use default signing key
Justin Tobler [Fri, 13 Mar 2026 01:39:37 +0000 (20:39 -0500)] 
gpg-interface: allow sign_buffer() to use default signing key

The `sign_commit_to_strbuf()` helper in "commit.c" provides fallback
logic to get the default configured signing key when a key is not
provided and handles generating the commit signature accordingly. This
signing operation is not really specific to commits as any arbitrary
buffer can be signed. Also, in a subsequent commit, this same logic is
reused by git-fast-import(1) when signing commits with invalid
signatures.

Remove the `sign_commit_to_strbuf()` helper from "commit.c" and extend
`sign_buffer()` in "gpg-interface.c" to support using the default key as
a fallback when the `SIGN_BUFFER_USE_DEFAULT_KEY` flag is provided. Call
sites are updated accordingly.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agocommit: remove unused forward declaration
Justin Tobler [Fri, 13 Mar 2026 01:39:36 +0000 (20:39 -0500)] 
commit: remove unused forward declaration

In 6206089cbd (commit: write commits for both hashes, 2023-10-01),
`sign_with_header()` was removed, but its forward declaration in
"commit.h" was left. Remove the unused declaration.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoThe 16th batch
Junio C Hamano [Thu, 12 Mar 2026 21:08:20 +0000 (14:08 -0700)] 
The 16th batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoMerge branch 'ps/odb-sources'
Junio C Hamano [Thu, 12 Mar 2026 21:09:06 +0000 (14:09 -0700)] 
Merge branch 'ps/odb-sources'

The object source API is getting restructured to allow plugging new
backends.

* ps/odb-sources:
  odb/source: make `begin_transaction()` function pluggable
  odb/source: make `write_alternate()` function pluggable
  odb/source: make `read_alternates()` function pluggable
  odb/source: make `write_object_stream()` function pluggable
  odb/source: make `write_object()` function pluggable
  odb/source: make `freshen_object()` function pluggable
  odb/source: make `for_each_object()` function pluggable
  odb/source: make `read_object_stream()` function pluggable
  odb/source: make `read_object_info()` function pluggable
  odb/source: make `close()` function pluggable
  odb/source: make `reprepare()` function pluggable
  odb/source: make `free()` function pluggable
  odb/source: introduce source type for robustness
  odb: move reparenting logic into respective subsystems
  odb: embed base source in the "files" backend
  odb: introduce "files" source
  odb: split `struct odb_source` into separate header

2 months agoMerge branch 'hn/status-compare-with-push'
Junio C Hamano [Thu, 12 Mar 2026 21:09:06 +0000 (14:09 -0700)] 
Merge branch 'hn/status-compare-with-push'

"git status" learned to show comparison between the current branch
and various other branches listed on status.compareBranches
configuration.

* hn/status-compare-with-push:
  status: clarify how status.compareBranches deduplicates
  status: add status.compareBranches config for multiple branch comparisons
  refactor format_branch_comparison in preparation

2 months agoMerge branch 'ds/for-each-repo-w-worktree'
Junio C Hamano [Thu, 12 Mar 2026 21:09:05 +0000 (14:09 -0700)] 
Merge branch 'ds/for-each-repo-w-worktree'

"git for-each-repo" started from a secondary worktree did not work
as expected, which has been corrected.

* ds/for-each-repo-w-worktree:
  for-each-repo: simplify passing of parameters
  for-each-repo: work correctly in a worktree
  run-command: extract sanitize_repo_env helper
  for-each-repo: test outside of repo context

2 months agoSync with 'master'
Junio C Hamano [Thu, 12 Mar 2026 17:59:13 +0000 (10:59 -0700)] 
Sync with 'master'

2 months agoMerge branch 'bk/run-command-wo-the-repository' into next
Junio C Hamano [Thu, 12 Mar 2026 17:59:00 +0000 (10:59 -0700)] 
Merge branch 'bk/run-command-wo-the-repository' into next

The run_command() API lost its implicit dependence on the singleton
the_repository instance.

* bk/run-command-wo-the-repository:
  run-command: wean auto_maintenance() functions off the_repository
  run-command: wean start_command() off the_repository

2 months agoMerge branch 'ps/editorconfig-unanchor' into next
Junio C Hamano [Thu, 12 Mar 2026 17:58:59 +0000 (10:58 -0700)] 
Merge branch 'ps/editorconfig-unanchor' into next

Editorconfig filename patterns were specified incorrectly, making
many source files inside subdirectories uncovered, which has been
corrected.

* ps/editorconfig-unanchor:
  editorconfig: fix style not applying to subdirs anymore

2 months agoMerge branch 'ss/t3200-test-zero-oid' into next
Junio C Hamano [Thu, 12 Mar 2026 17:58:57 +0000 (10:58 -0700)] 
Merge branch 'ss/t3200-test-zero-oid' into next

A test now use symbolic constant $ZERO_OID instead of 40 "0" to
work better with SHA-256 as well as SHA-1.

* ss/t3200-test-zero-oid:
  t3200: replace hardcoded null OID with $ZERO_OID

2 months agoMerge branch 'dd/list-objects-filter-options-wo-strbuf-split' into next
Junio C Hamano [Thu, 12 Mar 2026 17:58:56 +0000 (10:58 -0700)] 
Merge branch 'dd/list-objects-filter-options-wo-strbuf-split' into next

Revamp the way combined option filter is parsed.

* dd/list-objects-filter-options-wo-strbuf-split:
  list-objects-filter-options: avoid strbuf_split_str()
  worktree: do not pass strbuf by value

2 months agoMerge branch 'ps/t9200-test-path-is-helpers' into next
Junio C Hamano [Thu, 12 Mar 2026 17:58:54 +0000 (10:58 -0700)] 
Merge branch 'ps/t9200-test-path-is-helpers' into next

Test update.

* ps/t9200-test-path-is-helpers:
  t9200: replace test -f with modern path helper
  t9200: handle missing CVS with skip_all

2 months agoThe 15th batch
Junio C Hamano [Thu, 12 Mar 2026 17:55:41 +0000 (10:55 -0700)] 
The 15th batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoMerge branch 'sp/send-email-validate-charset'
Junio C Hamano [Thu, 12 Mar 2026 17:56:05 +0000 (10:56 -0700)] 
Merge branch 'sp/send-email-validate-charset'

"git send-email" has learned to be a bit more careful when it
accepts charset to use from the end-user, to avoid 'y' (mistaken
'yes' when expecting a charset like 'UTF-8') and other nonsense.

* sp/send-email-validate-charset:
  send-email: validate charset name in 8bit encoding prompt

2 months agoMerge branch 'dt/send-email-client-cert'
Junio C Hamano [Thu, 12 Mar 2026 17:56:04 +0000 (10:56 -0700)] 
Merge branch 'dt/send-email-client-cert'

"git send-email" learns to support use of client-side certificates.

* dt/send-email-client-cert:
  send-email: add client certificate options

2 months agoMerge branch 'ps/ci-gitlab-prepare-for-macos-14-deprecation'
Junio C Hamano [Thu, 12 Mar 2026 17:56:04 +0000 (10:56 -0700)] 
Merge branch 'ps/ci-gitlab-prepare-for-macos-14-deprecation'

Move gitlab CI from macOS 14 images that are being deprecated.

* ps/ci-gitlab-prepare-for-macos-14-deprecation:
  gitlab-ci: update to macOS 15 images
  meson: detect broken iconv that requires ICONV_RESTART_RESET
  meson: simplify iconv-emits-BOM check

2 months agoMerge branch 'ag/send-email-sasl-with-host-port'
Junio C Hamano [Thu, 12 Mar 2026 17:56:04 +0000 (10:56 -0700)] 
Merge branch 'ag/send-email-sasl-with-host-port'

"git send-email" learns to pass hostname/port to Authen::SASL
module.

* ag/send-email-sasl-with-host-port:
  send-email: pass smtp hostname and port to Authen::SASL

2 months agoMerge branch 'ss/t9123-setup-inside-test-expect-success'
Junio C Hamano [Thu, 12 Mar 2026 17:56:04 +0000 (10:56 -0700)] 
Merge branch 'ss/t9123-setup-inside-test-expect-success'

Test clean-up.

* ss/t9123-setup-inside-test-expect-success:
  t9123: use test_when_finished for cleanup

2 months agoMerge branch 'sk/oidmap-clear-with-custom-free-func'
Junio C Hamano [Thu, 12 Mar 2026 17:56:04 +0000 (10:56 -0700)] 
Merge branch 'sk/oidmap-clear-with-custom-free-func'

A bit of OIDmap API enhancement and cleanup.

* sk/oidmap-clear-with-custom-free-func:
  builtin/rev-list: migrate missing_objects cleanup to oidmap_clear_with_free()
  oidmap: make entry cleanup explicit in oidmap_clear