]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
9 months agot/unit-tests: introduce reftable library
Patrick Steinhardt [Mon, 16 Sep 2024 08:50:11 +0000 (10:50 +0200)] 
t/unit-tests: introduce reftable library

We have recently migrated all of the reftable unit tests that were part
of the reftable library into our own unit testing framework. As part of
that migration we have duplicated some of the functionality that was
part of the reftable test framework into each of the migrated test
suites. This was a sensible decision to not have all of the migrations
dependent on each other, but now that the migration is done it makes
sense to deduplicate the functionality again.

Introduce a new reftable test library that hosts some shared code and
adapt tests to use it.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoMakefile: stop listing test library objects twice
Patrick Steinhardt [Mon, 16 Sep 2024 08:50:08 +0000 (10:50 +0200)] 
Makefile: stop listing test library objects twice

Whenever one adds another test library compilation unit one has to wire
it up twice in the Makefile: once to append it to `UNIT_TEST_OBJS`, and
once to append it to the `UNIT_TEST_PROGS` target. Ideally, we'd just
reuse the `UNIT_TEST_OBJS` variable in the target so that we can avoid
the duplication. But it also contains all the objects for our test
programs, each of which contains a `cmd_main()`, and thus we cannot link
them all into the target executable.

Refactor the code such that `UNIT_TEST_OBJS` does not contain the unit
test program objects anymore, which we can instead manually append to
the `OBJECTS` variable. Like this, the former variable now only contains
objects for test libraries and can thus be reused.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agobuiltin/receive-pack: fix exclude patterns when announcing refs
Patrick Steinhardt [Mon, 16 Sep 2024 08:50:05 +0000 (10:50 +0200)] 
builtin/receive-pack: fix exclude patterns when announcing refs

In `write_head_info()` we announce references to the remote client. We
need to honor "transfer.hideRefs" here so that we do not announce any
references that the client shouldn't be able to learn about. This is
done via two separate mechanisms:

  - We hand over exclude patterns to the reference backend. We can only
    honor "plain" exclude patterns here that do not have prefixes with
    special meaning such as "^" or "!". Filtering down the references is
    handled by `hidden_refs_to_excludes()`.

  - In `show_ref_cb()` we perform a second check against hidden refs.
    For one this is done such that we can handle those special prefixes.
    And second, handling exclude patterns in ref backends is optional,
    so we also have to handle "normal" patterns.

The special-meaning "^" prefix alters whether a hidden ref applies to
the namespace-stripped reference name or the full name. So while we
would usually call `refs_for_each_namespaced_ref()` to only get those
references in the current namespace, we can't because we'd get the
already-rewritten reference names. Instead, we are forced to use
`refs_for_each_fullref_in()` and then manually strip away the namespace
prefix such that we have access to both names.

But this also means that we do not get namespace handling for exclude
patterns, which `refs_for_each_namespaced_ref()` brings for free. This
results in a bug because we potentially end up hiding away references
based on their namespaced name and not on the stripped name as we really
should be doing.

Fix this by manually rewriting the exclude patterns to their namespaced
variants.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agorefs: properly apply exclude patterns to namespaced refs
Patrick Steinhardt [Mon, 16 Sep 2024 08:50:03 +0000 (10:50 +0200)] 
refs: properly apply exclude patterns to namespaced refs

Reference namespaces allow commands like git-upload-pack(1) to serve
different sets of references to the client depending on which namespace
is enabled, which is for example useful in fork networks. Namespaced
refs are stored with a `refs/namespaces/$namespace` prefix, but all the
user will ultimately see is a stripped version where that prefix is
removed.

The way that this interacts with "transfer.hideRefs" is not immediately
obvious: the hidden refs can either apply to the stripped references, or
to the non-stripped ones that still have the namespace prefix. In fact,
the "transfer.hideRefs" machinery does the former and applies to the
stripped reference by default, but rules can have "^" prefixed to switch
this behaviour to instead match against the full reference name.

Namespaces are exclusively handled at the generic "refs" layer, the
respective backends have no clue that such a thing even exists. This
also has the consequence that they cannot handle hiding references as
soon as reference namespaces come into play because they neither know
whether a namespace is active, nor do they know how to strip references
if they are active.

Handling such exclude patterns in `refs_for_each_namespaced_ref()` and
`refs_for_each_fullref_in_prefixes()` is broken though, as both support
that the user passes both namespaces and exclude patterns. In the case
where both are set we will exclude references with unstripped names,
even though we really wanted to exclude references based on their
stripped names.

This only surfaces when:

  - A repository uses reference namespaces.

  - "transfer.hideRefs" is active.

  - The namespaced references are packed into the "packed-refs" file.

None of our tests exercise this scenario, and thus we haven't ever hit
it. While t5509 exercises both (1) and (2), it does not happen to hit
(3). It is trivial to demonstrate the bug though by explicitly packing
refs in the tests, and then we indeed surface the breakage.

Fix this bug by prefixing exclude patterns with the namespace in the
generic layer. The newly introduced function will be used outside of
"refs.c" in the next patch, so we add a declaration to "refs.h".

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoMerge branch 'cp/unit-test-reftable-stack' into ps/reftable-exclude
Junio C Hamano [Mon, 9 Sep 2024 17:13:44 +0000 (10:13 -0700)] 
Merge branch 'cp/unit-test-reftable-stack' into ps/reftable-exclude

* cp/unit-test-reftable-stack:
  t-reftable-stack: add test for stack iterators
  t-reftable-stack: add test for non-default compaction factor
  t-reftable-stack: use reftable_ref_record_equal() to compare ref records
  t-reftable-stack: use Git's tempfile API instead of mkstemp()
  t: harmonize t-reftable-stack.c with coding guidelines
  t: move reftable/stack_test.c to the unit testing framework

9 months agot-reftable-stack: add test for stack iterators
Chandra Pratap [Sun, 8 Sep 2024 04:06:01 +0000 (09:36 +0530)] 
t-reftable-stack: add test for stack iterators

reftable_stack_init_ref_iterator and reftable_stack_init_log_iterator
as defined by reftable/stack.{c,h} initialize a stack iterator to
iterate over the ref and log records in a reftable stack respectively.
Since these functions are not exercised by any of the existing tests,
add a test for them.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agot-reftable-stack: add test for non-default compaction factor
Chandra Pratap [Sun, 8 Sep 2024 04:06:00 +0000 (09:36 +0530)] 
t-reftable-stack: add test for non-default compaction factor

In a recent codebase update (commit ae8e378430, merge branch
'ps/reftable-write-options', 2024/05/13) the geometric factor used
in auto-compaction of reftable tables was made configurable. Add
a test to verify the functionality introduced by this update.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agot-reftable-stack: use reftable_ref_record_equal() to compare ref records
Chandra Pratap [Sun, 8 Sep 2024 04:05:59 +0000 (09:35 +0530)] 
t-reftable-stack: use reftable_ref_record_equal() to compare ref records

In the current stack tests, ref records are compared for equality
by sometimes using the dedicated function for ref-record comparison,
reftable_ref_record_equal(), and sometimes by explicity comparing
contents of the ref records.

The latter method is undesired because there can exist unequal ref
records with some of the contents being equal. Replace the latter
instances of ref-record comparison with the former. This has the
added benefit of preserving uniformity throughout the test file.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agot-reftable-stack: use Git's tempfile API instead of mkstemp()
Chandra Pratap [Sun, 8 Sep 2024 04:05:58 +0000 (09:35 +0530)] 
t-reftable-stack: use Git's tempfile API instead of mkstemp()

