]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
17 months agoMerge branch 'jc/t0017-clarify-bogus-expectation'
Junio C Hamano [Tue, 28 May 2024 18:17:09 +0000 (11:17 -0700)] 
Merge branch 'jc/t0017-clarify-bogus-expectation'

Test clean-up.

* jc/t0017-clarify-bogus-expectation:
  t0017: clarify dubious test set-up

17 months agoMerge branch 'ds/send-email-per-message-block'
Junio C Hamano [Tue, 28 May 2024 18:17:09 +0000 (11:17 -0700)] 
Merge branch 'ds/send-email-per-message-block'

Preliminary code clean-up for "git send-email".

* ds/send-email-per-message-block:
  send-email: move newline characters out of a few translatable strings

17 months agoMerge branch 'ps/complete-config-w-subcommands'
Junio C Hamano [Tue, 28 May 2024 18:17:08 +0000 (11:17 -0700)] 
Merge branch 'ps/complete-config-w-subcommands'

The command line completion script (in contrib/) has been adjusted
to the recent update to "git config" that adopted subcommand based
UI.

* ps/complete-config-w-subcommands:
  completion: adapt git-config(1) to complete subcommands

17 months agoMerge branch 'jc/doc-diff-name-only'
Junio C Hamano [Tue, 28 May 2024 18:17:08 +0000 (11:17 -0700)] 
Merge branch 'jc/doc-diff-name-only'

The documentation for "git diff --name-only" has been clarified
that it is about showing the names in the post-image tree.

* jc/doc-diff-name-only:
  diff: document what --name-only shows

17 months agoMerge branch 'tb/pack-bitmap-write-cleanups'
Junio C Hamano [Tue, 28 May 2024 18:17:07 +0000 (11:17 -0700)] 
Merge branch 'tb/pack-bitmap-write-cleanups'

The pack bitmap code saw some clean-up to prepare for a follow-up topic.

* tb/pack-bitmap-write-cleanups:
  pack-bitmap: introduce `bitmap_writer_free()`
  pack-bitmap-write.c: avoid uninitialized 'write_as' field
  pack-bitmap: drop unused `max_bitmaps` parameter
  pack-bitmap: avoid use of static `bitmap_writer`
  pack-bitmap-write.c: move commit_positions into commit_pos fields
  object.h: add flags allocated by pack-bitmap.h

17 months agoMerge branch 'ps/builtin-config-cleanup'
Junio C Hamano [Tue, 28 May 2024 18:17:07 +0000 (11:17 -0700)] 
Merge branch 'ps/builtin-config-cleanup'

Code clean-up to reduce inter-function communication inside
builtin/config.c done via the use of global variables.

* ps/builtin-config-cleanup: (21 commits)
  builtin/config: pass data between callbacks via local variables
  builtin/config: convert flags to a local variable
  builtin/config: track "fixed value" option via flags only
  builtin/config: convert `key` to a local variable
  builtin/config: convert `key_regexp` to a local variable
  builtin/config: convert `regexp` to a local variable
  builtin/config: convert `value_pattern` to a local variable
  builtin/config: convert `do_not_match` to a local variable
  builtin/config: move `respect_includes_opt` into location options
  builtin/config: move default value into display options
  builtin/config: move type options into display options
  builtin/config: move display options into local variables
  builtin/config: move location options into local variables
  builtin/config: refactor functions to have common exit paths
  config: make the config source const
  builtin/config: check for writeability after source is set up
  builtin/config: move actions into `cmd_config_actions()`
  builtin/config: move legacy options into `cmd_config()`
  builtin/config: move subcommand options into `cmd_config()`
  builtin/config: move legacy mode into its own function
  ...

17 months agoMerge branch 'ps/pseudo-ref-terminology'
Junio C Hamano [Tue, 28 May 2024 18:17:06 +0000 (11:17 -0700)] 
Merge branch 'ps/pseudo-ref-terminology'

Terminology to call various ref-like things are getting
straightened out.

* ps/pseudo-ref-terminology:
  refs: refuse to write pseudorefs
  ref-filter: properly distinuish pseudo and root refs
  refs: pseudorefs are no refs
  refs: classify HEAD as a root ref
  refs: do not check ref existence in `is_root_ref()`
  refs: rename `is_special_ref()` to `is_pseudo_ref()`
  refs: rename `is_pseudoref()` to `is_root_ref()`
  Documentation/glossary: define root refs as refs
  Documentation/glossary: clarify limitations of pseudorefs
  Documentation/glossary: redefine pseudorefs as special refs

17 months agoMerge branch 'kn/patch-iteration-doc'
Junio C Hamano [Tue, 28 May 2024 18:17:06 +0000 (11:17 -0700)] 
Merge branch 'kn/patch-iteration-doc'

Doc updates.

* kn/patch-iteration-doc:
  SubmittingPatches: add section for iterating patches

17 months agoMerge branch 'mt/t0211-typofix'
Junio C Hamano [Tue, 28 May 2024 18:17:05 +0000 (11:17 -0700)] 
Merge branch 'mt/t0211-typofix'

Test fix.

* mt/t0211-typofix:
  t/t0211-trace2-perf.sh: fix typo patern -> pattern

17 months agoMerge branch 'jc/doc-manpages-l10n'
Junio C Hamano [Tue, 28 May 2024 18:17:05 +0000 (11:17 -0700)] 
Merge branch 'jc/doc-manpages-l10n'

The SubmittingPatches document now refers folks to manpages
translation project.

* jc/doc-manpages-l10n:
  SubmittingPatches: advertise git-manpages-l10n project a bit

17 months agoThe seventh batch
Junio C Hamano [Thu, 23 May 2024 18:01:49 +0000 (11:01 -0700)] 
The seventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agoMerge branch 'mt/openindiana-portability'
Junio C Hamano [Thu, 23 May 2024 18:04:29 +0000 (11:04 -0700)] 
Merge branch 'mt/openindiana-portability'

Portability updates to various uses of grep and sed.

* mt/openindiana-portability:
  t/t9001-send-email.sh: sed - remove the i flag for s
  t/t9118-git-svn-funky-branch-names.sh: sed needs semicolon
  t/t1700-split-index.sh: mv -v is not portable
  t/t4202-log.sh: fix misspelled variable
  t/t0600-reffiles-backend.sh: rm -v is not portable
  t/t9902-completion.sh: backslashes in echo
  Switch grep from non-portable BRE to portable ERE

17 months agoMerge branch 'dg/fetch-pack-code-cleanup'
Junio C Hamano [Thu, 23 May 2024 18:04:28 +0000 (11:04 -0700)] 
Merge branch 'dg/fetch-pack-code-cleanup'

Code clean-up to remove an unused struct definition.

* dg/fetch-pack-code-cleanup:
  fetch-pack: remove unused 'struct loose_object_iter'

17 months agoMerge branch 'dm/update-index-doc-fix'
Junio C Hamano [Thu, 23 May 2024 18:04:28 +0000 (11:04 -0700)] 
Merge branch 'dm/update-index-doc-fix'

Doc fix.

