]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
3 months agofast-export, fast-import: add support for signed-commits
Luke Shumaker [Mon, 10 Mar 2025 15:57:46 +0000 (16:57 +0100)] 
fast-export, fast-import: add support for signed-commits

fast-export has a --signed-tags= option that controls how to handle tag
signatures.  However, there is no equivalent for commit signatures; it
just silently strips the signature out of the commit (analogously to
--signed-tags=strip).

While signatures are generally problematic for fast-export/fast-import
(because hashes are likely to change), if they're going to support tag
signatures, there's no reason to not also support commit signatures.

So, implement a --signed-commits= option that mirrors the --signed-tags=
option.

On the fast-export side, try to be as much like signed-tags as possible,
in both implementation and in user-interface.  This will change the
default behavior to '--signed-commits=abort' from what is now
'--signed-commits=strip'.  In order to provide an escape hatch for users
of third-party tools that call fast-export and do not yet know of the
--signed-commits= option, add an environment variable
'FAST_EXPORT_SIGNED_COMMITS_NOABORT=1' that changes the default to
'--signed-commits=warn-strip'.

Signed-off-by: Luke Shumaker <lukeshu@datawire.io>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agofast-export: do not modify memory from get_commit_buffer
Luke Shumaker [Mon, 10 Mar 2025 15:57:45 +0000 (16:57 +0100)] 
fast-export: do not modify memory from get_commit_buffer

fast-export's helper function find_encoding() takes a `const char *`, but
modifies that memory despite the `const`.  Ultimately, this memory came
from get_commit_buffer(), and you're not supposed to modify the memory
that you get from get_commit_buffer().

So, get rid of find_encoding() in favor of commit.h:find_commit_header(),
which gives back a string length, rather than mutating the memory to
insert a '\0' terminator.

Because find_commit_header() detects the "\n\n" string that separates the
headers and the commit message, move the call to be above the
`message = strstr(..., "\n\n")` call.  This helps readability, and allows
for the value of `encoding` to be used for a better value of "..." so that
the same memory doesn't need to be checked twice.  Introduce a
`commit_buffer_cursor` variable to avoid writing an awkward
`encoding ? encoding + encoding_len : committer_end` expression.

Signed-off-by: Luke Shumaker <lukeshu@datawire.io>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agogit-fast-export.adoc: clarify why 'verbatim' may not be a good idea
Luke Shumaker [Mon, 10 Mar 2025 15:57:44 +0000 (16:57 +0100)] 
git-fast-export.adoc: clarify why 'verbatim' may not be a good idea

Signed-off-by: Luke Shumaker <lukeshu@datawire.io>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agofast-export: rename --signed-tags='warn' to 'warn-verbatim'
Luke Shumaker [Mon, 10 Mar 2025 15:57:43 +0000 (16:57 +0100)] 
fast-export: rename --signed-tags='warn' to 'warn-verbatim'

The --signed-tags= option takes one of five arguments specifying how to
handle signed tags during export.  Among these arguments, 'strip' is to
'warn-strip' as 'verbatim' is to 'warn' (the unmentioned argument is
'abort', which stops the fast-export process entirely).  That is,
signatures are either stripped or copied verbatim while exporting, with
or without a warning.

Match the pattern and rename 'warn' to 'warn-verbatim' to make it clear
that it instructs fast-export to copy signatures verbatim.

To maintain backwards compatibility, 'warn' is still recognized as
deprecated synonym of 'warn-verbatim'.

Signed-off-by: Luke Shumaker <lukeshu@datawire.io>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agofast-export: fix missing whitespace after switch
Christian Couder [Mon, 10 Mar 2025 15:57:42 +0000 (16:57 +0100)] 
fast-export: fix missing whitespace after switch

"Documentation/CodingGuidelines" says that there should be whitespaces
around operators like 'if', 'switch', 'for', etc.

Let's fix this in "builtin/fast-export.c".

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 months agogit-fast-import.adoc: add missing LF in the BNF
Luke Shumaker [Mon, 10 Mar 2025 15:57:41 +0000 (16:57 +0100)] 
git-fast-import.adoc: add missing LF in the BNF

Signed-off-by: Luke Shumaker <lukeshu@datawire.io>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoThe thirteenth batch
Junio C Hamano [Fri, 21 Feb 2025 18:35:39 +0000 (10:35 -0800)] 
The thirteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoMerge branch 'ac/doc-http-ssl-type-config'
Junio C Hamano [Fri, 21 Feb 2025 18:35:53 +0000 (10:35 -0800)] 
Merge branch 'ac/doc-http-ssl-type-config'

Two configuration variables about SSL authentication material that
weren't mentioned in the documentations are now mentioned.

* ac/doc-http-ssl-type-config:
  docs: indicate http.sslCertType and sslKeyType

4 months agoMerge branch 'jc/doc-boolean-synonyms'
Junio C Hamano [Fri, 21 Feb 2025 18:35:53 +0000 (10:35 -0800)] 
Merge branch 'jc/doc-boolean-synonyms'

Doc updates.

* jc/doc-boolean-synonyms:
  doc: centrally document various ways tospell `true` and `false`

4 months agoMerge branch 'en/doc-renormalize'
Junio C Hamano [Fri, 21 Feb 2025 18:35:53 +0000 (10:35 -0800)] 
Merge branch 'en/doc-renormalize'

Doc updates.

* en/doc-renormalize:
  doc: clarify the intent of the renormalize option in the merge machinery

4 months agoMerge branch 'ua/update-server-info-sans-the-repository'
Junio C Hamano [Fri, 21 Feb 2025 18:35:52 +0000 (10:35 -0800)] 
Merge branch 'ua/update-server-info-sans-the-repository'

Code clean-up.

* ua/update-server-info-sans-the-repository:
  builtin/update-server-info: remove the_repository global variable

4 months agoMerge branch 'master' of https://github.com/j6t/gitk
Junio C Hamano [Thu, 20 Feb 2025 13:59:56 +0000 (05:59 -0800)] 
Merge branch 'master' of https://github.com/j6t/gitk

* 'master' of https://github.com/j6t/gitk:
  gitk: introduce support for the Meson build system
  gitk: extract script to build executable
  gitk: make the "list references" default window width wider
  gitk: fix arrow keys in input fields with Tcl/Tk >= 8.6
  gitk: Use an external icon file on Windows
  gitk: Unicode file name support
  gitk(Windows): avoid inadvertently calling executables in the worktree

4 months agoMerge branch 'pks-meson-support' of https://github.com/pks-t/gitk
Johannes Sixt [Thu, 20 Feb 2025 09:54:37 +0000 (10:54 +0100)] 
Merge branch 'pks-meson-support' of https://github.com/pks-t/gitk

* 'pks-meson-support' of https://github.com/pks-t/gitk:
  gitk: introduce support for the Meson build system
  gitk: extract script to build executable

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
4 months agoMerge branch 'g4w-gitk' of https://github.com/dscho/gitk
Johannes Sixt [Thu, 20 Feb 2025 09:53:53 +0000 (10:53 +0100)] 
Merge branch 'g4w-gitk' of https://github.com/dscho/gitk

* 'g4w-gitk' of https://github.com/dscho/gitk:
  gitk: make the "list references" default window width wider
  gitk: fix arrow keys in input fields with Tcl/Tk >= 8.6
  gitk: Use an external icon file on Windows
  gitk: Unicode file name support
  gitk(Windows): avoid inadvertently calling executables in the worktree

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
4 months agogitk: introduce support for the Meson build system
Patrick Steinhardt [Wed, 19 Feb 2025 12:42:50 +0000 (13:42 +0100)] 
gitk: introduce support for the Meson build system

Upstream Git has introduced support for the Meson build system.
Introduce support for Meson into gitk, as well, so that Git can easily
build its vendored copy of Gitk via a `subproject()` directive. The
instructions can be set up as follows:

  $ meson setup build
  $ meson compile -C build
  $ meson install -C build