Git's tempfile API defined by $GIT_DIR/tempfile.{c,h} provides
a unified interface for tempfile operations. Since reftable/stack.c
uses this API for all its tempfile needs instead of raw functions
like mkstemp(), make the ported stack test strictly use Git's
tempfile API as well.

A bigger benefit is the fact that we know to clean up the tempfile
in case the test fails because it gets registered and pruned via a
signal handler.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agot: harmonize t-reftable-stack.c with coding guidelines
Chandra Pratap [Sun, 8 Sep 2024 04:05:57 +0000 (09:35 +0530)] 
t: harmonize t-reftable-stack.c with coding guidelines

Harmonize the newly ported test unit-tests/t-reftable-stack.c
with the following guidelines:
- Single line 'for' statements must omit curly braces.
- Structs must be 0-initialized with '= { 0 }' instead of '= { NULL }'.
- Array sizes and indices should preferably be of type 'size_t' and
  not 'int'.
- Function pointers should be passed as 'func' and not '&func'.

While at it, remove initialization for those variables that are
re-used multiple times, like loop variables.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agot: move reftable/stack_test.c to the unit testing framework
Chandra Pratap [Sun, 8 Sep 2024 04:05:56 +0000 (09:35 +0530)] 
t: move reftable/stack_test.c to the unit testing framework

reftable/stack_test.c exercises the functions defined in
reftable/stack.{c, h}. Migrate reftable/stack_test.c to the
unit testing framework. Migration involves refactoring the tests
to use the unit testing framework instead of reftable's test
framework and renaming the tests to be in-line with unit-tests'
standards.

Since some of the tests use set_test_hash() defined by
reftable/test_framework.{c, h} but these files are not
'#included' in the test file, copy this function in the
ported test file.

With the migration of stack test to the unit-tests framework,
"test-tool reftable" becomes a no-op. Hence, get rid of everything
that uses "test-tool reftable" alongside everything that is used
to implement it.

While at it, alphabetically sort the cmds[] list in
helper/test-tool.c by moving the entry for "dump-reftable".

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoThe thirteenth batch
Junio C Hamano [Fri, 6 Sep 2024 17:22:39 +0000 (10:22 -0700)] 
The thirteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoMerge branch 'jk/maybe-unused-cleanup'
Junio C Hamano [Fri, 6 Sep 2024 17:38:52 +0000 (10:38 -0700)] 
Merge branch 'jk/maybe-unused-cleanup'

Code clean-up.

* jk/maybe-unused-cleanup:
  grep: prefer UNUSED to MAYBE_UNUSED for pcre allocators
  gc: drop MAYBE_UNUSED annotation from used parameter

9 months agoMerge branch 'jc/unused-on-windows'
Junio C Hamano [Fri, 6 Sep 2024 17:38:51 +0000 (10:38 -0700)] 
Merge branch 'jc/unused-on-windows'

Fix more fallouts from -Werror=unused-parameter.

* jc/unused-on-windows:
  refs/files-backend: work around -Wunused-parameter

9 months agoMerge branch 'jc/maybe-unused'
Junio C Hamano [Fri, 6 Sep 2024 17:38:50 +0000 (10:38 -0700)] 
Merge branch 'jc/maybe-unused'

Developer doc updates.

* jc/maybe-unused:
  CodingGuidelines: also mention MAYBE_UNUSED

9 months agoMerge branch 'jk/unused-parameters'
Junio C Hamano [Fri, 6 Sep 2024 17:38:49 +0000 (10:38 -0700)] 
Merge branch 'jk/unused-parameters'

Make our codebase compilable with the -Werror=unused-parameter
option.

* jk/unused-parameters:
  CodingGuidelines: mention -Wunused-parameter and UNUSED
  config.mak.dev: enable -Wunused-parameter by default
  compat: mark unused parameters in win32/mingw functions
  compat: disable -Wunused-parameter in win32/headless.c
  compat: disable -Wunused-parameter in 3rd-party code
  t-reftable-readwrite: mark unused parameter in callback function
  gc: mark unused config parameter in virtual functions

9 months agoMerge branch 'jk/send-email-mailmap'
Junio C Hamano [Fri, 6 Sep 2024 17:38:49 +0000 (10:38 -0700)] 
Merge branch 'jk/send-email-mailmap'

"git send-email" learned "--mailmap" option to allow rewriting the
recipient addresses.

* jk/send-email-mailmap:
  send-email: add mailmap support via sendemail.mailmap and --mailmap
  check-mailmap: add options for additional mailmap sources
  check-mailmap: accept "user@host" contacts

9 months agoThe twelfth batch
Junio C Hamano [Tue, 3 Sep 2024 16:13:21 +0000 (09:13 -0700)] 
The twelfth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoMerge branch 'jc/config-doc-update'
Junio C Hamano [Tue, 3 Sep 2024 16:15:04 +0000 (09:15 -0700)] 
Merge branch 'jc/config-doc-update'

Docfix.

* jc/config-doc-update:
  git-config.1: fix description of --regexp in synopsis
  git-config.1: --get-all description update

9 months agoMerge branch 'rs/remote-leakfix'
Junio C Hamano [Tue, 3 Sep 2024 16:15:03 +0000 (09:15 -0700)] 
Merge branch 'rs/remote-leakfix'

Leakfix.

* rs/remote-leakfix:
  remote: plug memory leaks at early returns

9 months agoMerge branch 'ps/reftable-concurrent-compaction'
Junio C Hamano [Tue, 3 Sep 2024 16:15:02 +0000 (09:15 -0700)] 
Merge branch 'ps/reftable-concurrent-compaction'

The code path for compacting reftable files saw some bugfixes
against concurrent operation.

* ps/reftable-concurrent-compaction:
  reftable/stack: fix segfault when reload with reused readers fails
  reftable/stack: reorder swapping in the reloaded stack contents
  reftable/reader: keep readers alive during iteration
  reftable/reader: introduce refcounting
  reftable/stack: fix broken refnames in `write_n_ref_tables()`
  reftable/reader: inline `reader_close()`
  reftable/reader: inline `init_reader()`
  reftable/reader: rename `reftable_new_reader()`
  reftable/stack: inline `stack_compact_range_stats()`
  reftable/blocksource: drop malloc block source

9 months agoMerge branch 'js/fetch-push-trace2-annotation'
Junio C Hamano [Tue, 3 Sep 2024 16:15:01 +0000 (09:15 -0700)] 
Merge branch 'js/fetch-push-trace2-annotation'

More trace2 events at key points on push and fetch code paths have
been added.

* js/fetch-push-trace2-annotation:
  send-pack: add new tracing regions for push
  fetch: add top-level trace2 regions
  trace2: implement trace2_printf() for event target

9 months agoMerge branch 'aa/cat-file-batch-output-doc'
Junio C Hamano [Tue, 3 Sep 2024 16:15:01 +0000 (09:15 -0700)] 
Merge branch 'aa/cat-file-batch-output-doc'

Docfix.

* aa/cat-file-batch-output-doc:
  docs: explain the order of output in the batched mode of git-cat-file(1)

9 months agoMerge branch 'dh/runtime-prefix-on-zos'
Junio C Hamano [Tue, 3 Sep 2024 16:15:00 +0000 (09:15 -0700)] 
Merge branch 'dh/runtime-prefix-on-zos'

Support for the RUNTIME_PREFIX feature has been added to z/OS port.

* dh/runtime-prefix-on-zos:
  exec_cmd: RUNTIME_PREFIX on z/OS systems

