]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
2 months agomeson: do a full usage-based compile check for sysinfo
Eli Schwartz [Fri, 25 Apr 2025 05:25:42 +0000 (01:25 -0400)] 
meson: do a full usage-based compile check for sysinfo

On Solaris, sys/sysinfo.h is a completely different file and doesn't
resemble the linux file at all. There is also a sysinfo() function, but
it takes a totally different call signature, which asks for:

- the field you wish to receive
- a `char *buf` to copy the data to

and is very useful IFF you want to know, say, the hardware provider. Or,
get *specific* fields from uname(2).

https://docs.oracle.com/cd/E86824_01/html/E54765/sysinfo-2.html

It is surely possible to do this manually via `sysconf(3)` without the
nice API. I can't find anything more direct. Either way, I'm not very
attached to Solaris, so someone who cares can add it. Either way, it's
wrong to assume that sysinfo.h contains what we are looking for.

Check that sysinfo.h defines the struct we actually utilize in
builtins/gc.c, which will correctly fail on systems that don't have it.

Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agomeson: check for getpagesize before using it
Eli Schwartz [Fri, 25 Apr 2025 05:25:41 +0000 (01:25 -0400)] 
meson: check for getpagesize before using it

It is deprecated and removed in SUS v3 / POSIX 2001, so various systems
may not include it. Solaris, in particular, carefully refrains from
defining it except inside of a maze of `#ifdef` to make sure you have
kept your nose clean and only used it in code that *targets* SUS v2 or
earlier.

config.mak.uname defines this automatically, though only for QNX.

Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agomeson: simplify and parameterize various standard function checks
Eli Schwartz [Fri, 25 Apr 2025 05:25:40 +0000 (01:25 -0400)] 
meson: simplify and parameterize various standard function checks

This is repetitive logic. We either want to use some -lc function, or if
it is not available we define it as -DNO_XXX and usually (but not
always) provide some custom compatibility impl instead.

Checking the intent of each block when reading through the file is slow
and not very DRY. Switch to taking an array of checkable functions
instead.

Not all functions are straightforward to move, since different macro
prefixes are used.

Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoThe seventh batch
Junio C Hamano [Thu, 17 Apr 2025 15:55:34 +0000 (08:55 -0700)] 
The seventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoMerge branch 'ab/environment-clean-header'
Junio C Hamano [Thu, 17 Apr 2025 17:28:20 +0000 (10:28 -0700)] 
Merge branch 'ab/environment-clean-header'

Code clean-up.

* ab/environment-clean-header:
  environment.h: remove unused variables

2 months agoMerge branch 'ps/refname-avail-check-optim'
Junio C Hamano [Thu, 17 Apr 2025 17:28:19 +0000 (10:28 -0700)] 
Merge branch 'ps/refname-avail-check-optim'

Incorrect sorting of refs with bytes with high-bit set on platforms
with signed char led to a BUG, which has been corrected.

* ps/refname-avail-check-optim:
  refs/packed: fix BUG when seeking refs with UTF-8 characters

2 months agoMerge branch 'cj/refname-avail-check-optim-typofix'
Junio C Hamano [Thu, 17 Apr 2025 17:28:19 +0000 (10:28 -0700)] 
Merge branch 'cj/refname-avail-check-optim-typofix'

Comment fix.

* cj/refname-avail-check-optim-typofix:
  refs: fix duplicated word in comment

2 months agoMerge branch 'ua/update-update-server-info'
Junio C Hamano [Thu, 17 Apr 2025 17:28:18 +0000 (10:28 -0700)] 
Merge branch 'ua/update-update-server-info'

Code simplification.

* ua/update-update-server-info:
  builtin/update-server-info: remove unnecessary if statement

2 months agoMerge branch 'en/merge-recursive-debug'
Junio C Hamano [Thu, 17 Apr 2025 17:28:18 +0000 (10:28 -0700)] 
Merge branch 'en/merge-recursive-debug'

Remove remnants of the recursive merge strategy backend, which was
superseded by the ort merge strategy.

* en/merge-recursive-debug:
  builtin/{merge,rebase,revert}: remove GIT_TEST_MERGE_ALGORITHM
  tests: remove GIT_TEST_MERGE_ALGORITHM and test_expect_merge_algorithm
  merge-recursive.[ch]: thoroughly debug these
  merge, sequencer: switch recursive merges over to ort
  sequencer: switch non-recursive merges over to ort
  merge-ort: enable diff-algorithms other than histogram
  builtin/merge-recursive: switch to using merge_ort_generic()
  checkout: replace merge_trees() with merge_ort_nonrecursive()

2 months agoMerge branch 'kn/blame-porcelain-unblamable'
Junio C Hamano [Thu, 17 Apr 2025 17:28:17 +0000 (10:28 -0700)] 
Merge branch 'kn/blame-porcelain-unblamable'

"git blame --porcelain" mode now talks about unblamable lines and
lines that are blamed to an ignored commit.

* kn/blame-porcelain-unblamable:
  blame: print unblamable and ignored commits in porcelain mode

2 months agoMerge branch 'jk/fetch-follow-remote-head-fix'
Junio C Hamano [Thu, 17 Apr 2025 17:28:17 +0000 (10:28 -0700)] 
Merge branch 'jk/fetch-follow-remote-head-fix'

"git fetch [<remote>]" with only the configured fetch refspec
should be the only thing to update refs/remotes/<remote>/HEAD,
but the code was overly eager to do so in other cases.

* jk/fetch-follow-remote-head-fix:
  fetch: make set_head() call easier to read
  fetch: don't ask for remote HEAD if followRemoteHEAD is "never"
  fetch: only respect followRemoteHEAD with configured refspecs

2 months agoThe sixth batch
Junio C Hamano [Wed, 16 Apr 2025 20:54:47 +0000 (13:54 -0700)] 
The sixth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoMerge branch 'ps/cat-file-filter-batch'
Junio C Hamano [Wed, 16 Apr 2025 20:54:20 +0000 (13:54 -0700)] 
Merge branch 'ps/cat-file-filter-batch'

"git cat-file --batch" and friends learned to allow "--filter=" to
omit certain objects, just like the transport layer does.

* ps/cat-file-filter-batch:
  builtin/cat-file: use bitmaps to efficiently filter by object type
  builtin/cat-file: deduplicate logic to iterate over all objects
  pack-bitmap: introduce function to check whether a pack is bitmapped
  pack-bitmap: add function to iterate over filtered bitmapped objects
  pack-bitmap: allow passing payloads to `show_reachable_fn()`
  builtin/cat-file: support "object:type=" objects filter
  builtin/cat-file: support "blob:limit=" objects filter
  builtin/cat-file: support "blob:none" objects filter
  builtin/cat-file: wire up an option to filter objects
  builtin/cat-file: introduce function to report object status
  builtin/cat-file: rename variable that tracks usage

2 months agoMerge branch 'ps/test-wo-perl-prereq'
Junio C Hamano [Wed, 16 Apr 2025 20:54:20 +0000 (13:54 -0700)] 
Merge branch 'ps/test-wo-perl-prereq'

"make test" used to have a hard dependency on (basic) Perl; tests
have been rewritten help environment with NO_PERL test the build as
much as possible.

* ps/test-wo-perl-prereq:
  t5703: refactor test to not depend on Perl
  t5316: refactor `max_chain()` to not depend on Perl
  t0210: refactor trace2 scrubbing to not use Perl
  t0021: refactor `generate_random_characters()` to not depend on Perl
  t/lib-httpd: refactor "one-time-perl" CGI script to not depend on Perl
  t/lib-t6000: refactor `name_from_description()` to not depend on Perl
  t/lib-gpg: refactor `sanitize_pgp()` to not depend on Perl
  t: refactor tests depending on Perl for textconv scripts
  t: refactor tests depending on Perl to print data
  t: refactor tests depending on Perl substitution operator
  t: refactor tests depending on Perl transliteration operator
  Makefile: stop requiring Perl when running tests
  meson: stop requiring Perl when tests are enabled
  t: adapt existing PERL prerequisites
  t: introduce PERL_TEST_HELPERS prerequisite
  t: adapt `test_readlink()` to not use Perl
  t: adapt `test_copy_bytes()` to not use Perl
  t: adapt character translation helpers to not use Perl
  t: refactor environment sanitization to not use Perl
  t: skip chain lint when PERL_PATH is unset