Specific options, like for example where Gitk shall be installed to, can
be specified at setup time via `-D`. Available options can be discovered
by running `meson configure` either in the source or build directory.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
4 months agogitk: extract script to build executable
Patrick Steinhardt [Wed, 19 Feb 2025 12:34:30 +0000 (13:34 +0100)] 
gitk: extract script to build executable

Extract the scrip that "builds" Gitk from our Makefile so that we can
reuse it in Meson.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
4 months agoThe twelfth batch
Junio C Hamano [Tue, 18 Feb 2025 23:02:31 +0000 (15:02 -0800)] 
The twelfth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoMerge branch 'bc/contrib-thunderbird-patch-inline-fix'
Junio C Hamano [Tue, 18 Feb 2025 23:30:33 +0000 (15:30 -0800)] 
Merge branch 'bc/contrib-thunderbird-patch-inline-fix'

A thunderbird helper script lost its bashism.

* bc/contrib-thunderbird-patch-inline-fix:
  thunderbird-patch-inline: avoid bashism

4 months agoMerge branch 'lo/t7603-path-is-file-update'
Junio C Hamano [Tue, 18 Feb 2025 23:30:33 +0000 (15:30 -0800)] 
Merge branch 'lo/t7603-path-is-file-update'

Test clean-up.

* lo/t7603-path-is-file-update:
  t7603: replace test -f by test_path_is_file

4 months agoMerge branch 'da/difftool-sans-the-repository'
Junio C Hamano [Tue, 18 Feb 2025 23:30:32 +0000 (15:30 -0800)] 
Merge branch 'da/difftool-sans-the-repository'

"git difftool" code clean-up.

* da/difftool-sans-the-repository:
  difftool: eliminate use of USE_THE_REPOSITORY_VARIABLE
  difftool: eliminate use of the_repository
  difftool: eliminate use of global variables

4 months agoMerge branch 'jt/rev-list-missing-print-info'
Junio C Hamano [Tue, 18 Feb 2025 23:30:32 +0000 (15:30 -0800)] 
Merge branch 'jt/rev-list-missing-print-info'

"git rev-list --missing=" learned to accept "print-info" that gives
known details expected of the missing objects, like path and type.

* jt/rev-list-missing-print-info:
  rev-list: extend print-info to print missing object type
  rev-list: add print-info action to print missing object path

4 months agoMerge branch 'ps/send-pack-unhide-error-in-atomic-push'
Junio C Hamano [Tue, 18 Feb 2025 23:30:32 +0000 (15:30 -0800)] 
Merge branch 'ps/send-pack-unhide-error-in-atomic-push'

"git push --atomic --porcelain" used to ignore failures from the
other side, losing the error status from the child process, which
has been corrected.

* ps/send-pack-unhide-error-in-atomic-push:
  send-pack: gracefully close the connection for atomic push
  t5543: atomic push reports exit code failure
  send-pack: new return code "ERROR_SEND_PACK_BAD_REF_STATUS"
  t5548: add porcelain push test cases for dry-run mode
  t5548: add new porcelain test cases
  t5548: refactor test cases by resetting upstream
  t5548: refactor to reuse setup_upstream() function
  t5504: modernize test by moving heredocs into test bodies

4 months agoMerge branch 'ds/backfill'
Junio C Hamano [Tue, 18 Feb 2025 23:30:31 +0000 (15:30 -0800)] 
Merge branch 'ds/backfill'

Lazy-loading missing files in a blobless clone on demand is costly
as it tends to be one-blob-at-a-time.  "git backfill" is introduced
to help bulk-download necessary files beforehand.

* ds/backfill:
  backfill: assume --sparse when sparse-checkout is enabled
  backfill: add --sparse option
  backfill: add --min-batch-size=<n> option
  backfill: basic functionality and tests
  backfill: add builtin boilerplate

4 months agoThe eleventh batch
Junio C Hamano [Sat, 15 Feb 2025 01:53:32 +0000 (17:53 -0800)] 
The eleventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoMerge branch 'ps/doc-http-upload-archive-service'
Junio C Hamano [Sat, 15 Feb 2025 01:53:49 +0000 (17:53 -0800)] 
Merge branch 'ps/doc-http-upload-archive-service'

Doc update.

* ps/doc-http-upload-archive-service:
  doc: documentation for http.uploadarchive config option

4 months agoMerge branch 'kn/reflog-migration-fix-followup'
Junio C Hamano [Sat, 15 Feb 2025 01:53:48 +0000 (17:53 -0800)] 
Merge branch 'kn/reflog-migration-fix-followup'

Code clean-up.

* kn/reflog-migration-fix-followup:
  reftable: prevent 'update_index' changes after adding records
  refs: use 'uint64_t' for 'ref_update.index'
  refs: mark `ref_transaction_update_reflog()` as static

4 months agoMerge branch 'bf/fetch-set-head-fix'
Junio C Hamano [Sat, 15 Feb 2025 01:53:48 +0000 (17:53 -0800)] 
Merge branch 'bf/fetch-set-head-fix'

Fetching into a bare repository incorrectly assumed it always used
a mirror layout when deciding to update remote-tracking HEAD, which
has been corrected.

* bf/fetch-set-head-fix:
  fetch set_head: fix non-mirror remotes in bare repositories
  fetch set_head: refactor to use remote directly

4 months agoMerge branch 'op/worktree-is-main-bare-fix'
Junio C Hamano [Sat, 15 Feb 2025 01:53:48 +0000 (17:53 -0800)] 
Merge branch 'op/worktree-is-main-bare-fix'

Going into a secondary worktree and asking "is the main worktree
bare?" did not work correctly when per-worktree configuration
option was in use, which has been corrected.

* op/worktree-is-main-bare-fix:
  worktree: detect from secondary worktree if main worktree is bare

4 months agoMerge branch 'tc/clone-single-revision'
Junio C Hamano [Sat, 15 Feb 2025 01:53:47 +0000 (17:53 -0800)] 
Merge branch 'tc/clone-single-revision'

"git clone" learned to make a shallow clone for a single commit
that is not necessarily be at the tip of any branch.

* tc/clone-single-revision:
  builtin/clone: teach git-clone(1) the --revision= option
  parse-options: introduce die_for_incompatible_opt2()
  clone: introduce struct clone_opts in builtin/clone.c
  clone: add tags refspec earlier to fetch refspec
  clone: refactor wanted_peer_refs()
  clone: make it possible to specify --tags
  clone: cut down on global variables in clone.c

4 months agoMerge branch 'bc/doc-adoc-not-txt'
Junio C Hamano [Sat, 15 Feb 2025 01:53:47 +0000 (17:53 -0800)] 
Merge branch 'bc/doc-adoc-not-txt'

All the documentation .txt files have been renamed to .adoc to help
content aware editors.

* bc/doc-adoc-not-txt:
  Remove obsolete ".txt" extensions for AsciiDoc files
  doc: use .adoc extension for AsciiDoc files
  gitattributes: mark AsciiDoc files as LF-only
  editorconfig: add .adoc extension
  doc: update gitignore for .adoc extension

4 months agoThe tenth batch
Junio C Hamano [Wed, 12 Feb 2025 18:09:08 +0000 (10:09 -0800)] 
The tenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoMerge branch 'da/help-autocorrect-one-fix'
Junio C Hamano [Wed, 12 Feb 2025 18:08:55 +0000 (10:08 -0800)] 
Merge branch 'da/help-autocorrect-one-fix'

"git -c help.autocorrect=0 psuh" shows the suggested typofix,
unlike the previous attempt in the base topic.

* da/help-autocorrect-one-fix:
  help: add "show" as a valid configuration value
  help: show the suggested command when help.autocorrect is false

4 months agoMerge branch 'sc/help-autocorrect-one'
Junio C Hamano [Wed, 12 Feb 2025 18:08:54 +0000 (10:08 -0800)] 
Merge branch 'sc/help-autocorrect-one'

"[help] autocorrect = 1" used to be a way to say "please wait for
0.1 second after suggesting a typofix of the command name before
running that command"; now it means "yes, if there is a plausible
typofix for the command name, please run it immediately".

