]> git.99rst.org Git - git.git/log
git.git
2 years agoMerge branch 'rs/column-leakfix' into maint-2.43
Junio C Hamano [Fri, 9 Feb 2024 00:22:06 +0000 (16:22 -0800)]
Merge branch 'rs/column-leakfix' into maint-2.43

Leakfix.

* rs/column-leakfix:
  column: release strbuf and string_list after use

2 years agoMerge branch 'rs/i18n-cannot-be-used-together' into maint-2.43
Junio C Hamano [Fri, 9 Feb 2024 00:22:05 +0000 (16:22 -0800)]
Merge branch 'rs/i18n-cannot-be-used-together' into maint-2.43

Clean-up code that handles combinations of incompatible options.

* rs/i18n-cannot-be-used-together:
  i18n: factorize even more 'incompatible options' messages

2 years agoMerge branch 'jb/reflog-expire-delete-dry-run-options' into maint-2.43
Junio C Hamano [Fri, 9 Feb 2024 00:22:05 +0000 (16:22 -0800)]
Merge branch 'jb/reflog-expire-delete-dry-run-options' into maint-2.43

Command line parsing fix for "git reflog".

* jb/reflog-expire-delete-dry-run-options:
  builtin/reflog.c: fix dry-run option short name

2 years agoMerge branch 'js/packfile-h-typofix' into maint-2.43
Junio C Hamano [Fri, 9 Feb 2024 00:22:05 +0000 (16:22 -0800)]
Merge branch 'js/packfile-h-typofix' into maint-2.43

Typofix.

* js/packfile-h-typofix:
  packfile.c: fix a typo in `each_file_in_pack_dir_fn()`'s declaration

2 years agoMerge branch 'jk/commit-graph-slab-clear-fix' into maint-2.43
Junio C Hamano [Fri, 9 Feb 2024 00:22:05 +0000 (16:22 -0800)]
Merge branch 'jk/commit-graph-slab-clear-fix' into maint-2.43

