]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
2 months agot9822: use prereq to check for ISO-8859-1 support
Patrick Steinhardt [Mon, 2 Jun 2025 06:44:43 +0000 (08:44 +0200)] 
t9822: use prereq to check for ISO-8859-1 support

Tests in t9822 depend on filesystem support for ISO-8859-1 encoding. We
thus have a block of code that acts as a prerequisite -- if we fail to
write a file with an ISO-8859-1-encoded file name to disk then we skip
all tests.

When the prerequisite fails though we end up printing an error message
to stderr, which breaks the TAP format. Fix this by converting the code
to a proper prerequisite, which handles output redirection for us.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot: silence output from `test_create_repo()`
Patrick Steinhardt [Mon, 2 Jun 2025 06:44:42 +0000 (08:44 +0200)] 
t: silence output from `test_create_repo()`

There are a couple users of `test_create_repo()` that use this function
outside of any test case. This function is nowadays only a thin wrapper
around `git init`, which by default prints a message to stdout that the
repository has been initialized. The resulting output may thus confuse
TAP parsers.

Refactor these users to instead create the repository in a "setup" test
case so that we don't explicitly have to silence them. There's one
exception in t1007: we use `push_repo()` and its `pop_repo()` equivalent
multiple times, so to reduce the noise introduced by this patch we
instead silence this invocation.

While at it, convert callsites to use git-init(1) directly as the
`test_create_repo()` function has been deprecated in f0d4d398e28
(test-lib: split up and deprecate test_create_repo(), 2021-05-10).

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot: stop announcing prereqs
Patrick Steinhardt [Mon, 2 Jun 2025 06:44:41 +0000 (08:44 +0200)] 
t: stop announcing prereqs

We have a couple of cases where our tests end up announcing that a
certain prerequisite is or isn't fulfilled. While this is supposed to
help the developer it has the downside that it breaks the TAP format.

We could convert these cases to just have a "#" prefix, but it feels
rather unlikely that these are generally useful in the first place. We
already do announce why a specific test is being skipped, so we should
try to use this mechanism to the best extent possible.

Stop announcing these prereqs to fix the TAP format. Where possible,
convert the tests to rely on the prerequisites themselves to announce
why a test ran or didn't ran.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoconfig.mak.uname: update settings for OpenBSD
Brad Smith [Mon, 2 Jun 2025 03:14:43 +0000 (23:14 -0400)] 
config.mak.uname: update settings for OpenBSD

OpenBSD requires DIR_HAS_BSD_GROUP_SEMANTICS.

OpenBSD has never had the BSD sysctl KERN_PROC_PATHNAME nor
does it support or use the /proc filesystem.

OpenBSD has had strcasestr() since 3.8. OpenBSD has had memmem()
since 5.4.

Signed-off-by: Brad Smith <brad@comstyle.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agobuiltin/gc: correct physical memory detection for OpenBSD / NetBSD
Brad Smith [Sun, 1 Jun 2025 08:24:12 +0000 (04:24 -0400)] 
builtin/gc: correct physical memory detection for OpenBSD / NetBSD

OpenBSD / NetBSD use HW_PHYSMEM64 to detect the amount of physical
memory in a system. HW_PHYSMEM will not provide the correct amount
on a system with >=4GB of memory.

Signed-off-by: Brad Smith <brad@comstyle.com>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: column: fix blank lines around block delimiters
Kristoffer Haugsbakk [Sun, 1 Jun 2025 11:36:53 +0000 (13:36 +0200)] 
doc: column: fix blank lines around block delimiters

227c4f33a03 (doc: add a blank line around block delimiters,
2025-03-09) added blank lines around block delimiters as a
defensive measure.  For each block you had to mind the con-
text (like the commit says):

• Top-level: just add blank lines
• Block: use list continuation (+)

But list continuation was used here at the top level, which
results in literal `+` in the output formats.

Acked-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agothread-utils.c: detect online CPU count on OpenBSD / NetBSD
Brad Smith [Fri, 9 May 2025 06:13:13 +0000 (02:13 -0400)] 
thread-utils.c: detect online CPU count on OpenBSD / NetBSD

OpenBSD / NetBSD use HW_NCPUONLINE to detect the online CPU
count. OpenBSD ships with SMT disabled on X86 systems so
HW_NCPU would provide double the number of CPUs as opposed
to the proper online count.

Signed-off-by: Brad Smith <brad@comstyle.com>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot: run tests from a normalized working directory
Mark Mentovai [Wed, 28 May 2025 20:17:37 +0000 (16:17 -0400)] 
t: run tests from a normalized working directory

Some tests make git perform actions that produce observable pathnames,
and have expectations on those paths. Tests run with $HOME set to a
$TRASH_DIRECTORY, and with their working directory the same
$TRASH_DIRECTORY, although these paths are logically identical, they do
not observe the same pathname canonicalization rules and thus might not
be represented by strings that compare equal. In particular, no pathname
normalization is applied to $TRASH_DIRECTORY or $HOME, while tests
change their working directory with `cd -P`, which normalizes the
working directory's path by fully resolving symbolic links.

t7900's macOS maintenance tests (which are not limited to running on
macOS) have an expectation on a path that `git maintenance` forms by
using abspath.c strbuf_realpath() to resolve a canonical absolute path
based on $HOME. When t7900 runs from a working directory that contains
symbolic links in its pathname, $HOME will also contain symbolic links,
which `git maintenance` resolves but the test's expectation does not,
causing a test failure.

Align $TRASH_DIRECTORY and $HOME with the normalized path as used for
the working directory by resetting them to match the working directory
after it's established by `cd -P`. With all paths in agreement and
symbolic links resolved, pathname expectations can be set and met based
on string comparison without regard to external environmental factors
such as the presence of symbolic links in a path.

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Mark Mentovai <mark@chromium.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoA bit more topics for -rc1
Junio C Hamano [Fri, 30 May 2025 18:59:01 +0000 (11:59 -0700)] 
A bit more topics for -rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoMerge branch 'ps/midx-negative-packfile-cache'
Junio C Hamano [Fri, 30 May 2025 18:59:18 +0000 (11:59 -0700)] 
Merge branch 'ps/midx-negative-packfile-cache'

When a stale .midx file refers to .pack files that no longer exist,
we ended up checking for these non-existent files repeatedly, which
has been optimized by memoizing the non-existence.

* ps/midx-negative-packfile-cache:
  midx: stop repeatedly looking up nonexistent packfiles
  packfile: explain ordering of how we look up auxiliary pack files

2 months agoMerge branch 'kh/notes-doc-fixes'
Junio C Hamano [Fri, 30 May 2025 18:59:17 +0000 (11:59 -0700)] 
Merge branch 'kh/notes-doc-fixes'

"git notes --help" documentation updates.

* kh/notes-doc-fixes:
  doc: notes: use stuck form throughout
  doc: notes: treat --stdin equally between copy/remove
  doc: notes: point out copy --stdin use with argv
  doc: notes: clearly state that --stripspace is the default
  doc: notes: remove stripspace discussion from other options
  doc: notes: rework --[no-]stripspace
  doc: notes: split out options with negated forms
  doc: config: mention core.commentChar on commit.cleanup
  doc: stripspace: mention where the default comes from

2 months agoMerge branch 'mm/apply-reverse-mode-of-deleted-path'
Junio C Hamano [Fri, 30 May 2025 18:59:17 +0000 (11:59 -0700)] 
Merge branch 'mm/apply-reverse-mode-of-deleted-path'

"git apply --index/--cached" when applying a deletion patch in
reverse failed to give the mode bits of the path "removed" by the
patch to the file it creates, which has been corrected.

* mm/apply-reverse-mode-of-deleted-path:
  apply: set file mode when --reverse creates a deleted file
  t4129: test that git apply warns for unexpected mode changes

2 months agoMerge branch 'op/cvsserver-perl-warning'
Junio C Hamano [Fri, 30 May 2025 18:59:16 +0000 (11:59 -0700)] 
Merge branch 'op/cvsserver-perl-warning'

Recent versions of Perl started warning against "! A =~ /pattern/"
which does not negate the result of the matching.  As it turns out
that the problematic function is not even called, it was removed.

* op/cvsserver-perl-warning:
  cvsserver: remove unused escapeRefName function

2 months agoMerge branch 'am/sparse-index-name-hash-fix'
Junio C Hamano [Fri, 30 May 2025 18:59:16 +0000 (11:59 -0700)] 
Merge branch 'am/sparse-index-name-hash-fix'

Avoid adding directory path to a sparse-index tree entries to the
name-hash, since they would bloat the hashtable without anybody
querying for them.  This was done already for a single threaded
part of the code, but now the multi-threaded code also does the
same.

* am/sparse-index-name-hash-fix:
  name-hash: don't add sparse directories in threaded lazy init

2 months agoMerge branch 'pw/midx-repack-overflow-fix'
Junio C Hamano [Fri, 30 May 2025 18:59:16 +0000 (11:59 -0700)] 
Merge branch 'pw/midx-repack-overflow-fix'

Integer overflow fix around code paths for "git multi-pack-index repack"..