* sc/help-autocorrect-one:
  help: interpret boolean string values for help.autocorrect

4 months agoMerge branch 'ms/remote-valid-remote-name'
Junio C Hamano [Wed, 12 Feb 2025 18:08:54 +0000 (10:08 -0800)] 
Merge branch 'ms/remote-valid-remote-name'

Code shuffling.

* ms/remote-valid-remote-name:
  remote: relocate valid_remote_name

4 months agoMerge branch 'ms/refspec-cleanup'
Junio C Hamano [Wed, 12 Feb 2025 18:08:54 +0000 (10:08 -0800)] 
Merge branch 'ms/refspec-cleanup'

Code clean-up.  cf. <Z6G-toOJjMmK8iJG@pks.im>

* ms/refspec-cleanup:
  refspec: relocate apply_refspecs and related funtions
  refspec: relocate matching related functions
  remote: rename query_refspecs functions
  refspec: relocate refname_matches_negative_refspec_item
  remote: rename function omit_name_by_refspec

4 months agoMerge branch 'jp/doc-trailer-config'
Junio C Hamano [Wed, 12 Feb 2025 18:08:53 +0000 (10:08 -0800)] 
Merge branch 'jp/doc-trailer-config'

Documentaiton updates.

* jp/doc-trailer-config:
  config.txt: add trailer.* variables

4 months agoMerge branch 'zh/gc-expire-to'
Junio C Hamano [Wed, 12 Feb 2025 18:08:53 +0000 (10:08 -0800)] 
Merge branch 'zh/gc-expire-to'

"git gc" learned the "--expire-to" option and passes it down to
underlying "git repack".

* zh/gc-expire-to:
  gc: add `--expire-to` option

4 months agoMerge branch 'js/libgit-rust'
Junio C Hamano [Wed, 12 Feb 2025 18:08:53 +0000 (10:08 -0800)] 
Merge branch 'js/libgit-rust'

Foreign language interface for Rust into our code base has been added.

* js/libgit-rust:
  libgit: add higher-level libgit crate
  libgit-sys: also export some config_set functions
  libgit-sys: introduce Rust wrapper for libgit.a
  common-main: split init and exit code into new files

4 months agoMerge branch 'ac/t5401-use-test-path-is-file'
Junio C Hamano [Wed, 12 Feb 2025 18:08:52 +0000 (10:08 -0800)] 
Merge branch 'ac/t5401-use-test-path-is-file'

Test clean-up.

* ac/t5401-use-test-path-is-file:
  t5401: prefer test_path_is_* helper function

4 months agoMerge branch 'ac/t6423-unhide-git-exit-status'
Junio C Hamano [Wed, 12 Feb 2025 18:08:52 +0000 (10:08 -0800)] 
Merge branch 'ac/t6423-unhide-git-exit-status'

Test clean-up.

* ac/t6423-unhide-git-exit-status:
  t6423: fix suppression of Git’s exit code in tests

4 months agoMerge branch 'ps/repack-keep-unreachable-in-unpacked-repo'
Junio C Hamano [Wed, 12 Feb 2025 18:08:51 +0000 (10:08 -0800)] 
Merge branch 'ps/repack-keep-unreachable-in-unpacked-repo'

"git repack --keep-unreachable" to send unreachable objects to the
main pack "git repack -ad" produces did not work when there is no
existing packs, which has been corrected.

* ps/repack-keep-unreachable-in-unpacked-repo:
  builtin/repack: fix `--keep-unreachable` when there are no packs

4 months agoMerge branch 'ds/name-hash-tweaks'
Junio C Hamano [Wed, 12 Feb 2025 18:08:51 +0000 (10:08 -0800)] 
Merge branch 'ds/name-hash-tweaks'

"git pack-objects" and its wrapper "git repack" learned an option
to use an alternative path-hash function to improve delta-base
selection to produce a packfile with deeper history than window
size.

* ds/name-hash-tweaks:
  pack-objects: prevent name hash version change
  test-tool: add helper for name-hash values
  p5313: add size comparison test
  pack-objects: add GIT_TEST_NAME_HASH_VERSION
  repack: add --name-hash-version option
  pack-objects: add --name-hash-version option
  pack-objects: create new name-hash function version

4 months agodoc: clarify the intent of the renormalize option in the merge machinery
Elijah Newren [Tue, 11 Feb 2025 21:01:52 +0000 (21:01 +0000)] 
doc: clarify the intent of the renormalize option in the merge machinery

The -X renormalize (or merge.renormalize config) option is intended to
reduce conflicts due to normalization of newer versions of history.  It
does so by renormalizing files that it is about to do a three-way
content merge on.  Some folks thought it would renormalize all files
throughout the tree, and the previous wording wasn't clear enough to
dispell that misconception.  Update the docs to make it clear that the
merge machinery will only apply renormalization to files which need a
three-way content merge.

(Technically, the merge machinery also does renormalization on
modify/delete conflicts, in order to see if the modification was merely
a normalization; if so, it can accept the delete and not report a
conflict.  But it's not clear that this piece needs to be explained to
users, and trying to distinguish it might feel like splitting hairs and
overcomplicating the explanation, so we leave it out.)

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agodoc: centrally document various ways tospell `true` and `false`
Junio C Hamano [Tue, 11 Feb 2025 17:20:07 +0000 (09:20 -0800)] 
doc: centrally document various ways tospell `true` and `false`

We do not seem to centrally document exhaustively ways to spell
Boolean values.

The description in the Environment Variables of git(1) section
assumes that the reader is already familiar with how "Boolean valued
configuration variables" are specified, without referring to
anything, so there is no way for the readers to find out more.

The description of `bool` in the section on "--type
<type>" in "git config --help" might be the place to do so, but it
is not telling us all that much.

The description of Boolean valued placeholders in the pretty formats
section of "git log --help" enumerates the possible values with "etc."
implying there may be other synonyms; shrink the list of samples and
instead refer to the canonical and authoritative source of truth, which
now is git-config(1).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agobuiltin/update-server-info: remove the_repository global variable
Usman Akinyemi [Mon, 10 Feb 2025 18:10:30 +0000 (23:40 +0530)] 
builtin/update-server-info: remove the_repository global variable

Remove the_repository global variable in favor of the repository
argument that gets passed in "builtin/update-server-info.c".

When `-h` is passed to the command outside a Git repository, the
`run_builtin()` will call the `cmd_update_server_info()` function
with `repo` set to NULL and then early in the function, "parse_options()"
call will give the options help and exit, without having to consult much
of the configuration file. So it is safe to omit reading the config when
`repo` argument the caller gave us is NULL.

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agothunderbird-patch-inline: avoid bashism
brian m. carlson [Mon, 10 Feb 2025 23:49:47 +0000 (23:49 +0000)] 
thunderbird-patch-inline: avoid bashism

The use of "echo -e" is not portable and not specified by POSIX.  dash
does not support any options except "-n", and so this script will not
work on operating systems which use that as /bin/sh.

Fortunately, the solution is easy: switch to printf(1), which is
specified by POSIX and allows the escape sequences we want to use.  This
will allow the script to work with any POSIX shell.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoThe ninth batch
Junio C Hamano [Mon, 10 Feb 2025 18:18:17 +0000 (10:18 -0800)] 
The ninth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoMerge branch 'jk/ci-coverity-update'
Junio C Hamano [Mon, 10 Feb 2025 18:18:31 +0000 (10:18 -0800)] 
Merge branch 'jk/ci-coverity-update'

CI update to make Coverity job work again.

* jk/ci-coverity-update:
  ci: set CI_JOB_IMAGE for coverity job

4 months agoMerge branch 'sk/unit-tests-0130'
Junio C Hamano [Mon, 10 Feb 2025 18:18:31 +0000 (10:18 -0800)] 
Merge branch 'sk/unit-tests-0130'

Convert a handful of unit tests to work with the clar framework.

