]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
11 months agoMerge branch 'sp/mailmap'
Junio C Hamano [Tue, 10 Sep 2024 20:16:43 +0000 (13:16 -0700)] 
Merge branch 'sp/mailmap'

Update to a mailmap entry.

* sp/mailmap:
  .mailmap document current address.

11 months agoMerge branch 'ps/declare-pack-redundamt-dead'
Junio C Hamano [Tue, 10 Sep 2024 20:16:43 +0000 (13:16 -0700)] 
Merge branch 'ps/declare-pack-redundamt-dead'

"git pack-redundant" has been marked for removal in Git 3.0.

* ps/declare-pack-redundamt-dead:
  Documentation/BreakingChanges: announce removal of git-pack-redundant(1)

11 months agoMerge branch 'ah/mergetols-vscode'
Junio C Hamano [Tue, 10 Sep 2024 20:16:42 +0000 (13:16 -0700)] 
Merge branch 'ah/mergetols-vscode'

"git mergetool" learned to use VSCode as a merge backend.

* ah/mergetols-vscode:
  mergetools: vscode: new tool

11 months agoMerge branch 'rj/compat-terminal-unused-fix'
Junio C Hamano [Tue, 10 Sep 2024 20:16:41 +0000 (13:16 -0700)] 
Merge branch 'rj/compat-terminal-unused-fix'

Build fix.

* rj/compat-terminal-unused-fix:
  compat/terminal: mark parameter of git_terminal_prompt() UNUSED

11 months agoMerge branch 'jk/free-commit-buffer-of-skipped-commits'
Junio C Hamano [Tue, 10 Sep 2024 20:16:41 +0000 (13:16 -0700)] 
Merge branch 'jk/free-commit-buffer-of-skipped-commits'

The code forgot to discard unnecessary in-core commit buffer data
for commits that "git log --skip=<number>" traversed but omitted
from the output, which has been corrected.

* jk/free-commit-buffer-of-skipped-commits:
  revision: free commit buffers for skipped commits

11 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>
11 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

11 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

11 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

11 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

11 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

11 months ago.mailmap document current address.
Stephen P. Smith [Fri, 6 Sep 2024 15:30:02 +0000 (08:30 -0700)] 
.mailmap document current address.

Cox Communications no longer supports email and transfered accounts to
yahoo. I closed the account at yahoo since I use gmail.com.

Signed-off-by: Stephen P. Smith <ishchis2@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agoDocumentation/BreakingChanges: announce removal of git-pack-redundant(1)
Patrick Steinhardt [Mon, 2 Sep 2024 08:13:00 +0000 (10:13 +0200)] 
Documentation/BreakingChanges: announce removal of git-pack-redundant(1)

The git-pack-redundant(1) command is already in the process of being
phased out and dies unless the user passes the `--i-still-use-this` flag
since 4406522b76 (pack-redundant: escalate deprecation warning to an
error, 2023-03-23). We haven't heard any complaints, so let's announce
the removal of this command in Git 3.0 in our breaking changes document.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 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>
11 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

11 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

11 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

11 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

11 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)

11 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

11 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

11 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)

11 months agomergetools: vscode: new tool
Alex Henrie [Mon, 2 Sep 2024 02:59:14 +0000 (20:59 -0600)] 
mergetools: vscode: new tool

VSCode has supported three-way merges since 2022, see
<https://github.com/microsoft/vscode/issues/5770#issuecomment-1188658476>.

Although the program binary is located at /usr/bin/code, name the
mergetool "vscode" because the word "code" is too generic and would lead
to confusion. The name "vscode" also matches Git's existing
contrib/vscode directory.

On Windows, VSCode adds the directory that contains code.cmd to %PATH%,
so there is no need to invoke mergetool_find_win32_cmd to search for the
program.

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agocompat/terminal: mark parameter of git_terminal_prompt() UNUSED
Ramsay Jones [Sat, 31 Aug 2024 14:58:56 +0000 (15:58 +0100)] 
compat/terminal: mark parameter of git_terminal_prompt() UNUSED

