Commit Graph

175385 Commits

Author SHA1 Message Date
Johannes Schindelin
35481d3d6b unix-socket: avoid leak when initialization fails
When a Unix socket is initialized, the current directory's path is
stored so that the cleanup code can `chdir()` back to where it was
before exit.

If the path that needs to be stored exceeds the default size of the
`sun_path` attribute of `struct sockaddr_un` (which is defined as a
108-sized byte array on Linux), a larger buffer needs to be allocated so
that it can hold the path, and it is the responsibility of the
`unix_sockaddr_cleanup()` function to release that allocated memory.

In Git's CI, this stack allocation is not necessary because the code is
checked out to `/home/runner/work/git/git`. Concatenate the path
`t/trash directory.t0301-credential-cache/.cache/git/credential/socket`
and a terminating NUL, and you end up with 96 bytes, 12 shy of the
default `sun_path` size.

However, I use worktrees with slightly longer paths:
`/home/me/projects/git/yes/i/nest/worktrees/to/organize/them/` is more
in line with what I have. When I recently tried to locally reproduce a
failure of the `linux-leaks` CI job, this t0301 test failed (where it
had not failed in CI).

The reason: When `credential-cache` tries to reach its daemon initially
by calling `unix_sockaddr_init()`, it is expected that the daemon cannot
be reached (the idea is to spin up the daemon in that case and try
again). However, when this first call to `unix_sockaddr_init()` fails,
the code returns early from the `unix_stream_connect()` function
_without_ giving the cleanup code a chance to run, skipping the
deallocation of above-mentioned path.

The fix is easy: do not return early but instead go directly to the
cleanup code.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2026-04-02 02:07:35 +00:00
Git for Windows Build Agent
30ae3040ec Start the merging-rebase to upstream/master
This commit starts the rebase of b4cd1d3aef to cf2139f8e1
2026-04-02 02:07:33 +00:00
Junio C Hamano
cf2139f8e1 The 24th batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-04-01 10:28:20 -07:00
Junio C Hamano
949f59e963 Merge branch 'kj/refspec-parsing-outside-repository'
"git ls-remote '+refs/tags/*:refs/tags/*' https://..." run outside a
repository would dereference a NULL while trying to see if the given
refspec is a single-object refspec, which has been corrected.

* kj/refspec-parsing-outside-repository:
  refspec: fix typo in comment
  remote-curl: fall back to default hash outside repo
2026-04-01 10:28:19 -07:00
Junio C Hamano
93841d029e Merge branch 'jk/t0061-bat-test-update'
A test to run a .bat file with whitespaces in the name with arguments
with whitespaces in them was flaky in that sometimes it got killed
before it produced expected side effects, which has been rewritten to
make it more robust.

* jk/t0061-bat-test-update:
  t0061: simplify .bat test
2026-04-01 10:28:19 -07:00
Junio C Hamano
9d498801a7 Merge branch 'mk/repo-help-strings'
"git repo info -h" and "git repo structure -h" limit their help output
to the part that is specific to the subcommand.

* mk/repo-help-strings:
  repo: show subcommand-specific help text
  repo: factor repo usage strings into shared macros
2026-04-01 10:28:19 -07:00
Junio C Hamano
0f85c4c100 Merge branch 'jc/macos-homebrew-wo-reg-enhanced'
In case homebrew breaks REG_ENHANCED again, leave a in-code comment
to suggest use of our replacement regex as a workaround.

* jc/macos-homebrew-wo-reg-enhanced:
  regexp: leave a pointer to resurrect workaround for Homebrew
2026-04-01 10:28:19 -07:00
Junio C Hamano
51a74900aa Merge branch 'rs/use-strvec-pushv'
Code paths that loop over another array to push each element into a
strvec have been rewritten to use strvec_pushv() instead.

* rs/use-strvec-pushv:
  use strvec_pushv() to add another strvec
2026-04-01 10:28:19 -07:00
Junio C Hamano
11f494d5b2 Merge branch 'bk/t5315-test-path-is-helpers'
Test clean-up.

* bk/t5315-test-path-is-helpers:
  t5315: use test_path_is_file for loose-object check
2026-04-01 10:28:18 -07:00
Junio C Hamano
8744cef324 Merge branch 'jk/diff-highlight-more'
Various updates to contrib/diff-highlight, including documentation
updates, test improvements, and color configuration handling.

* jk/diff-highlight-more:
  diff-highlight: fetch all config with one process
  diff-highlight: allow module callers to pass in color config
  diff-highlight: test color config
  diff-highlight: use test_decode_color in tests
  t: add matching negative attributes to test_decode_color
  diff-highlight: check diff-highlight exit status in tests
  diff-highlight: drop perl version dependency back to 5.8
  diff-highlight: mention build instructions