* sk/unit-tests-0130:
  t/unit-tests: convert strcmp-offset test to use clar test framework
  t/unit-tests: convert strbuf test to use clar test framework
  t/unit-tests: adapt example decorate test to use clar test framework
  t/unit-tests: convert hashmap test to use clar test framework

4 months agoMerge branch 'ps/hash-cleanup'
Junio C Hamano [Mon, 10 Feb 2025 18:18:30 +0000 (10:18 -0800)] 
Merge branch 'ps/hash-cleanup'

Further code clean-up on the use of hash functions.  Now the
context object knows what hash function it is working with.

* ps/hash-cleanup:
  global: adapt callers to use generic hash context helpers
  hash: provide generic wrappers to update hash contexts
  hash: stop typedeffing the hash context
  hash: convert hashing context to a structure

4 months agoMerge branch 'jt/gitlab-ci-base-fix'
Junio C Hamano [Mon, 10 Feb 2025 18:18:30 +0000 (10:18 -0800)] 
Merge branch 'jt/gitlab-ci-base-fix'

Two CI tasks, whitespace check and style check, work on the
difference from the base version and the version being checked, but
the base was computed incorrectly in GitLab CI in some cases, which
has been corrected.

* jt/gitlab-ci-base-fix:
  ci: fix base commit fallback for check-whitespace and check-style

4 months agoMerge branch 'pw/apply-ulong-overflow-check'
Junio C Hamano [Mon, 10 Feb 2025 18:18:30 +0000 (10:18 -0800)] 
Merge branch 'pw/apply-ulong-overflow-check'

"git apply" internally uses unsigned long for line numbers and uses
strtoul() to parse numbers on the hunk headers.  It however forgot
to check parse errors.

* pw/apply-ulong-overflow-check:
  apply: detect overflow when parsing hunk header

4 months agoMerge branch 'ps/setup-reinit-fixes'
Junio C Hamano [Mon, 10 Feb 2025 18:18:29 +0000 (10:18 -0800)] 
Merge branch 'ps/setup-reinit-fixes'

"git init" to reinitialize a repository that already exists cannot
change the hash function and ref backends; such a request is
silently ignored now.

* ps/setup-reinit-fixes:
  setup: fix reinit of repos with incompatible GIT_DEFAULT_HASH
  setup: fix reinit of repos with incompatible GIT_DEFAULT_REF_FORMAT
  t0001: remove duplicate test

4 months agot7603: replace test -f by test_path_is_file
Lucas Oshiro [Sat, 8 Feb 2025 16:57:31 +0000 (13:57 -0300)] 
t7603: replace test -f by test_path_is_file

`test_path_is_file` provides a better output when asserting whether a
file exists. Replace the occurrences of `test -f` in t7603 with it,
facilitating the trace of possible test failures.

Signed-off-by: Lucas Oshiro <lucasseikioshiro@gmail.com>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoThe eighth batch
Junio C Hamano [Thu, 6 Feb 2025 22:24:26 +0000 (14:24 -0800)] 
The eighth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoMerge branch 'ps/leakfixes-0129'
Junio C Hamano [Thu, 6 Feb 2025 22:56:45 +0000 (14:56 -0800)] 
Merge branch 'ps/leakfixes-0129'

A few more leakfixes.

* ps/leakfixes-0129:
  scalar: free result of `remote_default_branch()`
  unix-socket: fix memory leak when chdir(3p) fails

4 months agoMerge branch 'ps/zlib-ng'
Junio C Hamano [Thu, 6 Feb 2025 22:56:45 +0000 (14:56 -0800)] 
Merge branch 'ps/zlib-ng'

The code paths to interact with zlib has been cleaned up in
preparation for building with zlib-ng.

* ps/zlib-ng:
  ci: make "linux-musl" job use zlib-ng
  ci: switch linux-musl to use Meson
  compat/zlib: allow use of zlib-ng as backend
  git-zlib: cast away potential constness of `next_in` pointer
  compat/zlib: provide stubs for `deflateSetHeader()`
  compat/zlib: provide `deflateBound()` shim centrally
  git-compat-util: move include of "compat/zlib.h" into "git-zlib.h"
  compat: introduce new "zlib.h" header
  git-compat-util: drop `z_const` define
  compat: drop `uncompress2()` compatibility shim

4 months agoMerge branch 'js/bundle-unbundle-fd-reuse-fix'
Junio C Hamano [Thu, 6 Feb 2025 22:56:44 +0000 (14:56 -0800)] 
Merge branch 'js/bundle-unbundle-fd-reuse-fix'

The code path used when "git fetch" fetches from a bundle file
closed the same file descriptor twice, which sometimes broke things
unexpectedly when the file descriptor was reused, which has been
corrected.

* js/bundle-unbundle-fd-reuse-fix:
  bundle: avoid closing file descriptor twice

4 months agoMerge branch 'ps/ci-misc-updates'
Junio C Hamano [Thu, 6 Feb 2025 22:56:44 +0000 (14:56 -0800)] 
Merge branch 'ps/ci-misc-updates'

CI updates (containerization, dropping stale ones, etc.).

* ps/ci-misc-updates:
  ci: remove stale code for Azure Pipelines
  ci: use latest Ubuntu release
  ci: stop special-casing for Ubuntu 16.04
  gitlab-ci: add linux32 job testing against i386
  gitlab-ci: remove the "linux-old" job
  github: simplify computation of the job's distro
  github: convert all Linux jobs to be containerized
  github: adapt containerized jobs to be rootless
  t7422: fix flaky test caused by buffered stdout
  t0060: fix EBUSY in MinGW when setting up runtime prefix

4 months agodifftool: eliminate use of USE_THE_REPOSITORY_VARIABLE
David Aguilar [Thu, 6 Feb 2025 04:20:10 +0000 (20:20 -0800)] 
difftool: eliminate use of USE_THE_REPOSITORY_VARIABLE

Remove the USE_THE_REPOSITORY_VARIABLE #define now that all
state is passed to each function from callers.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agodifftool: eliminate use of the_repository
David Aguilar [Thu, 6 Feb 2025 04:20:09 +0000 (20:20 -0800)] 
difftool: eliminate use of the_repository

Make callers pass a repository struct into each function instead
of relying on the global the_repository variable.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agodifftool: eliminate use of global variables
David Aguilar [Thu, 6 Feb 2025 04:20:08 +0000 (20:20 -0800)] 
difftool: eliminate use of global variables

Move difftool's global variables into a difftools_option struct
in preparation for removal of USE_THE_REPOSITORY_VARIABLE.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agodoc: documentation for http.uploadarchive config option
Piotr Szlazak [Thu, 6 Feb 2025 17:45:27 +0000 (17:45 +0000)] 
doc: documentation for http.uploadarchive config option

In Git v2.44.0 support for 'git archive' over HTTP protocol
was added, but it was nowhere documented how it should be
enabled in git-http-backend.

Add missing documentation.

Signed-off-by: Piotr Szlazak <piotr.szlazak@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agobuiltin/clone: teach git-clone(1) the --revision= option
Toon Claes [Thu, 6 Feb 2025 06:33:35 +0000 (07:33 +0100)] 
builtin/clone: teach git-clone(1) the --revision= option

The git-clone(1) command has the option `--branch` that allows the user
to select the branch they want HEAD to point to. In a non-bare
repository this also checks out that branch.

Option `--branch` also accepts a tag. When a tag name is provided, the
commit this tag points to is checked out and HEAD is detached. Thus
`--branch` can be used to clone a repository and check out a ref kept
under `refs/heads` or `refs/tags`. But some other refs might be in use
as well. For example Git forges might use refs like `refs/pull/<id>` and
`refs/merge-requests/<id>` to track pull/merge requests. These refs
cannot be selected upon git-clone(1).

Add option `--revision` to git-clone(1). This option accepts a fully
qualified reference, or a hexadecimal commit ID. This enables the user
to clone and check out any revision they want. `--revision` can be used
in conjunction with `--depth` to do a minimal clone that only contains
the blob and tree for a single revision. This can be useful for
automated tests running in CI systems.