* pw/midx-repack-overflow-fix:
  midx docs: clarify tie breaking
  midx: avoid negative array index
  midx repack: avoid potential integer overflow on 64 bit systems
  midx repack: avoid integer overflow on 32 bit systems

2 months agoMerge branch 'cb/reftable-unused-portability-fix'
Junio C Hamano [Fri, 30 May 2025 18:59:15 +0000 (11:59 -0700)] 
Merge branch 'cb/reftable-unused-portability-fix'

Build fix.

* cb/reftable-unused-portability-fix:
  reftable: make REFTABLE_UNUSED C99 compatible

2 months agodocs: make the purpose of using app password for Gmail more clear in send-email
Aditya Garg [Fri, 30 May 2025 15:50:07 +0000 (15:50 +0000)] 
docs: make the purpose of using app password for Gmail more clear in send-email

The current example for Gmail suggests using app passwords for
send-email if user has multi-factor authentication set up for their
account. However, it does not clarify that the user cannot use their
normal password in case they do not have multi-factor authentication
enabled. Most likely the example was written in the days when Google
allowed using normal passwords without multi-factor authentication.

Clarify that regular passwords do not work for Gmail and app-passwords
are the only way for basic authentication. Also encourage users to use
OAuth2.0 as a more secure alternative.

While at it, also prefer using the word "mechanism" over "method" for
`OAUTHBEARER` and `XOAUTH2` since that is what official docs use.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodocs: remove credential helper links for emails from gitcredentials
Aditya Garg [Fri, 30 May 2025 15:50:05 +0000 (15:50 +0000)] 
docs: remove credential helper links for emails from gitcredentials

In a recent attempt to add links of email helpers to git-scm.com [1], I
came to a conclusion that the links in the gitcredentials page are meant
for people needing credential helpers for cloning, fetching and pushing
repositories to remote hosts, and not sending emails. gitcredentials
docs don't even talk about send emails, thus confirming this view.

So, lets remove these links from the gitcredentials page. The links are
still available in the git-send-email documentation, which is the right
place for them.

[1]: https://github.com/git/git-scm.com/pull/2005

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodocs: improve formatting in git-send-email documentation
Aditya Garg [Fri, 30 May 2025 15:50:04 +0000 (15:50 +0000)] 
docs: improve formatting in git-send-email documentation

The current documentation for git-send-email had an inconsistent use of
"", ``, and '' for quoting. This commit improves the formatting by
using the same style throughout the documentation. Missing full stops
have also been added at some places.

Finally, the cpan links of necessary perl modules have been added to
make their installation easier.

While at it, the unecessary use of $ with <num> and <int> placeholders
has also been removed.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodocs: add credential helper for yahoo and link Google's sendgmail tool
Aditya Garg [Fri, 30 May 2025 15:50:02 +0000 (15:50 +0000)] 
docs: add credential helper for yahoo and link Google's sendgmail tool

This commit links `git-credential-yahoo` as a credential helper for
Yahoo accounts. Also, Google's `sendgmail` tool has been linked as an
alternative method for sending emails through Gmail.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: sparse-checkout: use consistent inline list style
Wonuk Kim [Fri, 30 May 2025 07:22:36 +0000 (07:22 +0000)] 
doc: sparse-checkout: use consistent inline list style

Fix this inline list to use a single style, namely numeric, instead of
`(1)` followed by `(b)`.

Signed-off-by: Wonuk Kim <kimww0306@gmail.com>
Acked-by: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agouserdiff: add support for R programming language
Rodrigo Carvalho [Thu, 29 May 2025 22:16:41 +0000 (19:16 -0300)] 
userdiff: add support for R programming language

Add userdiff patterns to support R programming language.

Also, add three userdiff tests for R programming language
files. These files define simple function and nested function,
with and without indentation.

Signed-off-by: Rodrigo Carvalho <rodrigorsdc@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agol10n: bg.po: Updated Bulgarian translation (5819t)
Alexander Shopov [Thu, 29 May 2025 18:27:11 +0000 (20:27 +0200)] 
l10n: bg.po: Updated Bulgarian translation (5819t)

Signed-off-by: Alexander Shopov <ash@kambanaria.org>
2 months agoreftable: make REFTABLE_UNUSED C99 compatible
Carlo Marcelo Arenas Belón [Thu, 29 May 2025 10:11:36 +0000 (03:11 -0700)] 
reftable: make REFTABLE_UNUSED C99 compatible

Since f93b2a0424 (reftable/basics: introduce `REFTABLE_UNUSED`
annotation, 2025-02-18), the reftable library was migrated to
use an internal version of `UNUSED`, which unconditionally sets
a GNU __attribute__ to avoid warnings function parameters that
are not being used.

Make the definition conditional to prevent breaking the build
with non GNU compilers.

Reported-by: "Randall S. Becker" <rsbecker@nexbridge.com>
Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoMerge branch 'master' of https://github.com/j6t/git-gui
Junio C Hamano [Thu, 29 May 2025 16:03:01 +0000 (09:03 -0700)] 
Merge branch 'master' of https://github.com/j6t/git-gui

* 'master' of https://github.com/j6t/git-gui:
  git-gui: wire up support for the Meson build system
  git-gui: stop including GIT-VERSION-FILE file
  git-gui: extract script to generate macOS app
  git-gui: extract script to generate macOS wrapper
  git-gui: extract script to generate "tclIndex"
  git-gui: extract script to generate "git-gui"
  git-gui: drop no-op GITGUI_SCRIPT replacement
  git-gui: make output of GIT-VERSION-GEN source'able
  git-gui: prepare GIT-VERSION-GEN for out-of-tree builds
  git-gui: replace GIT-GUI-VARS with GIT-GUI-BUILD-OPTIONS

2 months agoMerge branch 'master' of https://github.com/j6t/gitk
Junio C Hamano [Thu, 29 May 2025 16:02:14 +0000 (09:02 -0700)] 
Merge branch 'master' of https://github.com/j6t/gitk

* 'master' of https://github.com/j6t/gitk:
  gitk: do not hard-code color of search results in commit list
  gitk: place file name arguments after options in msgfmt call
  gitk: Legacy widgets doesn't have combobox

2 months agol10n: tr: Update Turkish translations for 2.50
Emir SARI [Thu, 29 May 2025 08:42:21 +0000 (11:42 +0300)] 
l10n: tr: Update Turkish translations for 2.50

Signed-off-by: Emir SARI <emir_sari@icloud.com>
2 months agol10n: fr: v2.50 round 1
Jean-Noël Avila [Thu, 29 May 2025 10:58:38 +0000 (12:58 +0200)] 
l10n: fr: v2.50 round 1

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
2 months agol10n: Add full Irish translation (ga.po)
Aindriú Mac Giolla Eoin [Thu, 15 May 2025 23:25:38 +0000 (00:25 +0100)] 
l10n: Add full Irish translation (ga.po)

- Added complete Irish translation (ga.po).
- Added entry for Irish in po/TEAMS.
- Corrected email format and removed trailing whitespace.
- Translated new strings from Git 2.50.0-rc0

Signed-off-by: Aindriú Mac Giolla Eoin <aindriu80@gmail.com>
2 months agoMerge branch 'pks-meson-support' of github.com:pks-t/git-gui
Johannes Sixt [Thu, 29 May 2025 08:01:14 +0000 (10:01 +0200)] 
Merge branch 'pks-meson-support' of github.com:pks-t/git-gui

* 'pks-meson-support' of github.com:pks-t/git-gui:
  git-gui: wire up support for the Meson build system
  git-gui: stop including GIT-VERSION-FILE file
  git-gui: extract script to generate macOS app
  git-gui: extract script to generate macOS wrapper
  git-gui: extract script to generate "tclIndex"
  git-gui: extract script to generate "git-gui"
  git-gui: drop no-op GITGUI_SCRIPT replacement
  git-gui: make output of GIT-VERSION-GEN source'able
  git-gui: prepare GIT-VERSION-GEN for out-of-tree builds
  git-gui: replace GIT-GUI-VARS with GIT-GUI-BUILD-OPTIONS

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
2 months agoGit 2.48.2 v2.48.2
Taylor Blau [Wed, 28 May 2025 19:18:19 +0000 (15:18 -0400)] 
Git 2.48.2

Signed-off-by: Taylor Blau <me@ttaylorr.com>
2 months agoSync with 2.47.3
Taylor Blau [Wed, 28 May 2025 19:17:05 +0000 (15:17 -0400)] 
Sync with 2.47.3