If neither HAVE_DEV_TTY nor GIT_WINDOWS_NATIVE is set, the fallback
code calls the system getpass(). This unfortunately ignores the "echo"
boolean parameter, as we have no way to implement that functionality.
But we still have to keep the unused parameter, since our interface
has to match the other implementations.

Co-authored-by: Jeff King <peff@peff.net>
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 months agorevision: free commit buffers for skipped commits
Jeff King [Fri, 30 Aug 2024 20:53:31 +0000 (16:53 -0400)] 
revision: free commit buffers for skipped commits

In git-log we leave the save_commit_buffer flag set to "1", which tells
the commit parsing code to store the object content after it has parsed
it to find parents, tree, etc. That lets us reuse the contents for
pretty-printing the commit in the output. And then after printing each
commit, we call free_commit_buffer(), since we don't need it anymore.

But some options may cause us to traverse commits which are not part of
the output. And so git-log does not see them at all, and doesn't free
them. One such case is something like:

  git log -n 1000 --skip=1000000

which will churn through a million commits, before showing only a
thousand. We loop through these inside get_revision(), without freeing
the contents. As a result, we end up storing the object data for those
million commits simultaneously.

We should free the stored buffers (if any) for those commits as we skip
over them, which is what this patch does. Running the above command in
linux.git drops the peak heap usage from ~1.1GB to ~200MB, according to
valgrind/massif. (I thought we might get an even bigger improvement, but
the remaining memory is going to commit/tree structs, which we do hold
on to forever).

Note that this problem doesn't occur if:

  - you're running a git-rev-list without a --format parameter; it turns
    off save_commit_buffer by default, since it only output the object
    id

  - you've built a commit-graph file, since in that case we'd use the
    optimized graph data instead of the initial parse, and then do a
    lazy parse for commits we're actually going to output

There are probably some other option combinations that can likewise
end up with useless stored commit buffers. For example, if you ask for
"foo..bar", then we'll have to walk down to the merge base, and
everything on the "foo" side won't be shown. Tuning the "save" behavior
to handle that might be tricky (I guess maybe drop buffers for anything
we mark as UNINTERESTING?). And in the long run, the right solution here
is probably to make sure the commit-graph is built (since it fixes the
memory problem _and_ drastically reduces CPU usage).

But since this "--skip" case is an easy one-liner, it's worth fixing in
the meantime. It should be OK to make this call even if there is no
saved buffer (e.g., because save_commit_buffer=0, or because a
commit-graph was used), since it's O(1) to look up the buffer and is a
noop if it isn't present. I verified by running the above command after
"git commit-graph write --reachable", and it takes the same time with
and without this patch.

Reported-by: Yuri Karnilaev <karnilaev@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
11 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>
11 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>
11 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>
11 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>
11 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

11 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>
11 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

11 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

11 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

11 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>
11 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

11 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

11 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

11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 months agoSync with 'maint'
Junio C Hamano [Mon, 26 Aug 2024 18:36:13 +0000 (11:36 -0700)] 
Sync with 'maint'

11 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>
11 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

11 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

11 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

11 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

11 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()

11 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

11 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

11 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()`

11 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>
11 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

11 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

11 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

11 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

11 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()

11 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

11 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

11 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()"

11 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

11 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()

11 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()

11 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

11 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

11 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

11 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

11 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>
11 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>
11 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

11 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

11 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

11 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()`

11 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
  ...

11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 months agodocs: explain the order of output in the batched mode of git-cat-file(1)
ahmed akef [Thu, 22 Aug 2024 19:50:31 +0000 (19:50 +0000)] 
docs: explain the order of output in the batched mode of git-cat-file(1)

The batched mode of git-cat-file(1) reads multiple objects from stdin
and prints their respective contents to stdout.
The order in which those objects are printed is not documented
and may not be immediately obvious to the user.
Document it.

Signed-off-by: ahmed akef <aemed.akef.1@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>