Using option `--branch` and `--single-branch` together is a similar
scenario, but serves a different purpose. Using these two options, a
singlet remote tracking branch is created and the fetch refspec is set
up so git-fetch(1) will receive updates on that branch from the remote.
This allows the user work on that single branch.

Option `--revision` on contrary detaches HEAD, creates no tracking
branches, and writes no fetch refspec.

Signed-off-by: Toon Claes <toon@iotcl.com>
Acked-by: Patrick Steinhardt <ps@pks.im>
[jc: removed unnecessary TEST_PASSES_SANITIZE_LEAK from the test]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoparse-options: introduce die_for_incompatible_opt2()
Toon Claes [Thu, 6 Feb 2025 06:33:34 +0000 (07:33 +0100)] 
parse-options: introduce die_for_incompatible_opt2()

The functions die_for_incompatible_opt3() and
die_for_incompatible_opt4() already exist to die whenever a user
specifies three or four options respectively that are not compatible.

Introduce die_for_incompatible_opt2() which dies when two options that
are incompatible are set.

Signed-off-by: Toon Claes <toon@iotcl.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoclone: introduce struct clone_opts in builtin/clone.c
Toon Claes [Thu, 6 Feb 2025 06:33:33 +0000 (07:33 +0100)] 
clone: introduce struct clone_opts in builtin/clone.c

There is a lot of state stored in global variables in builtin/clone.c.
In the long run we'd like to remove many of those.

Introduce `struct clone_opts` in this file. This struct will be used to
contain all details needed to perform the clone. The struct object can
be thrown around to all the functions that need these details.

The first field we're adding is `wants_head`. In some scenarios
(specifically when both `--single-branch` and `--branch` are given) we
are not interested in `HEAD` on the remote. The field `wants_head` in
`struct clone_opts` will hold this information. We could have put
`option_branch` and `option_single_branch` into that struct instead, but
in a following commit we'll be using `wants_head` as well.

Signed-off-by: Toon Claes <toon@iotcl.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoclone: add tags refspec earlier to fetch refspec
Toon Claes [Thu, 6 Feb 2025 06:33:32 +0000 (07:33 +0100)] 
clone: add tags refspec earlier to fetch refspec

In clone.c we call refspec_ref_prefixes() to copy the fetch refspecs
from the `remote->fetch` refspec into `ref_prefixes` of
`transport_ls_refs_options`. Afterwards we add the tags prefix
`refs/tags/` prefix as well. At a later point, in wanted_peer_refs() we
process refs using both `remote->fetch` and `TAG_REFSPEC`.

Simplify the code by appending `TAG_REFSPEC` to `remote->fetch` before
calling refspec_ref_prefixes().

To be able to do this, we set `option_tags` to 0 when --mirror is given.
This is because --mirror mirrors (hence the name) all the refs,
including tags and they do not need to be treated separately.

Signed-off-by: Toon Claes <toon@iotcl.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoclone: refactor wanted_peer_refs()
Toon Claes [Thu, 6 Feb 2025 06:33:31 +0000 (07:33 +0100)] 
clone: refactor wanted_peer_refs()

The function wanted_peer_refs() is used to map the refs returned by the
server to refs we will save in our clone.

Over time this function grown to be very complex. Refactor it.

Previously, there was a separate code path for when
`option_single_branch` was set. It resulted in duplicated code and
deeper nested conditions. After this refactor the code path for when
`option_single_branch` is truthy modifies `refs` and then falls through
to the common code path. This approach relies on the `refspec` being set
correctly and thus only mapping refs that are relevant.

Signed-off-by: Toon Claes <toon@iotcl.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoclone: make it possible to specify --tags
Toon Claes [Thu, 6 Feb 2025 06:33:30 +0000 (07:33 +0100)] 
clone: make it possible to specify --tags

Option --no-tags was added in 0dab2468ee (clone: add a --no-tags option
to clone without tags, 2017-04-26). At the time there was no need to
support --tags as well, although there was some conversation about
it[1].

To simplify the code and to prepare for future commits, invert the flag
internally. Functionally there is no change, because the flag is
default-enabled passing `--tags` has no effect, so there's no need to
add tests for this.

[1]: https://lore.kernel.org/git/CAGZ79kbHuMpiavJ90kQLEL_AR0BEyArcZoEWAjPPhOFacN16YQ@mail.gmail.com/

Signed-off-by: Toon Claes <toon@iotcl.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoclone: cut down on global variables in clone.c
Toon Claes [Thu, 6 Feb 2025 06:33:29 +0000 (07:33 +0100)] 
clone: cut down on global variables in clone.c

In clone.c the `struct option` which is used to parse the input options
for git-clone(1) is a global variable. Due to this, many variables that
are used to parse the value into, are also global.

Make `builtin_clone_options` a local variable in cmd_clone() and carry
along all variables that are only used in that function.

Signed-off-by: Toon Claes <toon@iotcl.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoworktree: detect from secondary worktree if main worktree is bare
Olga Pilipenco [Wed, 5 Feb 2025 06:30:13 +0000 (06:30 +0000)] 
worktree: detect from secondary worktree if main worktree is bare

When extensions.worktreeConfig is true and the main worktree is
bare -- that is, its config.worktree file contains core.bare=true
-- commands run from secondary worktrees incorrectly see the main
worktree as not bare. As such, those commands incorrectly think
that the repository's default branch (typically "main" or
"master") is checked out in the bare repository even though it's
not. This makes it impossible, for instance, to checkout or delete
the default branch from a secondary worktree, among other
shortcomings.

This problem occurs because, when extensions.worktreeConfig is
true, commands run in secondary worktrees only consult
$commondir/config and $commondir/worktrees/<id>/config.worktree,
thus they never see the main worktree's core.bare=true setting in
$commondir/config.worktree.

Fix this problem by consulting the main worktree's config.worktree
file when checking whether it is bare. (This extra work is
performed only when running from a secondary worktree.)

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Olga Pilipenco <olga.pilipenco@shopify.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agodocs: indicate http.sslCertType and sslKeyType
Andrew Carter [Wed, 5 Feb 2025 05:38:56 +0000 (23:38 -0600)] 
docs: indicate http.sslCertType and sslKeyType

0a01d41ee4 (http: add support for different sslcert and sslkey types.,
2023-03-20) added useful SSL config options, but did not document them.

Signed-off-by: Andrew Carter <andrew@emailcarter.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agorev-list: extend print-info to print missing object type
Justin Tobler [Wed, 5 Feb 2025 00:41:47 +0000 (18:41 -0600)] 
rev-list: extend print-info to print missing object type

Additional information about missing objects found in git-rev-list(1)
can be printed by specifying the `print-info` missing action for the
`--missing` option. Extend this action to also print missing object type
information inferred from its containing object. This token follows the
form `type=<type>` and specifies the expected object type of the missing
object.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
Acked-by: Christian Couder <christian.couder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agorev-list: add print-info action to print missing object path
Justin Tobler [Wed, 5 Feb 2025 00:41:46 +0000 (18:41 -0600)] 
rev-list: add print-info action to print missing object path

Missing objects identified through git-rev-list(1) can be printed by
setting the `--missing=print` option. Additional information about the
missing object, such as its path and type, may be present in its
containing object.

Add the `print-info` missing action for the `--missing` option that,
when set, prints additional insight about the missing object inferred
from its containing object. Each line of output for a missing object is
in the form: `?<oid> [<token>=<value>]...`. The `<token>=<value>` pairs
containing additional information are separated from each other by a SP.
The value is encoded in a token specific fashion, but SP or LF contained
in value are always expected to be represented in such a way that the
resulting encoded value does not have either of these two problematic
bytes. This format is kept generic so it can be extended in the future
to support additional information.

For now, only a missing object path info is implemented. It follows the
form `path=<path>` and specifies the full path to the object from the
top-level tree. A path containing SP or special characters is enclosed
in double-quotes in the C style as needed. In a subsequent commit,
missing object type info will also be added.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
Acked-by: Christian Couder <christian.couder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agobuiltin/repack: fix `--keep-unreachable` when there are no packs
Patrick Steinhardt [Tue, 4 Feb 2025 07:00:41 +0000 (08:00 +0100)] 
builtin/repack: fix `--keep-unreachable` when there are no packs