* maint-2.47:
  Git 2.47.3
  Git 2.46.4
  Git 2.45.4
  Git 2.44.4
  Git 2.43.7
  wincred: avoid buffer overflow in wcsncat()
  bundle-uri: fix arbitrary file writes via parameter injection
  config: quote values containing CR character
  git-gui: sanitize 'exec' arguments: convert new 'cygpath' calls
  git-gui: do not mistake command arguments as redirection operators
  git-gui: introduce function git_redir for git calls with redirections
  git-gui: pass redirections as separate argument to git_read
  git-gui: pass redirections as separate argument to _open_stdout_stderr
  git-gui: convert git_read*, git_write to be non-variadic
  git-gui: override exec and open only on Windows
  gitk: sanitize 'open' arguments: revisit recently updated 'open' calls
  git-gui: use git_read in githook_read
  git-gui: sanitize $PATH on all platforms
  git-gui: break out a separate function git_read_nice
  git-gui: assure PATH has only absolute elements.
  git-gui: remove option --stderr from git_read
  git-gui: cleanup git-bash menu item
  git-gui: sanitize 'exec' arguments: background
  git-gui: avoid auto_execok in do_windows_shortcut
  git-gui: sanitize 'exec' arguments: simple cases
  git-gui: avoid auto_execok for git-bash menu item
  git-gui: treat file names beginning with "|" as relative paths
  git-gui: remove unused proc is_shellscript
  git-gui: remove git config --list handling for git < 1.5.3
  git-gui: remove special treatment of Windows from open_cmd_pipe
  git-gui: remove HEAD detachment implementation for git < 1.5.3
  git-gui: use only the configured shell
  git-gui: remove Tcl 8.4 workaround on 2>@1 redirection
  git-gui: make _shellpath usable on startup
  git-gui: use [is_Windows], not bad _shellpath
  git-gui: _which, only add .exe suffix if not present
  gitk: encode arguments correctly with "open"
  gitk: sanitize 'open' arguments: command pipeline
  gitk: collect construction of blameargs into a single conditional
  gitk: sanitize 'open' arguments: simple commands, readable and writable
  gitk: sanitize 'open' arguments: simple commands with redirections
  gitk: sanitize 'open' arguments: simple commands
  gitk: sanitize 'exec' arguments: redirect to process
  gitk: sanitize 'exec' arguments: redirections and background
  gitk: sanitize 'exec' arguments: redirections
  gitk: sanitize 'exec' arguments: 'eval exec'
  gitk: sanitize 'exec' arguments: simple cases
  gitk: have callers of diffcmd supply pipe symbol when necessary
  gitk: treat file names beginning with "|" as relative paths

2 months agoGit 2.47.3 v2.47.3
Taylor Blau [Wed, 28 May 2025 19:16:03 +0000 (15:16 -0400)] 
Git 2.47.3

Signed-off-by: Taylor Blau <me@ttaylorr.com>
2 months agoSync with 2.46.4
Taylor Blau [Wed, 28 May 2025 18:59:31 +0000 (14:59 -0400)] 
Sync with 2.46.4

* maint-2.46:
  Git 2.46.4
  Git 2.45.4
  Git 2.44.4
  Git 2.43.7
  wincred: avoid buffer overflow in wcsncat()
  bundle-uri: fix arbitrary file writes via parameter injection
  config: quote values containing CR character
  git-gui: sanitize 'exec' arguments: convert new 'cygpath' calls
  git-gui: do not mistake command arguments as redirection operators
  git-gui: introduce function git_redir for git calls with redirections
  git-gui: pass redirections as separate argument to git_read
  git-gui: pass redirections as separate argument to _open_stdout_stderr
  git-gui: convert git_read*, git_write to be non-variadic
  git-gui: override exec and open only on Windows
  gitk: sanitize 'open' arguments: revisit recently updated 'open' calls
  git-gui: use git_read in githook_read
  git-gui: sanitize $PATH on all platforms
  git-gui: break out a separate function git_read_nice
  git-gui: assure PATH has only absolute elements.
  git-gui: remove option --stderr from git_read
  git-gui: cleanup git-bash menu item
  git-gui: sanitize 'exec' arguments: background
  git-gui: avoid auto_execok in do_windows_shortcut
  git-gui: sanitize 'exec' arguments: simple cases
  git-gui: avoid auto_execok for git-bash menu item
  git-gui: treat file names beginning with "|" as relative paths
  git-gui: remove unused proc is_shellscript
  git-gui: remove git config --list handling for git < 1.5.3
  git-gui: remove special treatment of Windows from open_cmd_pipe
  git-gui: remove HEAD detachment implementation for git < 1.5.3
  git-gui: use only the configured shell
  git-gui: remove Tcl 8.4 workaround on 2>@1 redirection
  git-gui: make _shellpath usable on startup
  git-gui: use [is_Windows], not bad _shellpath
  git-gui: _which, only add .exe suffix if not present
  gitk: encode arguments correctly with "open"
  gitk: sanitize 'open' arguments: command pipeline
  gitk: collect construction of blameargs into a single conditional
  gitk: sanitize 'open' arguments: simple commands, readable and writable
  gitk: sanitize 'open' arguments: simple commands with redirections
  gitk: sanitize 'open' arguments: simple commands
  gitk: sanitize 'exec' arguments: redirect to process
  gitk: sanitize 'exec' arguments: redirections and background
  gitk: sanitize 'exec' arguments: redirections
  gitk: sanitize 'exec' arguments: 'eval exec'
  gitk: sanitize 'exec' arguments: simple cases
  gitk: have callers of diffcmd supply pipe symbol when necessary
  gitk: treat file names beginning with "|" as relative paths

Signed-off-by: Taylor Blau <me@ttaylorr.com>
2 months agoGit 2.46.4 v2.46.4
Taylor Blau [Wed, 28 May 2025 18:58:48 +0000 (14:58 -0400)] 
Git 2.46.4

Signed-off-by: Taylor Blau <me@ttaylorr.com>
2 months agoSync with 2.45.4
Taylor Blau [Wed, 28 May 2025 18:57:08 +0000 (14:57 -0400)] 
Sync with 2.45.4

* maint-2.45:
  Git 2.45.4
  Git 2.44.4
  Git 2.43.7
  wincred: avoid buffer overflow in wcsncat()
  bundle-uri: fix arbitrary file writes via parameter injection
  config: quote values containing CR character
  git-gui: sanitize 'exec' arguments: convert new 'cygpath' calls
  git-gui: do not mistake command arguments as redirection operators
  git-gui: introduce function git_redir for git calls with redirections
  git-gui: pass redirections as separate argument to git_read
  git-gui: pass redirections as separate argument to _open_stdout_stderr
  git-gui: convert git_read*, git_write to be non-variadic
  git-gui: override exec and open only on Windows
  gitk: sanitize 'open' arguments: revisit recently updated 'open' calls
  git-gui: use git_read in githook_read
  git-gui: sanitize $PATH on all platforms
  git-gui: break out a separate function git_read_nice
  git-gui: assure PATH has only absolute elements.
  git-gui: remove option --stderr from git_read
  git-gui: cleanup git-bash menu item
  git-gui: sanitize 'exec' arguments: background
  git-gui: avoid auto_execok in do_windows_shortcut
  git-gui: sanitize 'exec' arguments: simple cases
  git-gui: avoid auto_execok for git-bash menu item
  git-gui: treat file names beginning with "|" as relative paths
  git-gui: remove unused proc is_shellscript
  git-gui: remove git config --list handling for git < 1.5.3
  git-gui: remove special treatment of Windows from open_cmd_pipe
  git-gui: remove HEAD detachment implementation for git < 1.5.3
  git-gui: use only the configured shell
  git-gui: remove Tcl 8.4 workaround on 2>@1 redirection
  git-gui: make _shellpath usable on startup
  git-gui: use [is_Windows], not bad _shellpath
  git-gui: _which, only add .exe suffix if not present
  gitk: encode arguments correctly with "open"
  gitk: sanitize 'open' arguments: command pipeline
  gitk: collect construction of blameargs into a single conditional
  gitk: sanitize 'open' arguments: simple commands, readable and writable
  gitk: sanitize 'open' arguments: simple commands with redirections
  gitk: sanitize 'open' arguments: simple commands
  gitk: sanitize 'exec' arguments: redirect to process
  gitk: sanitize 'exec' arguments: redirections and background
  gitk: sanitize 'exec' arguments: redirections
  gitk: sanitize 'exec' arguments: 'eval exec'
  gitk: sanitize 'exec' arguments: simple cases
  gitk: have callers of diffcmd supply pipe symbol when necessary
  gitk: treat file names beginning with "|" as relative paths

Signed-off-by: Taylor Blau <me@ttaylorr.com>
2 months agoGit 2.45.4 v2.45.4
Taylor Blau [Wed, 28 May 2025 18:54:04 +0000 (14:54 -0400)] 
Git 2.45.4

Signed-off-by: Taylor Blau <me@ttaylorr.com>
2 months agoSync with 2.44.4
Taylor Blau [Wed, 28 May 2025 18:51:38 +0000 (14:51 -0400)] 
Sync with 2.44.4