2 months agoMerge branch 'jt/help-sha-backend-info-in-build-options'
Junio C Hamano [Wed, 16 Apr 2025 20:54:19 +0000 (13:54 -0700)] 
Merge branch 'jt/help-sha-backend-info-in-build-options'

"git help --build-options" reports SHA-1 and SHA-256 backends used
in the build.

* jt/help-sha-backend-info-in-build-options:
  help: include unsafe SHA-1 build info in version
  help: include SHA implementation in version info

2 months agoMerge branch 'kn/non-transactional-batch-updates'
Junio C Hamano [Wed, 16 Apr 2025 20:54:19 +0000 (13:54 -0700)] 
Merge branch 'kn/non-transactional-batch-updates'

Updating multiple references have only been possible in all-or-none
fashion with transactions, but it can be more efficient to batch
multiple updates even when some of them are allowed to fail in a
best-effort manner.  A new "best effort batches of updates" mode
has been introduced.

* kn/non-transactional-batch-updates:
  update-ref: add --batch-updates flag for stdin mode
  refs: support rejection in batch updates during F/D checks
  refs: implement batch reference update support
  refs: introduce enum-based transaction error types
  refs/reftable: extract code from the transaction preparation
  refs/files: remove duplicate duplicates check
  refs: move duplicate refname update check to generic layer
  refs/files: remove redundant check in split_symref_update()

2 months agoMerge branch 'zy/send-email-error-handling'
Junio C Hamano [Wed, 16 Apr 2025 20:54:19 +0000 (13:54 -0700)] 
Merge branch 'zy/send-email-error-handling'

Auth-related (and unrelated) error handling in send-email has been
made more robust.

* zy/send-email-error-handling:
  send-email: finer-grained SMTP error handling
  send-email: capture errors in an eval {} block

2 months agoMerge branch 'ps/maintenance-reflog-expire'
Junio C Hamano [Wed, 16 Apr 2025 20:54:19 +0000 (13:54 -0700)] 
Merge branch 'ps/maintenance-reflog-expire'

"git maintenance" learns a new task to expire reflog entries.

* ps/maintenance-reflog-expire:
  builtin/maintenance: introduce "reflog-expire" task
  builtin/gc: split out function to expire reflog entries
  builtin/reflog: make functions regarding `reflog_expire_options` public
  builtin/reflog: stop storing per-reflog expiry dates globally
  builtin/reflog: stop storing default reflog expiry dates globally
  reflog: rename `cmd_reflog_expire_cb` to `reflog_expire_options`

2 months agoMerge branch 'jt/rev-list-z'
Junio C Hamano [Wed, 16 Apr 2025 20:54:18 +0000 (13:54 -0700)] 
Merge branch 'jt/rev-list-z'

"git rev-list" learns machine-parsable output format that delimits
each field with NUL.

* jt/rev-list-z:
  rev-list: support NUL-delimited --missing option
  rev-list: support NUL-delimited --boundary option
  rev-list: support delimiting objects with NUL bytes
  rev-list: refactor early option parsing
  rev-list: inline `show_object_with_name()` in `show_object()`

2 months agoMerge branch 'ab/pathspec-sign-compare-workaround'
Junio C Hamano [Wed, 16 Apr 2025 20:54:18 +0000 (13:54 -0700)] 
Merge branch 'ab/pathspec-sign-compare-workaround'

Some warnings from "-Wsign-compare" for pathspec.c have been
squelched.

* ab/pathspec-sign-compare-workaround:
  pathspec: fix sign comparison warnings

2 months agoMerge branch 'ps/misc-build-fixes'
Junio C Hamano [Wed, 16 Apr 2025 20:54:18 +0000 (13:54 -0700)] 
Merge branch 'ps/misc-build-fixes'

Random build fixes.

* ps/misc-build-fixes:
  ci: use Visual Studio for win+meson job on GitHub Workflows
  meson: distinguish build and target host binaries
  meson: respect 'tests' build option in contrib
  gitweb: fix generation of "gitweb.js"
  meson: fix handling of '-Dcurl=auto'

2 months agoMerge branch 'sk/clar-trailer-urlmatch-norm-test'
Junio C Hamano [Wed, 16 Apr 2025 20:54:17 +0000 (13:54 -0700)] 
Merge branch 'sk/clar-trailer-urlmatch-norm-test'

A few traditional unit tests have been rewritten to use the clar
framework.

* sk/clar-trailer-urlmatch-norm-test:
  t/unit-tests: convert urlmatch-normalization test to clar
  t/unit-tests: convert trailer test to use clar

2 months agoMerge branch 'ab/rm-sign-compare'
Junio C Hamano [Wed, 16 Apr 2025 20:54:17 +0000 (13:54 -0700)] 
Merge branch 'ab/rm-sign-compare'

Some warnings from "-Wsign-compare" for builtin/rm.c have been
squelched.

* ab/rm-sign-compare:
  rm: fix sign comparison warnings

2 months agoMerge branch 'jt/ref-transaction-abort-fix'
Junio C Hamano [Wed, 16 Apr 2025 20:54:17 +0000 (13:54 -0700)] 
Merge branch 'jt/ref-transaction-abort-fix'

A ref transaction corner case fix.

* jt/ref-transaction-abort-fix:
  builtin/fetch: avoid aborting closed reference transaction

2 months agoMerge branch 'js/ci-fedora-gawk'
Junio C Hamano [Wed, 16 Apr 2025 20:54:16 +0000 (13:54 -0700)] 
Merge branch 'js/ci-fedora-gawk'

Work around CI breakage due to fedora base image getting updated.

* js/ci-fedora-gawk:
  ci(pedantic): ensure that awk is installed

2 months agoMerge branch 'js/ci-github-update-ubuntu'
Junio C Hamano [Wed, 16 Apr 2025 20:54:16 +0000 (13:54 -0700)] 
Merge branch 'js/ci-github-update-ubuntu'

Adjust to the deprecation of use of Ubuntu 20.04 GitHub Actions CI.

* js/ci-github-update-ubuntu:
  ci: upgrade `sparse` to supported build agents

2 months agoMerge branch 'dd/sparse-glibc-workaround'
Junio C Hamano [Wed, 16 Apr 2025 20:54:16 +0000 (13:54 -0700)] 
Merge branch 'dd/sparse-glibc-workaround'

Squelch false-positive from sparse.

* dd/sparse-glibc-workaround:
  sparse: ignore warning from new glibc headers

2 months agoci(pedantic): ensure that awk is installed
Johannes Schindelin [Wed, 16 Apr 2025 05:31:01 +0000 (07:31 +0200)] 
ci(pedantic): ensure that awk is installed

The image pointed to by the fedora:latest tag has moved from fedora
41 to 42. The fedora 41 container images have awk installed while
the fedora 42 images do not.  That change is most likely just part
of reducing the size of the base container images.

In both AlmaLinux and Fedora (as well as other RHEL
derivatives/relatives), awk is provided by the gawk package.

On Fedora, `dnf install awk` would work, by using the package
filelist data to determine that /usr/bin/awk is provided by gawk and
installs gawk as a result.

On AlmaLinux (8 & 9, by quick testing by Todd), that is not the case
and you'd need to use `dnf install gawk` or `dnf install '*bin/awk'`
to get it installed. Having said that, awk _is_ included in the
current AlmaLinux 8 and 9 images, so it isn't strictly needed.  But
it's probably better to be explicit that we need it installed, as a
defense against some future change to the AlmaLinux container
removing awk.

Because we know that on both of these distros, our scripts that call
for 'awk' had been using 'gawk' that was installed as part of the
base image, let's make sure that we explicitly install 'gawk'.  If
the image already has it, it would be a no-op that does not cause
breakage.

Suggested-by: Todd Zullinger <tmz@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoThe fifth batch
Junio C Hamano [Tue, 15 Apr 2025 20:50:30 +0000 (13:50 -0700)] 
The fifth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoMerge branch 'bc/allow-upload-pack-from-other-people'
Junio C Hamano [Tue, 15 Apr 2025 20:50:17 +0000 (13:50 -0700)] 
Merge branch 'bc/allow-upload-pack-from-other-people'