The "--keep-unreachable" flag is supposed to append any unreachable
objects to the newly written pack. This flag is explicitly documented as
appending both packed and loose unreachable objects to the new packfile.
And while this works alright when repacking with preexisting packfiles,
it stops working when the repository does not have any packfiles at all.

The root cause are the conditions used to decide whether or not we want
to append "--pack-loose-unreachable" to git-pack-objects(1). There are
a couple of conditions here:

  - `has_existing_non_kept_packs()` checks whether there are existing
    packfiles. This condition makes sense to guard "--keep-pack=",
    "--unpack-unreachable" and "--keep-unreachable", because all of
    these flags only make sense in combination with existing packfiles.
    But it does not make sense to disable `--pack-loose-unreachable`
    when there aren't any preexisting packfiles, as loose objects can be
    packed into the new packfile regardless of that.

  - `delete_redundant` checks whether we want to delete any objects or
    packs that are about to become redundant. The documentation of
    `--keep-unreachable` explicitly says that `git repack -ad` needs to
    be executed for the flag to have an effect.

    It is not immediately obvious why such redundant objects need to be
    deleted in order for "--pack-unreachable-objects" to be effective.
    But as things are working as documented this is nothing we'll change
    for now.

  - `pack_everything & PACK_CRUFT` checks that we're not creating a
    cruft pack. This condition makes sense in the context of
    "--pack-loose-unreachable", as unreachable objects would end up in
    the cruft pack anyway.

So while the second and third condition are sensible, it does not make
any sense to condition `--pack-loose-unreachable` on the existence of
packfiles.

Fix the bug by splitting out the "--pack-loose-unreachable" and only
making it depend on the second and third condition. Like this, loose
unreachable objects will be packed regardless of any preexisting
packfiles.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoremote: relocate valid_remote_name
Meet Soni [Tue, 4 Feb 2025 14:28:52 +0000 (19:58 +0530)] 
remote: relocate valid_remote_name

Move the `valid_remote_name()` function from the refspec subsystem to
the remote subsystem to better align with the separation of concerns.

Signed-off-by: Meet Soni <meetsoni3017@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agorefspec: relocate apply_refspecs and related funtions
Meet Soni [Tue, 4 Feb 2025 04:05:58 +0000 (09:35 +0530)] 
refspec: relocate apply_refspecs and related funtions

Move the functions `apply_refspecs()` and `apply_negative_refspecs()`
from `remote.c` to `refspec.c`. These functions focus on applying
refspecs, so centralizing them in `refspec.c` improves code organization
by keeping refspec-related logic in one place.

Signed-off-by: Meet Soni <meetsoni3017@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agorefspec: relocate matching related functions
Meet Soni [Tue, 4 Feb 2025 04:05:57 +0000 (09:35 +0530)] 
refspec: relocate matching related functions

Move the functions `refspec_find_match()`, `refspec_find_all_matches()`
and `refspec_find_negative_match()` from `remote.c` to `refspec.c`.
These functions focus on matching refspecs, so centralizing them in
`refspec.c` improves code organization by keeping refspec-related logic
in one place.

Signed-off-by: Meet Soni <meetsoni3017@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoremote: rename query_refspecs functions
Meet Soni [Tue, 4 Feb 2025 04:05:56 +0000 (09:35 +0530)] 
remote: rename query_refspecs functions

Rename functions related to handling refspecs in preparation for their
move from `remote.c` to `refspec.c`. Update their names to better
reflect their intent:

    - `query_refspecs()` -> `refspec_find_match()` for clarity, as it
      finds a single matching refspec.

    - `query_refspecs_multiple()` -> `refspec_find_all_matches()` to
      better reflect that it collects all matching refspecs instead of
      returning just the first match.

    - `query_matches_negative_refspec()` ->
      `refspec_find_negative_match()` for consistency with the
      updated naming convention, even though this static function
      didn't strictly require renaming.

Signed-off-by: Meet Soni <meetsoni3017@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agorefspec: relocate refname_matches_negative_refspec_item
Meet Soni [Tue, 4 Feb 2025 04:05:55 +0000 (09:35 +0530)] 
refspec: relocate refname_matches_negative_refspec_item

Move the functions `refname_matches_negative_refspec_item()`,
`refspec_match()`, and `match_name_with_pattern()` from `remote.c` to
`refspec.c`. These functions focus on refspec matching, so placing them
in `refspec.c` aligns with the separation of concerns. Keep
refspec-related logic in `refspec.c` and remote-specific logic in
`remote.c` for better code organization.

Signed-off-by: Meet Soni <meetsoni3017@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoremote: rename function omit_name_by_refspec
Meet Soni [Tue, 4 Feb 2025 04:05:54 +0000 (09:35 +0530)] 
remote: rename function omit_name_by_refspec

Rename the function `omit_name_by_refspec()` to
`refname_matches_negative_refspec_item()` to provide clearer intent.
The previous function name was vague and did not accurately describe its
purpose. By using `refname_matches_negative_refspec_item`, make the
function's purpose more intuitive, clarifying that it checks if a
reference name matches any negative refspec.

Rename function parameters for consistency with existing naming
conventions. Use `refname` instead of `name` to align with terminology
in `refs.h`.

Remove the redundant doc comment since the function name is now
self-explanatory.

Signed-off-by: Meet Soni <meetsoni3017@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agobackfill: assume --sparse when sparse-checkout is enabled
Derrick Stolee [Mon, 3 Feb 2025 17:11:07 +0000 (17:11 +0000)] 
backfill: assume --sparse when sparse-checkout is enabled

The previous change introduced the '--[no-]sparse' option for the 'git
backfill' command, but did not assume it as enabled by default. However,
this is likely the behavior that users will most often want to happen.
Without this default, users with a small sparse-checkout may be confused
when 'git backfill' downloads every version of every object in the full
history.

However, this is left as a separate change so this decision can be reviewed
independently of the value of the '--[no-]sparse' option.

Add a test of adding the '--sparse' option to a repo without sparse-checkout
to make it clear that supplying it without a sparse-checkout is an error.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agobackfill: add --sparse option
Derrick Stolee [Mon, 3 Feb 2025 17:11:06 +0000 (17:11 +0000)] 
backfill: add --sparse option

One way to significantly reduce the cost of a Git clone and later fetches is
to use a blobless partial clone and combine that with a sparse-checkout that
reduces the paths that need to be populated in the working directory. Not
only does this reduce the cost of clones and fetches, the sparse-checkout
reduces the number of objects needed to download from a promisor remote.

However, history investigations can be expensive as computing blob diffs
will trigger promisor remote requests for one object at a time. This can be
avoided by downloading the blobs needed for the given sparse-checkout using
'git backfill' and its new '--sparse' mode, at a time that the user is
willing to pay that extra cost.

Note that this is distinctly different from the '--filter=sparse:<oid>'
option, as this assumes that the partial clone has all reachable trees and
we are using client-side logic to avoid downloading blobs outside of the
sparse-checkout cone. This avoids the server-side cost of walking trees
while also achieving a similar goal. It also downloads in batches based on
similar path names, presenting a resumable download if things are
interrupted.

This augments the path-walk API to have a possibly-NULL 'pl' member that may
point to a 'struct pattern_list'. This could be more general than the
sparse-checkout definition at HEAD, but 'git backfill --sparse' is currently
the only consumer.

Be sure to test this in both cone mode and not cone mode. Cone mode has the
benefit that the path-walk can skip certain paths once they would expand
beyond the sparse-checkout. Non-cone mode can describe the included files
using both positive and negative patterns, which changes the possible return
values of path_matches_pattern_list(). Test both kinds of matches for
increased coverage.