* dm/update-index-doc-fix:
  documentation: git-update-index: add --show-index-version to synopsis

17 months agoMerge branch 'jc/patch-flow-updates'
Junio C Hamano [Thu, 23 May 2024 18:04:27 +0000 (11:04 -0700)] 
Merge branch 'jc/patch-flow-updates'

Doc updates.

* jc/patch-flow-updates:
  SubmittingPatches: extend the "flow" section
  SubmittingPatches: move the patch-flow section earlier

17 months agoMerge branch 'it/refs-name-conflict'
Junio C Hamano [Thu, 23 May 2024 18:04:27 +0000 (11:04 -0700)] 
Merge branch 'it/refs-name-conflict'

Expose "name conflict" error when a ref creation fails due to D/F
conflict in the ref namespace, to improve an error message given by
"git fetch".

* it/refs-name-conflict:
  refs: return conflict error when checking packed refs

17 months agoMerge branch 'la/hide-trailer-info'
Junio C Hamano [Thu, 23 May 2024 18:04:26 +0000 (11:04 -0700)] 
Merge branch 'la/hide-trailer-info'

The trailer API has been reshuffled a bit.

* la/hide-trailer-info:
  trailer unit tests: inspect iterator contents
  trailer: document parse_trailers() usage
  trailer: retire trailer_info_get() from API
  trailer: make trailer_info struct private
  trailer: make parse_trailers() return trailer_info pointer
  interpret-trailers: access trailer_info with new helpers
  sequencer: use the trailer iterator
  trailer: teach iterator about non-trailer lines
  trailer: add unit tests for trailer iterator
  Makefile: sort UNIT_TEST_PROGRAMS

17 months agoThe sixth batch
Junio C Hamano [Mon, 20 May 2024 17:48:30 +0000 (10:48 -0700)] 
The sixth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agoMerge branch 'jc/compat-regex-calloc-fix'
Junio C Hamano [Mon, 20 May 2024 18:20:04 +0000 (11:20 -0700)] 
Merge branch 'jc/compat-regex-calloc-fix'

Windows CI running in GitHub Actions started complaining about the
order of arguments given to calloc(); the imported regex code uses
the wrong order almost consistently, which has been corrected.

* jc/compat-regex-calloc-fix:
  compat/regex: fix argument order to calloc(3)

17 months agoMerge branch 'kn/ref-transaction-symref'
Junio C Hamano [Mon, 20 May 2024 18:20:04 +0000 (11:20 -0700)] 
Merge branch 'kn/ref-transaction-symref'

Updates to symbolic refs can now be made as a part of ref
transaction.

* kn/ref-transaction-symref:
  refs: remove `create_symref` and associated dead code
  refs: rename `refs_create_symref()` to `refs_update_symref()`
  refs: use transaction in `refs_create_symref()`
  refs: add support for transactional symref updates
  refs: move `original_update_refname` to 'refs.c'
  refs: support symrefs in 'reference-transaction' hook
  files-backend: extract out `create_symref_lock()`
  refs: accept symref values in `ref_transaction_update()`

17 months agot/t9001-send-email.sh: sed - remove the i flag for s
Marcel Telka [Fri, 17 May 2024 16:57:46 +0000 (18:57 +0200)] 
t/t9001-send-email.sh: sed - remove the i flag for s

The 'i' flag for the 's' command of sed is not specified by POSIX so
it is not portable.  Replace its usage by different and portable
syntax.

Signed-off-by: Marcel Telka <marcel@telka.sk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agot/t9118-git-svn-funky-branch-names.sh: sed needs semicolon
Marcel Telka [Fri, 17 May 2024 15:39:28 +0000 (17:39 +0200)] 
t/t9118-git-svn-funky-branch-names.sh: sed needs semicolon

POSIX specifies that all editing commands between braces shall be
terminated by a <newline> or <semicolon>.

Signed-off-by: Marcel Telka <marcel@telka.sk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agot/t1700-split-index.sh: mv -v is not portable
Marcel Telka [Fri, 17 May 2024 15:27:41 +0000 (17:27 +0200)] 
t/t1700-split-index.sh: mv -v is not portable

The -v option for mv is not specified by POSIX.  The illumos
implementation of mv does not support -v.  Since we do not need the
verbose mv output we just drop -v for mv.

Signed-off-by: Marcel Telka <marcel@telka.sk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agot/t4202-log.sh: fix misspelled variable
Marcel Telka [Fri, 17 May 2024 13:40:00 +0000 (15:40 +0200)] 
t/t4202-log.sh: fix misspelled variable

The GPGSSH_GOOD_SIGNATURE_TRUSTED variable was spelled as
GOOD_SIGNATURE_TRUSTED and so the grep was used the null RE that
matches everything.

Signed-off-by: Marcel Telka <marcel@telka.sk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agot/t0600-reffiles-backend.sh: rm -v is not portable
Marcel Telka [Fri, 17 May 2024 13:19:00 +0000 (15:19 +0200)] 
t/t0600-reffiles-backend.sh: rm -v is not portable

The -v option for rm is not specified by POSIX.  The illumos
implementation of rm does not support -v.  Since we do not need the
verbose rm output we just drop -v for rm.

Signed-off-by: Marcel Telka <marcel@telka.sk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agot/t9902-completion.sh: backslashes in echo
Marcel Telka [Fri, 17 May 2024 14:08:45 +0000 (16:08 +0200)] 
t/t9902-completion.sh: backslashes in echo

The usage of backslashes in echo is not portable.  Since some tests
tries to output strings containing '\b' it is safer to use printf
here.  The usage of printf instead of echo is also preferred by POSIX.

Signed-off-by: Marcel Telka <marcel@telka.sk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agoSwitch grep from non-portable BRE to portable ERE
Marcel Telka [Fri, 17 May 2024 19:01:49 +0000 (21:01 +0200)] 
Switch grep from non-portable BRE to portable ERE

This makes the grep usage fully POSIX compliant.  The ability to
enable ERE features in BRE using backslash is a GNU extension.

Signed-off-by: Marcel Telka <marcel@telka.sk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agodiff: document what --name-only shows
Junio C Hamano [Fri, 17 May 2024 17:14:46 +0000 (10:14 -0700)] 
diff: document what --name-only shows