9 months agoMerge branch 'ps/leakfixes-part-5'
Junio C Hamano [Tue, 3 Sep 2024 16:14:59 +0000 (09:14 -0700)] 
Merge branch 'ps/leakfixes-part-5'

Even more leak fixes.

* ps/leakfixes-part-5:
  transport: fix leaking negotiation tips
  transport: fix leaking arguments when fetching from bundle
  builtin/fetch: fix leaking transaction with `--atomic`
  remote: fix leaking peer ref when expanding refmap
  remote: fix leaks when matching refspecs
  remote: fix leaking config strings
  builtin/fetch-pack: fix leaking refs
  sideband: fix leaks when configuring sideband colors
  builtin/send-pack: fix leaking refspecs
  transport: fix leaking OID arrays in git:// transport data
  t/helper: fix leaking multi-pack-indices in "read-midx"
  builtin/repack: fix leaks when computing packs to repack
  midx-write: fix leaking hashfile on error cases
  builtin/archive: fix leaking `OPT_FILENAME()` value
  builtin/upload-archive: fix leaking args passed to `write_archive()`
  builtin/merge-tree: fix leaking `-X` strategy options
  pretty: fix leaking key/value separator buffer
  pretty: fix memory leaks when parsing pretty formats
  convert: fix leaks when resetting attributes
  mailinfo: fix leaking header data

9 months agoMerge branch 'cl/config-regexp-docfix'
Junio C Hamano [Tue, 3 Sep 2024 16:14:59 +0000 (09:14 -0700)] 
Merge branch 'cl/config-regexp-docfix'

Docfix.

* cl/config-regexp-docfix:
  doc: replace 3 dash with correct 2 dash in git-config(1)

9 months agorefs/files-backend: work around -Wunused-parameter
Junio C Hamano [Fri, 30 Aug 2024 19:33:13 +0000 (12:33 -0700)] 
refs/files-backend: work around -Wunused-parameter

This is needed to build things with -Werror=unused-parameter on a
platform without symbolic link support.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agogrep: prefer UNUSED to MAYBE_UNUSED for pcre allocators
Jeff King [Thu, 29 Aug 2024 20:09:53 +0000 (16:09 -0400)] 
grep: prefer UNUSED to MAYBE_UNUSED for pcre allocators

We provide custom malloc/free callbacks for the pcre library to use.
Those take an extra "data" parameter, but we don't use it. Back when
these were added in 513f2b0bbd (grep: make PCRE2 aware of custom
allocator, 2019-10-16), we only had MAYBE_UNUSED.

But these days we have UNUSED, which we should prefer, as it will
let the compiler inform us if the code changes to actually use the
parameters.

I also moved the annotations to come after the variable name, which is
how we typically spell it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agogc: drop MAYBE_UNUSED annotation from used parameter
Jeff King [Thu, 29 Aug 2024 20:08:33 +0000 (16:08 -0400)] 
gc: drop MAYBE_UNUSED annotation from used parameter

The "opts" parameter is always used, so marking it with MAYBE_UNUSED is
just confusing.