To test this, we can create a blobless sparse clone, expand the
sparse-checkout slightly, and then run 'git backfill --sparse' to see
how much data is downloaded. The general steps are

 1. git clone --filter=blob:none --sparse <url>
 2. git sparse-checkout set <dir1> ... <dirN>
 3. git backfill --sparse

For the Git repository with the 'builtin' directory in the
sparse-checkout, we get these results for various batch sizes:

| Batch Size      | Pack Count | Pack Size | Time  |
|-----------------|------------|-----------|-------|
| (Initial clone) | 3          | 110 MB    |       |
| 10K             | 12         | 192 MB    | 17.2s |
| 15K             | 9          | 192 MB    | 15.5s |
| 20K             | 8          | 192 MB    | 15.5s |
| 25K             | 7          | 192 MB    | 14.7s |

This case matters less because a full clone of the Git repository from
GitHub is currently at 277 MB.

Using a copy of the Linux repository with the 'kernel/' directory in the
sparse-checkout, we get these results:

| Batch Size      | Pack Count | Pack Size | Time |
|-----------------|------------|-----------|------|
| (Initial clone) | 2          | 1,876 MB  |      |
| 10K             | 11         | 2,187 MB  | 46s  |
| 25K             | 7          | 2,188 MB  | 43s  |
| 50K             | 5          | 2,194 MB  | 44s  |
| 100K            | 4          | 2,194 MB  | 48s  |

This case is more meaningful because a full clone of the Linux
repository is currently over 6 GB, so this is a valuable way to download
a fraction of the repository and no longer need network access for all
reachable objects within the sparse-checkout.

Choosing a batch size will depend on a lot of factors, including the
user's network speed or reliability, the repository's file structure,
and how many versions there are of the file within the sparse-checkout
scope. There will not be a one-size-fits-all solution.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agobackfill: add --min-batch-size=<n> option
Derrick Stolee [Mon, 3 Feb 2025 17:11:05 +0000 (17:11 +0000)] 
backfill: add --min-batch-size=<n> option

Users may want to specify a minimum batch size for their needs. This is only
a minimum: the path-walk API provides a list of OIDs that correspond to the
same path, and thus it is optimal to allow delta compression across those
objects in a single server request.

We could consider limiting the request to have a maximum batch size in the
future. For now, we let the path-walk API batches determine the
boundaries.

To get a feeling for the value of specifying the --min-batch-size parameter,
I tested a number of open source repositories available on GitHub. The
procedure was generally:

 1. git clone --filter=blob:none <url>
 2. git backfill

Checking the number of packfiles and the size of the .git/objects/pack
directory helps to identify the effects of different batch sizes.

For the Git repository, we get these results:

| Batch Size      | Pack Count | Pack Size | Time  |
|-----------------|------------|-----------|-------|
| (Initial clone) | 2          | 119 MB    |       |
| 25K             | 8          | 290 MB    | 24s   |
| 50K             | 5          | 290 MB    | 24s   |
| 100K            | 4          | 290 MB    | 29s   |

Other than the packfile counts decreasing as we need fewer batches, the
size and time required is not changing much for this small example.

For the nodejs/node repository, we see these results:

| Batch Size      | Pack Count | Pack Size | Time   |
|-----------------|------------|-----------|--------|
| (Initial clone) | 2          | 330 MB    |        |
| 25K             | 19         | 1,222 MB  | 1m 22s |
| 50K             | 11         | 1,221 MB  | 1m 24s |
| 100K            | 7          | 1,223 MB  | 1m 40s |
| 250K            | 4          | 1,224 MB  | 2m 23s |
| 500K            | 3          | 1,216 MB  | 4m 38s |

Here, we don't have much difference in the size of the repo, though the
500K batch size results in a few MB gained. That comes at a cost of a
much longer time. This extra time is due to server-side delta
compression happening as the on-disk deltas don't appear to be reusable
all the time. But for smaller batch sizes, the server is able to find
reasonable deltas partly because we are asking for objects that appear
in the same region of the directory tree and include all versions of a
file at a specific path.

To contrast this example, I tested the microsoft/fluentui repo, which
has been known to have inefficient packing due to name hash collisions.
These results are found before GitHub had the opportunity to repack the
server with more advanced name hash versions:

| Batch Size      | Pack Count | Pack Size | Time   |
|-----------------|------------|-----------|--------|
| (Initial clone) | 2          | 105 MB    |        |
| 5K              | 53         | 348 MB    | 2m 26s |
| 10K             | 28         | 365 MB    | 2m 22s |
| 15K             | 19         | 407 MB    | 2m 21s |
| 20K             | 15         | 393 MB    | 2m 28s |
| 25K             | 13         | 417 MB    | 2m 06s |
| 50K             | 8          | 509 MB    | 1m 34s |
| 100K            | 5          | 535 MB    | 1m 56s |
| 250K            | 4          | 698 MB    | 1m 33s |
| 500K            | 3          | 696 MB    | 1m 42s |

Here, a larger variety of batch sizes were chosen because of the great
variation in results. By asking the server to download small batches
corresponding to fewer paths at a time, the server is able to provide
better compression for these batches than it would for a regular clone.
A typical full clone for this repository would require 738 MB.

This example justifies the choice to batch requests by path name,
leading to improved communication with a server that is not optimally
packed.

Finally, the same experiment for the Linux repository had these results:

| Batch Size      | Pack Count | Pack Size | Time    |
|-----------------|------------|-----------|---------|
| (Initial clone) | 2          | 2,153 MB  |         |
| 25K             | 63         | 6,380 MB  | 14m 08s |
| 50K             | 58         | 6,126 MB  | 15m 11s |
| 100K            | 30         | 6,135 MB  | 18m 11s |
| 250K            | 14         | 6,146 MB  | 18m 22s |
| 500K            | 8          | 6,143 MB  | 33m 29s |

Even in this example, where the default name hash algorithm leads to
decent compression of the Linux kernel repository, there is value for
selecting a smaller batch size, to a limit. The 25K batch size has the
fastest time, but uses 250 MB more than the 50K batch size. The 500K
batch size took much more time due to server compression time and thus
we should avoid large batch sizes like this.

Based on these experiments, a batch size of 50,000 was chosen as the
default value.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agobackfill: basic functionality and tests
Derrick Stolee [Mon, 3 Feb 2025 17:11:04 +0000 (17:11 +0000)] 
backfill: basic functionality and tests

The default behavior of 'git backfill' is to fetch all missing blobs that
are reachable from HEAD. Document and test this behavior.

The implementation is a very simple use of the path-walk API, initializing
the revision walk at HEAD to start the path-walk from all commits reachable
from HEAD. Ignore the object arrays that correspond to tree entries,
assuming that they are all present already.

The path-walk API provides lists of objects in batches according to a
common path, but that list could be very small. We want to balance the
number of requests to the server with the ability to have the process
interrupted with minimal repeated work to catch up in the next run.
Based on some experiments (detailed in the next change) a minimum batch
size of 50,000 is selected for the default.

This batch size is a _minimum_. As the path-walk API emits lists of blob
IDs, they are collected into a list of objects for a request to the
server. When that list is at least the minimum batch size, then the
request is sent to the server for the new objects. However, the list of
blob IDs from the path-walk API could be much longer than the batch
size. At this moment, it is unclear if there is a benefit to split the
list when there are too many objects at the same path.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agobackfill: add builtin boilerplate
Derrick Stolee [Mon, 3 Feb 2025 17:11:03 +0000 (17:11 +0000)] 
backfill: add builtin boilerplate

In anticipation of implementing 'git backfill', populate the necessary files
with the boilerplate of a new builtin. Mark the builtin as experimental at
this time, allowing breaking changes in the near future, if necessary.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoMerge branch 'master' into ds/backfill
Junio C Hamano [Tue, 4 Feb 2025 00:12:33 +0000 (16:12 -0800)] 
Merge branch 'master' into ds/backfill