Test fix for an already graduated topic.

* bc/allow-upload-pack-from-other-people:
  t5605: fix test for cloning from a different user

2 months agoMerge branch 'pw/custom-conflict-marker-size-for-merge-related-docs'
Junio C Hamano [Tue, 15 Apr 2025 20:50:17 +0000 (13:50 -0700)] 
Merge branch 'pw/custom-conflict-marker-size-for-merge-related-docs'

"git-merge-file" documentation source, which has lines that look
like conflict markers, lacked custom conflict marker size defined,
which has been corrected..

* pw/custom-conflict-marker-size-for-merge-related-docs:
  merge-file doc: set conflict-marker-size attribute

2 months agoMerge branch 'js/comma-semicolon-confusion'
Junio C Hamano [Tue, 15 Apr 2025 20:50:16 +0000 (13:50 -0700)] 
Merge branch 'js/comma-semicolon-confusion'

Code clean-up.

* js/comma-semicolon-confusion:
  detect-compiler: detect clang even if it found CUDA
  clang: warn when the comma operator is used
  compat/regex: explicitly mark intentional use of the comma operator
  wildmatch: avoid using of the comma operator
  diff-delta: avoid using the comma operator
  xdiff: avoid using the comma operator unnecessarily
  clar: avoid using the comma operator unnecessarily
  kwset: avoid using the comma operator unnecessarily
  rebase: avoid using the comma operator unnecessarily
  remote-curl: avoid using the comma operator unnecessarily

2 months agoMerge branch 'jt/clone-guess-remote-head-fix'
Junio C Hamano [Tue, 15 Apr 2025 20:50:16 +0000 (13:50 -0700)] 
Merge branch 'jt/clone-guess-remote-head-fix'

"git clone" still gave the message about the default branch name;
this message has been turned into an advice message that can be
turned off.

* jt/clone-guess-remote-head-fix:
  advice: allow disabling default branch name advice
  builtin/clone: suppress unexpected default branch advice
  remote: allow `guess_remote_head()` to suppress advice

2 months agoMerge branch 'ds/maintenance-loose-objects-batchsize'
Junio C Hamano [Tue, 15 Apr 2025 20:50:16 +0000 (13:50 -0700)] 
Merge branch 'ds/maintenance-loose-objects-batchsize'

The job to coalesce loose objects into packfiles in "git
maintenance" now has configurable batch size.

* ds/maintenance-loose-objects-batchsize:
  maintenance: add loose-objects.batchSize config
  maintenance: force progress/no-quiet to children

2 months agoMerge branch 'lo/userdiff-gitconfig'
Junio C Hamano [Tue, 15 Apr 2025 20:50:15 +0000 (13:50 -0700)] 
Merge branch 'lo/userdiff-gitconfig'

* lo/userdiff-gitconfig:
  userdiff: add builtin driver for INI files

2 months agoMerge branch 'ps/mingw-creat-excl-fix'
Junio C Hamano [Tue, 15 Apr 2025 20:50:15 +0000 (13:50 -0700)] 
Merge branch 'ps/mingw-creat-excl-fix'

Fix lockfile contention in reftable code on Windows.

* ps/mingw-creat-excl-fix:
  compat/mingw: fix EACCESS when opening files with `O_CREAT | O_EXCL`
  meson: fix compat sources when compiling with MSVC

2 months agoMerge branch 'kn/reflog-drop'
Junio C Hamano [Tue, 15 Apr 2025 20:50:15 +0000 (13:50 -0700)] 
Merge branch 'kn/reflog-drop'

"git reflog" learns "drop" subcommand, that discards the entire
reflog data for a ref.

* kn/reflog-drop:
  reflog: implement subcommand to drop reflogs
  reflog: improve error for when reflog is not found

2 months agoMerge branch 'ps/object-wo-the-repository'
Junio C Hamano [Tue, 15 Apr 2025 20:50:14 +0000 (13:50 -0700)] 
Merge branch 'ps/object-wo-the-repository'

The object layer has been updated to take an explicit repository
instance as a parameter in more code paths.

* ps/object-wo-the-repository:
  hash: stop depending on `the_repository` in `null_oid()`
  hash: fix "-Wsign-compare" warnings
  object-file: split out logic regarding hash algorithms
  delta-islands: stop depending on `the_repository`
  object-file-convert: stop depending on `the_repository`
  pack-bitmap-write: stop depending on `the_repository`
  pack-revindex: stop depending on `the_repository`
  pack-check: stop depending on `the_repository`
  environment: move access to "core.bigFileThreshold" into repo settings
  pack-write: stop depending on `the_repository` and `the_hash_algo`
  object: stop depending on `the_repository`
  csum-file: stop depending on `the_repository`

2 months agoMerge branch 'md/t1403-path-is-file'
Junio C Hamano [Tue, 15 Apr 2025 20:50:14 +0000 (13:50 -0700)] 
Merge branch 'md/t1403-path-is-file'

Test tweak.

* md/t1403-path-is-file:
  t1403: verify that path exists and is a file

2 months agoMerge branch 'jk/zlib-inflate-fixes'
Junio C Hamano [Tue, 15 Apr 2025 20:50:13 +0000 (13:50 -0700)] 
Merge branch 'jk/zlib-inflate-fixes'

Fix our use of zlib corner cases.

* jk/zlib-inflate-fixes:
  unpack_loose_rest(): rewrite return handling for clarity
  unpack_loose_rest(): simplify error handling
  unpack_loose_rest(): never clean up zstream
  unpack_loose_rest(): avoid numeric comparison of zlib status
  unpack_loose_header(): avoid numeric comparison of zlib status
  git_inflate(): skip zlib_post_call() sanity check on Z_NEED_DICT
  unpack_loose_header(): fix infinite loop on broken zlib input
  unpack_loose_header(): report headers without NUL as "bad"
  unpack_loose_header(): simplify next_out assignment
  loose_object_info(): BUG() on inflating content with unknown type

2 months agoMerge branch 'ps/reftable-windows-unlink-fix'
Junio C Hamano [Tue, 15 Apr 2025 20:50:13 +0000 (13:50 -0700)] 
Merge branch 'ps/reftable-windows-unlink-fix'

Portability fix.

* ps/reftable-windows-unlink-fix:
  reftable: ignore file-in-use errors when unlink(3p) fails on Windows

2 months agoenvironment.h: remove unused variables
Arnav Bhate [Sat, 5 Apr 2025 16:45:32 +0000 (22:15 +0530)] 
environment.h: remove unused variables

packed_git_window_size and packed_git_limit are not used anywhere in
the codebase. A search found that all references were removed in
d284713bae (config: make `packed_git_(limit|window_size)` non-global
variables, 2024-12-03), except the ones in this file, as they were moved
to struct repo_settings.

Remove packed_git_window_size and packed_git_limit from environment.h.

Signed-off-by: Arnav Bhate <bhatearnav@gmail.com>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agorefs: fix duplicated word in comment
Christian Fredrik Johnsen [Sat, 5 Apr 2025 12:57:47 +0000 (12:57 +0000)] 
refs: fix duplicated word in comment

Fix a typo in a comment in refs.c: "checking checking" → "checking".

Signed-off-by: Christian Fredrik Johnsen <christian@johnsen.no>
Acked-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agorefs/packed: fix BUG when seeking refs with UTF-8 characters
Patrick Steinhardt [Fri, 4 Apr 2025 10:58:38 +0000 (12:58 +0200)] 
refs/packed: fix BUG when seeking refs with UTF-8 characters

It was reported that using git-pull(1) in a repository whose remote
contains branches with emojis leads to the following bug:

    $ git pull
    remote: Enumerating objects: 161255, done.
    remote: Counting objects: 100% (55884/55884), done.
    remote: Compressing objects: 100% (5518/5518), done.
    remote: Total 161255 (delta 54253), reused 50509 (delta 50364),
    pack-reused 105371 (from 4)
    Receiving objects: 100% (161255/161255), 309.90 MiB | 16.87 MiB/s, done.
    Resolving deltas: 100% (118048/118048), completed with 13416 local objects.
    From github.com:github/github
       97ab7ae3f3745..8fb2f9fa180ed  master -> origin/master
    [...snip many screenfuls of updates to origin remotes...]
    BUG: refs/packed-backend.c:984: packed-refs backend yielded reference
    preceding its prefix
    error: fetch died of signal 6