This annotation goes back to 41abfe15d9 (maintenance: add pack-refs
task, 2021-02-09), when it really was unused. Back then we did not have
the UNUSED macro that would complain if the code changed to use the
parameter. So when we started using it in bfc2f9eb8e (builtin/gc:
forward git-gc(1)'s `--auto` flag when packing refs, 2024-03-25), nobody
noticed.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoCodingGuidelines: also mention MAYBE_UNUSED
Junio C Hamano [Thu, 29 Aug 2024 18:18:06 +0000 (11:18 -0700)] 
CodingGuidelines: also mention MAYBE_UNUSED

A function that uses a parameter in one build may lose all uses of
the parameter in another build, depending on the configuration.  A
workaround for such a case, MAYBE_UNUSED, should also be mentioned
when we recommend the use of UNUSED to our developers.

Keep the addition to the guideline short and document the criteria
to choose between UNUSED and MAYBE_UNUSED near their definition.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoMerge branch 'jk/unused-parameters' into jc/maybe-unused
Junio C Hamano [Thu, 29 Aug 2024 18:09:20 +0000 (11:09 -0700)] 
Merge branch 'jk/unused-parameters' into jc/maybe-unused

* jk/unused-parameters:
  CodingGuidelines: mention -Wunused-parameter and UNUSED
  config.mak.dev: enable -Wunused-parameter by default
  compat: mark unused parameters in win32/mingw functions
  compat: disable -Wunused-parameter in win32/headless.c
  compat: disable -Wunused-parameter in 3rd-party code
  t-reftable-readwrite: mark unused parameter in callback function
  gc: mark unused config parameter in virtual functions

9 months agoThe eleventh batch
Junio C Hamano [Thu, 29 Aug 2024 17:38:34 +0000 (10:38 -0700)] 
The eleventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoMerge branch 'ds/sparse-diff-index'
Junio C Hamano [Thu, 29 Aug 2024 18:08:17 +0000 (11:08 -0700)] 
Merge branch 'ds/sparse-diff-index'

The underlying machinery for "git diff-index" has long been made to
expand the sparse index as needed, but the command fully expanded
the sparse index upfront, which now has been taught not to do.

* ds/sparse-diff-index:
  diff-index: integrate with the sparse index

9 months agoMerge branch 'cp/unit-test-reftable-block'
Junio C Hamano [Thu, 29 Aug 2024 18:08:16 +0000 (11:08 -0700)] 
Merge branch 'cp/unit-test-reftable-block'

Another test for reftable library ported to the unit test framework.

* cp/unit-test-reftable-block:
  t-reftable-block: mark unused argv/argc
  t-reftable-block: add tests for index blocks
  t-reftable-block: add tests for obj blocks
  t-reftable-block: add tests for log blocks
  t-reftable-block: remove unnecessary variable 'j'
  t-reftable-block: use xstrfmt() instead of xstrdup()
  t-reftable-block: use block_iter_reset() instead of block_iter_close()
  t-reftable-block: use reftable_record_key() instead of strbuf_addstr()
  t-reftable-block: use reftable_record_equal() instead of check_str()
  t-reftable-block: release used block reader
  t: harmonize t-reftable-block.c with coding guidelines
  t: move reftable/block_test.c to the unit testing framework

9 months agoMerge branch 'ps/reftable-drop-generic'
Junio C Hamano [Thu, 29 Aug 2024 18:08:15 +0000 (11:08 -0700)] 
Merge branch 'ps/reftable-drop-generic'

The code in the reftable library has been cleaned up by discarding
unused "generic" interface.

* ps/reftable-drop-generic:
  reftable: mark unused parameters in empty iterator functions
  reftable/generic: drop interface
  t/helper: refactor to not use `struct reftable_table`
  t/helper: use `hash_to_hex_algop()` to print hashes
  t/helper: inline printing of reftable records
  t/helper: inline `reftable_table_print()`
  t/helper: inline `reftable_stack_print_directory()`
  t/helper: inline `reftable_reader_print_file()`
  t/helper: inline `reftable_dump_main()`
  reftable/dump: drop unused `compact_stack()`
  reftable/generic: move generic iterator code into iterator interface
  reftable/iter: drop double-checking logic
  reftable/stack: open-code reading refs
  reftable/merged: stop using generic tables in the merged table
  reftable/merged: rename `reftable_new_merged_table()`
  reftable/merged: expose functions to initialize iterators

9 months agoThe tenth batch
Junio C Hamano [Wed, 28 Aug 2024 17:31:11 +0000 (10:31 -0700)] 
The tenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoMerge branch 'ah/git-prompt-portability'
Junio C Hamano [Wed, 28 Aug 2024 17:31:28 +0000 (10:31 -0700)] 
Merge branch 'ah/git-prompt-portability'

The command line prompt support used to be littered with bash-isms,
which has been corrected to work with more shells.

* ah/git-prompt-portability:
  git-prompt: support custom 0-width PS1 markers
  git-prompt: ta-da! document usage in other shells
  git-prompt: don't use shell $'...'
  git-prompt: add some missing quotes
  git-prompt: replace [[...]] with standard code
  git-prompt: don't use shell arrays
  git-prompt: fix uninitialized variable
  git-prompt: use here-doc instead of here-string

9 months agoMerge branch 'gt/unit-test-urlmatch-normalization'
Junio C Hamano [Wed, 28 Aug 2024 17:31:27 +0000 (10:31 -0700)] 
Merge branch 'gt/unit-test-urlmatch-normalization'

Another rewrite of test.

* gt/unit-test-urlmatch-normalization:
  t: migrate t0110-urlmatch-normalization to the new framework

9 months agoMerge branch 'mt/rebase-x-quiet'
Junio C Hamano [Wed, 28 Aug 2024 17:31:26 +0000 (10:31 -0700)] 
Merge branch 'mt/rebase-x-quiet'

"git rebase -x --quiet" was not quiet, which was corrected.

* mt/rebase-x-quiet:
  rebase --exec: respect --quiet

9 months agoreftable: mark unused parameters in empty iterator functions
Jeff King [Wed, 28 Aug 2024 04:09:44 +0000 (00:09 -0400)] 
reftable: mark unused parameters in empty iterator functions

These unused parameters were marked in a68ec8683a (reftable: mark unused
parameters in virtual functions, 2024-08-17), but the functions were
moved to a new file in a parallel branch via f2406c81b9
(reftable/generic: move generic iterator code into iterator interface,
2024-08-22).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agot-reftable-block: mark unused argv/argc
Jeff King [Wed, 28 Aug 2024 04:08:03 +0000 (00:08 -0400)] 
t-reftable-block: mark unused argv/argc

This is conceptually the same as the cases in df9d638c24 (unit-tests:
ignore unused argc/argv, 2024-08-17), but this unit test was migrated
from the reftable tests in a parallel branch.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoCodingGuidelines: mention -Wunused-parameter and UNUSED
Jeff King [Wed, 28 Aug 2024 14:48:14 +0000 (10:48 -0400)] 
CodingGuidelines: mention -Wunused-parameter and UNUSED

Now that -Wunused-parameter is on by default for DEVELOPER=1 builds,
people may trigger it, blocking their build. When it's a mistake for the
parameter to exist, the path forward is obvious: remove it. But
sometimes you need to suppress the warning, and the "UNUSED" mechanism
for that is specific to our project, so people may not know about it.

Let's put some advice in CodingGuidelines, including an example warning
message. That should help people who grep for the warning text after
seeing it from the compiler.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoconfig.mak.dev: enable -Wunused-parameter by default
Jeff King [Wed, 28 Aug 2024 04:00:49 +0000 (00:00 -0400)] 
config.mak.dev: enable -Wunused-parameter by default

Having now removed or annotated all of the unused function parameters in
our code base, I found that each instance falls into one of three
categories:

  1. ignoring the parameter is a bug (e.g., a function takes a ptr/len
     pair, but ignores the length). Detecting these helps us find the
     bugs.

  2. the parameter is unnecessary (and usually left over from a
     refactoring or earlier iteration of a patches series). Removing
     these cleans up the code.

  3. the function has to conform to a specific interface (because it's
     used via a function pointer, or matches something on the other side
     of an #ifdef). These ones are annoying, but annotating them with
     UNUSED is not too bad (especially if the compiler tells you about
     the problem promptly).

Certainly instances of (3) are more common than (1), but after finding
all of these, I think there were enough cases of (1) that it justifies
the work in annotating all of the (3)s.

And since the code base is now at a spot where we compile cleanly with
-Wunused-parameter, turning it on will make it the responsibility of
individual patch writers going forward.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agocompat: mark unused parameters in win32/mingw functions
Jeff King [Wed, 28 Aug 2024 04:00:16 +0000 (00:00 -0400)] 
compat: mark unused parameters in win32/mingw functions

The compat/ directory contains many stub functions, wrappers, and so on
that have to conform to a specific interface, but don't necessarily need
to use all of their parameters. Let's mark them to avoid complaints from
-Wunused-parameter.

This was done mostly via guess-and-check with the Windows build in
GitHub CI. I also confirmed that the win+VS build is similarly happy.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agocompat: disable -Wunused-parameter in win32/headless.c
Jeff King [Wed, 28 Aug 2024 03:59:52 +0000 (23:59 -0400)] 
compat: disable -Wunused-parameter in win32/headless.c

As with the files touched in the previous commit, win32/headless.c does
not include git-compat-util.h, so it doesn't have our UNUSED macro.
Unlike those ones, this is not third-party code, so it would not be a
big deal to modify it.

However, I'm not sure if including git-compat-util.h would create other
headaches (and I don't even have a machine to test this on; I'm relying
on Windows CI to compile it at all). Given how trivial the file is, and
that the unused parameters are not interesting (they are just
boilerplate for the wWinMain() function), we can just use the same trick
as the previous commit and disable the warnings via pragma.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agocompat: disable -Wunused-parameter in 3rd-party code
Jeff King [Wed, 28 Aug 2024 03:58:55 +0000 (23:58 -0400)] 
compat: disable -Wunused-parameter in 3rd-party code

We carry some vendored 3rd-party code in compat/ that does not build
cleanly with -Wunused-parameters. We could mark these with UNUSED, but
there are two reasons not to:

  1. This is code imported from elsewhere, so we'd prefer to avoid
     modifying it in an invasive way that could create conflicts if we
     tried to pull in a new version.

  2. These files don't include git-compat-util.h at all, so we'd need to
     factor out (or repeat) our UNUSED macro.

In theory we could modify the build process to invoke the compiler with
the extra warning disabled for these files, but there are tricky corner
cases there (e.g., for NO_REGEX we cannot assume that the compiler
understands -Wno-unused-parameter as an option, so we'd have to use our
detect-compiler script).

Instead, let's rely on the gcc diagnostic #pragma. This is horribly
unportable, of course, but it should do what we want.  Compilers which
don't understand this particular pragma should ignore it (per the
standard), and compilers which do care about "-Wunused-parameter" will
hopefully respect it, even if they are not gcc (e.g., clang does).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agot-reftable-readwrite: mark unused parameter in callback function
Jeff King [Wed, 28 Aug 2024 03:57:58 +0000 (23:57 -0400)] 
t-reftable-readwrite: mark unused parameter in callback function

This spot was originally marked in in 4695c3f3a9 (reftable: mark unused
parameters in virtual functions, 2024-08-17), but was copied in
5b539a5361 (t: move reftable/readwrite_test.c to the unit testing
framework, 2024-08-13).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agogc: mark unused config parameter in virtual functions
Jeff King [Wed, 28 Aug 2024 03:57:46 +0000 (23:57 -0400)] 
gc: mark unused config parameter in virtual functions

Commit d1ae15d68b (builtin/gc: refactor to read config into structure,
2024-08-16) added a new parameter to the maintenance_task virtual
functions, but most of them don't need to look at it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agosend-email: add mailmap support via sendemail.mailmap and --mailmap
Jacob Keller [Tue, 27 Aug 2024 21:27:18 +0000 (14:27 -0700)] 
send-email: add mailmap support via sendemail.mailmap and --mailmap

In some cases, a user may be generating a patch for an old commit which
now has an out-of-date author or other identity. For example, consider a
team member who contributes to an internal fork of an upstream project,
but leaves before this change is submitted upstream.

In this case, the team members company address may no longer be valid,
and will thus bounce when sending email.

This can be manually avoided by editing the generated patch files, or by
carefully using --suppress-<cc|to> options. This requires a lot of
manual intervention and is easy to forget.

Git has support for mapping old email addresses and names to a canonical
name and address via the .mailmap file (and its associated mailmap.file,
mailmap.blob, and log.mailmap options).

Teach git send-email to enable mailmap support for all addresses. This
ensures that addresses point to the canonical real name and email
address.

Add the sendemail.mailmap configuration option and its associated
--mailmap (and --use-mailmap for compatibility with git log) options.
For now, the default behavior is to disable the mailmap in order to
avoid any surprises or breaking any existing setups.

These options support per-identity configuration via the
sendemail.identity configuration blocks. This enables identity-specific
configuration in cases where users may not want to enable support.

In addition, support send-email specific mailmap data via
sendemail.mailmap.file, sendemail.mailmap.blob and their
identity-specific variants.

The intention of these options is to enable mapping addresses which are
no longer valid to a current project or team maintainer. Such mappings
may change the actual person being referred to, and may not make sense
in a traditional mailmap file which is intended for updating canonical
name and address for the same individual.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agocheck-mailmap: add options for additional mailmap sources
Jacob Keller [Tue, 27 Aug 2024 21:27:17 +0000 (14:27 -0700)] 
check-mailmap: add options for additional mailmap sources

The git check-mailmap command reads the mailmap from either the default
.mailmap location and then from the mailmap.blob and mailmap.file
configurations.

A following change to git send-email will want to support new
configuration options based on the configured identity. The
identity-based configuration and options only make sense in the context
of git send-email.

Expose the read_mailmap_file and read_mailmap_blob functions from
mailmap.c.  Teach git check-mailmap the --mailmap-file and
--mailmap-blob options which load the additional mailmap sources.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agocheck-mailmap: accept "user@host" contacts
Jacob Keller [Tue, 27 Aug 2024 21:27:16 +0000 (14:27 -0700)] 
check-mailmap: accept "user@host" contacts

git check-mailmap splits each provided contact using split_ident_line.
This function requires that the contact either be of the form "Name
<user@host>" or of the form "<user@host>". In particular, if the mail
portion of the contact is not surrounded by angle brackets,
split_ident_line will reject it.

This results in git check-mailmap rejecting attempts to translate simple
email addresses:

  $ git check-mailmap user@host
  fatal: unable to parse contact: user@host

This limits the usability of check-mailmap as it requires placing angle
brackets around plain email addresses.

In particular, attempting to use git check-mailmap to support mapping
addresses in git send-email is not straight forward. The sanitization
and validation functions in git send-email strip angle brackets from
plain email addresses. It is not trivial to add brackets prior to
invoking git check-mailmap.

Instead, modify check_mailmap() to allow such strings as contacts. In
particular, treat any line which cannot be split by split_ident_line as
a simple email address.

No attempt is made to actually parse the address line, or validate that
it is actually an email address. Implementing such validation is not
trivial. Besides, we weren't validating the address between angle
brackets before anyways.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agogit-config.1: fix description of --regexp in synopsis
Junio C Hamano [Mon, 26 Aug 2024 18:48:57 +0000 (11:48 -0700)] 
git-config.1: fix description of --regexp in synopsis

The synopsis says --regexp=<regexp> but the --regexp option is a
Boolean that says "the name given is not literal, but a pattern to
match the name".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agogit-config.1: --get-all description update
Junio C Hamano [Mon, 26 Aug 2024 17:31:19 +0000 (10:31 -0700)] 
git-config.1: --get-all description update

"git config --get-all foo.bar" shows all values for the foo.bar
variable, but does not give the variable name in each output entry.
Hence it is equivalent to "git config get --all foo.bar", without
"--show-names", in the more modern syntax.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoSync with 'maint'
Junio C Hamano [Mon, 26 Aug 2024 18:36:13 +0000 (11:36 -0700)] 
Sync with 'maint'

9 months agoThe ninth batch
Junio C Hamano [Mon, 26 Aug 2024 18:02:47 +0000 (11:02 -0700)] 
The ninth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoMerge branch 'jc/coding-style-c-operator-with-spaces'
Junio C Hamano [Mon, 26 Aug 2024 18:32:24 +0000 (11:32 -0700)] 
Merge branch 'jc/coding-style-c-operator-with-spaces'

Write down whitespacing rules around C opeators.

* jc/coding-style-c-operator-with-spaces:
  CodingGuidelines: spaces around C operators

9 months agoMerge branch 'ds/for-each-ref-is-base'
Junio C Hamano [Mon, 26 Aug 2024 18:32:24 +0000 (11:32 -0700)] 
Merge branch 'ds/for-each-ref-is-base'

'git for-each-ref' learned a new "--format" atom to find the branch
that the history leading to a given commit "%(is-base:<commit>)" is
likely based on.

* ds/for-each-ref-is-base:
  p1500: add is-base performance tests
  for-each-ref: add 'is-base' token
  commit: add gentle reference lookup method
  commit-reach: add get_branch_base_for_tip

9 months agoMerge branch 'jk/send-email-translate-aliases'
Junio C Hamano [Mon, 26 Aug 2024 18:32:23 +0000 (11:32 -0700)] 
Merge branch 'jk/send-email-translate-aliases'

"git send-email" learned "--translate-aliases" option that reads
addresses from the standard input and emits the result of applying
aliases on them to the standard output.

* jk/send-email-translate-aliases:
  send-email: teach git send-email option to translate aliases
  t9001-send-email.sh: update alias list used for pine test
  t9001-send-email.sh: fix quoting for mailrc --dump-aliases test

9 months agoMerge branch 'jk/mark-unused-parameters'
Junio C Hamano [Mon, 26 Aug 2024 18:32:22 +0000 (11:32 -0700)] 
Merge branch 'jk/mark-unused-parameters'

Mark unused parameters as UNUSED to squelch -Wunused warnings.

* jk/mark-unused-parameters:
  t-hashmap: stop calling setup() for t_intern() test
  scalar: mark unused parameters in dummy function
  daemon: mark unused parameters in non-posix fallbacks
  setup: mark unused parameter in config callback
  test-mergesort: mark unused parameters in trivial callback
  t-hashmap: mark unused parameters in callback function
  reftable: mark unused parameters in virtual functions
  reftable: drop obsolete test function declarations
  reftable: ignore unused argc/argv in test functions
  unit-tests: ignore unused argc/argv
  t/helper: mark more unused argv/argc arguments
  oss-fuzz: mark unused argv/argc argument
  refs: mark unused parameters in do_for_each_reflog_helper()
  refs: mark unused parameters in ref_store fsck callbacks
  update-ref: mark more unused parameters in parser callbacks
  imap-send: mark unused parameter in ssl_socket_connect() fallback

9 months agoMerge branch 'jk/drop-unused-parameters'
Junio C Hamano [Mon, 26 Aug 2024 18:32:21 +0000 (11:32 -0700)] 
Merge branch 'jk/drop-unused-parameters'

Drop unused parameters from functions.

* jk/drop-unused-parameters:
  diff-lib: drop unused index argument from get_stat_data()
  ref-filter: drop unused parameters from email_atom_option_parser()
  pack-bitmap: drop unused parameters from select_pseudo_merges()
  pack-bitmap: load writer config from repository parameter
  refs: drop some unused parameters from create_symref_lock()

9 months agoMerge branch 'tb/pseudo-merge-bitmap-fixes'
Junio C Hamano [Mon, 26 Aug 2024 18:32:21 +0000 (11:32 -0700)] 
Merge branch 'tb/pseudo-merge-bitmap-fixes'

We created a useless pseudo-merge reachability bitmap that is about
0 commits, and attempted to include commits that are not in packs,
which made no sense.  These bugs have been corrected.

* tb/pseudo-merge-bitmap-fixes:
  pseudo-merge.c: ensure pseudo-merge groups are closed
  pseudo-merge.c: do not generate empty pseudo-merge commits
  t/t5333-pseudo-merge-bitmaps.sh: demonstrate empty pseudo-merge groups
  pack-bitmap-write.c: select pseudo-merges even for small bitmaps
  pack-bitmap: drop redundant args from `bitmap_writer_finish()`
  pack-bitmap: drop redundant args from `bitmap_writer_build()`
  pack-bitmap: drop redundant args from `bitmap_writer_build_type_index()`
  pack-bitmap: initialize `bitmap_writer_init()` with packing_data

9 months agoMerge branch 'ps/maintenance-detach-fix-more'
Junio C Hamano [Mon, 26 Aug 2024 18:32:20 +0000 (11:32 -0700)] 
Merge branch 'ps/maintenance-detach-fix-more'

A tests for "git maintenance" that were broken on Windows have been
corrected.

* ps/maintenance-detach-fix-more:
  builtin/maintenance: fix loose objects task emitting pack hash
  t7900: exercise detaching via trace2 regions
  t7900: fix flaky test due to leaking background job

9 months agoMerge branch 'ps/maintenance-detach-fix'
Junio C Hamano [Mon, 26 Aug 2024 18:32:20 +0000 (11:32 -0700)] 
Merge branch 'ps/maintenance-detach-fix'

Maintenance tasks other than "gc" now properly go background when
"git maintenance" runs them.

* ps/maintenance-detach-fix:
  run-command: fix detaching when running auto maintenance
  builtin/maintenance: add a `--detach` flag
  builtin/gc: add a `--detach` flag
  builtin/gc: stop processing log file on signal
  builtin/gc: fix leaking config values
  builtin/gc: refactor to read config into structure
  config: fix constness of out parameter for `git_config_get_expiry()`

9 months agoA bit more topics for 2.46.x maintenance track
Junio C Hamano [Mon, 26 Aug 2024 18:13:19 +0000 (11:13 -0700)] 
A bit more topics for 2.46.x maintenance track

Signed-off-by: Junio C Hamano <gitster@pobox.com>
9 months agoMerge branch 'xx/diff-tree-remerge-diff-fix' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:24 +0000 (11:10 -0700)] 
Merge branch 'xx/diff-tree-remerge-diff-fix' into maint-2.46