* master: (446 commits)
  The seventh batch
  The sixth batch
  The fifth batch
  The fourth batch
  refs/reftable: fix uninitialized memory access of `max_index`
  remote: announce removal of "branches/" and "remotes/"
  The third batch
  hash.h: drop unsafe_ function variants
  csum-file: introduce hashfile_checkpoint_init()
  t/helper/test-hash.c: use unsafe_hash_algo()
  csum-file.c: use unsafe_hash_algo()
  hash.h: introduce `unsafe_hash_algo()`
  csum-file.c: extract algop from hashfile_checksum_valid()
  csum-file: store the hash algorithm as a struct field
  t/helper/test-tool: implement sha1-unsafe helper
  trace2: prevent segfault on config collection with valueless true
  refs: fix creation of reflog entries for symrefs
  ci: wire up Visual Studio build with Meson
  ci: raise error when Meson generates warnings
  meson: fix compilation with Visual Studio
  ...

4 months agosend-pack: gracefully close the connection for atomic push
Jiang Xin [Mon, 3 Feb 2025 06:29:38 +0000 (07:29 +0100)] 
send-pack: gracefully close the connection for atomic push

Patrick reported an issue that the exit code of git-receive-pack(1) is
ignored during atomic push with "--porcelain" flag, and added new test
cases in t5543.

This issue originated from commit 7dcbeaa0df (send-pack: fix
inconsistent porcelain output, 2020-04-17). At that time, I chose to
ignore the exit code of "finish_connect()" without investigating the
root cause of the abnormal termination of git-receive-pack. That was an
incorrect solution.

The root cause is that an atomic push operation terminates early without
sending a flush packet to git-receive-pack. As a result,
git-receive-pack continues waiting for commands without exiting. By
sending a flush packet at the appropriate location in "send_pack()", we
ensure that the git-receive-pack process closes properly, avoiding an
erroneous exit code for git-push. At the same time, revert the changes
to the "transport.c" file made in commit 7dcbeaa0df.

Reported-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agot5543: atomic push reports exit code failure
Patrick Steinhardt [Mon, 3 Feb 2025 06:29:37 +0000 (07:29 +0100)] 
t5543: atomic push reports exit code failure

Add new test cases in t5543 to avoid ignoring the exit code of
git-receive-pack(1) during atomic push with "--porcelain" flag.

We'd typically notice this case because the refs would have their error
message set. But there is an edge case when pushing refs succeeds, but
git-receive-pack(1) exits with a non-zero exit code at a later point in
time due to another error. An atomic git-push(1) would ignore that error
code, and consequently it would return successfully and not print any
error message at all.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agosend-pack: new return code "ERROR_SEND_PACK_BAD_REF_STATUS"
Jiang Xin [Mon, 3 Feb 2025 06:29:36 +0000 (07:29 +0100)] 
send-pack: new return code "ERROR_SEND_PACK_BAD_REF_STATUS"

The "push_refs" function in the transport_vtable is the handler for
git-push operation. All the "push_refs" functions for different
transports (protocols) should have the same behavior, but the behavior
of "git_transport_push()" function for builtin_smart_vtable in
"transport.c" (which calls "send_pack()" in "send-pack.c") differs from
the handler of the HTTP protocol.

The "push_refs()" function for the HTTP protocol which calls the
"push_refs_with_push()" function in "transport-helper.c" will return 0
even when a bad REF_STATUS (such as REF_STATUS_REJECT_NONFASTFORWARD)
was found. But "send_pack()" for Git smart protocol will return -1 for
a bad REF_STATUS.

We cannot ignore bad REF_STATUS directly in the "send_pack()" function,
because the function is also used in "builtin/send-pack.c". So we add a
new non-zero error code "SEND_PACK_ERROR_REF_STATUS" for "send_pack()".

Ignore the specific error code in the "git_transport_push()" function to
have the same behavior as "push_refs()" for HTTP protocol. Note that
even though we ignore the error here, we'll ultimately still end up
detecting that a subset of refs was not pushed in `transport_push()`
because we eventually call `push_had_errors()` on the remote refs.

Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agot5548: add porcelain push test cases for dry-run mode
Jiang Xin [Mon, 3 Feb 2025 06:29:35 +0000 (07:29 +0100)] 
t5548: add porcelain push test cases for dry-run mode

New dry-run test cases:

 - git push --porcelain --dry-run
 - git push --porcelain --dry-run --force
 - git push --porcelain --dry-run --atomic
 - git push --porcelain --dry-run --atomic --force

Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agot5548: add new porcelain test cases
Patrick Steinhardt [Mon, 3 Feb 2025 06:29:34 +0000 (07:29 +0100)] 
t5548: add new porcelain test cases

Add two more test cases exercising git-push(1) with `--procelain`, one
exercising a non-atomic and one exercising an atomic push.

Based-on-patch-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agot5548: refactor test cases by resetting upstream
Jiang Xin [Mon, 3 Feb 2025 06:29:33 +0000 (07:29 +0100)] 
t5548: refactor test cases by resetting upstream

Refactor the test cases with the following changes:

 - Calling setup_upstream() to reset upstream after running each test
   case.

 - Change the initial branch tips of the workspace to reduce the branch
   setup operations in the workspace.

 - Reduced the two steps of setting up and cleaning up the pre-receive
   hook by moving the operations into the corresponding test case,

Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agot5548: refactor to reuse setup_upstream() function
Jiang Xin [Mon, 3 Feb 2025 06:29:32 +0000 (07:29 +0100)] 
t5548: refactor to reuse setup_upstream() function

Refactor the function setup_upstream_and_workbench(), extracting
create_upstream_template() and setup_upstream() from it. The former is
used to create the upstream repository template, while the latter is
used to rebuild the upstream repository and will be reused in subsequent
commits.

To ensure that setup_upstream() works properly in both local and HTTP
protocols, the HTTP settings have been moved to the setup_upstream() and
setup_upstream_and_workbench() functions.

Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agot5504: modernize test by moving heredocs into test bodies
Patrick Steinhardt [Mon, 3 Feb 2025 06:29:31 +0000 (07:29 +0100)] 
t5504: modernize test by moving heredocs into test bodies

We have several heredocs in t5504 located outside of any particular test
bodies. Move these into the test bodies to match our modern coding
style.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agot6423: fix suppression of Git’s exit code in tests
Ayush Chandekar [Sun, 2 Feb 2025 12:09:26 +0000 (17:39 +0530)] 
t6423: fix suppression of Git’s exit code in tests

Some test in t6423 supress Git's exit code, which can cause test
failures go unnoticed. Specifically using git <subcommand> |
<other-command> masks potential failures of the Git command.

This commit ensures that Git's exit status is correctly propogated by:
- Avoiding pipes that suppress exit codes.

Signed-off-by: Ayush Chandekar <ayu.chandekar@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agohelp: add "show" as a valid configuration value
David Aguilar [Sat, 1 Feb 2025 21:33:19 +0000 (13:33 -0800)] 
help: add "show" as a valid configuration value

Add a literal value for showing the suggested autocorrection
for consistency with the rest of the help.autocorrect options.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agohelp: show the suggested command when help.autocorrect is false
David Aguilar [Sat, 1 Feb 2025 21:33:18 +0000 (13:33 -0800)] 
help: show the suggested command when help.autocorrect is false

Make the handling of false boolean values for help.autocorrect
consistent with the handling of value 0 by showing the suggested
commands but not running them.

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 months agoMerge branch 'sc/help-autocorrect-one' into da/help-autocorrect-one-fix
Junio C Hamano [Mon, 3 Feb 2025 23:21:57 +0000 (15:21 -0800)] 
Merge branch 'sc/help-autocorrect-one' into da/help-autocorrect-one-fix

* sc/help-autocorrect-one:
  help: interpret boolean string values for help.autocorrect

4 months agot5401: prefer test_path_is_* helper function
ambar chakravartty [Sat, 1 Feb 2025 07:12:10 +0000 (12:42 +0530)] 
t5401: prefer test_path_is_* helper function

"test -f" does not provide a nice error message when we hit test
failures, so use test_path_is_file instead.

Signed-off-by: ambar chakravartty <amch9605@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>