This issue bisects to 22600c04529 (refs/iterator: implement seeking for
packed-ref iterators, 2025-03-12) where we have implemented seeking for
the packed-ref iterator. As part of that change we introduced a check
that verifies that the iterator only returns refnames bigger than the
prefix. In theory, this check should always hold: when a prefix is set
we know that we would've seeked that prefix first, so we should never
see a reference sorting before that prefix.

But in practice the check itself is misbehaving when handling unicode
characters. The particular issue triggered with a branch that got the
"shaved ice" unicode character in its name, which is composed of the
bytes "0xEE 0x90 0xBF". The bug triggers when we compare the refname
"refs/heads/<shaved-ice>" to something like "refs/heads/z", and it
specifically hits when comparing the first byte, "0xEE".

The root cause is that the most-significant bit of 0xEE is set. The
`refname` and `prefix` pointers that we use to compare bytes with one
another are both pointers to signed characters. As such, when we
dereference the 0xEE byte the result is a _negative_ value, and this
value will of course compare smaller than "z".

We can see that this issue is avoided in `cmp_packed_refname()`, where
we explicitly cast each byte to its unsigned form. Fix the bug by doing
the same in `packed_ref_iterator_advance()`.

Reported-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agofetch: make set_head() call easier to read
Jeff King [Fri, 4 Apr 2025 08:58:12 +0000 (04:58 -0400)] 
fetch: make set_head() call easier to read

We ignore any error returned from set_head(), but 638060dcb9 (fetch
set_head: refactor to use remote directly, 2025-01-26) left its call in
a noop "if" conditional as a sort of note-to-self.

When c834d1a7ce (fetch: only respect followRemoteHEAD with configured
refspecs, 2025-03-18) added a "do_set_head" flag, it was rolled into the
same conditional, putting set_head() on the right-hand side of a
short-circuit AND.

That's not wrong, but it really hides the point of the line, which
is (maybe) calling the function.

Instead, let's have a full if() block for the flag, and then our comment
(with some rewording) will be sufficient to clarify the error handling.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoci: upgrade `sparse` to supported build agents
Johannes Schindelin [Tue, 8 Apr 2025 20:56:33 +0000 (22:56 +0200)] 
ci: upgrade `sparse` to supported build agents

The `sparse` job still uses the `ubuntu-20.04` runner pool, but that
pool is about to go away, so let's stop using it.

There is no `sparse-22.04` artifact provided by the "Build sparse for
Ubuntu" Azure Pipeline, but that is not necessary anyway because Ubuntu
22.04 has the `sparse` package: https://packages.ubuntu.com/jammy/sparse

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agosparse: ignore warning from new glibc headers
Đoàn Trần Công Danh [Tue, 16 Jul 2024 23:17:41 +0000 (06:17 +0700)] 
sparse: ignore warning from new glibc headers

With at least glibc 2.39, glibc provides a function declaration that
matches with this POSIX interface:

    int regexec(const regex_t *restrict preg, const char *restrict string,
           size_t nmatch, regmatch_t pmatch[restrict], int eflags);

such prototype requires variable-length-array for `pmatch'.

Thus, sparse reports this error:

> ../add-patch.c: note: in included file (through ../git-compat-util.h):
> /usr/include/regex.h:682:41: error: undefined identifier '__nmatch'
> /usr/include/regex.h:682:41: error: bad constant expression type
> /usr/include/regex.h:682:41: error: Variable length array is used.

Note: `__nmatch' is POSIX's nmatch.