Clearing in-core repository (happens during e.g., "git fetch
--recurse-submodules" with commit graph enabled) made in-core
commit object in an inconsistent state by discarding the necessary
data from commit-graph too early, which has been corrected.

* jk/commit-graph-slab-clear-fix:
  commit-graph: retain commit slab when closing NULL commit_graph

2 years agoMerge branch 'cp/git-flush-is-an-env-bool' into maint-2.43
Junio C Hamano [Fri, 9 Feb 2024 00:22:04 +0000 (16:22 -0800)]
Merge branch 'cp/git-flush-is-an-env-bool' into maint-2.43

Unlike other environment variables that took the usual
true/false/yes/no as well as 0/1, GIT_FLUSH only understood 0/1,
which has been corrected.

* cp/git-flush-is-an-env-bool:
  write-or-die: make GIT_FLUSH a Boolean environment variable

2 years agoMerge branch 'jc/sparse-checkout-set-default-fix' into maint-2.43
Junio C Hamano [Fri, 9 Feb 2024 00:22:04 +0000 (16:22 -0800)]
Merge branch 'jc/sparse-checkout-set-default-fix' into maint-2.43

"git sparse-checkout set" added default patterns even when the
patterns are being fed from the standard input, which has been
corrected.

* jc/sparse-checkout-set-default-fix:
  sparse-checkout: use default patterns for 'set' only !stdin

2 years agoMerge branch 'jc/archive-list-with-extra-args' into maint-2.43
Junio C Hamano [Fri, 9 Feb 2024 00:22:04 +0000 (16:22 -0800)]
Merge branch 'jc/archive-list-with-extra-args' into maint-2.43

"git archive --list extra garbage" silently ignored excess command
line parameters, which has been corrected.

* jc/archive-list-with-extra-args:
  archive: "--list" does not take further options

2 years agoMerge branch 'rj/status-bisect-while-rebase' into maint-2.43
Junio C Hamano [Fri, 9 Feb 2024 00:22:04 +0000 (16:22 -0800)]
Merge branch 'rj/status-bisect-while-rebase' into maint-2.43

"git status" is taught to show both the branch being bisected and
being rebased when both are in effect at the same time.
cf. <redacted>

* rj/status-bisect-while-rebase:
  status: fix branch shown when not only bisecting

2 years agoMerge branch 'sh/completion-with-reftable' into maint-2.43
Junio C Hamano [Fri, 9 Feb 2024 00:22:04 +0000 (16:22 -0800)]
Merge branch 'sh/completion-with-reftable' into maint-2.43

Command line completion script (in contrib/) learned to work better
with the reftable backend.

* sh/completion-with-reftable:
  completion: support pseudoref existence checks for reftables
  completion: refactor existence checks for pseudorefs

2 years agoMerge branch 'jx/fetch-atomic-error-message-fix' into maint-2.43
Junio C Hamano [Fri, 9 Feb 2024 00:22:03 +0000 (16:22 -0800)]
Merge branch 'jx/fetch-atomic-error-message-fix' into maint-2.43

"git fetch --atomic" issued an unnecessary empty error message,
which has been corrected.
cf. <redacted>

* jx/fetch-atomic-error-message-fix:
  fetch: no redundant error message for atomic fetch
  t5574: test porcelain output of atomic fetch

2 years agoMerge branch 'jk/mailinfo-iterative-unquote-comment' into maint-2.43
Junio C Hamano [Fri, 9 Feb 2024 00:22:03 +0000 (16:22 -0800)]
Merge branch 'jk/mailinfo-iterative-unquote-comment' into maint-2.43

The code to parse the From e-mail header has been updated to avoid
recursion.

* jk/mailinfo-iterative-unquote-comment:
  mailinfo: avoid recursion when unquoting From headers
  t5100: make rfc822 comment test more careful
  mailinfo: fix out-of-bounds memory reads in unquote_quoted_pair()

2 years agoMerge branch 'rs/show-ref-incompatible-options' into maint-2.43
Junio C Hamano [Fri, 9 Feb 2024 00:22:03 +0000 (16:22 -0800)]
Merge branch 'rs/show-ref-incompatible-options' into maint-2.43

Code clean-up for sanity checking of command line options for "git
show-ref".

* rs/show-ref-incompatible-options:
  show-ref: use die_for_incompatible_opt3()

2 years agoMerge branch 'jk/implicit-true' into maint-2.43
Junio C Hamano [Fri, 9 Feb 2024 00:22:03 +0000 (16:22 -0800)]
Merge branch 'jk/implicit-true' into maint-2.43

Some codepaths did not correctly parse configuration variables
specified with valueless "true", which has been corrected.

* jk/implicit-true:
  fsck: handle NULL value when parsing message config
  trailer: handle NULL value when parsing trailer-specific config
  submodule: handle NULL value when parsing submodule.*.branch
  help: handle NULL value for alias.* config
  trace2: handle NULL values in tr2_sysenv config callback
  setup: handle NULL value when parsing extensions
  config: handle NULL value when parsing non-bools

2 years agoMerge branch 'jk/bisect-reset-fix' into maint-2.43
Junio C Hamano [Fri, 9 Feb 2024 00:22:02 +0000 (16:22 -0800)]
Merge branch 'jk/bisect-reset-fix' into maint-2.43

"git bisect reset" has been taught to clean up state files and refs
even when BISECT_START file is gone.

* jk/bisect-reset-fix:
  bisect: always clean on reset

2 years agoMerge branch 'jk/end-of-options' into maint-2.43
Junio C Hamano [Fri, 9 Feb 2024 00:22:02 +0000 (16:22 -0800)]
Merge branch 'jk/end-of-options' into maint-2.43

"git $cmd --end-of-options --rev -- --path" for some $cmd failed
to interpret "--rev" as a rev, and "--path" as a path.  This was
fixed for many programs like "reset" and "checkout".

* jk/end-of-options:
  parse-options: decouple "--end-of-options" and "--"

2 years agoMerge branch 'jc/revision-parse-int' into maint-2.43
Junio C Hamano [Fri, 9 Feb 2024 00:22:02 +0000 (16:22 -0800)]
Merge branch 'jc/revision-parse-int' into maint-2.43

The command line parser for the "log" family of commands was too
loose when parsing certain numbers, e.g., silently ignoring the
extra 'q' in "git log -n 1q" without complaining, which has been
tightened up.

* jc/revision-parse-int:
  revision: parse integer arguments to --max-count, --skip, etc., more carefully

2 years agoMerge branch 'jp/use-diff-index-in-pre-commit-sample' into maint-2.43
Junio C Hamano [Fri, 9 Feb 2024 00:22:02 +0000 (16:22 -0800)]
Merge branch 'jp/use-diff-index-in-pre-commit-sample' into maint-2.43

The sample pre-commit hook that tries to catch introduction of new
paths that use potentially non-portable characters did not notice
an existing path getting renamed to such a problematic path, when
rename detection was enabled.

* jp/use-diff-index-in-pre-commit-sample:
  hooks--pre-commit: detect non-ASCII when renaming

2 years agoMerge branch 'jh/trace2-redact-auth' into maint-2.43
Junio C Hamano [Fri, 9 Feb 2024 00:22:01 +0000 (16:22 -0800)]
Merge branch 'jh/trace2-redact-auth' into maint-2.43

trace2 streams used to record the URLs that potentially embed
authentication material, which has been corrected.

* jh/trace2-redact-auth:
  t0212: test URL redacting in EVENT format
  t0211: test URL redacting in PERF format
  trace2: redact passwords from https:// URLs by default
  trace2: fix signature of trace2_def_param() macro

2 years agoMerge branch 'js/update-urls-in-doc-and-comment' into maint-2.43
Junio C Hamano [Fri, 9 Feb 2024 00:22:01 +0000 (16:22 -0800)]
Merge branch 'js/update-urls-in-doc-and-comment' into maint-2.43

Stale URLs have been updated to their current counterparts (or
archive.org) and HTTP links are replaced with working HTTPS links.

* js/update-urls-in-doc-and-comment:
  doc: refer to internet archive
  doc: update links for andre-simon.de
  doc: switch links to https
  doc: update links to current pages

2 years agoMerge branch 'ps/commit-graph-less-paranoid' into maint-2.43
Junio C Hamano [Fri, 9 Feb 2024 00:22:01 +0000 (16:22 -0800)]
Merge branch 'ps/commit-graph-less-paranoid' into maint-2.43

Earlier we stopped relying on commit-graph that (still) records
information about commits that are lost from the object store,
which has negative performance implications.  The default has been
flipped to disable this pessimization.

* ps/commit-graph-less-paranoid:
  commit-graph: disable GIT_COMMIT_GRAPH_PARANOIA by default

2 years agoMerge branch 'tz/send-email-negatable-options' into maint-2.43
Junio C Hamano [Fri, 9 Feb 2024 00:22:00 +0000 (16:22 -0800)]
Merge branch 'tz/send-email-negatable-options' into maint-2.43

Newer versions of Getopt::Long started giving warnings against our
(ab)use of it in "git send-email".  Bump the minimum version
requirement for Perl to 5.8.1 (from September 2002) to allow
simplifying our implementation.

* tz/send-email-negatable-options:
  send-email: avoid duplicate specification warnings
  perl: bump the required Perl version to 5.8.1 from 5.8.0

2 years agoMerge branch 'js/ci-discard-prove-state' into maint-2.43
Junio C Hamano [Fri, 9 Feb 2024 00:22:00 +0000 (16:22 -0800)]
Merge branch 'js/ci-discard-prove-state' into maint-2.43

The way CI testing used "prove" could lead to running the test
suite twice needlessly, which has been corrected.

* js/ci-discard-prove-state:
  ci: avoid running the test suite _twice_
  ci: add support for GitLab CI
  ci: install test dependencies for linux-musl
  ci: squelch warnings when testing with unusable Git repo
  ci: unify setup of some environment variables
  ci: split out logic to set up failed test artifacts
  ci: group installation of Docker dependencies
  ci: make grouping setup more generic
  ci: reorder definitions for grouping functions

2 years agot9210: do not rely on lazy fetching to fail
Junio C Hamano [Thu, 8 Feb 2024 23:15:12 +0000 (15:15 -0800)]
t9210: do not rely on lazy fetching to fail

With "rev-list --missing=print $start", where "$start" is a 40-hex
object name, the object may or may not be lazily fetched from the
promisor.  Make sure it fails by forcing dereference of "$start"
at that point.

Signed-off-by: Junio C Hamano <redacted>
2 years agoThe fifteenth batch
Junio C Hamano [Thu, 8 Feb 2024 21:20:41 +0000 (13:20 -0800)]
The fifteenth batch

Signed-off-by: Junio C Hamano <redacted>
2 years agoMerge branch 'jh/sparse-index-expand-to-path-fix'
Junio C Hamano [Thu, 8 Feb 2024 21:20:34 +0000 (13:20 -0800)]
Merge branch 'jh/sparse-index-expand-to-path-fix'

A caller called index_file_exists() that takes a string expressed
as <ptr, length> with a wrong length, which has been corrected.

* jh/sparse-index-expand-to-path-fix:
  sparse-index: pass string length to index_file_exists()

2 years agoMerge branch 'pb/imap-send-wo-curl-build-fix'
Junio C Hamano [Thu, 8 Feb 2024 21:20:34 +0000 (13:20 -0800)]
Merge branch 'pb/imap-send-wo-curl-build-fix'

Build fix.

* pb/imap-send-wo-curl-build-fix:
  imap-send: add missing "strbuf.h" include under NO_CURL

2 years agoMerge branch 'ja/doc-placeholders-fix'
Junio C Hamano [Thu, 8 Feb 2024 21:20:34 +0000 (13:20 -0800)]
Merge branch 'ja/doc-placeholders-fix'

Docfix.

* ja/doc-placeholders-fix:
  doc: enforce placeholders in documentation
  doc: enforce dashes in placeholders

2 years agoMerge branch 'mh/credential-oauth-refresh-token-with-wincred'
Junio C Hamano [Thu, 8 Feb 2024 21:20:34 +0000 (13:20 -0800)]
Merge branch 'mh/credential-oauth-refresh-token-with-wincred'

The wincred credential backend has been taught to support oauth refresh
token the same way as credential-cache and credential-libsecret backends.

* mh/credential-oauth-refresh-token-with-wincred:
  credential/wincred: store oauth_refresh_token

2 years agoMerge branch 'jk/unit-tests-buildfix'
Junio C Hamano [Thu, 8 Feb 2024 21:20:33 +0000 (13:20 -0800)]
Merge branch 'jk/unit-tests-buildfix'

Build dependency around unit tests has been fixed.

* jk/unit-tests-buildfix:
  t/Makefile: say the default target upfront
  t/Makefile: get UNIT_TESTS list from C sources
  Makefile: remove UNIT_TEST_BIN directory with "make clean"
  Makefile: use mkdir_p_parent_template for UNIT_TEST_BIN

2 years agoMerge branch 'jc/index-pack-fsck-levels'
Junio C Hamano [Thu, 8 Feb 2024 21:20:33 +0000 (13:20 -0800)]
Merge branch 'jc/index-pack-fsck-levels'

The "--fsck-objects" option of "git index-pack" now can take the
optional parameter to tweak severity of different fsck errors.

* jc/index-pack-fsck-levels:
  index-pack: --fsck-objects to take an optional argument for fsck msgs
  index-pack: test and document --strict=<msg-id>=<severity>...

2 years agoMerge branch 'cp/unit-test-prio-queue'
Junio C Hamano [Thu, 8 Feb 2024 21:20:33 +0000 (13:20 -0800)]
Merge branch 'cp/unit-test-prio-queue'

The priority queue test has been migrated to the unit testing
framework.

* cp/unit-test-prio-queue:
  tests: move t0009-prio-queue.sh to the new unit testing framework

2 years agosequencer: unset GIT_CHERRY_PICK_HELP for 'exec' commands
Vegard Nossum [Fri, 2 Feb 2024 09:18:50 +0000 (10:18 +0100)]
sequencer: unset GIT_CHERRY_PICK_HELP for 'exec' commands

Running "git cherry-pick" as an x-command in the rebase plan loses
the original authorship information.

To fix this, unset GIT_CHERRY_PICK_HELP for 'exec' commands.

Helped-by: Phillip Wood <redacted>
Signed-off-by: Vegard Nossum <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoref-filter.c: sort formatted dates by byte value
Victoria Dye [Thu, 8 Feb 2024 01:57:19 +0000 (01:57 +0000)]
ref-filter.c: sort formatted dates by byte value

Update the ref sorting functions of 'ref-filter.c' so that when date fields
are specified with a format string (such as in 'git for-each-ref
--sort=creatordate:<something>'), they are sorted by their formatted string
value rather than by the underlying numeric timestamp. Currently, date
fields are always sorted by timestamp, regardless of whether formatting
information is included in the '--sort' key.

Leaving the default (unformatted) date sorting unchanged, sorting by the
formatted date string adds some flexibility to 'for-each-ref' by allowing
for behavior like "sort by year, then by refname within each year" or "sort
by time of day". Because the inclusion of a format string previously had no
effect on sort behavior, this change likely will not affect existing usage
of 'for-each-ref' or other ref listing commands.

Additionally, update documentation & tests to document the new sorting
mechanism.

Signed-off-by: Victoria Dye <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agossh signing: signal an error with a negative return value
Junio C Hamano [Thu, 8 Feb 2024 05:29:00 +0000 (21:29 -0800)]
ssh signing: signal an error with a negative return value

The other backend for the sign_buffer() function followed our usual
"an error is signalled with a negative return" convention, but the
SSH signer did not.  Even though we already fixed the caller that
assumed only a negative return value is an error, tighten the callee
to signal an error with a negative return as well.  This way, the
callees will be strict on what they produce, while the callers will
be lenient in what they accept.

Signed-off-by: Junio C Hamano <redacted>
2 years agorefs/reftable: fix leak when copying reflog fails
Patrick Steinhardt [Thu, 8 Feb 2024 05:26:14 +0000 (06:26 +0100)]
refs/reftable: fix leak when copying reflog fails

When copying a ref with the reftable backend we also copy the
corresponding log records. When seeking the first log record that we're
about to copy fails though we directly return from `write_copy_table()`
without doing any cleanup, leaking several allocated data structures.

Fix this by exiting via our common cleanup logic instead.

Reported-by: Jeff King <redacted> via Coverity
Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agobisect: document command line arguments for "bisect start"
Junio C Hamano [Wed, 7 Feb 2024 21:44:36 +0000 (13:44 -0800)]
bisect: document command line arguments for "bisect start"

The syntax commonly used for alternatives is --opt-(a|b), not
--opt-{a,b}.

List bad/new and good/old consistently in this order, to be
consistent with the description for "git bisect terms".  Clarify
<term> to either <term-old> or <term-new> to make them consistent
with the description of "git bisect (good|bad)" subcommands.

Suggested-by: Matthieu Moy <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agobisect: document "terms" subcommand more fully
Junio C Hamano [Wed, 7 Feb 2024 21:44:35 +0000 (13:44 -0800)]
bisect: document "terms" subcommand more fully

The documentation for "git bisect terms", although it did not hide
any information, was a bit incomplete and forced readers to fill in
the blanks to get the complete picture.

Acked-by: Matthieu Moy <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agotag: fix sign_buffer() call to create a signed tag
Junio C Hamano [Wed, 7 Feb 2024 18:46:54 +0000 (10:46 -0800)]
tag: fix sign_buffer() call to create a signed tag

The command "git tag -s" internally calls sign_buffer() to make a
cryptographic signature using the chosen backend like GPG and SSH.
The internal helper functions used by "git tag" implementation seem
to use a "negative return values are errors, zero or positive return
values are not" convention, and there are places (e.g., verify_tag()
that calls gpg_verify_tag()) that these internal helper functions
translate return values that signal errors to conform to this
convention, but do_sign() that calls sign_buffer() forgets to do so.

Fix it, so that a failed call to sign_buffer() that can return the
exit status from pipe_command() will not be overlooked.

Reported-by: Sergey Kosukhin <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agot1400: use show-ref to check pseudorefs
Phillip Wood [Wed, 7 Feb 2024 16:44:36 +0000 (16:44 +0000)]
t1400: use show-ref to check pseudorefs

Now that "git show-ref --verify" accepts pseudorefs use that in
preference to "git rev-parse" when checking pseudorefs as we do when
checking branches etc.

Signed-off-by: Phillip Wood <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoshow-ref --verify: accept pseudorefs
Phillip Wood [Wed, 7 Feb 2024 16:44:35 +0000 (16:44 +0000)]
show-ref --verify: accept pseudorefs

"git show-ref --verify" is useful for scripts that want to look up a
fully qualified refname without falling back to the DWIM rules used by
"git rev-parse" rules when the ref does not exist. Currently it will
only accept "HEAD" or a refname beginning with "refs/". Running

    git show-ref --verify CHERRY_PICK_HEAD

will always result in

    fatal: 'CHERRY_PICK_HEAD' - not a valid ref

even when CHERRY_PICK_HEAD exists. By calling refname_is_safe() instead
of comparing the refname to "HEAD" we can accept all one-level refs that
contain only uppercase ascii letters and underscores.

Signed-off-by: Phillip Wood <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoci: add jobs to test with the reftable backend
Patrick Steinhardt [Wed, 7 Feb 2024 07:20:35 +0000 (08:20 +0100)]
ci: add jobs to test with the reftable backend

Add CI jobs for both GitHub Workflows and GitLab CI to run Git with the
new reftable backend.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agorefs: introduce reftable backend
Patrick Steinhardt [Wed, 7 Feb 2024 07:20:31 +0000 (08:20 +0100)]
refs: introduce reftable backend

Due to scalability issues, Shawn Pearce has originally proposed a new
"reftable" format more than six years ago [1]. Initially, this new
format was implemented in JGit with promising results. Around two years
ago, we have then added the "reftable" library to the Git codebase via
a4bbd13be3 (Merge branch 'hn/reftable', 2021-12-15). With this we have
landed all the low-level code to read and write reftables. Notably
missing though was the integration of this low-level code into the Git
code base in the form of a new ref backend that ties all of this
together.

This gap is now finally closed by introducing a new "reftable" backend
into the Git codebase. This new backend promises to bring some notable
improvements to Git repositories:

  - It becomes possible to do truly atomic writes where either all refs
    are committed to disk or none are. This was not possible with the
    "files" backend because ref updates were split across multiple loose
    files.

  - The disk space required to store many refs is reduced, both compared
    to loose refs and packed-refs. This is enabled both by the reftable
    format being a binary format, which is more compact, and by prefix
    compression.

  - We can ignore filesystem-specific behaviour as ref names are not
    encoded via paths anymore. This means there is no need to handle
    case sensitivity on Windows systems or Unicode precomposition on
    macOS.

  - There is no need to rewrite the complete refdb anymore every time a
    ref is being deleted like it was the case for packed-refs. This
    means that ref deletions are now constant time instead of scaling
    linearly with the number of refs.

  - We can ignore file/directory conflicts so that it becomes possible
    to store both "refs/heads/foo" and "refs/heads/foo/bar".

  - Due to this property we can retain reflogs for deleted refs. We have
    previously been deleting reflogs together with their refs to avoid
    file/directory conflicts, which is not necessary anymore.

  - We can properly enumerate all refs. With the "files" backend it is
    not easily possible to distinguish between refs and non-refs because
    they may live side by side in the gitdir.

Not all of these improvements are realized with the current "reftable"
backend implementation. At this point, the new backend is supposed to be
a drop-in replacement for the "files" backend that is used by basically
all Git repositories nowadays. It strives for 1:1 compatibility, which
means that a user can expect the same behaviour regardless of whether
they use the "reftable" backend or the "files" backend for most of the
part.

Most notably, this means we artificially limit the capabilities of the
"reftable" backend to match the limits of the "files" backend. It is not
possible to create refs that would end up with file/directory conflicts,
we do not retain reflogs, we perform stricter-than-necessary checks.
This is done intentionally due to two main reasons:

  - It makes it significantly easier to land the "reftable" backend as
    tests behave the same. It would be tough to argue for each and every
    single test that doesn't pass with the "reftable" backend.

  - It ensures compatibility between repositories that use the "files"
    backend and repositories that use the "reftable" backend. Like this,
    hosters can migrate their repositories to use the "reftable" backend
    without causing issues for clients that use the "files" backend in
    their clones.

It is expected that these artificial limitations may eventually go away
in the long term.

Performance-wise things very much depend on the actual workload. The
following benchmarks compare the "files" and "reftable" backends in the
current version:

  - Creating N refs in separate transactions shows that the "files"
    backend is ~50% faster. This is not surprising given that creating a
    ref only requires us to create a single loose ref. The "reftable"
    backend will also perform auto compaction on updates. In real-world
    workloads we would likely also want to perform pack loose refs,
    which would likely change the picture.

        Benchmark 1: update-ref: create refs sequentially (refformat = files, refcount = 1)
          Time (mean Â± Ïƒ):       2.1 ms Â±   0.3 ms    [User: 0.6 ms, System: 1.7 ms]
          Range (min â€¦ max):     1.8 ms â€¦   4.3 ms    133 runs

        Benchmark 2: update-ref: create refs sequentially (refformat = reftable, refcount = 1)
          Time (mean Â± Ïƒ):       2.7 ms Â±   0.1 ms    [User: 0.6 ms, System: 2.2 ms]
          Range (min â€¦ max):     2.4 ms â€¦   2.9 ms    132 runs

        Benchmark 3: update-ref: create refs sequentially (refformat = files, refcount = 1000)
          Time (mean Â± Ïƒ):      1.975 s Â±  0.006 s    [User: 0.437 s, System: 1.535 s]
          Range (min â€¦ max):    1.969 s â€¦  1.980 s    3 runs

        Benchmark 4: update-ref: create refs sequentially (refformat = reftable, refcount = 1000)
          Time (mean Â± Ïƒ):      2.611 s Â±  0.013 s    [User: 0.782 s, System: 1.825 s]
          Range (min â€¦ max):    2.597 s â€¦  2.622 s    3 runs

        Benchmark 5: update-ref: create refs sequentially (refformat = files, refcount = 100000)
          Time (mean Â± Ïƒ):     198.442 s Â±  0.241 s    [User: 43.051 s, System: 155.250 s]
          Range (min â€¦ max):   198.189 s â€¦ 198.670 s    3 runs

        Benchmark 6: update-ref: create refs sequentially (refformat = reftable, refcount = 100000)
          Time (mean Â± Ïƒ):     294.509 s Â±  4.269 s    [User: 104.046 s, System: 190.326 s]
          Range (min â€¦ max):   290.223 s â€¦ 298.761 s    3 runs

  - Creating N refs in a single transaction shows that the "files"
    backend is significantly slower once we start to write many refs.
    The "reftable" backend only needs to update two files, whereas the
    "files" backend needs to write one file per ref.

        Benchmark 1: update-ref: create many refs (refformat = files, refcount = 1)
          Time (mean Â± Ïƒ):       1.9 ms Â±   0.1 ms    [User: 0.4 ms, System: 1.4 ms]
          Range (min â€¦ max):     1.8 ms â€¦   2.6 ms    151 runs

        Benchmark 2: update-ref: create many refs (refformat = reftable, refcount = 1)
          Time (mean Â± Ïƒ):       2.5 ms Â±   0.1 ms    [User: 0.7 ms, System: 1.7 ms]
          Range (min â€¦ max):     2.4 ms â€¦   3.4 ms    148 runs

        Benchmark 3: update-ref: create many refs (refformat = files, refcount = 1000)
          Time (mean Â± Ïƒ):     152.5 ms Â±   5.2 ms    [User: 19.1 ms, System: 133.1 ms]
          Range (min â€¦ max):   148.5 ms â€¦ 167.8 ms    15 runs

        Benchmark 4: update-ref: create many refs (refformat = reftable, refcount = 1000)
          Time (mean Â± Ïƒ):      58.0 ms Â±   2.5 ms    [User: 28.4 ms, System: 29.4 ms]
          Range (min â€¦ max):    56.3 ms â€¦  72.9 ms    40 runs

        Benchmark 5: update-ref: create many refs (refformat = files, refcount = 1000000)
          Time (mean Â± Ïƒ):     152.752 s Â±  0.710 s    [User: 20.315 s, System: 131.310 s]
          Range (min â€¦ max):   152.165 s â€¦ 153.542 s    3 runs

        Benchmark 6: update-ref: create many refs (refformat = reftable, refcount = 1000000)
          Time (mean Â± Ïƒ):     51.912 s Â±  0.127 s    [User: 26.483 s, System: 25.424 s]
          Range (min â€¦ max):   51.769 s â€¦ 52.012 s    3 runs

  - Deleting a ref in a fully-packed repository shows that the "files"
    backend scales with the number of refs. The "reftable" backend has
    constant-time deletions.

        Benchmark 1: update-ref: delete ref (refformat = files, refcount = 1)
          Time (mean Â± Ïƒ):       1.7 ms Â±   0.1 ms    [User: 0.4 ms, System: 1.2 ms]
          Range (min â€¦ max):     1.6 ms â€¦   2.1 ms    316 runs

        Benchmark 2: update-ref: delete ref (refformat = reftable, refcount = 1)
          Time (mean Â± Ïƒ):       1.8 ms Â±   0.1 ms    [User: 0.4 ms, System: 1.3 ms]
          Range (min â€¦ max):     1.7 ms â€¦   2.1 ms    294 runs

        Benchmark 3: update-ref: delete ref (refformat = files, refcount = 1000)
          Time (mean Â± Ïƒ):       2.0 ms Â±   0.1 ms    [User: 0.5 ms, System: 1.4 ms]
          Range (min â€¦ max):     1.9 ms â€¦   2.5 ms    287 runs

        Benchmark 4: update-ref: delete ref (refformat = reftable, refcount = 1000)
          Time (mean Â± Ïƒ):       1.9 ms Â±   0.1 ms    [User: 0.5 ms, System: 1.3 ms]
          Range (min â€¦ max):     1.8 ms â€¦   2.1 ms    217 runs

        Benchmark 5: update-ref: delete ref (refformat = files, refcount = 1000000)
          Time (mean Â± Ïƒ):     229.8 ms Â±   7.9 ms    [User: 182.6 ms, System: 46.8 ms]
          Range (min â€¦ max):   224.6 ms â€¦ 245.2 ms    6 runs

        Benchmark 6: update-ref: delete ref (refformat = reftable, refcount = 1000000)
          Time (mean Â± Ïƒ):       2.0 ms Â±   0.0 ms    [User: 0.6 ms, System: 1.3 ms]
          Range (min â€¦ max):     2.0 ms â€¦   2.1 ms    3 runs

  - Listing all refs shows no significant advantage for either of the
    backends. The "files" backend is a bit faster, but not by a
    significant margin. When repositories are not packed the "reftable"
    backend outperforms the "files" backend because the "reftable"
    backend performs auto-compaction.

        Benchmark 1: show-ref: print all refs (refformat = files, refcount = 1, packed = true)
          Time (mean Â± Ïƒ):       1.6 ms Â±   0.1 ms    [User: 0.4 ms, System: 1.1 ms]
          Range (min â€¦ max):     1.5 ms â€¦   2.0 ms    1729 runs

        Benchmark 2: show-ref: print all refs (refformat = reftable, refcount = 1, packed = true)
          Time (mean Â± Ïƒ):       1.6 ms Â±   0.1 ms    [User: 0.4 ms, System: 1.1 ms]
          Range (min â€¦ max):     1.5 ms â€¦   1.8 ms    1816 runs

        Benchmark 3: show-ref: print all refs (refformat = files, refcount = 1000, packed = true)
          Time (mean Â± Ïƒ):       4.3 ms Â±   0.1 ms    [User: 0.9 ms, System: 3.3 ms]
          Range (min â€¦ max):     4.1 ms â€¦   4.6 ms    645 runs

        Benchmark 4: show-ref: print all refs (refformat = reftable, refcount = 1000, packed = true)
          Time (mean Â± Ïƒ):       4.5 ms Â±   0.2 ms    [User: 1.0 ms, System: 3.3 ms]
          Range (min â€¦ max):     4.2 ms â€¦   5.9 ms    643 runs

        Benchmark 5: show-ref: print all refs (refformat = files, refcount = 1000000, packed = true)
          Time (mean Â± Ïƒ):      2.537 s Â±  0.034 s    [User: 0.488 s, System: 2.048 s]
          Range (min â€¦ max):    2.511 s â€¦  2.627 s    10 runs

        Benchmark 6: show-ref: print all refs (refformat = reftable, refcount = 1000000, packed = true)
          Time (mean Â± Ïƒ):      2.712 s Â±  0.017 s    [User: 0.653 s, System: 2.059 s]
          Range (min â€¦ max):    2.692 s â€¦  2.752 s    10 runs

        Benchmark 7: show-ref: print all refs (refformat = files, refcount = 1, packed = false)
          Time (mean Â± Ïƒ):       1.6 ms Â±   0.1 ms    [User: 0.4 ms, System: 1.1 ms]
          Range (min â€¦ max):     1.5 ms â€¦   1.9 ms    1834 runs

        Benchmark 8: show-ref: print all refs (refformat = reftable, refcount = 1, packed = false)
          Time (mean Â± Ïƒ):       1.6 ms Â±   0.1 ms    [User: 0.4 ms, System: 1.1 ms]
          Range (min â€¦ max):     1.4 ms â€¦   2.0 ms    1840 runs

        Benchmark 9: show-ref: print all refs (refformat = files, refcount = 1000, packed = false)
          Time (mean Â± Ïƒ):      13.8 ms Â±   0.2 ms    [User: 2.8 ms, System: 10.8 ms]
          Range (min â€¦ max):    13.3 ms â€¦  14.5 ms    208 runs

        Benchmark 10: show-ref: print all refs (refformat = reftable, refcount = 1000, packed = false)
          Time (mean Â± Ïƒ):       4.5 ms Â±   0.2 ms    [User: 1.2 ms, System: 3.3 ms]
          Range (min â€¦ max):     4.3 ms â€¦   6.2 ms    624 runs

        Benchmark 11: show-ref: print all refs (refformat = files, refcount = 1000000, packed = false)
          Time (mean Â± Ïƒ):     12.127 s Â±  0.129 s    [User: 2.675 s, System: 9.451 s]
          Range (min â€¦ max):   11.965 s â€¦ 12.370 s    10 runs

        Benchmark 12: show-ref: print all refs (refformat = reftable, refcount = 1000000, packed = false)
          Time (mean Â± Ïƒ):      2.799 s Â±  0.022 s    [User: 0.735 s, System: 2.063 s]
          Range (min â€¦ max):    2.769 s â€¦  2.836 s    10 runs

  - Printing a single ref shows no real difference between the "files"
    and "reftable" backends.

        Benchmark 1: show-ref: print single ref (refformat = files, refcount = 1)
          Time (mean Â± Ïƒ):       1.5 ms Â±   0.1 ms    [User: 0.4 ms, System: 1.0 ms]
          Range (min â€¦ max):     1.4 ms â€¦   1.8 ms    1779 runs

        Benchmark 2: show-ref: print single ref (refformat = reftable, refcount = 1)
          Time (mean Â± Ïƒ):       1.6 ms Â±   0.1 ms    [User: 0.4 ms, System: 1.1 ms]
          Range (min â€¦ max):     1.4 ms â€¦   2.5 ms    1753 runs

        Benchmark 3: show-ref: print single ref (refformat = files, refcount = 1000)
          Time (mean Â± Ïƒ):       1.5 ms Â±   0.1 ms    [User: 0.3 ms, System: 1.1 ms]
          Range (min â€¦ max):     1.4 ms â€¦   1.9 ms    1840 runs

        Benchmark 4: show-ref: print single ref (refformat = reftable, refcount = 1000)
          Time (mean Â± Ïƒ):       1.6 ms Â±   0.1 ms    [User: 0.4 ms, System: 1.1 ms]
          Range (min â€¦ max):     1.5 ms â€¦   2.0 ms    1831 runs

        Benchmark 5: show-ref: print single ref (refformat = files, refcount = 1000000)
          Time (mean Â± Ïƒ):       1.6 ms Â±   0.1 ms    [User: 0.4 ms, System: 1.1 ms]
          Range (min â€¦ max):     1.5 ms â€¦   2.1 ms    1848 runs

        Benchmark 6: show-ref: print single ref (refformat = reftable, refcount = 1000000)
          Time (mean Â± Ïƒ):       1.6 ms Â±   0.1 ms    [User: 0.4 ms, System: 1.1 ms]
          Range (min â€¦ max):     1.5 ms â€¦   2.1 ms    1762 runs

So overall, performance depends on the usecases. Except for many
sequential writes the "reftable" backend is roughly on par or
significantly faster than the "files" backend though. Given that the
"files" backend has received 18 years of optimizations by now this can
be seen as a win. Furthermore, we can expect that the "reftable" backend
will grow faster over time when attention turns more towards
optimizations.

The complete test suite passes, except for those tests explicitly marked
to require the REFFILES prerequisite. Some tests in t0610 are marked as
failing because they depend on still-in-flight bug fixes. Tests can be
run with the new backend by setting the GIT_TEST_DEFAULT_REF_FORMAT
environment variable to "reftable".

There is a single known conceptual incompatibility with the dumb HTTP
transport. As "info/refs" SHOULD NOT contain the HEAD reference, and
because the "HEAD" file is not valid anymore, it is impossible for the
remote client to figure out the default branch without changing the
protocol. This shortcoming needs to be handled in a subsequent patch
series.

As the reftable library has already been introduced a while ago, this
commit message will not go into the details of how exactly the on-disk
format works. Please refer to our preexisting technical documentation at
Documentation/technical/reftable for this.

[1]: https://public-inbox.org/git/CAJo=hJtyof=HRy=2sLP0ng0uZ4=S-DpZ5dR1aF+VHVETKG20OQ@mail.gmail.com/

Original-idea-by: Shawn Pearce <redacted>
Based-on-patch-by: Han-Wen Nienhuys <redacted>
Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agocompletion: bisect: recognize but do not complete view subcommand
Britton Leo Kerin [Tue, 6 Feb 2024 21:50:48 +0000 (12:50 -0900)]
completion: bisect: recognize but do not complete view subcommand

The "view" alias for the visualize subcommand is neither completed nor
recognized.  It's undesirable to complete it because it's first letters
are the same as for visualize, making completion less rather than more
efficient without adding much in the way of interface discovery.
However, it needs to be recognized in order to enable log option
completion for it.

Recognize but do not complete the view command by creating and using
separate lists of completable_subcommands and all_subcommands.  Add
tests.

Signed-off-by: Britton Leo Kerin <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agocompletion: bisect: complete log opts for visualize subcommand
Britton Leo Kerin [Tue, 6 Feb 2024 21:50:47 +0000 (12:50 -0900)]
completion: bisect: complete log opts for visualize subcommand

Arguments passed to the "visualize" subcommand of git-bisect(1) get
forwarded to git-log(1). It thus supports the same options as git-log(1)
would, but our Bash completion script does not know to handle this.

Make completion of porcelain git-log options and option arguments to the
visualize subcommand work by calling __git_complete_log_opts when the
start of an option to the subcommand is seen (visualize doesn't support
any options besides the git-log options).  Add test.

Signed-off-by: Britton Leo Kerin <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agocompletion: new function __git_complete_log_opts
Britton Leo Kerin [Tue, 6 Feb 2024 21:50:46 +0000 (12:50 -0900)]
completion: new function __git_complete_log_opts

The options accepted by git-log are also accepted by at least one other
command (git-bisect).  Factor the common option completion code into a
new function and use it from _git_log.  The new function leaves
COMPREPLY empty if no option candidates are found, so that callers can
safely check it to determine if completion for other arguments should be
attempted.

Signed-off-by: Britton Leo Kerin <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agocompletion: bisect: complete missing --first-parent and - -no-checkout options
Britton Leo Kerin [Tue, 6 Feb 2024 21:50:45 +0000 (12:50 -0900)]
completion: bisect: complete missing --first-parent and - -no-checkout options

The --first-parent and --no-checkout options to the start subcommand of
git-bisect(1) are not completed.

Enable completion of the --first-parent and --no-checkout options to the
start subcommand.  Add test.

Signed-off-by: Britton Leo Kerin <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agocompletion: bisect: complete custom terms and related options
Britton Leo Kerin [Tue, 6 Feb 2024 21:50:44 +0000 (12:50 -0900)]
completion: bisect: complete custom terms and related options

git bisect supports the use of custom terms via the --term-(new|bad) and
--term-(old|good) options, but the completion code doesn't know about
these options or the new subcommands they define.

Add support for these options and the custom subcommands by checking for
BISECT_TERMS and adding them to the list of subcommands.  Add tests.

Signed-off-by: Britton Leo Kerin <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agocompletion: bisect: complete bad, new, old, and help subcommands
Britton Leo Kerin [Tue, 6 Feb 2024 21:50:43 +0000 (12:50 -0900)]
completion: bisect: complete bad, new, old, and help subcommands

The bad, new, old and help subcommands to git-bisect(1) are not
completed.

Add the bad, new, old, and help subcommands to the appropriate lists
such that the commands and their possible ref arguments are completed.
Add tests.

Signed-off-by: Britton Leo Kerin <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agocompletion: tests: always use 'master' for default initial branch name
Britton Leo Kerin [Tue, 6 Feb 2024 21:50:42 +0000 (12:50 -0900)]
completion: tests: always use 'master' for default initial branch name

The default initial branch name can normally be configured using the
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME environment variable.  However,
when testing e.g. <rev> completion it's convenient to know the
exact initial branch name that will be used.

To achieve that without too much trouble it is considered sufficient
to force the default initial branch name to 'master' for all of
t9902-completion.sh.

Signed-off-by: Britton Leo Kerin <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoThe fourteenth batch
Junio C Hamano [Tue, 6 Feb 2024 22:31:50 +0000 (14:31 -0800)]
The fourteenth batch

Signed-off-by: Junio C Hamano <redacted>
2 years agoMerge branch 'cb/use-freebsd-13-2-at-cirrus-ci'
Junio C Hamano [Tue, 6 Feb 2024 22:31:22 +0000 (14:31 -0800)]
Merge branch 'cb/use-freebsd-13-2-at-cirrus-ci'

Cirrus CI jobs started breaking because we specified version of
FreeBSD that is no longer available, which has been corrected.

* cb/use-freebsd-13-2-at-cirrus-ci:
  ci: update FreeBSD cirrus job

2 years agoMerge branch 'jc/make-libpath-template'
Junio C Hamano [Tue, 6 Feb 2024 22:31:22 +0000 (14:31 -0800)]
Merge branch 'jc/make-libpath-template'

The Makefile often had to say "-L$(path) -R$(path)" that repeats
the path to the same library directory for link time and runtime.
A Makefile template is used to reduce such repetition.

* jc/make-libpath-template:
  Makefile: simplify output of the libpath_template
  Makefile: reduce repetitive library paths

2 years agoMerge branch 'rj/test-with-leak-check'
Junio C Hamano [Tue, 6 Feb 2024 22:31:21 +0000 (14:31 -0800)]
Merge branch 'rj/test-with-leak-check'

More tests that are supposed to pass leak sanitizer are marked as such.

* rj/test-with-leak-check:
  t0080: mark as leak-free
  test-lib: check for TEST_PASSES_SANITIZE_LEAK
  t6113: mark as leak-free
  t5332: mark as leak-free

2 years agoMerge branch 'jc/t0091-with-unknown-git'
Junio C Hamano [Tue, 6 Feb 2024 22:31:21 +0000 (14:31 -0800)]
Merge branch 'jc/t0091-with-unknown-git'

The test did not work when Git was built from a repository without
tags.

* jc/t0091-with-unknown-git:
  t0091: allow test in a repository without tags

2 years agoMerge branch 'js/win32-retry-pipe-write-on-enospc'
Junio C Hamano [Tue, 6 Feb 2024 22:31:21 +0000 (14:31 -0800)]
Merge branch 'js/win32-retry-pipe-write-on-enospc'

Update to the code that writes to pipes on Windows.

* js/win32-retry-pipe-write-on-enospc:
  win32: special-case `ENOSPC` when writing to a pipe

2 years agoMerge branch 'ps/tests-with-ref-files-backend'
Junio C Hamano [Tue, 6 Feb 2024 22:31:21 +0000 (14:31 -0800)]
Merge branch 'ps/tests-with-ref-files-backend'

Prepare existing tests on refs to work better with non-default
backends.

* ps/tests-with-ref-files-backend:
  t: mark tests regarding git-pack-refs(1) to be backend specific
  t5526: break test submodule differently
  t1419: mark test suite as files-backend specific
  t1302: make tests more robust with new extensions
  t1301: mark test for `core.sharedRepository` as reffiles specific
  t1300: make tests more robust with non-default ref backends

2 years agoMerge branch 'jc/comment-style-fixes'
Junio C Hamano [Tue, 6 Feb 2024 22:31:21 +0000 (14:31 -0800)]
Merge branch 'jc/comment-style-fixes'

Rewrite //-comments to /* comments */ in files whose comments
prevalently use the latter.

* jc/comment-style-fixes:
  reftable/pq_test: comment style fix
  merge-ort.c: comment style fix
  builtin/worktree: comment style fixes

2 years agoMerge branch 'jk/diff-external-with-no-index'
Junio C Hamano [Tue, 6 Feb 2024 22:31:20 +0000 (14:31 -0800)]
Merge branch 'jk/diff-external-with-no-index'

"git diff --no-index file1 file2" segfaulted while invoking the
external diff driver, which has been corrected.

* jk/diff-external-with-no-index:
  diff: handle NULL meta-info when spawning external diff

2 years agoMerge branch 'kh/maintenance-use-xdg-when-it-should'
Junio C Hamano [Tue, 6 Feb 2024 22:31:20 +0000 (14:31 -0800)]
Merge branch 'kh/maintenance-use-xdg-when-it-should'

Comment fix.

* kh/maintenance-use-xdg-when-it-should:
  config: add back code comment

2 years agoMerge branch 'tb/pack-bitmap-drop-unused-struct-member'
Junio C Hamano [Tue, 6 Feb 2024 22:31:20 +0000 (14:31 -0800)]
Merge branch 'tb/pack-bitmap-drop-unused-struct-member'

Code clean-up.

* tb/pack-bitmap-drop-unused-struct-member:
  pack-bitmap: drop unused `reuse_objects`

2 years agoMerge branch 'jt/p4-spell-re-with-raw-string'
Junio C Hamano [Tue, 6 Feb 2024 22:31:20 +0000 (14:31 -0800)]
Merge branch 'jt/p4-spell-re-with-raw-string'

"git p4" update to squelch warnings from Python.

* jt/p4-spell-re-with-raw-string:
  git-p4: use raw string literals for regular expressions

2 years agoMerge branch 'ps/reftable-compacted-tables-permission-fix'
Junio C Hamano [Tue, 6 Feb 2024 22:31:20 +0000 (14:31 -0800)]
Merge branch 'ps/reftable-compacted-tables-permission-fix'

Reftable bugfix.

* ps/reftable-compacted-tables-permission-fix:
  reftable/stack: adjust permissions of compacted tables

2 years agoMerge branch 'jc/reftable-core-fsync'
Junio C Hamano [Tue, 6 Feb 2024 22:31:20 +0000 (14:31 -0800)]
Merge branch 'jc/reftable-core-fsync'

The write codepath for the reftable data learned to honor
core.fsync configuration.

* jc/reftable-core-fsync:
  reftable/stack: fsync "tables.list" during compaction
  reftable: honor core.fsync

2 years ago.github/PULL_REQUEST_TEMPLATE.md: add a note about single-commit PRs
Philippe Blain [Tue, 6 Feb 2024 13:20:12 +0000 (13:20 +0000)]
.github/PULL_REQUEST_TEMPLATE.md: add a note about single-commit PRs

Contributors using Gitgitgadget continue to send single-commit PRs with
their commit message text duplicated below the three-dash line,
increasing the signal-to-noise ratio for reviewers.

This is because Gitgitgadget copies the pull request description as an
in-patch commentary, for single-commit PRs, and _GitHub_ defaults to
prefilling the pull request description with the commit message, for
single-commit PRs (followed by the content of the pull request
template).

Add a note in the pull request template mentioning that for
single-commit PRs, the PR description should thus be kept empty, in the
hope that contributors read it and act on it.

This partly addresses:
https://github.com/gitgitgadget/gitgitgadget/issues/340

Signed-off-by: Philippe Blain <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoreftable/record: improve semantics when initializing records
Patrick Steinhardt [Tue, 6 Feb 2024 06:35:59 +0000 (07:35 +0100)]
reftable/record: improve semantics when initializing records

According to our usual coding style, the `reftable_new_record()`
function would indicate that it is allocating a new record. This is not
the case though as the function merely initializes records without
allocating any memory.

Replace `reftable_new_record()` with a new `reftable_record_init()`
function that takes a record pointer as input and initializes it
accordingly.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoreftable/merged: refactor initialization of iterators
Patrick Steinhardt [Tue, 6 Feb 2024 06:35:55 +0000 (07:35 +0100)]
reftable/merged: refactor initialization of iterators

Refactor the initialization of the merged iterator to fit our code style
better. This refactoring prepares the code for a refactoring of how
records are being initialized.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoreftable/merged: refactor seeking of records
Patrick Steinhardt [Tue, 6 Feb 2024 06:35:50 +0000 (07:35 +0100)]
reftable/merged: refactor seeking of records

The code to seek reftable records in the merged table code is quite hard
to read and does not conform to our coding style in multiple ways:

  - We have multiple exit paths where we release resources even though
    that is not really necessary.

  - We use a scoped error variable `e` which is hard to reason about.
    This variable is not required at all.

  - We allocate memory in the variable declarations, which is easy to
    miss.

Refactor the function so that it becomes more maintainable in the
future.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoreftable/stack: use `size_t` to track stack length
Patrick Steinhardt [Tue, 6 Feb 2024 06:35:46 +0000 (07:35 +0100)]
reftable/stack: use `size_t` to track stack length

While the stack length is already stored as `size_t`, we frequently use
`int`s to refer to those stacks throughout the reftable library. Convert
those cases to use `size_t` instead to make things consistent.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoreftable/stack: use `size_t` to track stack slices during compaction
Patrick Steinhardt [Tue, 6 Feb 2024 06:35:41 +0000 (07:35 +0100)]
reftable/stack: use `size_t` to track stack slices during compaction

We use `int`s to track reftable slices when compacting the reftable
stack, which is considered to be a code smell in the Git project.
Convert the code to use `size_t` instead.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoreftable/stack: index segments with `size_t`
Patrick Steinhardt [Tue, 6 Feb 2024 06:35:35 +0000 (07:35 +0100)]
reftable/stack: index segments with `size_t`

We use `int`s to index into arrays of segments and track the length of
them, which is considered to be a code smell in the Git project. Convert
the code to use `size_t` instead.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoreftable/stack: fix parameter validation when compacting range
Patrick Steinhardt [Tue, 6 Feb 2024 06:35:31 +0000 (07:35 +0100)]
reftable/stack: fix parameter validation when compacting range

The `stack_compact_range()` function receives a "first" and "last" index
that indicates which tables of the reftable stack should be compacted.
Naturally, "first" must be smaller than "last" in order to identify a
proper range of tables to compress, which we indeed also assert in the
function. But the validations happens after we have already allocated
arrays with a size of `last - first + 1`, leading to an underflow and
thus an invalid allocation size.

Fix this by reordering the array allocations to happen after we have
validated parameters. While at it, convert the array allocations to use
the newly introduced macros.

Note that the relevant variables pointing into arrays should also be
converted to use `size_t` instead of `int`. This is left for a later
commit in this series.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoreftable: introduce macros to allocate arrays
Patrick Steinhardt [Tue, 6 Feb 2024 06:35:27 +0000 (07:35 +0100)]
reftable: introduce macros to allocate arrays

Similar to the preceding commit, let's carry over macros to allocate
arrays with `REFTABLE_ALLOC_ARRAY()` and `REFTABLE_CALLOC_ARRAY()`. This
requires us to change the signature of `reftable_calloc()`, which only
takes a single argument right now and thus puts the burden on the caller
to calculate the final array's size. This is a net improvement though as
it means that we can now provide proper overflow checks when multiplying
the array size with the member size.

Convert callsites of `reftable_calloc()` to the new signature and start
using the new macros where possible.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoreftable: introduce macros to grow arrays
Patrick Steinhardt [Tue, 6 Feb 2024 06:35:23 +0000 (07:35 +0100)]
reftable: introduce macros to grow arrays

Throughout the reftable library we have many cases where we need to grow
arrays. In order to avoid too many reallocations, we roughly double the
capacity of the array on each iteration. The resulting code pattern is
duplicated across many sites.

We have similar patterns in our main codebase, which is why we have
eventually introduced an `ALLOC_GROW()` macro to abstract it away and
avoid some code duplication. We cannot easily reuse this macro here
though because `ALLOC_GROW()` uses `REALLOC_ARRAY()`, which in turn will
call realloc(3P) to grow the array. The reftable code is structured as a
library though (even if the boundaries are fuzzy), and one property this
brings with it is that it is possible to plug in your own allocators. So
instead of using realloc(3P), we need to use `reftable_realloc()` that
knows to use the user-provided implementation.

So let's introduce two new macros `REFTABLE_REALLOC_ARRAY()` and
`REFTABLE_ALLOC_GROW()` that mirror what we do in our main codebase,
with two modifications:

  - They use `reftable_realloc()`, as explained above.

  - They use a different growth factor of `2 * cap + 1` instead of `(cap
    + 16) * 3 / 2`.

The second change is because we know a bit more about the allocation
patterns in the reftable library. In most cases, we end up only having a
handful of items in the array and don't end up growing them. The initial
capacity that our normal growth factor uses (which is 24) would thus end
up over-allocating in a lot of code paths. This effect is measurable:

  - Before change:

      HEAP SUMMARY:
          in use at exit: 671,983 bytes in 152 blocks
        total heap usage: 3,843,446 allocs, 3,843,294 frees, 223,761,402 bytes allocated

  - After change with a growth factor of `(2 * alloc + 1)`:

      HEAP SUMMARY:
          in use at exit: 671,983 bytes in 152 blocks
        total heap usage: 3,843,446 allocs, 3,843,294 frees, 223,761,410 bytes allocated

  - After change with a growth factor of `(alloc + 16)* 2 / 3`:

      HEAP SUMMARY:
          in use at exit: 671,983 bytes in 152 blocks
        total heap usage: 3,833,673 allocs, 3,833,521 frees, 4,728,251,742 bytes allocated

While the total heap usage is roughly the same, we do end up allocating
significantly more bytes with our usual growth factor (in fact, roughly
21 times as many).

Convert the reftable library to use these new macros.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agobuiltin/stash: report failure to write to index
Patrick Steinhardt [Tue, 6 Feb 2024 05:34:41 +0000 (06:34 +0100)]
builtin/stash: report failure to write to index

The git-stash(1) command needs to write to the index for many of its
operations. When the index is locked by a concurrent writer it will thus
fail to operate, which is expected. What is not expected though is that
we do not print any error message at all in this case. The user can thus
easily miss the fact that the command didn't do what they expected it to
do and would be left wondering why that is.

Fix this bug and report failures to write to the index. Add tests for
the subcommands which hit the respective code paths.

While at it, unify error messages when writing to the index fails. The
chosen error message is already used in "builtin/stash.c".

Reported-by: moti sd <redacted>
Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoAlways check the return value of `repo_read_object_file()`
Johannes Schindelin [Mon, 5 Feb 2024 14:35:53 +0000 (14:35 +0000)]
Always check the return value of `repo_read_object_file()`

There are a couple of places in Git's source code where the return value
is not checked. As a consequence, they are susceptible to segmentation
faults.

Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agopack-objects: enable multi-pack reuse via `feature.experimental`
Taylor Blau [Mon, 5 Feb 2024 22:50:23 +0000 (17:50 -0500)]
pack-objects: enable multi-pack reuse via `feature.experimental`

Now that multi-pack reuse is supported, enable it via the
feature.experimental configuration in addition to the classic
`pack.allowPackReuse`.

This will allow more users to experiment with the new behavior who might
not otherwise be aware of the existing `pack.allowPackReuse`
configuration option.

The enum with values NO_PACK_REUSE, SINGLE_PACK_REUSE, and
MULTI_PACK_REUSE is defined statically in builtin/pack-objects.c's
compilation unit. We could hoist that enum into a scope visible from the
repository_settings struct, and then use that enum value in
pack-objects. Instead, define a single int that indicates what
pack-objects's default value should be to avoid additional unnecessary
code movement.

Though `feature.experimental` implies `pack.allowPackReuse=multi`, this
can still be overridden by explicitly setting the latter configuration
to either "single" or "false". Tests covering all of these cases are
showin t5332.

Signed-off-by: Taylor Blau <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agot5332-multi-pack-reuse.sh: extract pack-objects helper functions
Taylor Blau [Mon, 5 Feb 2024 22:50:19 +0000 (17:50 -0500)]
t5332-multi-pack-reuse.sh: extract pack-objects helper functions

Most of the tests in t5332 perform some setup before repeating a common
refrain that looks like:

    : >trace2.txt &&
    GIT_TRACE2_EVENT="$PWD/trace2.txt" \
      git pack-objects --stdout --revs --all >/dev/null &&

    test_pack_reused $objects_nr <trace2.txt &&
    test_packs_reused $packs_nr <trace2.txt

The next commit will add more tests which repeat the above refrain.
Avoid duplicating this invocation even further and prepare for the
following commit by wrapping the above in a helper function called
`test_pack_objects_reused_all()`.

Introduce another similar function `test_pack_objects_reused`, which
expects to read a list of revisions over stdin for tests which need more
fine-grained control of the contents of the pack they generate.

Signed-off-by: Taylor Blau <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoMerge branch 'jk/unit-tests-buildfix' into js/unit-test-suite-runner
Junio C Hamano [Sat, 3 Feb 2024 20:33:00 +0000 (12:33 -0800)]
Merge branch 'jk/unit-tests-buildfix' into js/unit-test-suite-runner

* jk/unit-tests-buildfix:
  t/Makefile: say the default target upfront
  t/Makefile: get UNIT_TESTS list from C sources
  Makefile: remove UNIT_TEST_BIN directory with "make clean"
  Makefile: use mkdir_p_parent_template for UNIT_TEST_BIN

2 years agot/Makefile: say the default target upfront
Junio C Hamano [Sat, 3 Feb 2024 01:32:42 +0000 (17:32 -0800)]
t/Makefile: say the default target upfront

Similar to how 2731d048 (Makefile: say the default target upfront.,
2005-12-01) added the default target to the very beginning of the
main Makefile to prevent a random rule that happens to be defined
first in an included makefile fragments from becoming the default
target, protect this Makefile the same way.

This started to matter as we started to include config.mak.uname
and that included makefile fragment does more than defining Make
macros, unfortunately.

Helped-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoMerge branch 'jc/maint-github-actions-update' into jc/github-actions-update
Junio C Hamano [Fri, 2 Feb 2024 21:02:41 +0000 (13:02 -0800)]
Merge branch 'jc/maint-github-actions-update' into jc/github-actions-update

This contains an evil merge to tell the fuzz-smoke-test job to
also use checkout@v4; the job has been added since the master
track diverged from the maintenance track.

* jc/maint-github-actions-update:
  GitHub Actions: update to github-script@v7
  GitHub Actions: update to checkout@v4

2 years agoGitHub Actions: update to github-script@v7
Junio C Hamano [Fri, 2 Feb 2024 20:39:35 +0000 (12:39 -0800)]
GitHub Actions: update to github-script@v7

We seem to be getting "Node.js 16 actions are deprecated." warnings
for jobs that use github-script@v6.  Update to github-script@v7,
which is said to use Node.js 20.

Signed-off-by: Junio C Hamano <redacted>
2 years agoGitHub Actions: update to checkout@v4
Junio C Hamano [Fri, 2 Feb 2024 20:39:34 +0000 (12:39 -0800)]
GitHub Actions: update to checkout@v4

We seem to be getting "Node.js 16 actions are deprecated." warnings
for jobs that use checkout@v3.  Except for the i686 containers job
that is kept at checkout@v1 [*], update to checkout@v4, which is
said to use Node.js 20.

[*] 6cf4d908 (ci(main): upgrade actions/checkout to v3, 2022-12-05)
    refers to https://github.com/actions/runner/issues/2115 and
    explains why container jobs are kept at checkout@v1.  We may
    want to check the current status of the issue and move it to the
    same version as other jobs, but that is outside the scope of
    this step.

Signed-off-by: Junio C Hamano <redacted>
2 years agoThe thirteenth batch
Junio C Hamano [Fri, 2 Feb 2024 18:33:01 +0000 (10:33 -0800)]
The thirteenth batch

Signed-off-by: Junio C Hamano <redacted>
2 years agoMerge branch 'zf/subtree-split-fix'
Junio C Hamano [Fri, 2 Feb 2024 19:31:51 +0000 (11:31 -0800)]
Merge branch 'zf/subtree-split-fix'

"git subtree" (in contrib/) update.

* zf/subtree-split-fix:
  subtree: fix split processing with multiple subtrees present

2 years agoMerge branch 'jc/ls-files-doc-update'
Junio C Hamano [Fri, 2 Feb 2024 19:31:51 +0000 (11:31 -0800)]
Merge branch 'jc/ls-files-doc-update'

The documentation for the --exclude-per-directory option marked it
as deprecated, which confused readers into thinking there may be a
plan to remove it in the future, which was not our intention.

* jc/ls-files-doc-update:
  ls-files: avoid the verb "deprecate" for individual options

2 years agoMerge branch 'jk/fetch-auto-tag-following-fix'
Junio C Hamano [Fri, 2 Feb 2024 19:31:51 +0000 (11:31 -0800)]
Merge branch 'jk/fetch-auto-tag-following-fix'

Fetching via protocol v0 over Smart HTTP transport sometimes failed
to correctly auto-follow tags.

* jk/fetch-auto-tag-following-fix:
  transport-helper: re-examine object dir after fetching

2 years agoMerge branch 'jc/coc-whitespace-fix'
Junio C Hamano [Fri, 2 Feb 2024 19:31:51 +0000 (11:31 -0800)]
Merge branch 'jc/coc-whitespace-fix'

Docfix.

* jc/coc-whitespace-fix:
  CoC: whitespace fix

2 years agoMerge branch 'ad/custom-merge-placeholder-for-symbolic-pathnames'
Junio C Hamano [Fri, 2 Feb 2024 19:31:50 +0000 (11:31 -0800)]
Merge branch 'ad/custom-merge-placeholder-for-symbolic-pathnames'

The labels on conflict markers for the common ancestor, our version,
and the other version are available to custom 3-way merge driver
via %S, %X, and %Y placeholders.

* ad/custom-merge-placeholder-for-symbolic-pathnames:
  merge-ll: expose revision names to custom drivers

2 years agoMerge branch 'jc/reffiles-tests'
Junio C Hamano [Fri, 2 Feb 2024 19:31:50 +0000 (11:31 -0800)]
Merge branch 'jc/reffiles-tests'

Tests on ref API are moved around to prepare for reftable.

* jc/reffiles-tests:
  t5312: move reffiles specific tests to t0601
  t4202: move reffiles specific tests to t0600
  t3903: make drop stash test ref backend agnostic
  t1503: move reffiles specific tests to t0600
  t1415: move reffiles specific tests to t0601
  t1410: move reffiles specific tests to t0600
  t1406: move reffiles specific tests to t0600
  t1405: move reffiles specific tests to t0601
  t1404: move reffiles specific tests to t0600
  t1414: convert test to use Git commands instead of writing refs manually
  remove REFFILES prerequisite for some tests in t1405 and t2017
  t3210: move to t0601

2 years agoMerge branch 'pb/complete-log-more'
Junio C Hamano [Fri, 2 Feb 2024 19:31:50 +0000 (11:31 -0800)]
Merge branch 'pb/complete-log-more'

The completion script (in contrib/) learned more options that can
be used with "git log".

* pb/complete-log-more:
  completion: complete missing 'git log' options
  completion: complete --encoding
  completion: complete --patch-with-raw
  completion: complete missing rev-list options

2 years agosparse-index: pass string length to index_file_exists()
Jeff Hostetler [Fri, 2 Feb 2024 18:04:54 +0000 (18:04 +0000)]
sparse-index: pass string length to index_file_exists()

The call to index_file_exists() in the loop in expand_to_path() passes
the wrong string length.  Let's fix that.

The loop in expand_to_path() searches the name-hash for each
sub-directory prefix in the provided pathname. That is, by searching
for "dir1/" then "dir1/dir2/" then "dir1/dir2/dir3/" and so on until
it finds a cache-entry representing a sparse directory.

The code creates "strbuf path_mutable" to contain the working pathname
and modifies the buffer in-place by temporarily replacing the character
following each successive "/" with NUL for the duration of the call to
index_file_exists().

It does not update the strbuf.len during this substitution.

Pass the patched length of the prefix path instead.

Signed-off-by: Jeff Hostetler <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoimap-send: add missing "strbuf.h" include under NO_CURL
Philippe Blain [Fri, 2 Feb 2024 00:18:33 +0000 (00:18 +0000)]
imap-send: add missing "strbuf.h" include under NO_CURL

Building with NO_CURL is currently broken since imap-send.c uses things
defined in "strbuf.h" wihtout including it.

The inclusion of that header was removed in eea0e59ffb (treewide: remove
unnecessary includes in source files, 2023-12-23), which failed to
notice that "strbuf.h" was transitively included in imap-send.c via
"http.h", but only if USE_CURL_FOR_IMAP_SEND is defined. Add back the
missing include. Note that it was explicitely added in 3307f7dde2
(imap-send: include strbuf.h, 2023-05-17) after a similar breakage in
ba3d1c73da (treewide: remove unnecessary cache.h includes, 2023-02-24) -
see the thread starting at [1].

It can be verified by inspection that this is the only case where a
header we include is dependent on a Makefile knob in the files modified
in eea0e59ffb.

[1] https://lore.kernel.org/git/20230517070632.71884-1-list@eworm.de/

Signed-off-by: Philippe Blain <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoreftable: document reading and writing indices
Patrick Steinhardt [Thu, 1 Feb 2024 07:52:12 +0000 (08:52 +0100)]
reftable: document reading and writing indices

The way the index gets written and read is not trivial at all and
requires the reader to piece together a bunch of parts to figure out how
it works. Add some documentation to hopefully make this easier to
understand for the next reader.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoreftable/writer: fix writing multi-level indices
Patrick Steinhardt [Thu, 1 Feb 2024 07:52:08 +0000 (08:52 +0100)]
reftable/writer: fix writing multi-level indices

When finishing a section we will potentially write an index that makes
it more efficient to look up relevant blocks. The index records written
will encode, for each block of the indexed section, what the offset of
that block is as well as the last key of that block. Thus, the reader
would iterate through the index records to find the first key larger or
equal to the wanted key and then use the encoded offset to look up the
desired block.

When there are a lot of blocks to index though we may end up writing
multiple index blocks, too. To not require a linear search across all
index blocks we instead end up writing a multi-level index. Instead of
referring to the block we are after, an index record may point to
another index block. The reader will then access the highest-level index
and follow down the chain of index blocks until it hits the sought-after
block.

It has been observed though that it is impossible to seek ref records of
the last ref block when using a multi-level index. While the multi-level
index exists and looks fine for most of the part, the highest-level
index was missing an index record pointing to the last block of the next
index. Thus, every additional level made more refs become unseekable at
the end of the ref section.

The root cause is that we are not flushing the last block of the current
level once done writing the level. Consequently, it wasn't recorded in
the blocks that need to be indexed by the next-higher level and thus we
forgot about it.

Fix this bug by flushing blocks after we have written all index records.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoreftable/writer: simplify writing index records
Patrick Steinhardt [Thu, 1 Feb 2024 07:52:04 +0000 (08:52 +0100)]
reftable/writer: simplify writing index records

When finishing the current section some index records might be written
for the section to the table. The logic that adds these records to the
writer duplicates what we already have in `writer_add_record()`, making
this more complicated than it really has to be.

Simplify the code by using `writer_add_record()` instead. While at it,
drop the unneeded braces around a loop to make the code conform to our
code style better.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoreftable/writer: use correct type to iterate through index entries
Patrick Steinhardt [Thu, 1 Feb 2024 07:52:00 +0000 (08:52 +0100)]
reftable/writer: use correct type to iterate through index entries

The reftable writer is tracking the number of blocks it has to index via
the `index_len` variable. But while this variable is of type `size_t`,
some sites use an `int` to loop through the index entries.

Convert the code to consistently use `size_t`.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoreftable/reader: be more careful about errors in indexed seeks
Patrick Steinhardt [Thu, 1 Feb 2024 07:51:56 +0000 (08:51 +0100)]
reftable/reader: be more careful about errors in indexed seeks

When doing an indexed seek we first need to do a linear seek in order to
find the index block for our wanted key. We do not check the returned
error of the linear seek though. This is likely not an issue because the
next call to `table_iter_next()` would return error, too. But it very
much is a code smell when an error variable is being assigned to without
actually checking it.

Safeguard the code by checking for errors.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoindex-pack: --fsck-objects to take an optional argument for fsck msgs
John Cai [Thu, 1 Feb 2024 01:38:02 +0000 (01:38 +0000)]
index-pack: --fsck-objects to take an optional argument for fsck msgs

git-index-pack has a --strict option that can take an optional argument
to provide a list of fsck issues to change their severity.
--fsck-objects does not have such a utility, which would be useful if
one would like to be more lenient or strict on data integrity in a
repository.

Like --strict, allow --fsck-objects to also take a list of fsck msgs to
change the severity.

Remove the "For internal use only" note for --fsck-objects, and document
the option. This won't often be used by the normal end user, but it
turns out it is useful for Git forges like GitLab.

Reviewed-by: Christian Couder <redacted>
Signed-off-by: John Cai <redacted>
Signed-off-by: Junio C Hamano <redacted>
2 years agoindex-pack: test and document --strict=<msg-id>=<severity>...
John Cai [Thu, 1 Feb 2024 01:38:01 +0000 (01:38 +0000)]
index-pack: test and document --strict=<msg-id>=<severity>...

5d477a334a (fsck (receive-pack): allow demoting errors to warnings,
2015-06-22) allowed a list of fsck msg to downgrade to be passed to
--strict. However this is a hidden argument that was not documented nor
tested. Though it is true that most users would not call this option
directly, (nor use index-pack for that matter) it is still useful to
document and test this feature.

Reviewed-by: Christian Couder <redacted>
Signed-off-by: John Cai <redacted>
Signed-off-by: Junio C Hamano <redacted>
git clone https://git.99rst.org/PROJECT