Commit Graph

175405 Commits

Author SHA1 Message Date
Johannes Schindelin
21503aef22 Merge branch 'msys2-python'
In MSYS2, we have two Python interpreters at our disposal, so we can
include the Python stuff in the build.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2026-04-02 21:30:05 +02:00
Johannes Schindelin
0042443936 Merge branch 'dont-clean-junctions'
This topic branch teaches `git clean` to respect NTFS junctions and Unix
bind mounts: it will now stop at those boundaries.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2026-04-02 21:30:05 +02:00
Johannes Schindelin
4fe471681d Merge branch 'drive-prefix'
This topic branch allows us to specify absolute paths without the drive
prefix e.g. when cloning.

Example:

	C:\Users\me> git clone https://github.com/git/git \upstream-git

This will clone into a new directory C:\upstream-git, in line with how
Windows interprets absolute paths.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2026-04-02 21:30:05 +02:00
Johannes Schindelin
13a251fee5 Merge 'remote-hg-prerequisites' into HEAD
These fixes were necessary for Sverre Rabbelier's remote-hg to work,
but for some magic reason they are not necessary for the current
remote-hg. Makes you wonder how that one gets away with it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2026-04-02 21:30:05 +02:00
Johannes Schindelin
72be1d2ca2 mingw: include the Python parts in the build
While Git for Windows does not _ship_ Python (in order to save on
bandwidth), MSYS2 provides very fine Python interpreters that users can
easily take advantage of, by using Git for Windows within its SDK.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2026-04-02 21:29:57 +02:00
Johannes Schindelin
b447e49528 clean: remove mount points when possible
Windows' equivalent to "bind mounts", NTFS junction points, can be
unlinked without affecting the mount target. This is clearly what users
expect to happen when they call `git clean -dfx` in a worktree that
contains NTFS junction points: the junction should be removed, and the
target directory of said junction should be left alone (unless it is
inside the worktree).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2026-04-02 21:29:57 +02:00
Johannes Schindelin
251bd7446e clean: do not traverse mount points
It seems to be not exactly rare on Windows to install NTFS junction
points (the equivalent of "bind mounts" on Linux/Unix) in worktrees,
e.g. to map some development tools into a subdirectory.

In such a scenario, it is pretty horrible if `git clean -dfx` traverses
into the mapped directory and starts to "clean up".

Let's just not do that. Let's make sure before we traverse into a
directory that it is not a mount point (or junction).

This addresses https://github.com/git-for-windows/git/issues/607

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2026-04-02 21:29:57 +02:00
Johannes Schindelin
4b8b233e87 mingw: prevent regressions with "drive-less" absolute paths
On Windows, there are several categories of absolute paths. One such
category starts with a backslash and is implicitly relative to the drive
associated with the current working directory. Example:

	c:
	git clone https://github.com/git-for-windows/git \G4W

should clone into C:\G4W.

Back in 2017, Juan Carlos Arevalo Baeza reported a bug in Git's handling
of those absolute paths was identified, and fixed. Let's make sure that
it stays fixed.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2026-04-02 21:29:56 +02:00
Johannes Schindelin
e59744675c Merge branch 'fixes-from-the-git-mailing-list'
These fixes have been sent to the Git mailing list but have not been
picked up by the Git project yet.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2026-04-02 21:29:56 +02:00
Johannes Schindelin
675a8cd1d4 Always auto-gc after calling a fast-import transport
After importing anything with fast-import, we should always let the
garbage collector do its job, since the objects are written to disk
inefficiently.

This brings down an initial import of http://selenic.com/hg from about
230 megabytes to about 14.

In the future, we may want to make this configurable on a per-remote
basis, or maybe teach fast-import about it in the first place.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2026-04-02 21:29:56 +02:00
Johannes Schindelin
4364f3bda0 Merge branch 'disallow-control-characters-in-sideband-channel'
This addresses:

- CVE-2024-52005:

	Insufficient neutralization of ANSI escape sequences in sideband
	payload can be used to mislead Git users into believing that
	certain remote-generated messages actually originate from Git.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