The glibc's intention is informing their users to provides a large
enough buffer to hold `__nmatch' results and provides diagnosis if
necessary.  It's merely a glibc' implementation detail.

Hide that usage from sparse by using standard C11's macro:
__STDC_NO_VLA__

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agobuiltin/update-server-info: remove unnecessary if statement
Usman Akinyemi [Mon, 7 Apr 2025 19:58:41 +0000 (01:28 +0530)] 
builtin/update-server-info: remove unnecessary if statement

Since we already teach the `repo_config()` in f29f1990 (config:
teach repo_config to allow `repo` to be NULL, 2025-03-08) to allow
`repo` to be NULL, no need to check if `repo` is NULL before calling
`repo_config()`.

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agobuiltin/{merge,rebase,revert}: remove GIT_TEST_MERGE_ALGORITHM
Elijah Newren [Tue, 8 Apr 2025 15:48:42 +0000 (15:48 +0000)] 
builtin/{merge,rebase,revert}: remove GIT_TEST_MERGE_ALGORITHM

This environment variable existed to allow the testsuite to reuse all
the merge-related tests in the testsuite while easily flipping between
the 'recursive' and the 'ort' backends.  Now that we have removed
merge-recursive and remapped 'recursive' to mean 'ort', we don't need
this scaffolding anymore.  Remove it from these three builtins.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agotests: remove GIT_TEST_MERGE_ALGORITHM and test_expect_merge_algorithm
Elijah Newren [Tue, 8 Apr 2025 15:48:41 +0000 (15:48 +0000)] 
tests: remove GIT_TEST_MERGE_ALGORITHM and test_expect_merge_algorithm

Both of these existed to allow us to reuse all the merge-related tests
in the testsuite while easily flipping between the 'recursive' and the
'ort' backends.  Now that we have removed merge-recursive and remapped
'recursive' to mean 'ort', we don't need this scaffolding anymore.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agomerge-recursive.[ch]: thoroughly debug these
Elijah Newren [Tue, 8 Apr 2025 15:48:40 +0000 (15:48 +0000)] 
merge-recursive.[ch]: thoroughly debug these

As a wise man once told me, "Deleted code is debugged code!"  So, move
the functions that are shared between merge-recursive and merge-ort from
the former to the latter, and then debug the remainder of
merge-recursive.[ch].

Joking aside, merge-ort was always intended to replace merge-recursive.
It has numerous advantages over merge-recursive (operates much faster,
can operate without a worktree or index, and fixes a number of known
bugs and suboptimal merges).  Since we have now replaced all callers of
merge-recursive with equivalent functions from merge-ort, move the
shared functions from the former to the latter, and delete the remainder
of merge-recursive.[ch].

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agomerge, sequencer: switch recursive merges over to ort
Elijah Newren [Tue, 8 Apr 2025 15:48:39 +0000 (15:48 +0000)] 
merge, sequencer: switch recursive merges over to ort

More precisely, replace calls to merge_recursive() with
merge_ort_recursive().

Also change t7615 to quit calling out recursive; it is not needed
anymore, and we are in fact using ort now.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agosequencer: switch non-recursive merges over to ort
Elijah Newren [Tue, 8 Apr 2025 15:48:38 +0000 (15:48 +0000)] 
sequencer: switch non-recursive merges over to ort

The do_recursive_merge() function, which is somewhat misleadingly named
since its purpose in life is to do a *non*-recursive merge, had code to
allow either using the recursive or ort backends.  The default has been
ort for a very long time, let's just remove the code path for allowing
the recursive backend to be selected.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agomerge-ort: enable diff-algorithms other than histogram
Elijah Newren [Tue, 8 Apr 2025 15:48:37 +0000 (15:48 +0000)] 
merge-ort: enable diff-algorithms other than histogram

The ort merge strategy has always used the histogram diff algorithm.
The recursive merge strategy, in contrast, defaults to the myers
diff algorithm, while allowing it to be changed.

Change the ort merge strategy to allow different diff algorithms, by
removing the hard coded value in merge_start() and instead just making
it a default in init_merge_options().  Technically, this also changes
the default diff algorithm for the recursive backend too, but we're
going to remove the final callers of the recursive backend in the next
two commits.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agobuiltin/merge-recursive: switch to using merge_ort_generic()
Elijah Newren [Tue, 8 Apr 2025 15:48:36 +0000 (15:48 +0000)] 
builtin/merge-recursive: switch to using merge_ort_generic()

Switch from merge-recursive to merge-ort.  Adjust the following
testcases due to the switch:

* t6430: most of the test differences here were due to improved D/F
  conflict handling explained in more detail in ef527787089c (merge
  tests: expect improved directory/file conflict handling in ort,
  2020-10-26).  These changes weren't made to this test back in that
  commit simply because I had been looking at `git merge` rather than
  `git merge-recursive`.  The final test in this testsuite, though, was
  expunged because it was looking for specific output, and the calls to
  output_commit_title() were discarded from merge_ort_internal() in its
  adaptation from merge_recursive_internal(); see 8119214f4e70
  (merge-ort: implement merge_incore_recursive(), 2020-12-16).

* t6434: This test is built entirely around rename/delete conflicts,
  which had a suboptimal handling under merge-recursive.  As explained
  in more detail in commits 1f3c9ba707 ("t6425: be more flexible with
  rename/delete conflict messages", 2020-08-10) and 727c75b23f ("t6404,
  t6423: expect improved rename/delete handling in ort backend",
  2020-10-26), rename/delete conflicts should each have two entries in
  the index rather than just one.  Adjust the expectations for all the
  tests in this testcase to see the two entries per rename/delete
  conflict.

* t6424: merge-recursive had a special check-if-toplevel-trees-match
  check that it ran at the beginning on both the merge-base and the
  other side being merged in.  In such a case, it exited early and
  printed an "Already up to date." message.  merge-ort got rid of
  this, and instead checks the merge base tree matching the other
  side throughout the tree instead of just at the toplevel, allowing
  it to avoid recursing into various subtrees.  As part of that, it
  got rid of the specialty toplevel message.  That message hasn't
  been missed for years from `git merge`, so I don't think it is
  necessary to keep it just for `git merge-recursive`, especially
  since the latter is rarely used.  (git itself only references it
  in the testsuite, whereas it used to power one of the three
  rebase backends that existed once upon a time.)

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agocheckout: replace merge_trees() with merge_ort_nonrecursive()
Elijah Newren [Tue, 8 Apr 2025 15:48:35 +0000 (15:48 +0000)] 
checkout: replace merge_trees() with merge_ort_nonrecursive()

Replace the use of merge_trees() from merge-recursive.[ch] with the
merge-ort equivalent.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoThe fourth batch
Junio C Hamano [Tue, 8 Apr 2025 18:42:53 +0000 (11:42 -0700)] 
The fourth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoMerge branch 'dk/vimdiff-doc-fix'
Junio C Hamano [Tue, 8 Apr 2025 18:43:16 +0000 (11:43 -0700)] 
Merge branch 'dk/vimdiff-doc-fix'

Doc update.

* dk/vimdiff-doc-fix:
  vimdiff: clarify the sigil used for marking the buffer to save

2 months agoMerge branch 'fr/vimdiff-layout-fixes'
Junio C Hamano [Tue, 8 Apr 2025 18:43:16 +0000 (11:43 -0700)] 
Merge branch 'fr/vimdiff-layout-fixes'

Layout configuration in vimdiff backend didn't work as advertised,
which has been corrected.

* fr/vimdiff-layout-fixes:
  mergetools: vimdiff: add tests for layout with REMOTE as the target
  mergetools: vimdiff: fix layout where REMOTE is the target

2 months agoMerge branch 'es/meson-build-skip-coccinelle'
Junio C Hamano [Tue, 8 Apr 2025 18:43:15 +0000 (11:43 -0700)] 
Merge branch 'es/meson-build-skip-coccinelle'

Build fix.

* es/meson-build-skip-coccinelle:
  meson: disable coccinelle configuration when building from a tarball

2 months agoMerge branch 'ta/bulk-checkin-signed-compare-false-warning-fix'
Junio C Hamano [Tue, 8 Apr 2025 18:43:15 +0000 (11:43 -0700)] 
Merge branch 'ta/bulk-checkin-signed-compare-false-warning-fix'

Compiler warnings workaround.

* ta/bulk-checkin-signed-compare-false-warning-fix:
  bulk-checkin: fix sign compare warnings

2 months agoMerge branch 'rs/clear-commit-marks-simplify'
Junio C Hamano [Tue, 8 Apr 2025 18:43:15 +0000 (11:43 -0700)] 
Merge branch 'rs/clear-commit-marks-simplify'

Code clean-up.

* rs/clear-commit-marks-simplify:
  commit: move clear_commit_marks_many() loop body to clear_commit_marks()

2 months agoMerge branch 'tb/incremental-midx-part-2'
Junio C Hamano [Tue, 8 Apr 2025 18:43:14 +0000 (11:43 -0700)] 
Merge branch 'tb/incremental-midx-part-2'

Incrementally updating multi-pack index files.

* tb/incremental-midx-part-2:
  midx: implement writing incremental MIDX bitmaps
  pack-bitmap.c: use `ewah_or_iterator` for type bitmap iterators
  pack-bitmap.c: keep track of each layer's type bitmaps
  ewah: implement `struct ewah_or_iterator`
  pack-bitmap.c: apply pseudo-merge commits with incremental MIDXs
  pack-bitmap.c: compute disk-usage with incremental MIDXs
  pack-bitmap.c: teach `rev-list --test-bitmap` about incremental MIDXs
  pack-bitmap.c: support bitmap pack-reuse with incremental MIDXs
  pack-bitmap.c: teach `show_objects_for_type()` about incremental MIDXs
  pack-bitmap.c: teach `bitmap_for_commit()` about incremental MIDXs
  pack-bitmap.c: open and store incremental bitmap layers
  pack-revindex: prepare for incremental MIDX bitmaps
  Documentation: describe incremental MIDX bitmaps
  Documentation: remove a "future work" item from the MIDX docs

2 months agoMerge branch 'ps/reftable-sans-compat-util'
Junio C Hamano [Tue, 8 Apr 2025 18:43:14 +0000 (11:43 -0700)] 
Merge branch 'ps/reftable-sans-compat-util'

Make the code in reftable library less reliant on the service
routines it used to borrow from Git proper, to make it easier to
use by external users of the library.

* ps/reftable-sans-compat-util:
  Makefile: skip reftable library for Coccinelle
  reftable: decouple from Git codebase by pulling in "compat/posix.h"
  git-compat-util.h: split out POSIX-emulating bits
  compat/mingw: split out POSIX-related bits
  reftable/basics: introduce `REFTABLE_UNUSED` annotation
  reftable/basics: stop using `SWAP()` macro
  reftable/stack: stop using `sleep_millisec()`
  reftable/system: introduce `reftable_rand()`
  reftable/reader: stop using `ARRAY_SIZE()` macro
  reftable/basics: provide wrappers for big endian conversion
  reftable/basics: stop using `st_mult()` in array allocators
  reftable: stop using `BUG()` in trivial cases
  reftable/record: don't `BUG()` in `reftable_record_cmp()`
  reftable/record: stop using `BUG()` in `reftable_record_init()`
  reftable/record: stop using `COPY_ARRAY()`
  reftable/blocksource: stop using `xmmap()`
  reftable/stack: stop using `write_in_full()`
  reftable/stack: stop using `read_in_full()`

2 months agoMerge branch 'ps/ci-meson-check-build-docs'
Junio C Hamano [Tue, 8 Apr 2025 18:43:13 +0000 (11:43 -0700)] 
Merge branch 'ps/ci-meson-check-build-docs'

CI update.

* ps/ci-meson-check-build-docs:
  ci: perform build and smoke tests for Meson docs

2 months agoMerge branch 'tb/http-curl-keepalive'
Junio C Hamano [Tue, 8 Apr 2025 18:43:13 +0000 (11:43 -0700)] 
Merge branch 'tb/http-curl-keepalive'

TCP keepalive behaviour on http transports can now be configured by
calling cURL library.

* tb/http-curl-keepalive:
  http.c: allow custom TCP keepalive behavior via config
  http.c: inline `set_curl_keepalive()`
  http.c: introduce `set_long_from_env()` for convenience
  http.c: remove unnecessary casts to long

2 months agoMerge branch 'tb/refspec-fetch-cleanup'
Junio C Hamano [Tue, 8 Apr 2025 18:43:13 +0000 (11:43 -0700)] 
Merge branch 'tb/refspec-fetch-cleanup'

Code clean-up.

* tb/refspec-fetch-cleanup:
  refspec: replace `refspec_item_init()` with fetch/push variants
  refspec: remove refspec_item_init_or_die()
  refspec: replace `refspec_init()` with fetch/push variants
  refspec: treat 'fetch' as a Boolean value

2 months agoMerge branch 'ms/reftable-block-writer-errors'
Junio C Hamano [Tue, 8 Apr 2025 18:43:12 +0000 (11:43 -0700)] 
Merge branch 'ms/reftable-block-writer-errors'

Give more meaningful error return values from block writer layer of
the reftable ref-API backend.

* ms/reftable-block-writer-errors:
  reftable: adapt write_object_record() to propagate block_writer_add() errors
  reftable: adapt writer_add_record() to propagate block_writer_add() errors
  reftable: propagate specific error codes in block_writer_add()

2 months agoMerge branch 'en/assert-wo-side-effects'
Junio C Hamano [Tue, 8 Apr 2025 18:43:12 +0000 (11:43 -0700)] 
Merge branch 'en/assert-wo-side-effects'

Ensure what we write in assert() does not have side effects,
and introduce ASSERT() macro to mark those that cannot be
mechanically checked for lack of side effects.

* en/assert-wo-side-effects:
  treewide: replace assert() with ASSERT() in special cases
  ci: add build checking for side-effects in assert() calls
  git-compat-util: introduce ASSERT() macro

2 months agoupdate-ref: add --batch-updates flag for stdin mode
Karthik Nayak [Tue, 8 Apr 2025 08:51:12 +0000 (10:51 +0200)] 
update-ref: add --batch-updates flag for stdin mode

When updating multiple references through stdin, Git's update-ref
command normally aborts the entire transaction if any single update
fails. This atomic behavior prevents partial updates. Introduce a new
batch update system, where the updates the performed together similar
but individual updates are allowed to fail.

Add a new `--batch-updates` flag that allows the transaction to continue
even when individual reference updates fail. This flag can only be used
in `--stdin` mode and builds upon the batch update support added to the
refs subsystem in the previous commits. When enabled, failed updates are
reported in the following format:

  rejected SP (<old-oid> | <old-target>) SP (<new-oid> | <new-target>) SP <rejection-reason> LF

Update the documentation to reflect this change and also tests to cover
different scenarios where an update could be rejected.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agorefs: support rejection in batch updates during F/D checks
Karthik Nayak [Tue, 8 Apr 2025 08:51:11 +0000 (10:51 +0200)] 
refs: support rejection in batch updates during F/D checks

The `refs_verify_refnames_available()` is used to batch check refnames
for F/D conflicts. While this is the more performant alternative than
its individual version, it does not provide rejection capabilities on a
single update level. For batched updates, this would mean a rejection of
the entire transaction whenever one reference has a F/D conflict.

Modify the function to call `ref_transaction_maybe_set_rejected()` to
check if a single update can be rejected. Since this function is only
internally used within 'refs/' and we want to pass in a `struct
ref_transaction *` as a variable. We also move and mark
`refs_verify_refnames_available()` to 'refs-internal.h' to be an
internal function.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agorefs: implement batch reference update support
Karthik Nayak [Tue, 8 Apr 2025 08:51:10 +0000 (10:51 +0200)] 
refs: implement batch reference update support

Git supports making reference updates with or without transactions.
Updates with transactions are generally better optimized. But
transactions are all or nothing. This means, if a user wants to batch
updates to take advantage of the optimizations without the hard
requirement that all updates must succeed, there is no way currently to
do so. Particularly with the reftable backend where batching multiple
reference updates is more efficient than performing them sequentially.

Introduce batched update support with a new flag,
'REF_TRANSACTION_ALLOW_FAILURE'. Batched updates while different from
transactions, use the transaction infrastructure under the hood. When
enabled, this flag allows individual reference updates that would
typically cause the entire transaction to fail due to non-system-related
errors to be marked as rejected while permitting other updates to
proceed. System errors referred by 'REF_TRANSACTION_ERROR_GENERIC'
continue to result in the entire transaction failing. This approach
enhances flexibility while preserving transactional integrity where
necessary.

The implementation introduces several key components:

  - Add 'rejection_err' field to struct `ref_update` to track failed
    updates with failure reason.

  - Add a new struct `ref_transaction_rejections` and a field within
    `ref_transaction` to this struct to allow quick iteration over
    rejected updates.

  - Modify reference backends (files, packed, reftable) to handle
    partial transactions by using `ref_transaction_set_rejected()`
    instead of failing the entire transaction when
    `REF_TRANSACTION_ALLOW_FAILURE` is set.

  - Add `ref_transaction_for_each_rejected_update()` to let callers
    examine which updates were rejected and why.

This foundational change enables batched update support throughout the
reference subsystem. A following commit will expose this capability to
users by adding a `--batch-updates` flag to 'git-update-ref(1)',
providing both a user-facing feature and a testable implementation.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agorefs: introduce enum-based transaction error types
Karthik Nayak [Tue, 8 Apr 2025 08:51:09 +0000 (10:51 +0200)] 
refs: introduce enum-based transaction error types

Replace preprocessor-defined transaction errors with a strongly-typed
enum `ref_transaction_error`. This change:

  - Improves type safety and function signature clarity.
  - Makes error handling more explicit and discoverable.
  - Maintains existing error cases, while adding new error cases for
    common scenarios.

This refactoring paves the way for more comprehensive error handling
which we will utilize in the upcoming commits to add batch reference
update support.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agorefs/reftable: extract code from the transaction preparation
Karthik Nayak [Tue, 8 Apr 2025 08:51:08 +0000 (10:51 +0200)] 
refs/reftable: extract code from the transaction preparation

Extract the core logic for preparing individual reference updates from
`reftable_be_transaction_prepare()` into `prepare_single_update()`. This
dedicated function now handles all validation and preparation steps for
each reference update in the transaction, including object ID
verification, HEAD reference handling, and symref processing.

The refactoring consolidates all reference update validation into a
single logical block, which improves code maintainability and
readability. More importantly, this restructuring lays the groundwork
for implementing batched reference update support in the reftable
backend, which will be introduced in a followup commit.

No functional changes are included in this commit - it is purely a code
reorganization to support future enhancements.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agorefs/files: remove duplicate duplicates check
Karthik Nayak [Tue, 8 Apr 2025 08:51:07 +0000 (10:51 +0200)] 
refs/files: remove duplicate duplicates check

Within the files reference backend's transaction's 'finish' phase, a
verification step is currently performed wherein the refnames list is
sorted and examined for multiple updates targeting the same refname.

It has been observed that this verification is redundant, as an
identical check is already executed during the transaction's 'prepare'
stage. Since the refnames list remains unmodified following the
'prepare' stage, this secondary verification can be safely eliminated.

The duplicate check has been removed accordingly, and the
`ref_update_reject_duplicates()` function has been marked as static, as
its usage is now confined to 'refs.c'.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agorefs: move duplicate refname update check to generic layer
Karthik Nayak [Tue, 8 Apr 2025 08:51:06 +0000 (10:51 +0200)] 
refs: move duplicate refname update check to generic layer

Move the tracking of refnames in `affected_refnames` from individual
backends into the generic layer in 'refs.c'. This centralizes the
duplicate refname detection that was previously handled separately by
each backend.

Make some changes to accommodate this move:

  - Add a `string_list` field `refnames` to `ref_transaction` to contain
    all the references in a transaction. This field is updated whenever
    a new update is added via `ref_transaction_add_update`, so manual
    additions in reference backends are dropped.

  - Modify the backends to use this field internally as needed. The
    backends need to check if an update for refname already exists when
    splitting symrefs or adding an update for 'HEAD'.

  - In the reftable backend, within `reftable_be_transaction_prepare()`,
    move the `string_list_has_string()` check above
    `ref_transaction_add_update()`. Since `ref_transaction_add_update()`
    automatically adds the refname to `transaction->refnames`,
    performing the check after will always return true, so we perform
    the check before adding the update.

This helps reduce duplication of functionality between the backends and
makes it easier to make changes in a more centralized manner.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agorefs/files: remove redundant check in split_symref_update()
Karthik Nayak [Tue, 8 Apr 2025 08:51:05 +0000 (10:51 +0200)] 
refs/files: remove redundant check in split_symref_update()

In `split_symref_update()`, there were two checks for duplicate
refnames:

  - At the start, `string_list_has_string()` ensures the refname is not
    already in `affected_refnames`, preventing duplicates from being
    added.

  - After adding the refname, another check verifies whether the newly
    inserted item has a `util` value.

The second check is unnecessary because the first one guarantees that
`string_list_insert()` will never encounter a preexisting entry.

The `item->util` field is assigned to validate that a rename doesn't
already exist in the list. The validation is done after the first check.
As this check is removed, clean up the validation and the assignment of
this field in `split_head_update()` and `files_transaction_prepare()`.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agobuiltin/maintenance: introduce "reflog-expire" task
Patrick Steinhardt [Tue, 8 Apr 2025 06:22:17 +0000 (08:22 +0200)] 
builtin/maintenance: introduce "reflog-expire" task

By default, git-maintenance(1) uses the "gc" task to ensure that the
repository is well-maintained. This can be changed, for example by
either explicitly configuring which tasks should be enabled or by using
the "incremental" maintenance strategy. If so, git-maintenance(1) does
not know to expire reflog entries, which is a subtask that git-gc(1)
knows to perform for the user. Consequently, the reflog will grow
indefinitely unless the user manually trims it.

Introduce a new "reflog-expire" task that plugs this gap:

  - When running the task directly, then we simply execute `git reflog
    expire --all`, which is the same as git-gc(1).

  - When running git-maintenance(1) with the `--auto` flag, then we only
    run the task in case the "HEAD" reflog has at least N reflog entries
    that would be discarded. By default, N is set to 100, but this can
    be configured via "maintenance.reflog-expire.auto". When a negative
    integer has been provided we always expire entries, zero causes us
    to never expire entries, and a positive value specifies how many
    entries need to exist before we consider pruning the entries.

Note that the condition for the `--auto` flags is merely a heuristic and
optimized for being fast. This is because `git maintenance run --auto`
will be executed quite regularly, so scanning through all reflogs would
likely be too expensive in many repositories.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agobuiltin/gc: split out function to expire reflog entries
Patrick Steinhardt [Tue, 8 Apr 2025 06:22:16 +0000 (08:22 +0200)] 
builtin/gc: split out function to expire reflog entries

We're about to introduce a new task for git-maintenance(1) that knows to
expire reflog entries. The logic will be shared with git-gc(1), which
already knows how to do this.

Pull out the common logic into a separate function so that we can share
the implementation between both builtins.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agobuiltin/reflog: make functions regarding `reflog_expire_options` public
Patrick Steinhardt [Tue, 8 Apr 2025 06:22:15 +0000 (08:22 +0200)] 
builtin/reflog: make functions regarding `reflog_expire_options` public

Make functions that are required to manage `reflog_expire_options`
available elsewhere by moving them into "reflog.c" and exposing them in
the corresponding header. The functions will be used in a subsequent
commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agobuiltin/reflog: stop storing per-reflog expiry dates globally
Patrick Steinhardt [Tue, 8 Apr 2025 06:22:14 +0000 (08:22 +0200)] 
builtin/reflog: stop storing per-reflog expiry dates globally

As described in the preceding commit, the per-reflog expiry dates are
stored in a global pair of variables. Refactor the code so that they are
contained in `struct reflog_expire_options` to make the structure useful
in other contexts.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agobuiltin/reflog: stop storing default reflog expiry dates globally
Patrick Steinhardt [Tue, 8 Apr 2025 06:22:13 +0000 (08:22 +0200)] 
builtin/reflog: stop storing default reflog expiry dates globally

When expiring reflog entries, it is possible to configure expiry dates
that depend on the name of the reflog. This requires us to store a
couple of different expiry dates:

  - The default expiry date for reflog entries that aren't otherwise
    specified.

  - The per-reflog expiry date.

  - The currently active set of expiry dates for a given reference.

While the last item is stored in `struct reflog_expire_options`, the
other items aren't, which makes it hard to reuse the structure in other
places.

Refactor the code so that the default expiry date is stored as part of
the structure. The per-reflog expiry dates will be adapted accordingly
in the subsequent commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoreflog: rename `cmd_reflog_expire_cb` to `reflog_expire_options`
Patrick Steinhardt [Tue, 8 Apr 2025 06:22:12 +0000 (08:22 +0200)] 
reflog: rename `cmd_reflog_expire_cb` to `reflog_expire_options`

We're about to expose `struct cmd_reflog_expire_cb` via "reflog.h" so
that we can also use this structure in "builtin/gc.c". Once we make it
accessible to a wider scope though it becomes awkwardly named, as it
isn't only useful in the context of a callback. Instead, the function is
containing all kinds of options relevant to whether or not a reflog
entry should be expired.

Rename the structure to `reflog_expire_options` to prepare for this.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agosend-email: finer-grained SMTP error handling
Zheng Yuting [Wed, 26 Mar 2025 07:52:46 +0000 (15:52 +0800)] 
send-email: finer-grained SMTP error handling

Code captured errors but did not process them further.
This treated all failures the same without distinguishing SMTP status.

Add handle-smtp_error to extract SMTP status codes using a regex (as
defined in RFC 5321) and handle errors as follows:

- No error present:
- If a result is provided, return 1 to indicate success.
- Otherwise, return 0 to indicate failure.

- Error present with a captured three-digit status code:
- For 4yz (transient errors), return 1 and allow retries.
- For 5yz (permanent errors), return 0 to indicate failure.
- For any other recognized status code, return 1, treating it as
a transient error.

- Error present but no status code found:
- Return 1 as a transient error.

Signed-off-by: Zheng Yuting <05ZYT30@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agosend-email: capture errors in an eval {} block
Zheng Yuting [Wed, 26 Mar 2025 07:52:45 +0000 (15:52 +0800)] 
send-email: capture errors in an eval {} block

Auth relied solely on return values without catching errors. This misjudges
non-credential errors as auth failure without error info.

Patch wraps the entire auth process in an eval {} block to catch
all exceptions, including non-credential errors. It adds a new $error var,
uses 'or do' to prevent flow break, and returns $result ? 1 : 0. And merges
if/else branches, integrates SASL and basic auth, with comments for
future status code handling.

Signed-off-by: Zheng Yuting <05ZYT30@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoblame: print unblamable and ignored commits in porcelain mode
Karthik Nayak [Thu, 3 Apr 2025 16:03:26 +0000 (18:03 +0200)] 
blame: print unblamable and ignored commits in porcelain mode

The 'git-blame(1)' command allows users to ignore specific revisions via
the '--ignore-rev <rev>' and '--ignore-revs-file <file>' flags. These
flags are often combined with the 'blame.markIgnoredLines' and
'blame.markUnblamableLines' config options. These config options prefix
ignored and unblamable lines with a '?' and '*', respectively.

However, this option was never extended to the porcelain mode of
'git-blame(1)'. Since the documentation does not indicate this
exclusion, it is a bug.

Fix this by printing 'ignored' and 'unblamable' respectively for the
options when using the porcelain modes.

Helped-by: Patrick Steinhardt <ps@pks.im>
Helped-by: Toon Claes <toon@iotcl.com>
Helped-by: Phillip Wood <phillip.wood123@gmail.com>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot5703: refactor test to not depend on Perl
Patrick Steinhardt [Thu, 3 Apr 2025 05:06:11 +0000 (07:06 +0200)] 
t5703: refactor test to not depend on Perl

We use Perl due to two different reasons in t5703:

  - To filter advertised capabilities.

  - To set up a CGI script with HTTPD.

Refactor the first category to use `test_grep` instead. Refactoring the
second category would be a bit more involved, so instead we add the
PERL_TEST_HELPERS prerequisite to those individual tests now.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot5316: refactor `max_chain()` to not depend on Perl
Patrick Steinhardt [Thu, 3 Apr 2025 05:06:10 +0000 (07:06 +0200)] 
t5316: refactor `max_chain()` to not depend on Perl

The `max_chain()` helper function is used to extract the maximum delta
chain of a packfile as printed by git-index-pack(1). The script uses
Perl to extract that data, but it can be trivially refactored to use
awk(1) instead.

Refactor the helper accordingly so that we can drop a couple of
PERL_TEST_HELPERS prerequisites.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot0210: refactor trace2 scrubbing to not use Perl
Patrick Steinhardt [Thu, 3 Apr 2025 05:06:09 +0000 (07:06 +0200)] 
t0210: refactor trace2 scrubbing to not use Perl

The output generated by our trace2 mechanism contains several fields
that are dependent on the environment they're being run in, which makes
it somewhat harder to test it. As a countermeasure we scrub the output
and strip out any fields that contain such information.

The logic to do so is implemented in Perl, but it can be trivially
ported to instead use sed(1). Refactor the code accordingly so that we
can drop the PERL_TEST_HELPERS prerequisite.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot0021: refactor `generate_random_characters()` to not depend on Perl
Patrick Steinhardt [Thu, 3 Apr 2025 05:06:08 +0000 (07:06 +0200)] 
t0021: refactor `generate_random_characters()` to not depend on Perl

The `generate_random_characters()` helper function generates N
random characters in the range 'a-z' and writes them into a file. The
logic currently uses Perl, but it can be adapted rather easily by:

  - Making `test-tool genrandom` generate an infinite stream.

  - Using `tr -dc` to strip all characters which aren't in the range of
    'a-z'.

  - Using `test_copy_bytes()` to copy the first N bytes.

This allows us to drop the PERL_TEST_HELPERS prerequisite.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot/lib-httpd: refactor "one-time-perl" CGI script to not depend on Perl
Patrick Steinhardt [Thu, 3 Apr 2025 05:06:07 +0000 (07:06 +0200)] 
t/lib-httpd: refactor "one-time-perl" CGI script to not depend on Perl

Our Apache HTTPD setup exposes an "one_time_perl" endpoint to access
repositories. If used, we execute the "apply-one-time-perl.sh" CGI
script that checks whether we have a "one-time-perl" script. If so, that
script gets executed so that it can munge what would be served. Once
done, the script gets removed so that it doesn't execute a second time.

As the name says, this functionality expects the user to pass a Perl
script. This isn't really necessary though: we can just as easily
implement the same thing with arbitrary scripts.

Refactor the code so that we instead expect an arbitrary script to
exist and rename the functionality to "one-time-script". Adapt callers
to use shell utilities instead of Perl so that we can drop the
PERL_TEST_HELPERS prerequisite.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot/lib-t6000: refactor `name_from_description()` to not depend on Perl
Patrick Steinhardt [Thu, 3 Apr 2025 05:06:06 +0000 (07:06 +0200)] 
t/lib-t6000: refactor `name_from_description()` to not depend on Perl

The `name_from_description()` test helper uses Perl to munge a given
description and convert it into a name. Refactor it to instead use a
combination of sed(1) and tr(1) so that we drop PERL_TEST_HELPERS
prerequisites in users of this library.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot/lib-gpg: refactor `sanitize_pgp()` to not depend on Perl
Patrick Steinhardt [Thu, 3 Apr 2025 05:06:05 +0000 (07:06 +0200)] 
t/lib-gpg: refactor `sanitize_pgp()` to not depend on Perl

The `sanitize_pgp()` test helper uses Perl to strip PGP signatures from
stdin. Refactor it to instead use sed(1) so that we drop the
PERL_TEST_HELPERS prerequisite in users of this library.

Note that we have to add PERL_TEST_HELPERS to a subset of tests in t6300
now that the test suite doesn't bail out early anymore in case the
prerequisite isn't set.

Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot: refactor tests depending on Perl for textconv scripts
Patrick Steinhardt [Thu, 3 Apr 2025 05:06:04 +0000 (07:06 +0200)] 
t: refactor tests depending on Perl for textconv scripts

We have a couple of tests that depend on Perl for textconv scripts.
Refactor these tests to instead be implemented via shell utilities so
that we can drop a couple of PERL_TEST_HELPERS prerequisites.

Note that the conversion in t4030 is not a one-to-one equivalent to the
previous textconv script. Before this change we used to essentially do a
hexdump via Perl. The obvious conversion here would be to use `test-tool
hexdump` like we do for the other tests. But this would lead to a ripple
effect where we would have to adapt a bunch of other tests with a bunch
of seemingly unrelated changes, which would be somewhat awkward.

Instead, we're going with the minimum viable change: the test files we
write contain "\001" and "\000", and the test's expectation is that
those get translated into proper ASCII characters. So instead of doing a
full hexdump, we simply use tr(1) to translate these specific bytes.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot: refactor tests depending on Perl to print data
Patrick Steinhardt [Thu, 3 Apr 2025 05:06:03 +0000 (07:06 +0200)] 
t: refactor tests depending on Perl to print data

A bunch of tests rely on Perl to print data in various different ways.
These usages fall into the following categories:

  - Print data conditionally by matching patterns. These usecases can be
    converted to use awk(1) rather easily.

  - Print data repeatedly. These usecases can typically be converted to
    use a combination of `test-tool genzeros` and sed(1).

  - Print data in reverse. These usecases can be converted to use
    awk(1) or `sort -r`.

Refactor the tests accordingly so that we can drop a couple of
PERL_TEST_HELPERS prerequisites.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot: refactor tests depending on Perl substitution operator
Patrick Steinhardt [Thu, 3 Apr 2025 05:06:02 +0000 (07:06 +0200)] 
t: refactor tests depending on Perl substitution operator

We have a bunch of tests that use Perl to perform substitution via the
"s/" operator. These usecases can be trivially replaced with sed(1) and
tr(1).

Refactor the tests accordingly so that we can drop a couple of
PERL_TEST_HELPERS prerequisites.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot: refactor tests depending on Perl transliteration operator
Patrick Steinhardt [Thu, 3 Apr 2025 05:06:01 +0000 (07:06 +0200)] 
t: refactor tests depending on Perl transliteration operator

We have a bunch of tests that use Perl to perform character
transliteration via the "y/" or "tr/" operator. These usecases can be
trivially replaced with tr(1).

Refactor the tests accordingly so that we can drop a couple of
PERL_TEST_HELPERS prerequisites.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agoMakefile: stop requiring Perl when running tests
Patrick Steinhardt [Thu, 3 Apr 2025 05:06:00 +0000 (07:06 +0200)] 
Makefile: stop requiring Perl when running tests

The Makefile for our tests has a couple of targets that depend on Perl.
Adapt those targets to only run conditionally in case Perl is available
on the system so that it becomes possible to run the test suite without
Perl.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agomeson: stop requiring Perl when tests are enabled
Patrick Steinhardt [Thu, 3 Apr 2025 05:05:59 +0000 (07:05 +0200)] 
meson: stop requiring Perl when tests are enabled

The Perl interpreter used to be a strict dependency for running our test
suite. This requirement is explicit in the Meson build system, where we
require Perl to be present unless tests have been disabled.

With the preceding commits we have loosened this restriction so that it
is now possible to run tests when Perl is unavailable. Loosen the above
requirement accordingly.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 months agot: adapt existing PERL prerequisites
Patrick Steinhardt [Thu, 3 Apr 2025 05:05:58 +0000 (07:05 +0200)] 
t: adapt existing PERL prerequisites

A couple of our tests depend on the PERL prerequisite even though it
isn't needed. These tests fall into one of the following classes:

  - The underlying logic used to be implemented in Perl but isn't
    anymore. Here we can simply drop the dependency altogether.

  - The test logic used to depend on Perl but doesn't anymore. Again, we
    can simply drop the dependency.

  - The test logic still relies on a Perl interpreter. These tests
    should use the newly introduced PERL_TEST_HELPERS prerequisite.

Adapt test cases accordingly.

Note that in t1006 we have to introduce another new prerequisite
depending on whether or not the IPC::Open2 module is available. Funny
enough, when starting to use `test_lazy_prereq` to do so we also get a
conflict of variables with the "script" variable that contains the Perl
logic because `test_run_lazy_prereq_` also sets that variable. We thus
rename the variable in t1006 to "perl_script".

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>