"git rev-list ... | git diff-tree -p --remerge-diff --stdin" should
behave more or less like "git log -p --remerge-diff" but instead it
crashed, forgetting to prepare a temporary object store needed.

* xx/diff-tree-remerge-diff-fix:
  diff-tree: fix crash when used with --remerge-diff

9 months agoMerge branch 'rs/t-example-simplify' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:24 +0000 (11:10 -0700)] 
Merge branch 'rs/t-example-simplify' into maint-2.46

Unit test simplification.

* rs/t-example-simplify:
  t-example-decorate: remove test messages

9 months agoMerge branch 'jc/safe-directory' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:23 +0000 (11:10 -0700)] 
Merge branch 'jc/safe-directory' into maint-2.46

Follow-up on 2.45.1 regression fix.

* jc/safe-directory:
  safe.directory: setting safe.directory="." allows the "current" directory
  safe.directory: normalize the configured path
  safe.directory: normalize the checked path
  safe.directory: preliminary clean-up

9 months agoMerge branch 'jc/document-use-of-local' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:23 +0000 (11:10 -0700)] 
Merge branch 'jc/document-use-of-local' into maint-2.46

Doc update.

* jc/document-use-of-local:
  doc: note that AT&T ksh does not work with our test suite

9 months agoMerge branch 'rs/use-decimal-width' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:22 +0000 (11:10 -0700)] 
Merge branch 'rs/use-decimal-width' into maint-2.46