* maint-2.44:
  Git 2.44.4
  Git 2.43.7
  wincred: avoid buffer overflow in wcsncat()
  bundle-uri: fix arbitrary file writes via parameter injection
  config: quote values containing CR character
  git-gui: sanitize 'exec' arguments: convert new 'cygpath' calls
  git-gui: do not mistake command arguments as redirection operators
  git-gui: introduce function git_redir for git calls with redirections
  git-gui: pass redirections as separate argument to git_read
  git-gui: pass redirections as separate argument to _open_stdout_stderr
  git-gui: convert git_read*, git_write to be non-variadic
  git-gui: override exec and open only on Windows
  gitk: sanitize 'open' arguments: revisit recently updated 'open' calls
  git-gui: use git_read in githook_read
  git-gui: sanitize $PATH on all platforms
  git-gui: break out a separate function git_read_nice
  git-gui: assure PATH has only absolute elements.
  git-gui: remove option --stderr from git_read
  git-gui: cleanup git-bash menu item
  git-gui: sanitize 'exec' arguments: background
  git-gui: avoid auto_execok in do_windows_shortcut
  git-gui: sanitize 'exec' arguments: simple cases
  git-gui: avoid auto_execok for git-bash menu item
  git-gui: treat file names beginning with "|" as relative paths
  git-gui: remove unused proc is_shellscript
  git-gui: remove git config --list handling for git < 1.5.3
  git-gui: remove special treatment of Windows from open_cmd_pipe
  git-gui: remove HEAD detachment implementation for git < 1.5.3
  git-gui: use only the configured shell
  git-gui: remove Tcl 8.4 workaround on 2>@1 redirection
  git-gui: make _shellpath usable on startup
  git-gui: use [is_Windows], not bad _shellpath
  git-gui: _which, only add .exe suffix if not present
  gitk: encode arguments correctly with "open"
  gitk: sanitize 'open' arguments: command pipeline
  gitk: collect construction of blameargs into a single conditional
  gitk: sanitize 'open' arguments: simple commands, readable and writable
  gitk: sanitize 'open' arguments: simple commands with redirections
  gitk: sanitize 'open' arguments: simple commands
  gitk: sanitize 'exec' arguments: redirect to process
  gitk: sanitize 'exec' arguments: redirections and background
  gitk: sanitize 'exec' arguments: redirections
  gitk: sanitize 'exec' arguments: 'eval exec'
  gitk: sanitize 'exec' arguments: simple cases
  gitk: have callers of diffcmd supply pipe symbol when necessary
  gitk: treat file names beginning with "|" as relative paths

Signed-off-by: Taylor Blau <me@ttaylorr.com>
2 months agoGit 2.44.4 v2.44.4
Taylor Blau [Wed, 28 May 2025 18:51:12 +0000 (14:51 -0400)] 
Git 2.44.4

Signed-off-by: Taylor Blau <me@ttaylorr.com>
2 months agoSync with 2.43.7
Taylor Blau [Wed, 28 May 2025 18:47:12 +0000 (14:47 -0400)] 
Sync with 2.43.7

* maint-2.43:
  Git 2.43.7
  wincred: avoid buffer overflow in wcsncat()
  bundle-uri: fix arbitrary file writes via parameter injection
  config: quote values containing CR character
  git-gui: sanitize 'exec' arguments: convert new 'cygpath' calls
  git-gui: do not mistake command arguments as redirection operators
  git-gui: introduce function git_redir for git calls with redirections
  git-gui: pass redirections as separate argument to git_read
  git-gui: pass redirections as separate argument to _open_stdout_stderr
  git-gui: convert git_read*, git_write to be non-variadic
  git-gui: override exec and open only on Windows
  gitk: sanitize 'open' arguments: revisit recently updated 'open' calls
  git-gui: use git_read in githook_read
  git-gui: sanitize $PATH on all platforms
  git-gui: break out a separate function git_read_nice
  git-gui: assure PATH has only absolute elements.
  git-gui: remove option --stderr from git_read
  git-gui: cleanup git-bash menu item
  git-gui: sanitize 'exec' arguments: background
  git-gui: avoid auto_execok in do_windows_shortcut
  git-gui: sanitize 'exec' arguments: simple cases
  git-gui: avoid auto_execok for git-bash menu item
  git-gui: treat file names beginning with "|" as relative paths
  git-gui: remove unused proc is_shellscript
  git-gui: remove git config --list handling for git < 1.5.3
  git-gui: remove special treatment of Windows from open_cmd_pipe
  git-gui: remove HEAD detachment implementation for git < 1.5.3
  git-gui: use only the configured shell
  git-gui: remove Tcl 8.4 workaround on 2>@1 redirection
  git-gui: make _shellpath usable on startup
  git-gui: use [is_Windows], not bad _shellpath
  git-gui: _which, only add .exe suffix if not present
  gitk: encode arguments correctly with "open"
  gitk: sanitize 'open' arguments: command pipeline
  gitk: collect construction of blameargs into a single conditional
  gitk: sanitize 'open' arguments: simple commands, readable and writable
  gitk: sanitize 'open' arguments: simple commands with redirections
  gitk: sanitize 'open' arguments: simple commands
  gitk: sanitize 'exec' arguments: redirect to process
  gitk: sanitize 'exec' arguments: redirections and background
  gitk: sanitize 'exec' arguments: redirections
  gitk: sanitize 'exec' arguments: 'eval exec'
  gitk: sanitize 'exec' arguments: simple cases
  gitk: have callers of diffcmd supply pipe symbol when necessary
  gitk: treat file names beginning with "|" as relative paths

Signed-off-by: Taylor Blau <me@ttaylorr.com>
2 months agoGit 2.43.7 v2.43.7
Taylor Blau [Wed, 28 May 2025 18:42:12 +0000 (14:42 -0400)] 
Git 2.43.7

Signed-off-by: Taylor Blau <me@ttaylorr.com>
2 months agoMerge branch 'tb/wincred-buffer-overflow' into maint-2.43
Taylor Blau [Wed, 28 May 2025 18:33:35 +0000 (14:33 -0400)] 
Merge branch 'tb/wincred-buffer-overflow' into maint-2.43

This merges in the fix for CVE-2025-48386.

* tb/wincred-buffer-overflow:
  wincred: avoid buffer overflow in wcsncat()

Signed-off-by: Taylor Blau <me@ttaylorr.com>
2 months agofast-export: --signed-commits is experimental
Junio C Hamano [Wed, 28 May 2025 17:29:19 +0000 (10:29 -0700)] 
fast-export: --signed-commits is experimental

As the design of signature handling is still being discussed, it is
likely that the data stream produced by the code in Git 2.50 would
have to be changed in such a way that is not backward compatible.

Mark the feature as experimental and discourge its use for now.

Also flip the default on the generation side to "strip"; users of
existing versions would not have passed --signed-commits=strip and
will be broken by this change if the default is made to abort, and
will be encouraged by the error message to produce data stream with
future breakage guarantees by passing --signed-commits option.

As we tone down the default behaviour, we no longer need the
FAST_EXPORT_SIGNED_COMMITS_NOABORT environment variable, which was
not discoverable enough.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agowincred: avoid buffer overflow in wcsncat()
Taylor Blau [Mon, 19 May 2025 22:30:29 +0000 (18:30 -0400)] 
wincred: avoid buffer overflow in wcsncat()

The wincred credential helper uses a static buffer ("target") as a
unique key for storing and comparing against internal storage. It does
this by building up a string is supposed to look like:

    git:$PROTOCOL://$USERNAME@$HOST/@PATH