2026-04-01 10:28:18 -07:00
Junio C Hamano
0a39ec283c Merge branch 'vp/http-rate-limit-retries'
The HTTP transport learned to react to "429 Too Many Requests".

* vp/http-rate-limit-retries:
  http: add support for HTTP 429 rate limit retries
  strbuf_attach: fix call sites to pass correct alloc
  strbuf: pass correct alloc to strbuf_attach() in strbuf_reencode()
2026-04-01 10:28:18 -07:00
Johannes Schindelin
f549d3f011 Don't traverse mount points in remove_dir_recurse() (#6151)
`remove_dir_recurse()` in `dir.c` doesn't check for mount points, even
though this check was already added for `git clean` in #2268. So `git
worktree remove` (or anything else that calls it) will traverse NTFS
junctions and delete whatever is there. Similar to #607.

This extends the same check from #2268 but for anything that calls
`remove_dir_recurse()`.
2026-03-31 11:20:45 +00:00
Maks Kuznia
88942a5253 dir: do not traverse mount points
It was already decided in ef22148 (clean: do not traverse mount points,
2018-12-07) that we shouldn't traverse NTFS junctions/bind mounts when
using `git clean`, partly because they're sometimes used in worktrees.
But the same check wasn't applied to `remove_dir_recurse()` in `dir.c`,
which `git worktree remove` uses. So removing a worktree suffers the
same problem we had previously with `git clean`.

Let's add the same guard from ef22148.

Signed-off-by: Maks Kuznia <makskuznia244@gmail.com>
2026-03-30 23:18:31 +02:00
Junio C Hamano
270e10ad6d The 23rd batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-30 13:57:03 -07:00
Junio C Hamano
6cb924707f Merge branch 'ai/t2107-test-path-is-helpers'
Test cleanup.

* ai/t2107-test-path-is-helpers:
  t2107: modernize path existence check
2026-03-30 13:57:03 -07:00
Junio C Hamano
a1d7a8fef1 Merge branch 'jw/object-name-bitset-to-enum'
The unsigned integer that is used as an bitset to specify the kind
of branches interpret_branch_name() function has been changed to
use a dedicated enum type.

* jw/object-name-bitset-to-enum:
  object-name: turn INTERPRET_BRANCH_* constants into enum values
2026-03-30 13:57:02 -07:00
Junio C Hamano
ffb31a39ad Merge branch 'jw/t2203-status-pipe-fix'
Test clean-up.

* jw/t2203-status-pipe-fix:
  t2203: avoid suppressing git status exit code
2026-03-30 13:57:01 -07:00
Junio C Hamano
5032e70fc2 Merge branch 'jw/apply-corrupt-location'
"git apply" now reports the name of the input file along with the
line number when it encounters a corrupt patch, and correctly
resets the line counter when processing multiple patch files.

* jw/apply-corrupt-location:
  apply: report input location in binary and garbage patch errors
  apply: report input location in header parsing errors
  apply: report the location of corrupt patches
2026-03-30 13:57:00 -07:00
Junio C Hamano
295eb2cc47 Merge branch 'rs/split-index-the-repo-fix'
split-index.c has been updated to not use the global the_repository
and the_hash_algo variables.

* rs/split-index-the-repo-fix:
  split-index: stop using the_repository and the_hash_algo
2026-03-30 13:56:59 -07:00
Junio C Hamano
cb7428fd7b Merge branch 'rs/ahead-behind-cleanup-optimization'
The cleanup of remaining bitmaps in "ahead_behind()" has been
simplified.

* rs/ahead-behind-cleanup-optimization:
  commit-reach: simplify cleanup of remaining bitmaps in ahead_behind ()
2026-03-30 13:56:59 -07:00
Junio C Hamano
5361983c07 The 22nd batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-27 11:00:03 -07:00
Junio C Hamano
7241be4123 Merge branch 'jc/rerere-modern-strbuf-handling'
Code clean-up overdue by 19 years.

* jc/rerere-modern-strbuf-handling:
  cocci: strbuf.buf is never NULL
  rerere: update to modern representation of empty strbufs
2026-03-27 11:00:03 -07:00
Junio C Hamano
18396dc97d Merge branch 'kh/doc-interpret-trailers-1'
Doc updates.

* kh/doc-interpret-trailers-1:
  interpret-trailers: use placeholder instead of *
  doc: config: convert trailers section to synopsis style
  doc: interpret-trailers: normalize and fill out options
  doc: interpret-trailers: convert to synopsis style
2026-03-27 11:00:02 -07:00
Junio C Hamano
ae55b12bb3 Merge branch 'ej/ref-transaction-hook-preparing'
The reference-transaction hook was taught to be triggered before
taking locks on references in the "preparing" phase.

* ej/ref-transaction-hook-preparing:
  refs: add 'preparing' phase to the reference-transaction hook
2026-03-27 11:00:02 -07:00
Junio C Hamano
cb77c3a6a7 Merge branch 'mf/apply-p-no-atoi'
"git apply -p<n>" parses <n> more carefully now.

* mf/apply-p-no-atoi:
  apply.c: fix -p argument parsing
2026-03-27 11:00:02 -07:00
Junio C Hamano
f23054409b Merge branch 'gi/doc-boolean-config-typofix'
Doc typofix.

* gi/doc-boolean-config-typofix:
  doc: add missing space on git-config page
2026-03-27 11:00:02 -07:00
Junio C Hamano
828988bef3 Merge branch 'mr/merge-file-object-id-worktree-fix'
merge-file --object-id used to trigger a BUG when run in a linked
worktree, which has been fixed.

* mr/merge-file-object-id-worktree-fix:
  merge-file: fix BUG when --object-id is used in a worktree
2026-03-27 11:00:01 -07:00
Junio C Hamano
968e62c187 Merge branch 'rs/prio-queue-to-commit-stack'
Uses of prio_queue as a LIFO stack of commits have been written
with commit_stack.

* rs/prio-queue-to-commit-stack:
  use commit_stack instead of prio_queue in LIFO mode
2026-03-27 11:00:01 -07:00
Junio C Hamano
d1f07dd500 Merge branch 'ps/build-tweaks'
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
2026-03-27 11:00:01 -07:00
Junio C Hamano
ebd8fa7e12 Merge branch 'jk/diff-highlight-identical-pairs'
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
2026-03-27 11:00:00 -07:00
Junio C Hamano
bd66ed316c regexp: leave a pointer to resurrect workaround for Homebrew
Recently some GitHub CI jobs were broken by update on the platform
side, which was eventually resolved by image rollback, but in the
meantime Dscho invented a workaround patch to sidestep the broken
part of the platform.  Their future image update may contain the
same bug, in which case the workaround may again become needed.

As we do not want to be building with workaround that avoids system
regexp library altogether unless the system is known to be broken,
so short of an automated "detect broken system and apply workaround"
mechanism, let's use the folks who are compiling the code to detect
breakage on their system and cope with the breakage ;-)

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-25 15:04:30 -07:00
Johannes Schindelin
9b9e2dcc20 mingw: use strftime() directly in UCRT builds (#6130)
Currently, Git for Windows is built off of the MINGW64 tool chain. But
this will have to change because [the MSYS2 project deprecated this tool
chain in favor of
UCRT64](https://www.msys2.org/news/#2026-03-15-deprecating-the-mingw64-environment).
Of course, that's only possible because they dropped support for Windows
8.1, which Git for Windows will probably have to do relatively soon. The
best time to do that is probably [the Git 3.0 inflection
point](https://github.com/git-for-windows/git/discussions/6018) when we
already promised to drop support for older Windows versions.

To prepare for such a huge change, I investigated what needs to be
changed in Git for Windows' source code. And the good news is there's
actually not very much. This here patch seems to be the only change
that's necessary, and not even _strictly_ necessary: the
`mingw_strftime()` wrapper would still do the right thing. It would just
uselessly load the same function that's already loaded, dynamically,
again.

- The `strerror()` override [is guarded by an `#ifndef
_UCRT`](https://github.com/git-for-windows/git/blob/v2.53.0.windows.2/compat/mingw-posix.h#L294-L296),
- `PRIuMAX` resolves to standard `"llu"` [via
`<inttypes.h>`](https://github.com/git-for-windows/git/blob/v2.53.0.windows.2/compat/mingw-posix.h#L449-L454)
(note that `__MINGW64_VERSION_MAJOR` is defined both in MINGW64 and
UCRT64, by virtue of using the `mingw-w64-headers`),
-
[`__USE_MINGW_ANSI_STDIO=0`](https://github.com/git-for-windows/git/blob/v2.53.0.windows.2/config.mak.uname#L751C19-L751C33)
is irrelevant because [`_UCRT` short-circuits
it](08933e673c/mingw64/include/inttypes.h (L33)),
and
- `SNPRINTF_RETURNS_BOGUS` hasn't been set for Git for Windows' builds
since ec47a33fd2, i.e. for a _really_ long
time.
2026-03-25 20:04:38 +00:00
Junio C Hamano
41688c1a23 The 21st batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-25 12:58:05 -07:00
Junio C Hamano
8e2964dc89 Merge branch 'ps/object-counting'
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"
2026-03-25 12:58:05 -07:00
Junio C Hamano
105a22cf69 Merge branch 'tb/incremental-midx-part-3.2'
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
2026-03-25 12:58:04 -07:00
Mahi Kassa
abd728cdf6 repo: show subcommand-specific help text
Use subcommand-specific usage arrays for "git repo info" and
"git repo structure" so that each command shows only its own
synopsis in help output.

Add tests to cover the subcommand help behavior.

Signed-off-by: Mahi Kassa <mahlet.takassa@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-25 10:35:27 -07:00
Mahi Kassa
4be77c732c repo: factor repo usage strings into shared macros
Factor the "git repo info" and "git repo structure" usage
strings into shared macros so they can be reused in multiple
usage arrays.

This is a preparatory refactoring for subsequent changes to
subcommand-specific help output.

Signed-off-by: Mahi Kassa <mahlet.takassa@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-25 10:35:27 -07:00
Jeff King
3ad4921838 t0061: simplify .bat test
The test added by 71f4960b91 (t0061: fix test for argv[0] with spaces
(MINGW only), 2019-10-01) checks that we can use a .bat file with spaces
as GIT_SSH.

This is a good test in the sense that it's how the original bug was
detected. And as the commit message there describes, there are some
elements of the bug that are likely to come up with GIT_SSH and not
elsewhere: namely that in addition to the .bat file having spaces, we
must pass an argument with spaces (which happens naturally with ssh,
since we pass the upload-pack shell command for the other side to run).

But using GIT_SSH does complicate matters:

  1. We actually run the ssh command _twice_, once to probe the ssh
     variant with "-G" in fill_ssh_args(), and then a second time to
     actually make the connection. So we have to account for that when
     checking the output.

  2. Our fake ssh .bat file does not actually run ssh. So we expect the
     command to fail, but not before the .bat file has touched the "out"
     marker file that tells us it has run.

     This works now, but is fragile. In particular, the .bat file by
     default will echo commands it runs to stdout. From the perspective
     of the parent Git process, this is protocol-breaking garbage, and
     upon seeing it will die().

     That is OK for now because we don't bother to do any cleanup of the
     child process. But there is a patch under discussion, dd3693eb08
     (transport-helper, connect: use clean_on_exit to reap children on
     abnormal exit, 2026-03-12), which causes us to kill() the .bat
     process. This happens before it actually touches the "out" file,
     causing the test to fail.

We can simplify this by just using the "test-tool run-command" helper.
That lets us run whatever command we like with the arguments we want.
The argument here has a space, which is enough to trigger the original
bug that 71f4960b91 was testing. I verified that by reverting eb7c786314
(mingw: support spawning programs containing spaces in their names,
2019-07-16), the original fix, and confirming that the test fails (but
succeeds without the revert).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-24 23:37:10 -07:00
Junio C Hamano
ce74208c2f The 20th batch
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-24 12:31:34 -07:00
Junio C Hamano
253ddb6016 Merge branch 'dd/cocci-do-not-pass-strbuf-by-value'
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
2026-03-24 12:31:34 -07:00
Junio C Hamano
c006399b73 Merge branch 'ty/doc-diff-u-wo-number'
"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
2026-03-24 12:31:34 -07:00
Junio C Hamano
8023abc632 Merge branch 'ps/upload-pack-buffer-more-writes'
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
2026-03-24 12:31:34 -07:00
Junio C Hamano
231f8100c4 Merge branch 'yc/histogram-hunk-shift-fix'
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
2026-03-24 12:31:34 -07:00
Junio C Hamano
7f13e5c8c7 Merge branch 'mf/t0008-cleanup'
Test clean-up.

* mf/t0008-cleanup:
  t0008: improve test cleanup to fix failing test
2026-03-24 12:31:33 -07:00
Junio C Hamano
448cea8de0 Merge branch 'pb/t4200-test-path-is-helpers'
Test clean-up.

* pb/t4200-test-path-is-helpers:
  t4200: convert test -[df] checks to test_path_* helpers
2026-03-24 12:31:33 -07:00
Junio C Hamano
067ee91920 Merge branch 'jk/transport-color-leakfix'
Leakfix.

* jk/transport-color-leakfix:
  transport: plug leaks in transport_color_config()
2026-03-24 12:31:33 -07:00
Junio C Hamano
b9c55cff8a Merge branch 'rj/pack-refs-tests-path-is-helpers'
Test updates.

* rj/pack-refs-tests-path-is-helpers:
  t/pack-refs-tests: use test_path_is_missing
2026-03-24 12:31:33 -07:00
Junio C Hamano
9d9cd3830f Merge branch 'ps/clar-wo-path-max'
Clar (unit testing framework) update from the upstream.

* ps/clar-wo-path-max:
  clar: update to fix compilation on platforms without PATH_MAX
2026-03-24 12:31:32 -07:00
Junio C Hamano
04a7124af0 Merge branch 'gj/user-manual-fix-grep-example'
Fix an example in the user-manual.

* gj/user-manual-fix-grep-example:
  doc: fix git grep args order in Quick Reference
2026-03-24 12:31:32 -07:00
Junio C Hamano
49e6a7cd63 Merge branch 'ps/history-split'
"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"
2026-03-24 12:31:32 -07:00