Code clean-up.

* rs/use-decimal-width:
  log-tree: use decimal_width()

9 months agoMerge branch 'ss/packed-ref-store-leakfix' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:22 +0000 (11:10 -0700)] 
Merge branch 'ss/packed-ref-store-leakfix' into maint-2.46

Leakfix.

* ss/packed-ref-store-leakfix:
  refs/files: prevent memory leak by freeing packed_ref_store

9 months agoMerge branch 'kl/test-fixes' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:21 +0000 (11:10 -0700)] 
Merge branch 'kl/test-fixes' into maint-2.46

A flakey test and incorrect calls to strtoX() functions have been
fixed.

* kl/test-fixes:
  t6421: fix test to work when repo dir contains d0
  set errno=0 before strtoX calls

9 months agoMerge branch 'jc/reflog-expire-lookup-commit-fix' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:21 +0000 (11:10 -0700)] 
Merge branch 'jc/reflog-expire-lookup-commit-fix' into maint-2.46

"git reflog expire" failed to honor annotated tags when computing
reachable commits.

* jc/reflog-expire-lookup-commit-fix:
  Revert "reflog expire: don't use lookup_commit_reference_gently()"

9 months agoMerge branch 'jr/ls-files-expand-literal-doc' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:20 +0000 (11:10 -0700)] 
Merge branch 'jr/ls-files-expand-literal-doc' into maint-2.46

Docfix.

* jr/ls-files-expand-literal-doc:
  doc: fix hex code escapes in git-ls-files

9 months agoMerge branch 'jc/leakfix-mailmap' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:20 +0000 (11:10 -0700)] 
Merge branch 'jc/leakfix-mailmap' into maint-2.46

Leakfix.

* jc/leakfix-mailmap:
  mailmap: plug memory leak in read_mailmap_blob()

9 months agoMerge branch 'jc/leakfix-hashfile' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:19 +0000 (11:10 -0700)] 
Merge branch 'jc/leakfix-hashfile' into maint-2.46

Leakfix.

* jc/leakfix-hashfile:
  csum-file: introduce discard_hashfile()

9 months agoMerge branch 'jc/jl-git-no-advice-fix' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:19 +0000 (11:10 -0700)] 
Merge branch 'jc/jl-git-no-advice-fix' into maint-2.46

Remove leftover debugging cruft from a test script.

* jc/jl-git-no-advice-fix:
  t0018: remove leftover debugging cruft

9 months agoMerge branch 'tb/config-fixed-value-with-valueless-true' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:18 +0000 (11:10 -0700)] 
Merge branch 'tb/config-fixed-value-with-valueless-true' into maint-2.46

"git config --value=foo --fixed-value section.key newvalue" barfed
when the existing value in the configuration file used the
valueless true syntax, which has been corrected.

* tb/config-fixed-value-with-valueless-true:
  config.c: avoid segfault with --fixed-value and valueless config

9 months agoMerge branch 'ps/ls-remote-out-of-repo-fix' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:18 +0000 (11:10 -0700)] 
Merge branch 'ps/ls-remote-out-of-repo-fix' into maint-2.46

A recent update broke "git ls-remote" used outside a repository,
which has been corrected.

* ps/ls-remote-out-of-repo-fix:
  builtin/ls-remote: fall back to SHA1 outside of a repo