The "--name-only" option is about showing the name of each file in
the post-image tree that got changed and nothing else (like "was it
created?").  Unlike the "--name-status" option that tells how the
change happened (e.g., renamed with similarity), it does not give
anything else, like the name of the corresponding file in the old
tree.

For example, if you start from a clean checkout that has a file
whose name is COPYING, here is what you would see:

    $ git mv COPYING RENAMING
    $ git diff -M --name-only HEAD
    RENAMING
    $ git diff -M --name-status HEAD
    R100 COPYING RENAMING

Lack of the description of this fact has confused readers in the
past.  Even back when dda2d79a ([PATCH] Clean up diff option
descriptions., 2005-07-13) documented "--name-only", "git diff"
already supported the renames, so in a sense, from day one, this
should have been documented more clearly but it wasn't.

Belatedly clarify it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agoSubmittingPatches: advertise git-manpages-l10n project a bit
Junio C Hamano [Thu, 9 May 2024 17:32:09 +0000 (10:32 -0700)] 
SubmittingPatches: advertise git-manpages-l10n project a bit

The project takes our AsciiDoc sources of documentation and actively
maintains the translations to various languages.

Let's give them enhanced visibility to help those who want to
volunteer find them.

Acked-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agoSubmittingPatches: add section for iterating patches
Karthik Nayak [Fri, 17 May 2024 12:27:24 +0000 (14:27 +0200)] 
SubmittingPatches: add section for iterating patches

Add a section to explain how to work around other in-flight patches and
how to navigate conflicts which arise as a series is being iterated.
This provides the necessary steps that users can follow to reduce
friction with other ongoing topics and also provides guidelines on how
the users can also communicate this to the list efficiently.

Co-authored-by: Junio C Hamano <gitster@pobox.com>
Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agoMerge branch 'jc/patch-flow-updates' into kn/patch-iteration-doc
Junio C Hamano [Fri, 17 May 2024 17:31:38 +0000 (10:31 -0700)] 
Merge branch 'jc/patch-flow-updates' into kn/patch-iteration-doc

* jc/patch-flow-updates:
  SubmittingPatches: extend the "flow" section
  SubmittingPatches: move the patch-flow section earlier

17 months agocompletion: adapt git-config(1) to complete subcommands
Patrick Steinhardt [Fri, 17 May 2024 06:13:36 +0000 (08:13 +0200)] 
completion: adapt git-config(1) to complete subcommands

With fe3ccc7aab (Merge branch 'ps/config-subcommands', 2024-05-15),
git-config(1) has gained support for subcommands. These subcommands live
next to the old, action-based mode, so that both the old and new way
continue to work.

The manpage for this command has been updated to prominently show the
subcommands, and the action-based modes are marked as deprecated. Update
Bash completion scripts accordingly to advertise subcommands instead of
actions.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agot0017: clarify dubious test set-up
Junio C Hamano [Wed, 15 May 2024 19:32:42 +0000 (12:32 -0700)] 
t0017: clarify dubious test set-up

1ff750b1 (tests: make GIT_TEST_GETTEXT_POISON a boolean, 2019-06-21)
added this test, in which "test-tool -C" is fed a name of a
directory that does not exist, and expects that it dies because of a
failure to read the configuration file(s), because the configuration
setting is screwed up to contain mutual inclusion loop, before it
notices that the directory to chdir into does not exist and dies.

It is of dubious value to etch the current order of events, i.e.,
the configuration needs to be read that early (for initializing
trace2 subsystem) before we even notice the lack of the directory
and have a chance to fail, into stone.  Indeed, if you completely
compile out trace2 subsystem so that it does not even attempt to
read the configuration that early, we would die with a different
error message (i.e. "unable to chdir to 'cycle'") and this test will
fail.

At least give a bogus argument to "test-tool -C" a name that is
clearly bogus to make sure we can more easily see what is going on
with plenty of comments.

We may want to remove this test altogether, instead, though.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agoThe fifth batch
Junio C Hamano [Thu, 16 May 2024 17:11:24 +0000 (10:11 -0700)] 
The fifth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agoMerge branch 'ps/refs-without-the-repository'
Junio C Hamano [Thu, 16 May 2024 17:10:13 +0000 (10:10 -0700)] 
Merge branch 'ps/refs-without-the-repository'

The refs API lost functions that implicitly assumes to work on the
primary ref_store by forcing the callers to pass a ref_store as an
argument.

* ps/refs-without-the-repository:
  refs: remove functions without ref store
  cocci: apply rules to rewrite callers of "refs" interfaces
  cocci: introduce rules to transform "refs" to pass ref store
  refs: add `exclude_patterns` parameter to `for_each_fullref_in()`
  refs: introduce missing functions that accept a `struct ref_store`

17 months agoMerge branch 'jl/git-no-advice'
Junio C Hamano [Thu, 16 May 2024 17:10:13 +0000 (10:10 -0700)] 
Merge branch 'jl/git-no-advice'

A new global "--no-advice" option can be used to disable all advice
messages, which is meant to be used only in scripts.

* jl/git-no-advice:
  t0018: two small fixes
  advice: add --no-advice global option
  doc: add spacing around paginate options
  doc: clean up usage documentation for --no-* opts

17 months agoMerge branch 'rs/external-diff-with-exit-code'
Junio C Hamano [Thu, 16 May 2024 17:09:23 +0000 (10:09 -0700)] 
Merge branch 'rs/external-diff-with-exit-code'

* rs/external-diff-with-exit-code:
  Revert "diff: fix --exit-code with external diff"

17 months agoRevert "diff: fix --exit-code with external diff"
Junio C Hamano [Thu, 16 May 2024 17:08:35 +0000 (10:08 -0700)] 
Revert "diff: fix --exit-code with external diff"

This reverts commit 11be65cfa43416219e85384a3a80d672b65b76ba, per
original author's request to come up with a better strategy.

17 months agot/t0211-trace2-perf.sh: fix typo patern -> pattern
Marcel Telka [Thu, 16 May 2024 07:45:06 +0000 (09:45 +0200)] 
t/t0211-trace2-perf.sh: fix typo patern -> pattern

The bug went unnoticed because grep with null RE matches everything.

Signed-off-by: Marcel Telka <marcel@telka.sk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agoThe fourth batch
Junio C Hamano [Wed, 15 May 2024 16:07:20 +0000 (09:07 -0700)] 
The fourth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agoMerge branch 'ds/scalar-reconfigure-all-fix'
Junio C Hamano [Wed, 15 May 2024 16:52:55 +0000 (09:52 -0700)] 
Merge branch 'ds/scalar-reconfigure-all-fix'

Scalar fix.

* ds/scalar-reconfigure-all-fix:
  scalar: avoid segfault in reconfigure --all

17 months agoMerge branch 'vd/doc-merge-tree-x-option'
Junio C Hamano [Wed, 15 May 2024 16:52:54 +0000 (09:52 -0700)] 
Merge branch 'vd/doc-merge-tree-x-option'

Doc update.

* vd/doc-merge-tree-x-option:
  Documentation/git-merge-tree.txt: document -X

17 months agoMerge branch 'rs/external-diff-with-exit-code'
Junio C Hamano [Wed, 15 May 2024 16:52:54 +0000 (09:52 -0700)] 
Merge branch 'rs/external-diff-with-exit-code'

The "--exit-code" option of "git diff" command learned to work with
the "--ext-diff" option.

* rs/external-diff-with-exit-code:
  diff: fix --exit-code with external diff
  diff: report unmerged paths as changes in run_diff_cmd()

17 months agoMerge branch 'jt/port-ci-whitespace-check-to-gitlab'
Junio C Hamano [Wed, 15 May 2024 16:52:54 +0000 (09:52 -0700)] 
Merge branch 'jt/port-ci-whitespace-check-to-gitlab'

The "whitespace check" task that was enabled for GitHub Actions CI
has been ported to GitLab CI.

* jt/port-ci-whitespace-check-to-gitlab:
  gitlab-ci: add whitespace error check
  ci: make the whitespace report optional
  ci: separate whitespace check script
  github-ci: fix link to whitespace error
  ci: pre-collapse GitLab CI sections

17 months agoMerge branch 'ow/refspec-glossary-update'
Junio C Hamano [Wed, 15 May 2024 16:52:53 +0000 (09:52 -0700)] 
Merge branch 'ow/refspec-glossary-update'

Doc update.

* ow/refspec-glossary-update:
  Documentation: Mention that refspecs are explained elsewhere

17 months agoMerge branch 'jp/tag-trailer'
Junio C Hamano [Wed, 15 May 2024 16:52:53 +0000 (09:52 -0700)] 
Merge branch 'jp/tag-trailer'

"git tag" learned the "--trailer" option to futz with the trailers
in the same way as "git commit" does.

* jp/tag-trailer:
  builtin/tag: add --trailer option
  builtin/commit: refactor --trailer logic
  builtin/commit: use ARGV macro to collect trailers

17 months agoMerge branch 'ps/config-subcommands'
Junio C Hamano [Wed, 15 May 2024 16:52:52 +0000 (09:52 -0700)] 
Merge branch 'ps/config-subcommands'

The operation mode options (like "--get") the "git config" command
uses have been deprecated and replaced with subcommands (like "git
config get").

* ps/config-subcommands:
  builtin/config: display subcommand help
  builtin/config: introduce "edit" subcommand
  builtin/config: introduce "remove-section" subcommand
  builtin/config: introduce "rename-section" subcommand
  builtin/config: introduce "unset" subcommand
  builtin/config: introduce "set" subcommand
  builtin/config: introduce "get" subcommand
  builtin/config: introduce "list" subcommand
  builtin/config: pull out function to handle `--null`
  builtin/config: pull out function to handle config location
  builtin/config: use `OPT_CMDMODE()` to specify modes
  builtin/config: move "fixed-value" option to correct group
  builtin/config: move option array around
  config: clarify memory ownership when preparing comment strings

17 months agoMerge branch 'js/unit-test-suite-runner'
Junio C Hamano [Wed, 15 May 2024 16:52:52 +0000 (09:52 -0700)] 
Merge branch 'js/unit-test-suite-runner'

The "test-tool" has been taught to run testsuite tests in parallel,
bypassing the need to use the "prove" tool.

* js/unit-test-suite-runner:
  cmake: let `test-tool` run the unit tests, too
  ci: use test-tool as unit test runner on Windows
  t/Makefile: run unit tests alongside shell tests
  unit tests: add rule for running with test-tool
  test-tool run-command testsuite: support unit tests
  test-tool run-command testsuite: remove hardcoded filter
  test-tool run-command testsuite: get shell from env
  t0080: turn t-basic unit test into a helper

17 months agorefs: refuse to write pseudorefs
Patrick Steinhardt [Wed, 15 May 2024 06:51:10 +0000 (08:51 +0200)] 
refs: refuse to write pseudorefs

Pseudorefs are not stored in the ref database as by definition, they
carry additional metadata that essentially makes them not a ref. As
such, writing pseudorefs via the ref backend does not make any sense
whatsoever as the ref backend wouldn't know how exactly to store the
data.

Restrict writing pseudorefs via the ref backend.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agoref-filter: properly distinuish pseudo and root refs
Patrick Steinhardt [Wed, 15 May 2024 06:51:05 +0000 (08:51 +0200)] 
ref-filter: properly distinuish pseudo and root refs

The ref-filter interfaces currently define root refs as either a
detached HEAD or a pseudo ref. Pseudo refs aren't root refs though, so
let's properly distinguish those ref types.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agorefs: pseudorefs are no refs
Patrick Steinhardt [Wed, 15 May 2024 06:51:01 +0000 (08:51 +0200)] 
refs: pseudorefs are no refs

The `is_root_ref()` function will happily clarify a pseudoref as a root
ref, even though pseudorefs are no refs. Next to being wrong, it also
leads to inconsistent behaviour across ref backends: while the "files"
backend accidentally knows to parse those pseudorefs and thus yields
them to the caller, the "reftable" backend won't ever see the pseudoref
at all because they are never stored in the "reftable" backend.

Fix this issue by filtering out pseudorefs in `is_root_ref()`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agorefs: classify HEAD as a root ref
Patrick Steinhardt [Wed, 15 May 2024 06:50:56 +0000 (08:50 +0200)] 
refs: classify HEAD as a root ref

Root refs are those refs that live in the root of the ref hierarchy.
Our old and venerable "HEAD" reference falls into this category, but we
don't yet classify it as such in `is_root_ref()`.

Adapt the function to also treat "HEAD" as a root ref. This change is
safe to do for all current callers:

  - `ref_kind_from_refname()` already handles "HEAD" explicitly before
    calling `is_root_ref()`.

  - The "files" and "reftable" backends explicitly call both
    `is_root_ref()` and `is_headref()` together.

This also aligns behaviour or `is_root_ref()` and `is_headref()` such
that we stop checking for ref existence. This changes semantics for our
backends:

  - In the reftable backend we already know that the ref must exist
    because `is_headref()` is called as part of the ref iterator. The
    existence check is thus redundant, and the change is safe to do.

  - In the files backend we use it when populating root refs, where we
    would skip adding the "HEAD" file if it was not possible to resolve
    it. The new behaviour is to instead mark "HEAD" as broken, which
    will cause us to emit warnings in various places.

As there are no callers of `is_headref()` left afer the refactoring, we
can absorb it completely into `is_root_ref()`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agorefs: do not check ref existence in `is_root_ref()`
Patrick Steinhardt [Wed, 15 May 2024 06:50:51 +0000 (08:50 +0200)] 
refs: do not check ref existence in `is_root_ref()`

Before this patch series, root refs except for "HEAD" and our special
refs were classified as pseudorefs. Furthermore, our terminology
clarified that pseudorefs must not be symbolic refs. This restriction
is enforced in `is_root_ref()`, which explicitly checks that a supposed
root ref resolves to an object ID without recursing.

This has been extremely confusing right from the start because (in old
terminology) a ref name may sometimes be a pseudoref and sometimes not
depending on whether it is a symbolic or regular ref. This behaviour
does not seem reasonable at all and I very much doubt that it results in
anything sane.

Last but not least, the current behaviour can actually lead to a
segfault when calling `is_root_ref()` with a reference that either does
not exist or that is a symbolic ref because we never initialized `oid`,
but then read it via `is_null_oid()`.

We have now changed terminology to clarify that pseudorefs are really
only "MERGE_HEAD" and "FETCH_HEAD", whereas all the other refs that live
in the root of the ref hierarchy are just plain refs. Thus, we do not
need to check whether the ref is symbolic or not. In fact, we can now
avoid looking up the ref completely as the name is sufficient for us to
figure out whether something would be a root ref or not.

This change of course changes semantics for our callers. As there are
only three of them we can assess each of them individually:

  - "ref-filter.c:ref_kind_from_refname()" uses it to classify refs.
    It's clear that the intent is to classify based on the ref name,
    only.

  - "refs/reftable_backend.c:reftable_ref_iterator_advance()" uses it to
    filter root refs. Again, using existence checks is pointless here as
    the iterator has just surfaced the ref, so we know it does exist.

  - "refs/files_backend.c:add_pseudoref_and_head_entries()" uses it to
    determine whether it should add a ref to the root directory of its
    iterator. This had the effect that we skipped over any files that
    are either a symbolic ref, or which are not a ref at all.

    The new behaviour is to include symbolic refs know, which aligns us
    with the adapted terminology. Furthermore, files which look like
    root refs but aren't are now mark those as "broken". As broken refs
    are not surfaced by our tooling, this should not lead to a change in
    user-visible behaviour, but may cause us to emit warnings. This
    feels like the right thing to do as we would otherwise just silently
    ignore corrupted root refs completely.

So in all cases the existence check was either superfluous, not in line
with the adapted terminology or masked potential issues. This commit
thus changes the behaviour as proposed and drops the existence check
altogether.

Add a test that verifies that this does not change user-visible
behaviour. Namely, we still don't want to show broken refs to the user
by default in git-for-each-ref(1). What this does allow though is for
internal callers to surface dangling root refs when they pass in the
`DO_FOR_EACH_INCLUDE_BROKEN` flag.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agorefs: rename `is_special_ref()` to `is_pseudo_ref()`
Patrick Steinhardt [Wed, 15 May 2024 06:50:47 +0000 (08:50 +0200)] 
refs: rename `is_special_ref()` to `is_pseudo_ref()`

Rename `is_special_ref()` to `is_pseudo_ref()` to adapt to the newly
defined terminology in our gitglossary(7). Note that in the preceding
commit we have just renamed `is_pseudoref()` to `is_root_ref()`, where
there may be confusion for in-flight patch series that add new calls to
`is_pseudoref()`. In order to intentionally break such patch series we
have thus picked `is_pseudo_ref()` instead of `is_pseudoref()` as the
new name.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agorefs: rename `is_pseudoref()` to `is_root_ref()`
Patrick Steinhardt [Wed, 15 May 2024 06:50:42 +0000 (08:50 +0200)] 
refs: rename `is_pseudoref()` to `is_root_ref()`

Rename `is_pseudoref()` to `is_root_ref()` to adapt to the newly defined
terminology in our gitglossary(7).

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agoDocumentation/glossary: define root refs as refs
Patrick Steinhardt [Wed, 15 May 2024 06:50:37 +0000 (08:50 +0200)] 
Documentation/glossary: define root refs as refs

Except for the pseudorefs MERGE_HEAD and FETCH_HEAD, all refs that live
in the root of the ref hierarchy behave the exact same as normal refs.
They can be symbolic refs or direct refs and can be read, iterated over
and written via normal tooling. All of these refs are stored in the ref
backends, which further demonstrates that they are just normal refs.

Extend the definition of "ref" to also cover such root refs. The only
additional restriction for root refs is that they must conform to a
specific naming schema.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agoDocumentation/glossary: clarify limitations of pseudorefs
Patrick Steinhardt [Wed, 15 May 2024 06:50:33 +0000 (08:50 +0200)] 
Documentation/glossary: clarify limitations of pseudorefs

Clarify limitations that pseudorefs have:

  - They can be read via git-rev-parse(1) and similar tools.

  - They are not surfaced when iterating through refs, like when using
    git-for-each-ref(1). They are not refs, so iterating through refs
    should not surface them.

  - They cannot be written via git-update-ref(1) and related commands.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agoDocumentation/glossary: redefine pseudorefs as special refs
Patrick Steinhardt [Wed, 15 May 2024 06:50:28 +0000 (08:50 +0200)] 
Documentation/glossary: redefine pseudorefs as special refs

Nowadays, Git knows about three different kinds of refs. As defined in
gitglossary(7):

  - Regular refs that start with "refs/", like "refs/heads/main".

  - Pseudorefs, which live in the root directory. These must have
    all-caps names and must be a file that start with an object hash.
    Consequently, symbolic refs are not pseudorefs because they do not
    start with an object hash.

  - Special refs, of which we only have "FETCH_HEAD" and "MERGE_HEAD".

This state is extremely confusing, and I would claim that most folks
don't fully understand what is what here. The current definitions also
have several problems:

  - Where does "HEAD" fit in? It's not a pseudoref because it can be
    a symbolic ref. It's not a regular ref because it does not start
    with "refs/". And it's not a special ref, either.

  - There is a strong overlap between pseudorefs and special refs. The
    pseudoref section for example mentions "MERGE_HEAD", even though it
    is a special ref. Is it thus both a pseudoref and a special ref?

  - Why do we even need to distinguish refs that live in the root from
    other refs when they behave just like a regular ref anyway?

In other words, the current state is quite a mess and leads to wild
inconsistencies without much of a good reason.

The original reason why pseudorefs were introduced is that there are
some refs that sometimes behave like a ref, even though they aren't a
ref. And we really only have two of these nowadays, namely "MERGE_HEAD"
and "FETCH_HEAD". Those files are never written via the ref backends,
but are instead written by git-fetch(1), git-pull(1) and git-merge(1).
They contain additional metadata that highlights where a ref has been
fetched from or the list of commits that have been merged.

This original intent in fact matches the definition of special refs that
we have recently introduced in 8df4c5d205 (Documentation: add "special
refs" to the glossary, 2024-01-19). Due to the introduction of the new
reftable backend we were forced to distinguish those refs more clearly
such that we don't ever try to read or write them via the reftable
backend. In the same series, we also addressed all the other cases where
we used to write those special refs via the filesystem directly, thus
circumventing the ref backend, to instead write them via the backends.
Consequently, there are no other refs left anymore which are special.

Let's address this mess and return the pseudoref terminology back to its
original intent: a ref that sometimes behave like a ref, but which isn't
really a ref because it gets written to the filesystem directly. Or in
other words, let's redefine pseudorefs to match the current definition
of special refs. As special refs and pseudorefs are now the same per
definition, we can drop the "special refs" term again. It's not exposed
to our users and thus they wouldn't ever encounter that term anyway.

Refs that live in the root of the ref hierarchy but which are not
pseudorefs will be further defined in a subsequent commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agobuiltin/config: pass data between callbacks via local variables
Patrick Steinhardt [Wed, 15 May 2024 06:43:12 +0000 (08:43 +0200)] 
builtin/config: pass data between callbacks via local variables

We use several global variables to pass data between callers and
callbacks in `get_color()` and `get_colorbool()`. Convert those to use
callback data structures instead.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agobuiltin/config: convert flags to a local variable
Patrick Steinhardt [Wed, 15 May 2024 06:43:07 +0000 (08:43 +0200)] 
builtin/config: convert flags to a local variable

Both the `do_all` and `use_key_regexp` bits essentially act like flags
to `get_value()`. Let's convert them to actual flags so that we can get
rid of the last two remaining global variables that track options.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agobuiltin/config: track "fixed value" option via flags only
Patrick Steinhardt [Wed, 15 May 2024 06:43:02 +0000 (08:43 +0200)] 
builtin/config: track "fixed value" option via flags only

We track the "fixed value" option via two separate bits: once via the
global variable `fixed_value`, and once via the CONFIG_FLAGS_FIXED_VALUE
bit in `flags`. This is confusing and may easily lead to issues when one
is not aware that this is tracked via two separate mechanisms.

Refactor the code to use the flag exclusively. We already pass it to all
the required callsites anyway, except for `collect_config()`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agobuiltin/config: convert `key` to a local variable
Patrick Steinhardt [Wed, 15 May 2024 06:42:58 +0000 (08:42 +0200)] 
builtin/config: convert `key` to a local variable

The `key` variable is used by the `get_value()` function for two
purposes:

  - It is used to store the result of `git_config_parse_key()`, which is
    then passed on to `collect_config()`.

  - It is used as a store to convert the provided key to an
    all-lowercase key when `use_key_regexp` is set.

Neither of these cases warrant a global variable at all. In the former
case we can pass the key via `struct collect_config_data`. And in the
latter case we really only want to have it as a temporary local variable
such that we can free associated memory.

Refactor the code accordingly to reduce our reliance on global state.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agobuiltin/config: convert `key_regexp` to a local variable
Patrick Steinhardt [Wed, 15 May 2024 06:42:53 +0000 (08:42 +0200)] 
builtin/config: convert `key_regexp` to a local variable

The `key_regexp` variable is used by the `format_config()` callback when
`use_key_regexp` is set. It is only ever set up by its only caller,
`collect_config()` and can thus easily be moved into the
`collect_config_data` structure.

Do so to remove our reliance on global state.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agobuiltin/config: convert `regexp` to a local variable
Patrick Steinhardt [Wed, 15 May 2024 06:42:49 +0000 (08:42 +0200)] 
builtin/config: convert `regexp` to a local variable

The `regexp` variable is used by the `format_config()` callback when
`CONFIG_FLAGS_FIXED_VALUE` is not set. It is only ever set up by its
only caller, `collect_config()` and can thus easily be moved into the
`collect_config_data` structure.

Do so to remove our reliance on global state.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agobuiltin/config: convert `value_pattern` to a local variable
Patrick Steinhardt [Wed, 15 May 2024 06:42:44 +0000 (08:42 +0200)] 
builtin/config: convert `value_pattern` to a local variable

The `value_pattern` variable is used by the `format_config()` callback
when `CONFIG_FLAGS_FIXED_VALUE` is used. It is only ever set up by its
only caller, `collect_config()` and can thus easily be moved into the
`collect_config_data` structure.

Do so to remove our reliance on global state.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agobuiltin/config: convert `do_not_match` to a local variable
Patrick Steinhardt [Wed, 15 May 2024 06:42:39 +0000 (08:42 +0200)] 
builtin/config: convert `do_not_match` to a local variable

The `do_not_match` variable is used by the `format_config()` callback as
an indicator whether or not the passed regular expression is negated. It
is only ever set up by its only caller, `collect_config()` and can thus
easily be moved into the `collect_config_data` structure.

Do so to remove our reliance on global state.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agobuiltin/config: move `respect_includes_opt` into location options
Patrick Steinhardt [Wed, 15 May 2024 06:42:35 +0000 (08:42 +0200)] 
builtin/config: move `respect_includes_opt` into location options

The variable tracking whether or not we want to honor includes is
tracked via a global variable. Move it into the location options
instead.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agobuiltin/config: move default value into display options
Patrick Steinhardt [Wed, 15 May 2024 06:42:30 +0000 (08:42 +0200)] 
builtin/config: move default value into display options

The default value is tracked via a global variable. Move it into the
display options instead.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agobuiltin/config: move type options into display options
Patrick Steinhardt [Wed, 15 May 2024 06:42:25 +0000 (08:42 +0200)] 
builtin/config: move type options into display options

The type options are tracked via a global variable. Move it into the
display options instead.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agobuiltin/config: move display options into local variables
Patrick Steinhardt [Wed, 15 May 2024 06:42:21 +0000 (08:42 +0200)] 
builtin/config: move display options into local variables

The display options are tracked via a set of global variables. Move
them into a self-contained structure so that we can easily parse all
relevant options and hand them over to the various functions that
require them.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agobuiltin/config: move location options into local variables
Patrick Steinhardt [Wed, 15 May 2024 06:42:16 +0000 (08:42 +0200)] 
builtin/config: move location options into local variables

The location options are tracked via a set of global variables. Move
them into a self-contained structure so that we can easily parse all
relevant options and hand them over to the various functions that
require them.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agobuiltin/config: refactor functions to have common exit paths
Patrick Steinhardt [Wed, 15 May 2024 06:42:11 +0000 (08:42 +0200)] 
builtin/config: refactor functions to have common exit paths

Refactor functions to have a single exit path. This will make it easier
in subsequent commits to add common cleanup code.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agoconfig: make the config source const
Patrick Steinhardt [Wed, 15 May 2024 06:42:06 +0000 (08:42 +0200)] 
config: make the config source const

The `struct git_config_source` passed to `config_with_options()` is
never modified. Let's mark it as `const` to clarify.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agobuiltin/config: check for writeability after source is set up
Patrick Steinhardt [Wed, 15 May 2024 06:42:02 +0000 (08:42 +0200)] 
builtin/config: check for writeability after source is set up

The `check_write()` function verifies that we do not try to write to a
config source that cannot be written to, like for example stdin. But
while the new subcommands do call this function, they do so before
calling `handle_config_location()`. Consequently, we only end up
checking the default config location for writeability, not the location
that was actually specified by the caller of git-config(1).

Fix this by calling `check_write()` after `handle_config_location()`. We
will further clarify the relationship between those two functions in a
subsequent commit where we remove the global state that both implicitly
rely on.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agobuiltin/config: move actions into `cmd_config_actions()`
Patrick Steinhardt [Wed, 15 May 2024 06:41:57 +0000 (08:41 +0200)] 
builtin/config: move actions into `cmd_config_actions()`

We only use actions in the legacy mode. Convert them to an enum and move
them into `cmd_config_actions()` to clearly demonstrate that they are
not used anywhere else.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agobuiltin/config: move legacy options into `cmd_config()`
Patrick Steinhardt [Wed, 15 May 2024 06:41:52 +0000 (08:41 +0200)] 
builtin/config: move legacy options into `cmd_config()`

Move the legacy options as well some of the variables it references into
`cmd_config_action()`. This reduces our reliance on global state.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agobuiltin/config: move subcommand options into `cmd_config()`
Patrick Steinhardt [Wed, 15 May 2024 06:41:47 +0000 (08:41 +0200)] 
builtin/config: move subcommand options into `cmd_config()`

Move the subcommand options as well as the `subcommand` variable into
`cmd_config()`. This reduces our reliance on global state.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agobuiltin/config: move legacy mode into its own function
Patrick Steinhardt [Wed, 15 May 2024 06:41:43 +0000 (08:41 +0200)] 
builtin/config: move legacy mode into its own function

In `cmd_config()` we first try to parse the provided arguments as
subcommands and, if this is successful, call the respective functions
of that subcommand. Otherwise we continue with the "legacy" mode that
uses implicit actions and/or flags.

Disentangle this by moving the legacy mode into its own function. This
allows us to move the options into the respective functions and clearly
separates concerns.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agobuiltin/config: stop printing full usage on misuse
Patrick Steinhardt [Wed, 15 May 2024 06:41:38 +0000 (08:41 +0200)] 
builtin/config: stop printing full usage on misuse

When invoking git-config(1) with a wrong set of arguments we end up
calling `usage_builtin_config()` after printing an error message that
says what was wrong. As that function ends up printing the full list of
options, which is quite long, the actual error message will be buried by
a wall of text. This makes it really hard to figure out what exactly
caused the error.

Furthermore, now that we have recently introduced subcommands, the usage
information may actually be misleading as we unconditionally print
options of the subcommand-less mode.

Fix both of these issues by just not printing the options at all
anymore. Instead, we call `usage()` that makes us report in a single
line what has gone wrong. This should be way more discoverable for our
users and addresses the inconsistency.

Furthermore, this change allow us to inline the options into the
respective functions that use them to parse the command line.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agopack-bitmap: introduce `bitmap_writer_free()`
Taylor Blau [Tue, 14 May 2024 19:57:06 +0000 (15:57 -0400)] 
pack-bitmap: introduce `bitmap_writer_free()`

Now that there is clearer memory ownership around the bitmap_writer
structure, introduce a bitmap_writer_free() function that callers may
use to free any memory associated with their instance of the
bitmap_writer structure.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agopack-bitmap-write.c: avoid uninitialized 'write_as' field
Taylor Blau [Tue, 14 May 2024 19:57:03 +0000 (15:57 -0400)] 
pack-bitmap-write.c: avoid uninitialized 'write_as' field

Prepare to free() memory associated with bitmapped_commit structs by
zero'ing the 'write_as' field.

In ideal cases, it is fine to do something like:

    for (i = 0; i < writer->selected_nr; i++) {
        struct bitmapped_commit *bc = &writer->selected[i];
        if (bc->write_as != bc->bitmap)
            ewah_free(bc->write_as);
        ewah_free(bc->bitmap);
    }

but if not all of the 'write_as' fields were populated (e.g., because
the packing_data given does not form a reachability closure), then we
may attempt to free uninitialized memory.

Guard against this by preemptively zero'ing this field just in case.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agopack-bitmap: drop unused `max_bitmaps` parameter
Taylor Blau [Tue, 14 May 2024 19:57:00 +0000 (15:57 -0400)] 
pack-bitmap: drop unused `max_bitmaps` parameter

The `max_bitmaps` parameter in `bitmap_writer_select_commits()` was
introduced back in 7cc8f97108 (pack-objects: implement bitmap writing,
2013-12-21), making it original to the bitmap implementation in Git
itself.

When that patch was merged via 0f9e62e084 (Merge branch
'jk/pack-bitmap', 2014-02-27), its sole caller in builtin/pack-objects.c
passed a value of "-1" for `max_bitmaps`, indicating no limit.

Since then, the only other caller (in midx.c, added via c528e17966
(pack-bitmap: write multi-pack bitmaps, 2021-08-31)) also uses a value
of "-1" for `max_bitmaps`.

Since no callers have needed a finite limit for the `max_bitmaps`
parameter in the nearly decade that has passed since 0f9e62e084, let's
remove the parameter and any dead pieces of code connected to it.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agopack-bitmap: avoid use of static `bitmap_writer`
Taylor Blau [Tue, 14 May 2024 19:56:56 +0000 (15:56 -0400)] 
pack-bitmap: avoid use of static `bitmap_writer`

The pack-bitmap machinery uses a structure called 'bitmap_writer' to
collect the data necessary to write out .bitmap files. Since its
introduction in 7cc8f971085 (pack-objects: implement bitmap writing,
2013-12-21), there has been a single static bitmap_writer structure,
which is responsible for all bitmap writing-related operations.

In practice, this is OK, since we are only ever writing a single .bitmap
file in a single process (e.g., `git multi-pack-index write --bitmap`,
`git pack-objects --write-bitmap-index`, `git repack -b`, etc.).

However, having a single static variable makes issues like data
ownership unclear, when to free variables, what has/hasn't been
initialized unclear.

Refactor this code to be written in terms of a given bitmap_writer
structure instead of relying on a static global.

Note that this exposes the structure definition of the bitmap_writer at
the pack-bitmap.h level. We could work around this by, e.g., forcing
callers to declare their writers as:

    struct bitmap_writer *writer;
    bitmap_writer_init(&bitmap_writer);

and then declaring `bitmap_writer_init()` as taking in a double-pointer
like so:

    void bitmap_writer_init(struct bitmap_writer **writer);

which would avoid us having to expose the definition of the structure
itself. This patch takes a different approach, since future patches
(like for the ongoing pseudo-merge bitmaps work) will want to modify the
innards of this structure (in the previous example, via pseudo-merge.c).

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agopack-bitmap-write.c: move commit_positions into commit_pos fields
Taylor Blau [Tue, 14 May 2024 19:56:53 +0000 (15:56 -0400)] 
pack-bitmap-write.c: move commit_positions into commit_pos fields

In 7cc8f971085 (pack-objects: implement bitmap writing, 2013-12-21), the
bitmapped_commit struct was introduced, including the 'commit_pos'
field, which has been unused ever since its introduction more than a
decade ago.

Instead, we have used the nearby `commit_positions` array leaving the
bitmapped_commit struct with an unused 4-byte field.

We could drop the `commit_pos` field as unused, and continue to store
the values in the auxiliary array. But we could also drop the array and
store the data for each bitmapped_commit struct inside of the structure
itself, which is what this patch does.

In any spot that we previously read `commit_positions[i]`, we can now
instead read `writer.selected[i].commit_pos`. There are a few spots that
need changing as a result:

  - write_selected_commits_v1() is a simple transformation, since we're
    just reading the field. As a result, the function no longer needs an
    explicit argument to pass the commit_positions array.

  - write_lookup_table() also no longer needs the explicit
    commit_positions array passed in as an argument. But it still needs
    to sort an array of indices into the writer.selected array to read
    them in commit_pos order, so table_cmp() is adjusted accordingly.

  - bitmap_writer_finish() no longer needs to allocate, populate, and
    free the commit_positions table. Instead, we can just write the data
    directly into each struct bitmapped_commit.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agoobject.h: add flags allocated by pack-bitmap.h
Taylor Blau [Tue, 14 May 2024 19:56:50 +0000 (15:56 -0400)] 
object.h: add flags allocated by pack-bitmap.h

In commit 7cc8f971085 (pack-objects: implement bitmap writing,
2013-12-21) the NEEDS_BITMAP flag was introduced into pack-bitmap.h, but
no object flags allocation table existed at the time.

In 208acbfb82f (object.h: centralize object flag allocation, 2014-03-25)
when that table was first introduced, we never added the flags from
7cc8f971085, which has remained the case since.

Rectify this by including the flag bit used by pack-bitmap.h into the
centralized table in object.h.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agoSync with Git 2.45.1
Junio C Hamano [Tue, 14 May 2024 01:29:15 +0000 (18:29 -0700)] 
Sync with Git 2.45.1

* tag 'v2.45.1': (42 commits)
  Git 2.45.1
  Git 2.44.1
  Git 2.43.4
  Git 2.42.2
  Git 2.41.1
  Git 2.40.2
  Git 2.39.4
  fsck: warn about symlink pointing inside a gitdir
  core.hooksPath: add some protection while cloning
  init.templateDir: consider this config setting protected
  clone: prevent hooks from running during a clone
  Add a helper function to compare file contents
  init: refactor the template directory discovery into its own function
  find_hook(): refactor the `STRIP_EXTENSION` logic
  clone: when symbolic links collide with directories, keep the latter
  entry: report more colliding paths
  t5510: verify that D/F confusion cannot lead to an RCE
  submodule: require the submodule path to contain directories only
  clone_submodule: avoid using `access()` on directories
  submodules: submodule paths must not contain symlinks
  ...

17 months agodocumentation: git-update-index: add --show-index-version to synopsis
Dov Murik [Sun, 12 May 2024 03:14:00 +0000 (23:14 -0400)] 
documentation: git-update-index: add --show-index-version to synopsis

In 606e088d5d (update-index: add --show-index-version, 2023-09-12), we
added the new '--show-index-version' option to 'git-update-index' and
documented it, but forgot to add it to the synopsis section.

Add '--show-index-version' to the synopsis of 'git-update-index'.

Signed-off-by: Dov Murik <dov.murik@linux.dev>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agofetch-pack: remove unused 'struct loose_object_iter'
Dr. David Alan Gilbert [Sun, 12 May 2024 00:59:13 +0000 (01:59 +0100)] 
fetch-pack: remove unused 'struct loose_object_iter'

'struct loose_object_iter' in fetch-pack.c is unused since commit
97b2fa08 (fetch-pack: drop custom loose object cache, 2018-11-12).

Remove it.

Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agoThe third batch
Junio C Hamano [Mon, 13 May 2024 17:00:43 +0000 (10:00 -0700)] 
The third batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 months agoMerge branch 'jc/git-gui-maintainer-update'
Junio C Hamano [Mon, 13 May 2024 17:19:48 +0000 (10:19 -0700)] 
Merge branch 'jc/git-gui-maintainer-update'

* jc/git-gui-maintainer-update:
  SubmittingPatches: welcome the new maintainer of git-gui part

17 months agoMerge branch 'fa/p4-error'
Junio C Hamano [Mon, 13 May 2024 17:19:48 +0000 (10:19 -0700)] 
Merge branch 'fa/p4-error'

P4 update.

* fa/p4-error:
  git-p4: show Perforce error to the user

17 months agoMerge branch 'ps/ci-fuzzers-at-gitlab-fix'
Junio C Hamano [Mon, 13 May 2024 17:19:47 +0000 (10:19 -0700)] 
Merge branch 'ps/ci-fuzzers-at-gitlab-fix'

CI fix.

* ps/ci-fuzzers-at-gitlab-fix:
  gitlab-ci: fix installing dependencies for fuzz smoke tests
  gitlab-ci: add smoke test for fuzzers

17 months agoMerge branch 'jk/ci-test-with-jgit-fix'
Junio C Hamano [Mon, 13 May 2024 17:19:47 +0000 (10:19 -0700)] 
Merge branch 'jk/ci-test-with-jgit-fix'

CI fix.

* jk/ci-test-with-jgit-fix:
  ci: update coverity runs_on_pool reference

17 months agoMerge branch 'jk/ci-macos-gcc13-fix'
Junio C Hamano [Mon, 13 May 2024 17:19:47 +0000 (10:19 -0700)] 
Merge branch 'jk/ci-macos-gcc13-fix'

CI fix.

* jk/ci-macos-gcc13-fix:
  ci: stop installing "gcc-13" for osx-gcc
  ci: avoid bare "gcc" for osx-gcc job
  ci: drop mention of BREW_INSTALL_PACKAGES variable

17 months agoMerge branch 'jc/no-default-attr-tree-in-bare'
Junio C Hamano [Mon, 13 May 2024 17:19:46 +0000 (10:19 -0700)] 
Merge branch 'jc/no-default-attr-tree-in-bare'

Git 2.43 started using the tree of HEAD as the source of attributes
in a bare repository, which has severe performance implications.
For now, revert the change, without ripping out a more explicit
support for the attr.tree configuration variable.

* jc/no-default-attr-tree-in-bare:
  stop using HEAD for attributes in bare repository by default

17 months agoMerge branch 'ps/ci-python-2-deprecation'
Junio C Hamano [Mon, 13 May 2024 17:19:46 +0000 (10:19 -0700)] 
Merge branch 'ps/ci-python-2-deprecation'

Unbreak CI jobs so that we do not attempt to use Python 2 that has
been removed from the platform.

* ps/ci-python-2-deprecation:
  ci: fix Python dependency on Ubuntu 24.04

17 months agoMerge branch 'tb/attr-limits'
Junio C Hamano [Mon, 13 May 2024 17:19:46 +0000 (10:19 -0700)] 
Merge branch 'tb/attr-limits'

The maximum size of attribute files is enforced more consistently.

* tb/attr-limits:
  attr.c: move ATTR_MAX_FILE_SIZE check into read_attr_from_buf()

17 months agoMerge branch 'jc/test-workaround-broken-mv'
Junio C Hamano [Mon, 13 May 2024 17:19:45 +0000 (10:19 -0700)] 
Merge branch 'jc/test-workaround-broken-mv'

Tests that try to corrupt in-repository files in chunked format did
not work well on macOS due to its broken "mv", which has been
worked around.

* jc/test-workaround-broken-mv:
  t/lib-chunk: work around broken "mv" on some vintage of macOS

17 months agoMerge branch 'ma/win32-unix-domain-socket'
Junio C Hamano [Mon, 13 May 2024 17:19:45 +0000 (10:19 -0700)] 
Merge branch 'ma/win32-unix-domain-socket'

Build fix.

* ma/win32-unix-domain-socket:
  win32: fix building with NO_UNIX_SOCKETS

17 months agocompat/regex: fix argument order to calloc(3)
Junio C Hamano [Sun, 12 May 2024 06:25:04 +0000 (23:25 -0700)] 
compat/regex: fix argument order to calloc(3)

Windows compiler suddenly started complaining that calloc(3) takes
its arguments in <nmemb, size> order.  Indeed, there are many calls
that has their arguments in a _wrong_ order.

Fix them all.

A sample breakage can be seen at

  https://github.com/git/git/actions/runs/9046793153/job/24857988702#step:4:272

Signed-off-by: Junio C Hamano <gitster@pobox.com>