However, the static "target" buffer is declared as a wide string with no
more than 1,024 wide characters. The first call to wcsncat() is almost
correct (it copies no more than ARRAY_SIZE(target) wchar_t's), but does
not account for the trailing NUL, introducing an off-by-one error.

But subsequent calls to wcsncat() have an additional problem on top of
the off-by-one. They do not account for the length of the existing
wide string being built up in 'target'. So the following:

    $ perl -e '
        my $x = "x" x 1_000;
        print "protocol=$x\nhost=$x\nusername=$x\npath=$x\n"
      ' |
      C\:/Program\ Files/Git/mingw64/libexec/git-core/git-credential-wincred.exe get

will result in a segmentation fault from over-filling buffer.

This bug is as old as the wincred helper itself, dating back to
a6253da0f3 (contrib: add win32 credential-helper, 2012-07-27). Commit
8b2d219a3d (wincred: improve compatibility with windows versions,
2013-01-10) replaced the use of strncat() with wcsncat(), but retained
the buggy behavior.

Fix this by using a "target_append()" helper which accounts for both the
length of the existing string within the buffer, as well as the trailing
NUL character.

Reported-by: David Leadbeater <dgl@dgl.cx>
Helped-by: David Leadbeater <dgl@dgl.cx>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
2 months agoMerge branch 'jt/config-quote-cr' into maint-2.43
Taylor Blau [Wed, 28 May 2025 16:55:15 +0000 (12:55 -0400)] 
Merge branch 'jt/config-quote-cr' into maint-2.43

This merges in the fix for CVE-2025-48384.

* jt/config-quote-cr:
  config: quote values containing CR character

Signed-off-by: Taylor Blau <me@ttaylorr.com>
2 months agoMerge branch 'ps/bundle-uri-arbitrary-writes' into maint-2.43
Taylor Blau [Wed, 28 May 2025 16:53:52 +0000 (12:53 -0400)] 
Merge branch 'ps/bundle-uri-arbitrary-writes' into maint-2.43

This merges in the fix for CVE-2025-48385.

* ps/bundle-uri-arbitrary-writes:
  bundle-uri: fix arbitrary file writes via parameter injection

Signed-off-by: Taylor Blau <me@ttaylorr.com>
2 months agoMerge branch 'js/gitk-git-gui-harden-exec-open' into maint-2.43
Taylor Blau [Fri, 23 May 2025 21:17:06 +0000 (17:17 -0400)] 
Merge branch 'js/gitk-git-gui-harden-exec-open' into maint-2.43

This merges in fixes for CVE-2025-27614, CVE-2025-27613, CVE-2025-46334,
and CVE-2025-46835 targeting Gitk and Git GUI.

* js/gitk-git-gui-harden-exec-open: (41 commits)
  git-gui: sanitize 'exec' arguments: convert new 'cygpath' calls
  git-gui: do not mistake command arguments as redirection operators
  git-gui: introduce function git_redir for git calls with redirections
  git-gui: pass redirections as separate argument to git_read
  git-gui: pass redirections as separate argument to _open_stdout_stderr
  git-gui: convert git_read*, git_write to be non-variadic
  git-gui: override exec and open only on Windows
  gitk: sanitize 'open' arguments: revisit recently updated 'open' calls
  git-gui: use git_read in githook_read
  git-gui: sanitize $PATH on all platforms
  git-gui: break out a separate function git_read_nice
  git-gui: assure PATH has only absolute elements.
  git-gui: remove option --stderr from git_read
  git-gui: cleanup git-bash menu item
  git-gui: sanitize 'exec' arguments: background
  git-gui: avoid auto_execok in do_windows_shortcut
  git-gui: sanitize 'exec' arguments: simple cases
  git-gui: avoid auto_execok for git-bash menu item
  git-gui: treat file names beginning with "|" as relative paths
  git-gui: remove unused proc is_shellscript
  git-gui: remove git config --list handling for git < 1.5.3
  git-gui: remove special treatment of Windows from open_cmd_pipe
  git-gui: remove HEAD detachment implementation for git < 1.5.3
  git-gui: use only the configured shell
  git-gui: remove Tcl 8.4 workaround on 2>@1 redirection
  git-gui: make _shellpath usable on startup
  git-gui: use [is_Windows], not bad _shellpath
  git-gui: _which, only add .exe suffix if not present
  gitk: encode arguments correctly with "open"
  gitk: sanitize 'open' arguments: command pipeline
  gitk: collect construction of blameargs into a single conditional
  gitk: sanitize 'open' arguments: simple commands, readable and writable
  gitk: sanitize 'open' arguments: simple commands with redirections
  gitk: sanitize 'open' arguments: simple commands
  gitk: sanitize 'exec' arguments: redirect to process
  gitk: sanitize 'exec' arguments: redirections and background
  gitk: sanitize 'exec' arguments: redirections
  gitk: sanitize 'exec' arguments: 'eval exec'
  gitk: sanitize 'exec' arguments: simple cases
  gitk: have callers of diffcmd supply pipe symbol when necessary
  gitk: treat file names beginning with "|" as relative paths
  ...

Signed-off-by: Taylor Blau <me@ttaylorr.com>
2 months agoGit 2.50-rc0 v2.50.0-rc0
Junio C Hamano [Wed, 28 May 2025 14:59:41 +0000 (07:59 -0700)] 
Git 2.50-rc0

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoMerge branch 'jt/receive-pack-skip-connectivity-check'
Junio C Hamano [Wed, 28 May 2025 14:59:56 +0000 (07:59 -0700)] 
Merge branch 'jt/receive-pack-skip-connectivity-check'

"git receive-pack" optionally learns not to care about connectivity
check, which can be useful when the repository arranges to ensure
connectivity by some other means.

* jt/receive-pack-skip-connectivity-check:
  builtin/receive-pack: add option to skip connectivity check
  t5410: test receive-pack connectivity check

2 months agoMerge branch 'kn/passing-leak-tests'
Junio C Hamano [Wed, 28 May 2025 14:59:55 +0000 (07:59 -0700)] 
Merge branch 'kn/passing-leak-tests'

Remove the leftover hints to the test framework to mark tests that
do not pass the leak checker tests, as they should no longer be
needed.

* kn/passing-leak-tests:
  t: remove unexpected SANITIZE_LEAK variables

2 months agomidx: stop repeatedly looking up nonexistent packfiles
Patrick Steinhardt [Wed, 28 May 2025 12:24:11 +0000 (14:24 +0200)] 
midx: stop repeatedly looking up nonexistent packfiles

The multi-pack index acts as a cache across a set of packfiles so that
we can quickly look up which of those packfiles contains a given object.
As such, the multi-pack index naturally needs to be updated every time
one of the packfiles goes away, or otherwise the multi-pack index has
grown stale.

A stale multi-pack index should be handled gracefully by Git though, and
in fact it is: if the indexed pack cannot be found we simply ignore it
and eventually we fall back to doing the object lookup by just iterating
through all packs, even if those aren't indexed.

But while this fallback works, it has one significant downside: we don't
cache the fact that a pack has vanished. This leads to us repeatedly
trying to look up the same pack only to realize that it (still) doesn't
exist.

This issue can be easily demonstrated by creating a repository with a
stale multi-pack index and a couple of objects. We do so by creating a
repository with two packfiles, both of which are indexed by the
multi-pack index, and then repack those two packfiles. Note that we have
to move the multi-pack-index before doing the final repack, as Git knows
to delete it otherwise.

    $ git init repo
    $ cd repo/
    $ git config set maintenance.auto false
    $ for i in $(seq 1000); do printf "%d-original" $i >file-$i; done
    $ git add .
    $ git commit -moriginal
    $ git repack -dl
    $ for i in $(seq 1000); do printf "%d-modified" $i >file-$i; done
    $ git commit -a -mmodified
    $ git repack -dl
    $ git multi-pack-index write
    $ mv .git/objects/pack/multi-pack-index .
    $ git repack -Adl
    $ mv multi-pack-index .git/objects/pack/

Commands that cause a lot of objects lookups will now repeatedly invoke
`add_packed_git()`, which leads to three failed access(3p) calls as well
as one failed stat(3p) call. The following strace for example is done
for `git log --patch` in the above repository:

    % time     seconds  usecs/call     calls    errors syscall
    ------ ----------- ----------- --------- --------- ----------------
     74.67    0.024693           1     18038     18031 access
     25.33    0.008378           1      6045      6017 newfstatat
    ------ ----------- ----------- --------- --------- ----------------
    100.00    0.033071           1     24083     24048 total

Fix the issue by introducing a negative lookup cache for indexed packs.
This cache works by simply storing an invalid pointer for a missing pack
when `prepare_midx_pack()` fails to look up the pack. Most users of the
`packs` array don't need to be adjusted, either, as they all know to
call `prepare_midx_pack()` before accessing the array.

With this change in place we can now see a significantly reduced number
of syscalls:

    % time     seconds  usecs/call     calls    errors syscall
    ------ ----------- ----------- --------- --------- ----------------
     73.58    0.000323           5        60        28 newfstatat
     26.42    0.000116           5        23        16 access
    ------ ----------- ----------- --------- --------- ----------------
    100.00    0.000439           5        83        44 total

Furthermore, this change also results in a speedup:

    Benchmark 1: git log --patch (revision = HEAD~)
      Time (mean ± σ):      50.4 ms ±   2.5 ms    [User: 22.0 ms, System: 24.4 ms]
      Range (min … max):    45.4 ms …  54.9 ms    53 runs

    Benchmark 2: git log --patch (revision = HEAD)
      Time (mean ± σ):      12.7 ms ±   0.4 ms    [User: 11.1 ms, System: 1.6 ms]
      Range (min … max):    12.4 ms …  15.0 ms    191 runs

    Summary
      git log --patch (revision = HEAD) ran
        3.96 ± 0.22 times faster than git log --patch (revision = HEAD~)

In the end, it should in theory never be necessary to have this negative
lookup cache given that we know to update the multi-pack index together
with repacks. But as the change is quite contained and as the speedup
can be significant as demonstrated above, it does feel sensible to have
the negative lookup cache regardless.

Based-on-patch-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 agopackfile: explain ordering of how we look up auxiliary pack files
Patrick Steinhardt [Wed, 28 May 2025 12:24:10 +0000 (14:24 +0200)] 
packfile: explain ordering of how we look up auxiliary pack files

When adding a packfile to an object database we perform four syscalls:

  - Three calls to access(3p) are done to check for auxiliary data
    structures.

  - One call to stat(3p) is done to check for the ".pack" itself.

One curious bit is that we perform the access(3p) calls before checking
for the packfile itself, but if the packfile doesn't exist we discard
all results. The access(3p) calls are thus essentially wasted, so one
may be triggered to reorder those calls so that we can short-circuit the
other syscalls in case the packfile does not exist.

The order in which we look up files is quite important though to help
avoid races:

  - When installing a packfile we move auxiliary data structures into
    place before we install the ".idx" file.

  - When deleting a packfile we first delete the ".idx" and ".pack"
    files before deleting auxiliary data structures.

As such, to avoid any races with concurrently created or deleted packs
we need to make sure that we _first_ read auxiliary data structures
before we read the corresponding ".idx" or ".pack" file. Otherwise it
may easily happen that we return a populated but misclassified pack.

Add a comment to `add_packed_git()` to make future readers aware of this
ordering requirement.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: notes: use stuck form throughout
Kristoffer Haugsbakk [Tue, 27 May 2025 21:19:38 +0000 (23:19 +0200)] 
doc: notes: use stuck form throughout

gitcli(7) recommends the *stuck form*.  `--ref` is the only one which
does not use it.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: notes: treat --stdin equally between copy/remove
Kristoffer Haugsbakk [Tue, 27 May 2025 21:19:37 +0000 (23:19 +0200)] 
doc: notes: treat --stdin equally between copy/remove

46538012d94 (notes remove: --stdin reads from the standard input,
2011-05-18) added `--stdin` for the `remove` subcommand, documenting it
in the “Options” section.  But `copy --stdin` was added before that, in
160baa0d9cb (notes: implement 'git notes copy --stdin', 2010-03-12).

Treat this option equally between the two subcommands:

• remove: mention `--stdin` on the subcommand as well, like for `copy`
• copy: mention it as well under the option documentation

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: notes: point out copy --stdin use with argv
Kristoffer Haugsbakk [Tue, 27 May 2025 21:19:36 +0000 (23:19 +0200)] 
doc: notes: point out copy --stdin use with argv

Unlike `remove --stdin`, this option cannot be combined with object
names given via the command line.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: notes: clearly state that --stripspace is the default
Kristoffer Haugsbakk [Tue, 27 May 2025 21:19:35 +0000 (23:19 +0200)] 
doc: notes: clearly state that --stripspace is the default

Clearly state when which of the regular and negated form of the
option take effect.[1]

Also mention the subtle behavior that occurs when you mix options like
`-m` and `-C`, including a note that it might be fixed in the future.
The topic was brought up on v8 of the `--separator` series.[2][3]

[1]: https://lore.kernel.org/git/xmqqcyct1mtq.fsf@gitster.g/
[2]: https://lore.kernel.org/git/xmqq4jp326oj.fsf@gitster.g/
† 3: v11 was the version that landed

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: notes: remove stripspace discussion from other options
Kristoffer Haugsbakk [Tue, 27 May 2025 21:19:34 +0000 (23:19 +0200)] 
doc: notes: remove stripspace discussion from other options

Cleaning up whitespace in metadata is typical porcelain behavior and
this default does not need to be pointed out.[1]  Only speak up when
the default `--stripspace` is not used.

Also remove all misleading mentions of comment lines in the process;
see the previous commit.

Also remove the period that trails the parenthetical here.

† 1: See `-F` in git-commit(1) which has nothing to say about whitespace
    cleanup.  The cleanup discussion is on `--cleanup`.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: notes: rework --[no-]stripspace
Kristoffer Haugsbakk [Tue, 27 May 2025 21:19:33 +0000 (23:19 +0200)] 
doc: notes: rework --[no-]stripspace

Document this option by copying the bullet list from git-stripspace(1).
A bullet list is cleaner when there are this many points to consider.
We also get a more standardized description of the multiple-blank-lines
behavior.  Compare the repeating (git-notes(1)):

    empty lines other than a single line between paragraphs

With (git-stripspace(1)):

    multiple consecutive empty lines

And:

    leading [...] whitespace

With:

    empty lines from the beginning

Leading whitespace in the form of spaces (indentation) are not removed.
However, empty lines at the start of the message are removed.

Note that we drop the mentions of comment line handling because they are
wrong; this option does not control how lines which can be recognized as
comment lines are handled.  Only interactivity controls that:

• Comment lines are stripped after editing interactively
• Lines which could be recognized as comment lines are left alone when
  the message is given non-interactively

So it is misleading to document the comment line behavior on
this option.

Further, the text is wrong:

    Lines starting with `#` will be stripped out in non-editor cases
    like `-m`, [...]

Comment lines are still indirectly discussed on other options.  We will
deal with them in the next commit.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: notes: split out options with negated forms
Kristoffer Haugsbakk [Tue, 27 May 2025 21:19:32 +0000 (23:19 +0200)] 
doc: notes: split out options with negated forms

Split these out so that they are easier to search for.[1]

[1]: https://lore.kernel.org/git/xmqqcyct1mtq.fsf@gitster.g/

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: config: mention core.commentChar on commit.cleanup
Kristoffer Haugsbakk [Tue, 27 May 2025 21:19:31 +0000 (23:19 +0200)] 
doc: config: mention core.commentChar on commit.cleanup

Mention it in parentheses since we are in a configuration context.
Refer to the default as such, not as “the” character.

Also don’t mention `#` again; just say “comment character”.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: stripspace: mention where the default comes from
Kristoffer Haugsbakk [Tue, 27 May 2025 21:19:30 +0000 (23:19 +0200)] 
doc: stripspace: mention where the default comes from

Also quote `#` in line with the modern formatting convention.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoThe eighteenth batch
Junio C Hamano [Tue, 27 May 2025 20:58:38 +0000 (13:58 -0700)] 
The eighteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoMerge branch 'kj/my-first-contribution-updates'
Junio C Hamano [Tue, 27 May 2025 20:59:12 +0000 (13:59 -0700)] 
Merge branch 'kj/my-first-contribution-updates'

Doc updates.

* kj/my-first-contribution-updates:
  docs: replace git_config to repo_config
  docs: clarify cmd_psuh signature and explain UNUSED macro
  docs: remove unused mentoring mailing list reference

2 months agoMerge branch 'es/meson-configure-build-options-fix'
Junio C Hamano [Tue, 27 May 2025 20:59:11 +0000 (13:59 -0700)] 
Merge branch 'es/meson-configure-build-options-fix'

Build procedure updates.

* es/meson-configure-build-options-fix:
  meson: reformat default options to workaround bug in `meson configure`

2 months agoMerge branch 'en/sequencer-comment-messages'
Junio C Hamano [Tue, 27 May 2025 20:59:11 +0000 (13:59 -0700)] 
Merge branch 'en/sequencer-comment-messages'

Prefix '#' to the commit title in the "rebase -i" todo file, just
like a merge commit being replayed.

* en/sequencer-comment-messages:
  sequencer: make it clearer that commit descriptions are just comments

2 months agoMerge branch 'js/misc-fixes'
Junio C Hamano [Tue, 27 May 2025 20:59:10 +0000 (13:59 -0700)] 
Merge branch 'js/misc-fixes'

Assorted fixes for issues found with CodeQL.

* js/misc-fixes:
  sequencer: stop pretending that an assignment is a condition
  bundle-uri: avoid using undefined output of `sscanf()`
  commit-graph: avoid using stale stack addresses
  trace2: avoid "futile conditional"
  Avoid redundant conditions
  fetch: avoid unnecessary work when there is no current branch
  has_dir_name(): make code more obvious
  upload-pack: rename `enum` to reflect the operation
  commit-graph: avoid malloc'ing a local variable
  fetch: carefully clear local variable's address after use
  commit: simplify code

2 months agoMerge branch 'sj/use-mmap-to-check-packed-refs'
Junio C Hamano [Tue, 27 May 2025 20:59:10 +0000 (13:59 -0700)] 
Merge branch 'sj/use-mmap-to-check-packed-refs'

The code path to access the "packed-refs" file while "fsck" is
taught to mmap the file, instead of reading the whole file in the
memory.

* sj/use-mmap-to-check-packed-refs:
  packed-backend: mmap large "packed-refs" file during fsck
  packed-backend: extract snapshot allocation in `load_contents`
  packed-backend: fsck should warn when "packed-refs" file is empty

2 months agoMerge branch 'jc/doc-synopsis-option-markup'
Junio C Hamano [Tue, 27 May 2025 20:59:10 +0000 (13:59 -0700)] 
Merge branch 'jc/doc-synopsis-option-markup'

Doc mark-up fixes.

* jc/doc-synopsis-option-markup:
  git-var doc: fix usage of $ENV_VAR vs ENV_VAR
  git-verify-* doc: update mark-up of synopsis option descriptions
  git-{var,write-tree} docs: update mark-up of synopsis option descriptions
  git-daemon doc: update mark-up of synopsis option descriptions

2 months agoMerge branch 'ds/sparse-apply-add-p'
Junio C Hamano [Tue, 27 May 2025 20:59:09 +0000 (13:59 -0700)] 
Merge branch 'ds/sparse-apply-add-p'

"git apply" and "git add -i/-p" code paths no longer unnecessarily
expand sparse-index while working.

* ds/sparse-apply-add-p:
  p2000: add performance test for patch-mode commands
  reset: integrate sparse index with --patch
  git add: make -p/-i aware of sparse index
  apply: integrate with the sparse index

2 months agoMerge branch 'rj/build-tweaks-part2'
Junio C Hamano [Tue, 27 May 2025 20:59:09 +0000 (13:59 -0700)] 
Merge branch 'rj/build-tweaks-part2'

Updates to meson-based build procedure.

* rj/build-tweaks-part2:
  configure.ac: upgrade to a compilation check for sysinfo
  meson.build: correct setting of GIT_EXEC_PATH
  meson: correct path to system config/attribute files
  meson: correct install location of YAML.pm
  meson.build: quote the GITWEBDIR build configuration

2 months agoMerge branch 'en/merge-tree-check'
Junio C Hamano [Tue, 27 May 2025 20:59:08 +0000 (13:59 -0700)] 
Merge branch 'en/merge-tree-check'

"git merge-tree" learned an option to see if it resolves cleanly
without actually creating a result.

* en/merge-tree-check:
  merge-tree: add a new --quiet flag
  merge-ort: add a new mergeability_only option

2 months agoMerge branch 'jk/no-funny-object-types'
Junio C Hamano [Tue, 27 May 2025 20:59:08 +0000 (13:59 -0700)] 
Merge branch 'jk/no-funny-object-types'

Support to create a loose object file with unknown object type has
been dropped.

* jk/no-funny-object-types:
  object-file: drop support for writing objects with unknown types
  hash-object: handle --literally with OPT_NEGBIT
  hash-object: merge HASH_* and INDEX_* flags
  hash-object: stop allowing unknown types
  t: add lib-loose.sh
  t/helper: add zlib test-tool
  oid_object_info(): drop type_name strbuf
  fsck: stop using object_info->type_name strbuf
  oid_object_info_convert(): stop using string for object type
  cat-file: use type enum instead of buffer for -t option
  object-file: drop OBJECT_INFO_ALLOW_UNKNOWN_TYPE flag
  cat-file: make --allow-unknown-type a noop
  object-file.h: fix typo in variable declaration

2 months agoMerge branch 'ly/commit-graph-fill-oids-leakfix'
Junio C Hamano [Tue, 27 May 2025 20:59:07 +0000 (13:59 -0700)] 
Merge branch 'ly/commit-graph-fill-oids-leakfix'

Leakfix.

* ly/commit-graph-fill-oids-leakfix:
  commit-graph: fix memory leak when `fill_oids_from_packs()` fails

2 months agoMerge branch 'ly/sequencer-rearrange-leakfix'
Junio C Hamano [Tue, 27 May 2025 20:59:07 +0000 (13:59 -0700)] 
Merge branch 'ly/sequencer-rearrange-leakfix'

Leakfix.

* ly/sequencer-rearrange-leakfix:
  sequencer: fix memory leak if `todo_list_rearrange_squash()` failed

2 months agoMerge branch 'ly/mailinfo-decode-header-leakfix'
Junio C Hamano [Tue, 27 May 2025 20:59:06 +0000 (13:59 -0700)] 
Merge branch 'ly/mailinfo-decode-header-leakfix'

Leakfix.

* ly/mailinfo-decode-header-leakfix:
  mailinfo: fix pointential memory leak if `decode_header` failed

2 months agoMerge branch 'md/userdiff-bash-shell-function'
Junio C Hamano [Tue, 27 May 2025 20:59:06 +0000 (13:59 -0700)] 
Merge branch 'md/userdiff-bash-shell-function'

The userdiff pattern for shell scripts has been updated to cope
with more bash-isms.

* md/userdiff-bash-shell-function:
  userdiff: extend Bash pattern to cover more shell function forms

2 months agocvsserver: remove unused escapeRefName function
Ondřej Pohořelský [Mon, 26 May 2025 13:48:25 +0000 (13:48 +0000)] 
cvsserver: remove unused escapeRefName function

Function 'escapeRefName' introduced in 51a7e6dbc9 has never been used.

Despite being dead code, changes in Perl 5.41.4 exposed precedence
warning within its logic, which then caused test failures in t9402 by
logging the warnings to stderr while parsing the code. The affected
tests are t9402.30, t9402.31, t9402.32 and t9402.34.

Remove this unused function to simplify the codebase and stop the
warnings and test failures. Its corresponding unescapeRefName function,
which remains in use, has had its comments updated.

Reported-by: Jitka Plesnikova <jplesnik@redhat.com>
Signed-off-by: Ondřej Pohořelský <opohorel@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: convert git-switch manpage to new synopsis style
Jean-Noël Avila [Sun, 25 May 2025 20:27:09 +0000 (20:27 +0000)] 
doc: convert git-switch manpage to new synopsis style

- Switch the synopsis to a synopsis block which will automatically
  format placeholders in italics and keywords in monospace
- Use _<placeholder>_ instead of <placeholder> in the description
- Use `backticks` for keywords and more complex option
descriptions. The new rendering engine will apply synopsis rules to
these spans.

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: convert git-mergetool options to new synopsis style
Jean-Noël Avila [Sun, 25 May 2025 20:27:08 +0000 (20:27 +0000)] 
doc: convert git-mergetool options to new synopsis style

- Use _<placeholder>_ instead of <placeholder> in the description
- Use `backticks` for keywords and more complex option
descriptions. The new rendering engine will apply synopsis rules to
these spans.

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: convert git-mergetool manpage to new synopsis style
Jean-Noël Avila [Sun, 25 May 2025 20:27:07 +0000 (20:27 +0000)] 
doc: convert git-mergetool manpage to new synopsis style

- Switch the synopsis to a synopsis block which will automatically
  format placeholders in italics and keywords in monospace
- Use _<placeholder>_ instead of <placeholder> in the description
- Use `backticks` for keywords and more complex option
descriptions. The new rendering engine will apply synopsis rules to
these spans.

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: switch merge config description to new synopsis format
Jean-Noël Avila [Sun, 25 May 2025 20:27:06 +0000 (20:27 +0000)] 
doc: switch merge config description to new synopsis format

- Use _<placeholder>_ instead of <placeholder> in the description
- Use `backticks` for keywords and more complex option
descriptions. The new rendering engine will apply synopsis rules to
these spans.

Additionally, a list of option possible values has been reformatted as a
standalone definition list.

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: convert merge strategies to synopsis format
Jean-Noël Avila [Sun, 25 May 2025 20:27:05 +0000 (20:27 +0000)] 
doc: convert merge strategies to synopsis format

- Switch the synopsis to a synopsis block which will automatically
  format placeholders in italics and keywords in monospace
- Use _<placeholder>_ instead of <placeholder> in the description
- Use `backticks` for keywords and more complex option
descriptions. The new rendering engine will apply synopsis rules to
these spans.

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: merge-options.adoc remove a misleading double negation
Jean-Noël Avila [Sun, 25 May 2025 20:27:04 +0000 (20:27 +0000)] 
doc: merge-options.adoc remove a misleading double negation

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: convert merge options to new synopsis format
Jean-Noël Avila [Sun, 25 May 2025 20:27:03 +0000 (20:27 +0000)] 
doc: convert merge options to new synopsis format

- Use _<placeholder>_ instead of <placeholder> in the description
- Use `backticks` for keywords and more complex option
descriptions. The new rendering engine will apply synopsis rules to
these spans.

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: convert git-merge manpage to new style
Jean-Noël Avila [Sun, 25 May 2025 20:27:02 +0000 (20:27 +0000)] 
doc: convert git-merge manpage to new style

- Switch the synopsis to a synopsis block which will automatically
  format placeholders in italics and keywords in monospace
- Use _<placeholder>_ instead of <placeholder> in the description
- Use `backticks` for keywords and more complex option
descriptions. The new rendering engine will apply synopsis rules to
these spans.

In order to avoid breaking the format on '<<<<<<' and '>>>>>' lines
by applying the synopsis rules to these spans, they are formatted using '+'
signs instead of '`' signs.

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agodoc: convert git-checkout manpage to new style
Jean-Noël Avila [Sun, 25 May 2025 20:27:01 +0000 (20:27 +0000)] 
doc: convert git-checkout manpage to new style

- Switch the synopsis to a synopsis block which will automatically
  format placeholders in italics and keywords in monospace
- Use _<placeholder>_ instead of <placeholder> in the description
- Use `backticks` for keywords and more complex option
descriptions. The new rendering engine will apply synopsis rules to
these spans.

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoapply: set file mode when --reverse creates a deleted file
Mark Mentovai [Sat, 24 May 2025 03:40:46 +0000 (23:40 -0400)] 
apply: set file mode when --reverse creates a deleted file

Commit 01aff0a (apply: correctly reverse patch's pre- and post-image
mode bits, 2023-12-26) revised reverse_patches() to maintain the desired
property that when only one of patch::old_mode and patch::new_mode is
set, the mode will be carried in old_mode. That property is generally
correct, with one notable exception: when creating a file, only new_mode
will be set. Since reversing a deletion results in a creation, new_mode
must be set in that case.

Omitting handling for this case means that reversing a patch that
removes an executable file will not result in the executable permission
being set on the re-created file. Existing test coverage for file modes
focuses only on mode changes of existing files.

Swap old_mode and new_mode in reverse_patches() for what's represented
in the patch as a file deletion, as it is transformed into a file
creation under reversal. This causes git apply --reverse to set the
executable permission properly when re-creating a deleted executable
file.

Add tests ensuring that git apply sets file modes correctly on file
creation, both in the forward and reverse directions.

Signed-off-by: Mark Mentovai <mark@chromium.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot4129: test that git apply warns for unexpected mode changes
Mark Mentovai [Sat, 24 May 2025 03:40:45 +0000 (23:40 -0400)] 
t4129: test that git apply warns for unexpected mode changes

There is no test covering what commit 01aff0a (apply: correctly reverse
patch's pre- and post-image mode bits, 2023-12-26) addressed. Prior to
that commit, git apply was erroneously unaware of a file's expected mode
while reverse-patching a file whose mode was not changing.

Add the missing test coverage to assure that git apply is aware of the
expected mode of a file being patched when the patch does not indicate
that the file's mode is changing. This is achieved by arranging a file
mode so that it doesn't agree with patch being applied, and checking git
apply's output for the warning it's supposed to raise in this situation.
Test in both reverse and normal (forward) directions.

Signed-off-by: Mark Mentovai <mark@chromium.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoThe seventeenth batch
Junio C Hamano [Fri, 23 May 2025 22:33:39 +0000 (15:33 -0700)] 
The seventeenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoMerge branch 'lo/json-writer-docs'
Junio C Hamano [Fri, 23 May 2025 22:34:09 +0000 (15:34 -0700)] 
Merge branch 'lo/json-writer-docs'

In-code docstring updates.

* lo/json-writer-docs:
  json-writer: describe the usage of jw_* functions
  json-writer: add docstrings to jw_* functions

2 months agoMerge branch 'en/replay-wo-the-repository'
Junio C Hamano [Fri, 23 May 2025 22:34:08 +0000 (15:34 -0700)] 
Merge branch 'en/replay-wo-the-repository'

The dependency on the_repository variable has been reduced from the
code paths in "git replay".

* en/replay-wo-the-repository:
  replay: replace the_repository with repo parameter passed to cmd_replay ()

2 months agoMerge branch 'ag/send-email-hostname-f'
Junio C Hamano [Fri, 23 May 2025 22:34:08 +0000 (15:34 -0700)] 
Merge branch 'ag/send-email-hostname-f'

Teach "git send-email" to also consult `hostname -f` for mail
domain to compute the identity given to SMTP servers.

* ag/send-email-hostname-f:
  send-email: try to get fqdn by running hostname -f on Linux and macOS

2 months agoMerge branch 'ps/ci-gitlab-enable-msvc-meson-job'
Junio C Hamano [Fri, 23 May 2025 22:34:07 +0000 (15:34 -0700)] 
Merge branch 'ps/ci-gitlab-enable-msvc-meson-job'

CI settings at GitLab has been updated to run MSVC based Meson job
automatically (as opposed to be done only upon manual request).

* ps/ci-gitlab-enable-msvc-meson-job:
  gitlab-ci: always run MSVC-based Meson job

2 months agoMerge branch 'ds/scalar-no-maintenance'
Junio C Hamano [Fri, 23 May 2025 22:34:07 +0000 (15:34 -0700)] 
Merge branch 'ds/scalar-no-maintenance'

Two "scalar" subcommands that adds a repository that hasn't been
under "scalar"'s control are taught an option not to enable the
scheduled maintenance on it.

* ds/scalar-no-maintenance:
  scalar reconfigure: improve --maintenance docs
  scalar reconfigure: add --maintenance=<mode> option
  scalar clone: add --no-maintenance option
  scalar register: add --no-maintenance option
  scalar: customize register_dir()'s behavior

2 months agoMerge branch 'ly/pack-bitmap-load-leakfix'
Junio C Hamano [Fri, 23 May 2025 22:34:07 +0000 (15:34 -0700)] 
Merge branch 'ly/pack-bitmap-load-leakfix'

Leakfix.

* ly/pack-bitmap-load-leakfix:
  pack-bitmap: fix memory leak if `load_bitmap_entries_v1` failed

2 months agoMerge branch 'js/ci-build-win-in-release-mode'
Junio C Hamano [Fri, 23 May 2025 22:34:06 +0000 (15:34 -0700)] 
Merge branch 'js/ci-build-win-in-release-mode'

win+Meson CI pipeline, unlike other pipelines for Windows,
used to build artifacts in develper mode, which has been changed to
build them in release mode for consistency.

* js/ci-build-win-in-release-mode:
  ci(win+Meson): build in Release mode

2 months agobundle-uri: fix arbitrary file writes via parameter injection
Patrick Steinhardt' via Git Security [Wed, 14 May 2025 06:32:02 +0000 (08:32 +0200)] 
bundle-uri: fix arbitrary file writes via parameter injection

We fetch bundle URIs via `download_https_uri_to_file()`. The logic to
fetch those bundles is not handled in-process, but we instead use a
separate git-remote-https(1) process that performs the fetch for us. The
information about which file should be downloaded and where that file
should be put gets communicated via stdin of that process via a "get"
request. This "get" request has the form "get $uri $file\n\n". As may be
obvious to the reader, this will cause git-remote-https(1) to download
the URI "$uri" and put it into "$file".

The fact that we are using plain spaces and newlines as separators for
the request arguments means that we have to be extra careful with the
respective vaules of these arguments:

  - If "$uri" contained a space we would interpret this as both URI and
    target location.

  - If either "$uri" or "$file" contained a newline we would interpret
    this as a new command.

But we neither quote the arguments such that any characters with special
meaning would be escaped, nor do we verify that none of these special
characters are contained.

If either the URI or file contains a newline character, we are open to
protocol injection attacks. Likewise, if the URI itself contains a
space, then an attacker-controlled URI can lead to partially-controlled
file writes.

Note that the attacker-controlled URIs do not permit completely
arbitrary file writes, but instead allows an attacker to control the
path in which we will write a temporary (e.g., "tmp_uri_XXXXXX")
file.

The result is twofold:

  - By adding a space in "$uri" we can control where exactly a file will
    be written to, including out-of-repository writes. The final
    location is not completely arbitrary, as the injected string will be
    concatenated with the original "$file" path. Furthermore, the name
    of the bundle will be "tmp_uri_XXXXXX", further restricting what an
    adversary would be able to write.

    Also note that is not possible for the URI to contain a newline
    because we end up in `credential_from_url_1()` before we try to
    issue any requests using that URI. As such, it is not possible to
    inject arbitrary commands via the URI.

  - By adding a newline to "$file" we can inject arbitrary commands.
    This gives us full control over where a specific file will be
    written to. Potential attack vectors would be to overwrite hooks,
    but if an adversary were to guess where the user's home directory is
    located they might also easily write e.g. a "~/.profile" file and
    thus cause arbitrary code execution.

    This injection can only become possible when the adversary has full
    control over the target path where a bundle will be downloaded to.
    While this feels unlikely, it is possible to control this path when
    users perform a recursive clone with a ".gitmodules" file that is
    controlled by the adversary.

Luckily though, the use of bundle URIs is not enabled by default in Git
clients (yet): they have to be enabled by setting the `bundle.heuristic`
config key explicitly. As such, the blast radius of this parameter
injection should overall be quite contained.

Fix the issue by rejecting spaces in the URI and newlines in both the
URI and the file. As explained, it shouldn't be required to also
restrict the use of newlines in the URI, as we would eventually die
anyway in `credential_from_url_1()`. But given that we're only one small
step away from arbitrary code execution, let's rather be safe and
restrict newlines in URIs, as well.

Eventually we should probably refactor the way that Git talks with the
git-remote-https(1) subprocess so that it is less fragile. Until then,
these two restrictions should plug the issue.

Reported-by: David Leadbeater <dgl@dgl.cx>
Based-on-patch-by: David Leadbeater <dgl@dgl.cx>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
2 months agoconfig: quote values containing CR character
Justin Tobler [Tue, 20 May 2025 02:26:04 +0000 (21:26 -0500)] 
config: quote values containing CR character

When reading the config, values that contain a trailing CRLF are
stripped. If the value itself has a trailing CR, the normal LF that
follows results in the CR being unintentionally stripped. This may lead
to unintended behavior due to the config value written being different
when it gets read.

One such issue involves a repository with a submodule path containing a
trailing CR. When the submodule gets initialized, the submodule is
cloned without being checked out and has "core.worktree" set to the
submodule path. The git-checkout(1) that gets spawned later reads the
"core.worktree" config value, but without the trailing CR, and
consequently attempts to checkout to a different path than intended.

If the repository contains a matching path that is a symlink, it is
possible for the submodule repository to be checked out in arbitrary
locations. This is extra bad when the symlink points to the submodule
hooks directory and the submodule repository contains an executable
"post-checkout" hook. Once the submodule repository checkout completes,
the "post-checkout" hook immediately executes.

To prevent mismatched config state due to misinterpreting a trailing CR,
wrap config values containing CR in double quotes when writing the
entry. This ensures a trailing CR is always separated for an LF and thus
prevented from getting stripped.

Note that this problem cannot be addressed by just quoting each CR with
"\r". The reading side of the config interprets only a few backslash
escapes, and "\r" is not among them. This fix is sufficient though
because it only affects the CR at the end of a line and any literal CR
in the interior is already preserved.

Co-authored-by: David Leadbeater <dgl@dgl.cx>
Signed-off-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
2 months agoMerge branch 'js/fix-open-exec'
Johannes Sixt [Tue, 20 May 2025 06:56:09 +0000 (08:56 +0200)] 
Merge branch 'js/fix-open-exec'

This addresses CVE-2025-46835, Git GUI can create and overwrite a
user's files:

When a user clones an untrusted repository and is tricked into editing
a file located in a maliciously named directory in the repository, then
Git GUI can create and overwrite files for which the user has write
permission.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
2 months agogit-gui: sanitize 'exec' arguments: convert new 'cygpath' calls
Johannes Sixt [Wed, 14 May 2025 19:06:37 +0000 (21:06 +0200)] 
git-gui: sanitize 'exec' arguments: convert new 'cygpath' calls

The side branch merged in the previous commit introduces new 'exec'
calls. Convert these in the same way we did earlier for existing
'exec' calls.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Taylor Blau <me@ttaylorr.com>