9 months agoMerge branch 'jk/osxkeychain-username-is-nul-terminated' into maint-2.46
Junio C Hamano [Mon, 26 Aug 2024 18:10:17 +0000 (11:10 -0700)] 
Merge branch 'jk/osxkeychain-username-is-nul-terminated' into maint-2.46

The credential helper to talk to OSX keychain sometimes sent
garbage bytes after the username, which has been corrected.

* jk/osxkeychain-username-is-nul-terminated:
  credential/osxkeychain: respect NUL terminator in username

10 months agoremote: plug memory leaks at early returns
René Scharfe [Fri, 23 Aug 2024 20:21:10 +0000 (22:21 +0200)] 
remote: plug memory leaks at early returns

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoThe eighth batch
Junio C Hamano [Fri, 23 Aug 2024 15:57:03 +0000 (08:57 -0700)] 
The eighth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoMerge branch 'ps/stash-keep-untrack-empty-fix'
Junio C Hamano [Fri, 23 Aug 2024 16:02:36 +0000 (09:02 -0700)] 
Merge branch 'ps/stash-keep-untrack-empty-fix'

A corner case bug in "git stash" was fixed.

* ps/stash-keep-untrack-empty-fix:
  builtin/stash: fix `--keep-index --include-untracked` with empty HEAD

10 months agoMerge branch 'ps/hash-and-ref-format-from-config'
Junio C Hamano [Fri, 23 Aug 2024 16:02:35 +0000 (09:02 -0700)] 
Merge branch 'ps/hash-and-ref-format-from-config'

The default object hash and ref backend format used to be settable
only with explicit command line option to "git init" and
environment variables, but now they can be configured in the user's
global and system wide configuration.

* ps/hash-and-ref-format-from-config:
  setup: make ref storage format configurable via config
  setup: make object format configurable via config
  setup: merge configuration of repository formats
  t0001: delete repositories when object format tests finish
  t0001: exercise initialization with ref formats more thoroughly

10 months agoMerge branch 'cp/unit-test-reftable-readwrite'
Junio C Hamano [Fri, 23 Aug 2024 16:02:35 +0000 (09:02 -0700)] 
Merge branch 'cp/unit-test-reftable-readwrite'

* cp/unit-test-reftable-readwrite:
  t-reftable-readwrite: add test for known error
  t-reftable-readwrite: use 'for' in place of infinite 'while' loops
  t-reftable-readwrite: use free_names() instead of a for loop
  t: move reftable/readwrite_test.c to the unit testing framework

10 months agoMerge branch 'ps/config-wo-the-repository'
Junio C Hamano [Fri, 23 Aug 2024 16:02:34 +0000 (09:02 -0700)] 
Merge branch 'ps/config-wo-the-repository'

Use of API functions that implicitly depend on the_repository
object in the config subsystem has been rewritten to pass a
repository object through the callchain.

* ps/config-wo-the-repository:
  config: hide functions using `the_repository` by default
  global: prepare for hiding away repo-less config functions
  config: don't depend on `the_repository` with branch conditions
  config: don't have setters depend on `the_repository`
  config: pass repo to functions that rename or copy sections
  config: pass repo to `git_die_config()`
  config: pass repo to `git_config_get_expiry_in_days()`
  config: pass repo to `git_config_get_expiry()`
  config: pass repo to `git_config_get_max_percent_split_change()`
  config: pass repo to `git_config_get_split_index()`
  config: pass repo to `git_config_get_index_threads()`
  config: expose `repo_config_clear()`
  config: introduce missing setters that take repo as parameter
  path: hide functions using `the_repository` by default
  path: stop relying on `the_repository` in `worktree_git_path()`
  path: stop relying on `the_repository` when reporting garbage
  hooks: remove implicit dependency on `the_repository`
  editor: do not rely on `the_repository` for interactive edits
  path: expose `do_git_common_path()` as `repo_common_pathv()`
  path: expose `do_git_path()` as `repo_git_pathv()`

10 months agoMerge branch 'ps/leakfixes-part-4'
Junio C Hamano [Fri, 23 Aug 2024 16:02:33 +0000 (09:02 -0700)] 
Merge branch 'ps/leakfixes-part-4'

More leak fixes.

* ps/leakfixes-part-4: (22 commits)
  builtin/diff: free symmetric diff members
  diff: free state populated via options
  builtin/log: fix leak when showing converted blob contents
  userdiff: fix leaking memory for configured diff drivers
  builtin/format-patch: fix various trivial memory leaks
  diff: fix leak when parsing invalid ignore regex option
  unpack-trees: clear index when not propagating it
  sequencer: release todo list on error paths
  merge-ort: unconditionally release attributes index
  builtin/fast-export: plug leaking tag names
  builtin/fast-export: fix leaking diff options
  builtin/fast-import: plug trivial memory leaks
  builtin/notes: fix leaking `struct notes_tree` when merging notes
  builtin/rebase: fix leaking `commit.gpgsign` value
  config: fix leaking comment character config
  submodule-config: fix leaking name entry when traversing submodules
  read-cache: fix leaking hashfile when writing index fails
  bulk-checkin: fix leaking state TODO
  object-name: fix leaking symlink paths in object context
  object-file: fix memory leak when reading corrupted headers
  ...

10 months agoreftable/stack: fix segfault when reload with reused readers fails
Patrick Steinhardt [Fri, 23 Aug 2024 14:12:57 +0000 (16:12 +0200)] 
reftable/stack: fix segfault when reload with reused readers fails

It is expected that reloading the stack fails with concurrent writers,
e.g. because a table that we just wanted to read just got compacted.
In case we decided to reuse readers this will cause a segfault though
because we unconditionally release all new readers, including the reused
ones. As those are still referenced by the current stack, the result is
that we will eventually try to dereference those already-freed readers.

Fix this bug by incrementing the refcount of reused readers temporarily.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreftable/stack: reorder swapping in the reloaded stack contents
Patrick Steinhardt [Fri, 23 Aug 2024 14:12:54 +0000 (16:12 +0200)] 
reftable/stack: reorder swapping in the reloaded stack contents

The code flow of how we swap in the reloaded stack contents is somewhat
convoluted because we switch back and forth between swapping in
different parts of the stack.

Reorder the code to simplify it. We now first close and unlink the old
tables which do not get reused before we update the stack to point to
the new stack.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreftable/reader: keep readers alive during iteration
Patrick Steinhardt [Fri, 23 Aug 2024 14:12:51 +0000 (16:12 +0200)] 
reftable/reader: keep readers alive during iteration

The lifetime of a table iterator may survive the lifetime of a reader
when the stack gets reloaded. Keep the reader from being released by
increasing its refcount while the iterator is still being used.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreftable/reader: introduce refcounting
Patrick Steinhardt [Fri, 23 Aug 2024 14:12:48 +0000 (16:12 +0200)] 
reftable/reader: introduce refcounting

It was recently reported that concurrent reads and writes may cause the
reftable backend to segfault. The root cause of this is that we do not
properly keep track of reftable readers across reloads.

Suppose that you have a reftable iterator and then decide to reload the
stack while iterating through the iterator. When the stack has been
rewritten since we have created the iterator, then we would end up
discarding a subset of readers that may still be in use by the iterator.
The consequence is that we now try to reference deallocated memory,
which of course segfaults.