2026-04-02 21:29:56 +02:00
Jeff King
6b71bc19da grep: prevent ^$ false match at end of file
In some implementations, `regexec_buf()` assumes that it is fed lines;
Without `REG_NOTEOL` it thinks the end of the buffer is the end of a
line. Which makes sense, but trips up this case because we are not
feeding lines, but rather a whole buffer. So the final newline is not
the start of an empty line, but the true end of the buffer.

This causes an interesting bug:

  $ echo content >file.txt
  $ git grep --no-index -n '^$' file.txt
  file.txt:2:

This bug is fixed by making the end of the buffer consistently the end
of the final line.

The patch was applied from
https://lore.kernel.org/git/20250113062601.GD767856@coredump.intra.peff.net/

Reported-by: Olly Betts <olly@survex.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2026-04-02 21:29:56 +02:00
Sverre Rabbelier
225237b3c2 remote-helper: check helper status after import/export
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
2026-04-02 21:29:56 +02:00
Johannes Schindelin
9109830585 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 21:29:56 +02:00
Johannes Schindelin
04bbc336b8 sideband: do allow ANSI color sequences by default
The preceding two commits introduced special handling of the sideband
channel to neutralize ANSI escape sequences before sending the payload
to the terminal, and `sideband.allowControlCharacters` to override that
behavior.

However, some `pre-receive` hooks that are actively used in practice
want to color their messages and therefore rely on the fact that Git
passes them through to the terminal.

In contrast to other ANSI escape sequences, it is highly unlikely that
coloring sequences can be essential tools in attack vectors that mislead
Git users e.g. by hiding crucial information.

Therefore we can have both: Continue to allow ANSI coloring sequences to
be passed to the terminal, and neutralize all other ANSI escape
sequences.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2026-04-02 21:29:56 +02:00
Sverre Rabbelier
19e20cd5a6 transport-helper: add trailing --
[PT: ensure we add an additional element to the argv array]

Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2026-04-02 21:29:56 +02:00
Johannes Schindelin
dea5198ad2 sideband: introduce an "escape hatch" to allow control characters
The preceding commit fixed the vulnerability whereas sideband messages
(that are under the control of the remote server) could contain ANSI
escape sequences that would be sent to the terminal verbatim.

However, this fix may not be desirable under all circumstances, e.g.
when remote servers deliberately add coloring to their messages to
increase their urgency.

To help with those use cases, give users a way to opt-out of the
protections: `sideband.allowControlCharacters`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2026-04-02 21:29:56 +02:00
Sverre Rabbelier
564e8c56b4 t9350: point out that refs are not updated correctly
This happens only when the corresponding commits are not exported in
the current fast-export run. This can happen either when the relevant
commit is already marked, or when the commit is explicitly marked
as UNINTERESTING with a negative ref by another argument.

This breaks fast-export basec remote helpers.

Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
2026-04-02 21:29:56 +02:00
Johannes Schindelin
cad0438e70 sideband: mask control characters
The output of `git clone` is a vital component for understanding what
has happened when things go wrong. However, these logs are partially
under the control of the remote server (via the "sideband", which
typically contains what the remote `git pack-objects` process sends to
`stderr`), and is currently not sanitized by Git.

This makes Git susceptible to ANSI escape sequence injection (see
CWE-150, https://cwe.mitre.org/data/definitions/150.html), which allows
attackers to corrupt terminal state, to hide information, and even to
insert characters into the input buffer (i.e. as if the user had typed
those characters).

To plug this vulnerability, disallow any control character in the
sideband, replacing them instead with the common `^<letter/symbol>`
(e.g. `^[` for `\x1b`, `^A` for `\x01`).

There is likely a need for more fine-grained controls instead of using a
"heavy hammer" like this, which will be introduced subsequently.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2026-04-02 21:29:56 +02:00
Johannes Schindelin
0935e6b916 Start the merging-rebase to v2.54.0-rc0
This commit starts the rebase of a7ac2046fa to 74f5625775a
2026-04-02 21:29:02 +02:00
Junio C Hamano
256554692d Git 2.54-rc0
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-04-01 21:31:08 -07:00
Todd Zullinger
6cc95979c6 RelNotes: minor typo fixes in 2.54.0 draft
Signed-off-by: Todd Zullinger <tmz@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-04-01 21:15:26 -07: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