One way to trigger this is in t5616, where some background maintenance
jobs have been leaking from one test into another. This leads to stack
traces like the following one:

  + git -c protocol.version=0 -C pc1 fetch --filter=blob:limit=29999 --refetch origin
  AddressSanitizer:DEADLYSIGNAL
  =================================================================
  ==657994==ERROR: AddressSanitizer: SEGV on unknown address 0x7fa0f0ec6089 (pc 0x55f23e52ddf9 bp
0x7ffe7bfa1700 sp 0x7ffe7bfa1700 T0)
  ==657994==The signal is caused by a READ memory access.
      #0 0x55f23e52ddf9 in get_var_int reftable/record.c:29
      #1 0x55f23e53295e in reftable_decode_keylen reftable/record.c:170
      #2 0x55f23e532cc0 in reftable_decode_key reftable/record.c:194
      #3 0x55f23e54e72e in block_iter_next reftable/block.c:398
      #4 0x55f23e5573dc in table_iter_next_in_block reftable/reader.c:240
      #5 0x55f23e5573dc in table_iter_next reftable/reader.c:355
      #6 0x55f23e5573dc in table_iter_next reftable/reader.c:339
      #7 0x55f23e551283 in merged_iter_advance_subiter reftable/merged.c:69
      #8 0x55f23e55169e in merged_iter_next_entry reftable/merged.c:123
      #9 0x55f23e55169e in merged_iter_next_void reftable/merged.c:172
      #10 0x55f23e537625 in reftable_iterator_next_ref reftable/generic.c:175
      #11 0x55f23e2cf9c6 in reftable_ref_iterator_advance refs/reftable-backend.c:464
      #12 0x55f23e2d996e in ref_iterator_advance refs/iterator.c:13
      #13 0x55f23e2d996e in do_for_each_ref_iterator refs/iterator.c:452
      #14 0x55f23dca6767 in get_ref_map builtin/fetch.c:623
      #15 0x55f23dca6767 in do_fetch builtin/fetch.c:1659
      #16 0x55f23dca6767 in fetch_one builtin/fetch.c:2133
      #17 0x55f23dca6767 in cmd_fetch builtin/fetch.c:2432
      #18 0x55f23dba7764 in run_builtin git.c:484
      #19 0x55f23dba7764 in handle_builtin git.c:741
      #20 0x55f23dbab61e in run_argv git.c:805
      #21 0x55f23dbab61e in cmd_main git.c:1000
      #22 0x55f23dba4781 in main common-main.c:64
      #23 0x7fa0f063fc89 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
      #24 0x7fa0f063fd44 in __libc_start_main_impl ../csu/libc-start.c:360
      #25 0x55f23dba6ad0 in _start (git+0xadfad0) (BuildId: 803b2b7f59beb03d7849fb8294a8e2145dd4aa27)

While it is somewhat awkward that the maintenance processes survive
tests in the first place, it is totally expected that reftables should
work alright with concurrent writers. Seemingly they don't.

The only underlying resource that we need to care about in this context
is the reftable reader, which is responsible for reading a single table
from disk. These readers get discarded immediately (unless reused) when
calling `reftable_stack_reload()`, which is wrong. We can only close
them once we know that there are no iterators using them anymore.

Prepare for a fix by converting the reftable readers to be refcounted.

Reported-by: Jeff King <peff@peff.net>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreftable/stack: fix broken refnames in `write_n_ref_tables()`
Patrick Steinhardt [Fri, 23 Aug 2024 14:12:46 +0000 (16:12 +0200)] 
reftable/stack: fix broken refnames in `write_n_ref_tables()`

The `write_n_ref_tables()` helper function writes N references in
separate tables. We never reset the computed name of those references
though, leading us to end up with unexpected names.

Fix this by resetting the buffer.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreftable/reader: inline `reader_close()`
Patrick Steinhardt [Fri, 23 Aug 2024 14:12:43 +0000 (16:12 +0200)] 
reftable/reader: inline `reader_close()`

Same as with the preceding commit, we also provide a `reader_close()`
function that allows the caller to close a reader without freeing it.
This is unnecessary now that all users will have an allocated version of
the reader.

Inline it into `reftable_reader_free()`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreftable/reader: inline `init_reader()`
Patrick Steinhardt [Fri, 23 Aug 2024 14:12:37 +0000 (16:12 +0200)] 
reftable/reader: inline `init_reader()`

Most users use an allocated version of the `reftable_reader`, except for
some tests. We are about to convert the reader to become refcounted
though, and providing the ability to keep a reader on the stack makes
this conversion harder than necessary.

Update the tests to use `reftable_reader_new()` instead to prepare for
this change.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreftable/reader: rename `reftable_new_reader()`
Patrick Steinhardt [Fri, 23 Aug 2024 14:12:34 +0000 (16:12 +0200)] 
reftable/reader: rename `reftable_new_reader()`

Rename the `reftable_new_reader()` function to `reftable_reader_new()`
to match our coding guidelines.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreftable/stack: inline `stack_compact_range_stats()`
Patrick Steinhardt [Fri, 23 Aug 2024 14:12:32 +0000 (16:12 +0200)] 
reftable/stack: inline `stack_compact_range_stats()`

The only difference between `stack_compact_range_stats()` and
`stack_compact_range()` is that the former updates stats on failure,
whereas the latter doesn't. There are no callers anymore that do not
want their stats updated though, making the indirection unnecessary.

Inline the stat updates into `stack_compact_range()`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoreftable/blocksource: drop malloc block source
Patrick Steinhardt [Fri, 23 Aug 2024 14:12:29 +0000 (16:12 +0200)] 
reftable/blocksource: drop malloc block source

The reftable blocksource provides a generic interface to read blocks via
different sources, e.g. from disk or from memory. One of the block
sources is the malloc block source, which can in theory read data from
memory. We nowadays also have a strbuf block source though, which
provides essentially the same functionality with better ergonomics.

Adapt the only remaining user of the malloc block source in our tests
to use the strbuf block source, instead, and remove the now-unused
malloc block source.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agodoc: replace 3 dash with correct 2 dash in git-config(1)
Celeste Liu [Fri, 23 Aug 2024 08:21:08 +0000 (16:21 +0800)] 
doc: replace 3 dash with correct 2 dash in git-config(1)

Commit 4e51389000 (builtin/config: introduce "get" subcommand, 2024-05-06)
introduced this typo.  It uses 3 dashes for regexp argument instead of
correct 2 dashes.

Signed-off-by: Celeste Liu <CoelacanthusHex@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agosend-pack: add new tracing regions for push
Calvin Wan [Thu, 22 Aug 2024 21:57:47 +0000 (14:57 -0700)] 
send-pack: add new tracing regions for push

At $DAYJOB we experienced some slow pushes and needed additional trace
data to diagnose them.

Add trace2 regions for various sections of send_pack().

Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agofetch: add top-level trace2 regions
Josh Steadmon [Thu, 22 Aug 2024 21:57:46 +0000 (14:57 -0700)] 
fetch: add top-level trace2 regions

At $DAYJOB we experienced some slow fetch operations and needed some
additional data to help diagnose the issue.

Add top-level trace2 regions for the various modes of operation of
`git-fetch`. None of these regions are in recursive code, so any
enclosed trace messages should only see their nesting level increase by
one.

Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agotrace2: implement trace2_printf() for event target
Josh Steadmon [Thu, 22 Aug 2024 21:57:45 +0000 (14:57 -0700)] 
trace2: implement trace2_printf() for event target

The trace2 event target does not have an implementation for
trace2_printf(). While the event target is for structured events, and
trace2_printf() is for unstructured, human-readable messages, it may
still be useful to wrap these unstructured messages in a structured JSON
object. Among other things, it may reduce confusion when manually
debugging using event trace data.

Add a simple implementation for the event target that wraps
trace2_printf() messages in a minimal JSON object. Document this in
Documentation/technical/api-trace2.txt, and bump the event format
version since we're adding a new event type.

Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>