]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
9 months agoMerge branch 'ps/platform-compat-fixes'
Taylor Blau [Fri, 1 Nov 2024 16:53:16 +0000 (12:53 -0400)] 
Merge branch 'ps/platform-compat-fixes'

Various platform compatibility fixes split out of the larger effort
to use Meson as the primary build tool.

* ps/platform-compat-fixes:
  t6006: fix prereq handling with `test_format ()`
  http: fix build error on FreeBSD
  builtin/credential-cache: fix missing parameter for stub function
  t7300: work around platform-specific behaviour with long paths on MinGW
  t5500, t5601: skip tests which exercise paths with '[::1]' on Cygwin
  t3404: work around platform-specific behaviour on macOS 10.15
  t1401: make invocation of tar(1) work with Win32-provided one
  t/lib-gpg: fix setup of GNUPGHOME in MinGW
  t/lib-gitweb: test against the build version of gitweb
  t/test-lib: wire up NO_ICONV prerequisite
  t/test-lib: fix quoting of TEST_RESULTS_SAN_FILE

9 months agoMerge branch 'jc/breaking-changes-early-adopter-option'
Taylor Blau [Fri, 1 Nov 2024 16:53:14 +0000 (12:53 -0400)] 
Merge branch 'jc/breaking-changes-early-adopter-option'

Describe the policy to introduce breaking changes.

* jc/breaking-changes-early-adopter-option:
  BreakingChanges: early adopter option

9 months agoThe sixth batch
Taylor Blau [Wed, 30 Oct 2024 17:36:44 +0000 (13:36 -0400)] 
The sixth batch

9 months agoMerge branch 'sk/t7011-cleanup'
Taylor Blau [Wed, 30 Oct 2024 17:08:07 +0000 (13:08 -0400)] 
Merge branch 'sk/t7011-cleanup'

Test cleanup.

* sk/t7011-cleanup:
  t7011: ensure no whitespace after redirect

9 months agoMerge branch 'co/t6050-pipefix'
Taylor Blau [Wed, 30 Oct 2024 17:08:06 +0000 (13:08 -0400)] 
Merge branch 'co/t6050-pipefix'

Avoid losing exit status by having Git command being tested on the
upstream side of a pipe.

* co/t6050-pipefix:
  t6050: avoid pipes with upstream Git commands

9 months agoMerge branch 'ks/t4205-fixup'
Taylor Blau [Wed, 30 Oct 2024 17:08:05 +0000 (13:08 -0400)] 
Merge branch 'ks/t4205-fixup'

Testfix.

* ks/t4205-fixup:
  t4205: fix typo in 'NUL termination with --stat'

9 months agoMerge branch 'kh/submitting-patches'
Taylor Blau [Wed, 30 Oct 2024 17:08:04 +0000 (13:08 -0400)] 
Merge branch 'kh/submitting-patches'

Docfix.

* kh/submitting-patches:
  SubmittingPatches: tags -> trailers

9 months agoMerge branch 'ps/ref-filter-sort'
Taylor Blau [Wed, 30 Oct 2024 17:08:02 +0000 (13:08 -0400)] 
Merge branch 'ps/ref-filter-sort'

Teaches the ref-filter machinery to recognize and avoid cases where
sorting would be redundant.

* ps/ref-filter-sort:
  ref-filter: format iteratively with lexicographic refname sorting

9 months agoMerge branch 'ps/reftable-strbuf'
Taylor Blau [Wed, 30 Oct 2024 17:08:01 +0000 (13:08 -0400)] 
Merge branch 'ps/reftable-strbuf'

Implements a new reftable-specific strbuf replacement to reduce
reftable's dependency on Git-specific data structures.

* ps/reftable-strbuf:
  reftable: handle trivial `reftable_buf` errors
  reftable/stack: adapt `stack_filename()` to handle allocation failures
  reftable/record: adapt `reftable_record_key()` to handle allocation failures
  reftable/stack: adapt `format_name()` to handle allocation failures
  t/unit-tests: check for `reftable_buf` allocation errors
  reftable/blocksource: adapt interface name
  reftable: convert from `strbuf` to `reftable_buf`
  reftable/basics: provide new `reftable_buf` interface
  reftable: stop using `strbuf_addf()`
  reftable: stop using `strbuf_addbuf()`

9 months agot6006: fix prereq handling with `test_format ()`
Patrick Steinhardt [Mon, 28 Oct 2024 05:14:51 +0000 (06:14 +0100)] 
t6006: fix prereq handling with `test_format ()`

In df383b5842 (t/test-lib: wire up NO_ICONV prerequisite, 2024-10-16) we
have introduced a new NO_ICONV prerequisite that makes us skip tests in
case Git is not compiled with support for iconv. This change subtly
broke t6006: while the test suite still passes, some of its tests won't
execute because they run into an error.

    ./t6006-rev-list-format.sh: line 92: test_expect_%e: command not found

The broken tests use `test_format ()`, and the mentioned commit simply
prepended the new prerequisite to its arguments. But that does not work,
as the function is not aware of prereqs at all and will now treat all of
its arguments incorrectly.

Fix this by making the function aware of prereqs by accepting an
optional fourth argument. Adapt the callsites accordingly.

Reported-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agoThe fifth batch
Taylor Blau [Fri, 25 Oct 2024 18:11:13 +0000 (14:11 -0400)] 
The fifth batch

9 months agoMerge branch 'wm/shortlog-hash'
Taylor Blau [Fri, 25 Oct 2024 18:02:49 +0000 (14:02 -0400)] 
Merge branch 'wm/shortlog-hash'

Teaches 'shortlog' to explicitly use SHA-1 when operating outside of
a repository.

* wm/shortlog-hash:
  builtin/shortlog: explicitly set hash algo when there is no repo

9 months agoMerge branch 'sk/msvc-warnings'
Taylor Blau [Fri, 25 Oct 2024 18:02:44 +0000 (14:02 -0400)] 
Merge branch 'sk/msvc-warnings'

Fixes compile time warnings with 64-bit MSVC.

* sk/msvc-warnings:
  mingw.c: Fix complier warnings for a 64 bit msvc

9 months agoMerge branch 'jc/a-commands-without-the-repo'
Taylor Blau [Fri, 25 Oct 2024 18:02:36 +0000 (14:02 -0400)] 
Merge branch 'jc/a-commands-without-the-repo'

Commands that can also work outside Git have learned to take the
repository instance "repo" when we know we are in a repository, and
NULL when we are not, in a parameter.  The uses of the_repository
variable in a few of them have been removed using the new calling
convention.

* jc/a-commands-without-the-repo:
  archive: remove the_repository global variable
  annotate: remove usage of the_repository global
  git: pass in repo to builtin based on setup_git_directory_gently

9 months agoMerge branch 'pb/clar-build-fix'
Taylor Blau [Fri, 25 Oct 2024 18:02:25 +0000 (14:02 -0400)] 
Merge branch 'pb/clar-build-fix'

Build fix.

* pb/clar-build-fix:
  Makefile: fix dependency for $(UNIT_TEST_DIR)/clar/clar.o

9 months agoMerge branch 'bf/t-readme-mention-reftable'
Taylor Blau [Fri, 25 Oct 2024 18:02:21 +0000 (14:02 -0400)] 
Merge branch 'bf/t-readme-mention-reftable'

Doc update.

* bf/t-readme-mention-reftable:
  t/README: add missing value for GIT_TEST_DEFAULT_REF_FORMAT

9 months agoMerge branch 'ak/typofix'
Taylor Blau [Fri, 25 Oct 2024 18:02:08 +0000 (14:02 -0400)] 
Merge branch 'ak/typofix'

More typofixes.

* ak/typofix:
  t: fix typos

9 months agoMerge branch 'ak/typofixes'
Taylor Blau [Fri, 25 Oct 2024 18:02:04 +0000 (14:02 -0400)] 
Merge branch 'ak/typofixes'

Typofixes.

* ak/typofixes:
  t: fix typos
  t/helper: fix a typo
  t/perf: fix typos
  t/unit-tests: fix typos
  contrib: fix typos
  compat: fix typos

9 months agoMerge branch 'ps/ci-gitlab-windows'
Taylor Blau [Fri, 25 Oct 2024 18:01:21 +0000 (14:01 -0400)] 
Merge branch 'ps/ci-gitlab-windows'

Enable Windows-based CI in GitLab.

* ps/ci-gitlab-windows:
  gitlab-ci: exercise Git on Windows
  gitlab-ci: introduce stages and dependencies
  ci: handle Windows-based CI jobs in GitLab CI
  ci: create script to set up Git for Windows SDK
  t7300: work around platform-specific behaviour with long paths on MinGW

9 months agoMerge branch 'db/submodule-fetch-with-remote-name-fix'
Taylor Blau [Fri, 25 Oct 2024 18:01:09 +0000 (14:01 -0400)] 
Merge branch 'db/submodule-fetch-with-remote-name-fix'

A "git fetch" from the superproject going down to a submodule used
a wrong remote when the default remote names are set differently
between them.

* db/submodule-fetch-with-remote-name-fix:
  submodule: correct remote name with fetch

9 months agot7011: ensure no whitespace after redirect
Seyi Kuforiji [Sat, 19 Oct 2024 16:34:38 +0000 (17:34 +0100)] 
t7011: ensure no whitespace after redirect

This change updates the script to conform to the coding standards
outlined in the Git project's documentation. According to the guidelines
in Documentation/CodingGuidelines under "Redirection operators", there
should be no whitespace after redirection operators.

Signed-off-by: Seyi Kuforiji <kuforiji98@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agoThe third batch
Taylor Blau [Tue, 22 Oct 2024 18:43:46 +0000 (14:43 -0400)] 
The third batch

Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agoMerge branch 'cw/worktree-relative'
Taylor Blau [Tue, 22 Oct 2024 18:40:39 +0000 (14:40 -0400)] 
Merge branch 'cw/worktree-relative'

An extra worktree attached to a repository points at each other to
allow finding the repository from the worktree and vice versa
possible.  Turn this linkage to relative paths.

* cw/worktree-relative:
  worktree: add test for path handling in linked worktrees
  worktree: link worktrees with relative paths
  worktree: refactor infer_backlink() to use *strbuf
  worktree: repair copied repository and linked worktrees

9 months agoMerge branch 'ps/cache-tree-w-broken-index-entry'
Taylor Blau [Tue, 22 Oct 2024 18:40:38 +0000 (14:40 -0400)] 
Merge branch 'ps/cache-tree-w-broken-index-entry'

Fail gracefully instead of crashing when attempting to write the
contents of a corrupt in-core index as a tree object.

* ps/cache-tree-w-broken-index-entry:
  unpack-trees: detect mismatching number of cache-tree/index entries
  cache-tree: detect mismatching number of index entries
  cache-tree: refactor verification to return error codes

9 months agot6050: avoid pipes with upstream Git commands
Chizoba ODINAKA [Tue, 22 Oct 2024 01:27:01 +0000 (02:27 +0100)] 
t6050: avoid pipes with upstream Git commands

In pipes, the exit code of a chain of commands is determined by
the final command. In order not to miss the exit code of a failed
Git command, avoid pipes instead write output of Git commands
into a file.
For better debugging experience, instances of "grep" were changed
to "test_grep". "test_grep" provides more context in case of a
failed "grep".

Signed-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agot4205: fix typo in 'NUL termination with --stat'
Kousik Sanagavarapu [Sun, 20 Oct 2024 19:18:47 +0000 (00:48 +0530)] 
t4205: fix typo in 'NUL termination with --stat'

Correct "expected" to rightly terminate with NUL ie '\0' instead of '0'
which may have been typoed.

We didn't notice this before because the test is run with
"test_expect_failure", meaning the test would have been marked broken
anyways.

Signed-off-by: Kousik Sanagavarapu <five231003@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agoSubmittingPatches: tags -> trailers
Kristoffer Haugsbakk [Sun, 20 Oct 2024 16:57:01 +0000 (18:57 +0200)] 
SubmittingPatches: tags -> trailers

“Trailer” is the preferred nomenclature in this project.  Also add a
definite article where I think it makes sense.

As we can see the rest of the document already prefers this term.  This
just gets rid of the last stragglers.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agoref-filter: format iteratively with lexicographic refname sorting
Patrick Steinhardt [Mon, 21 Oct 2024 11:33:23 +0000 (13:33 +0200)] 
ref-filter: format iteratively with lexicographic refname sorting

In bd98f9774e (ref-filter.c: filter & format refs in the same callback,
2023-11-14), we have introduced logic into the ref-filter subsystem that
determines whether or not we can output references iteratively instead
of first collecting all references, post-processing them and printing
them once done. This has the advantage that we don't have to store all
refs in memory and, when used with e.g. `--count=1`, that we don't have
to read all refs in the first place.

One restriction we have in place for that is that caller must not ask
for sorted refs, because there is no way to sort the refs without first
reading them all into an array. So the benefits can only be reaped when
explicitly asking for output not to be sorted.

But there is one exception here where we _can_ get away with sorting
refs while streaming: ref backends sort references returned by their
iterators in lexicographic order. So if the following conditions are all
true we can do iterative streaming:

  - There must be at most a single sorting specification, as otherwise
    we're not using plain lexicographic ordering.

  - The sorting specification must use the "refname".

  - The sorting specification must not be using any flags, like
    case-insensitive sorting.

Now the resulting logic does feel quite fragile overall, which makes me
a bit uneasy. But after thinking about this for a while I couldn't find
any obvious gaps in my reasoning. Furthermore, given that lexicographic
sorting order is the default in git-for-each-ref(1), this is likely to
benefit a whole lot of usecases out there.

The following benchmark executes git-for-each-ref(1) in a crafted repo
with 1 million references:

  Benchmark 1: git for-each-ref (revision = HEAD~)
    Time (mean ± σ):      6.756 s ±  0.014 s    [User: 3.004 s, System: 3.541 s]
    Range (min … max):    6.738 s …  6.784 s    10 runs

  Benchmark 2: git for-each-ref (revision = HEAD)
    Time (mean ± σ):      6.479 s ±  0.017 s    [User: 2.858 s, System: 3.422 s]
    Range (min … max):    6.450 s …  6.519 s    10 runs

  Summary
    git for-each-ref (revision = HEAD)
      1.04 ± 0.00 times faster than git for-each-ref (revision = HEAD~)

The change results in a slight performance improvement, but nothing that
would really stand out. Something that cannot be seen in the benchmark
though is peak memory usage, which went from 404.5MB to 68.96kB.

A more interesting benchmark is printing a single referenence with
`--count=1`:

  Benchmark 1: git for-each-ref --count=1 (revision = HEAD~)
    Time (mean ± σ):      6.655 s ±  0.018 s    [User: 2.865 s, System: 3.576 s]
    Range (min … max):    6.630 s …  6.680 s    10 runs

  Benchmark 2: git for-each-ref --count=1 (revision = HEAD)
    Time (mean ± σ):       8.6 ms ±   1.3 ms    [User: 2.3 ms, System: 6.1 ms]
    Range (min … max):     6.7 ms …  14.4 ms    266 runs

  Summary
    git git for-each-ref --count=1 (revision = HEAD)
    770.58 ± 116.19 times faster than git for-each-ref --count=1 (revision = HEAD~)

Whereas we scaled with the number of references before, we now print the
first reference and exit immediately, which provides a massive win.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agoThe third batch
Taylor Blau [Fri, 18 Oct 2024 18:01:50 +0000 (14:01 -0400)] 
The third batch

Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agoMerge branch 'ps/maintenance-start-crash-fix'
Taylor Blau [Fri, 18 Oct 2024 17:56:26 +0000 (13:56 -0400)] 
Merge branch 'ps/maintenance-start-crash-fix'

"git maintenance start" crashed due to an uninitialized variable
reference, which has been corrected.

* ps/maintenance-start-crash-fix:
  builtin/gc: fix crash when running `git maintenance start`

9 months agoMerge branch 'xx/protocol-v2-doc-markup-fix'
Taylor Blau [Fri, 18 Oct 2024 17:56:25 +0000 (13:56 -0400)] 
Merge branch 'xx/protocol-v2-doc-markup-fix'

Docfix.

* xx/protocol-v2-doc-markup-fix:
  Documentation/gitprotocol-v2.txt: fix a slight inconsistency in format

9 months agoMerge branch 'tc/bundle-uri-leakfix'
Taylor Blau [Fri, 18 Oct 2024 17:56:24 +0000 (13:56 -0400)] 
Merge branch 'tc/bundle-uri-leakfix'

Leakfix.

* tc/bundle-uri-leakfix:
  bundle-uri: plug leak in unbundle_from_file()

9 months agoMerge branch 'kh/checkout-ignore-other-docfix'
Taylor Blau [Fri, 18 Oct 2024 17:56:24 +0000 (13:56 -0400)] 
Merge branch 'kh/checkout-ignore-other-docfix'

Doc updates.

* kh/checkout-ignore-other-docfix:
  checkout: refer to other-worktree branch, not ref

9 months agoMerge branch 'kh/merge-tree-doc'
Taylor Blau [Fri, 18 Oct 2024 17:56:23 +0000 (13:56 -0400)] 
Merge branch 'kh/merge-tree-doc'

Docfix.

* kh/merge-tree-doc:
  doc: merge-tree: improve example script

9 months agoMerge branch 'ng/rebase-merges-branch-name-as-label'
Taylor Blau [Fri, 18 Oct 2024 17:56:22 +0000 (13:56 -0400)] 
Merge branch 'ng/rebase-merges-branch-name-as-label'

"git rebase --rebase-merges" now uses branch names as labels when
able.

* ng/rebase-merges-branch-name-as-label:
  rebase-merges: try and use branch names as labels
  rebase-update-refs: extract load_branch_decorations
  load_branch_decorations: fix memory leak with non-static filters

9 months agoMerge branch 'kn/loose-object-layer-wo-global-hash'
Taylor Blau [Fri, 18 Oct 2024 17:56:22 +0000 (13:56 -0400)] 
Merge branch 'kn/loose-object-layer-wo-global-hash'

Code clean-up.

* kn/loose-object-layer-wo-global-hash:
  loose: don't rely on repository global state

9 months agoMerge branch 'jc/doc-refspec-syntax'
Taylor Blau [Fri, 18 Oct 2024 17:56:20 +0000 (13:56 -0400)] 
Merge branch 'jc/doc-refspec-syntax'

Doc updates.

* jc/doc-refspec-syntax:
  doc: clarify <src> in refspec syntax

9 months agoMerge branch 'aa/t7300-modernize'
Taylor Blau [Fri, 18 Oct 2024 17:54:43 +0000 (13:54 -0400)] 
Merge branch 'aa/t7300-modernize'

Test modernization.

* aa/t7300-modernize:
  t7300-clean.sh: use test_path_* helper functions for error logging

9 months agoreftable: handle trivial `reftable_buf` errors
Patrick Steinhardt [Thu, 17 Oct 2024 04:54:16 +0000 (06:54 +0200)] 
reftable: handle trivial `reftable_buf` errors

Convert the reftable library such that we handle failures with the
new `reftable_buf` interfaces.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agoreftable/stack: adapt `stack_filename()` to handle allocation failures
Patrick Steinhardt [Thu, 17 Oct 2024 04:54:13 +0000 (06:54 +0200)] 
reftable/stack: adapt `stack_filename()` to handle allocation failures

The `stack_filename()` function cannot pass any errors to the caller as it
has a `void` return type. Adapt it and its callers such that we can
handle errors and start handling allocation failures.

There are two interesting edge cases in `reftable_stack_destroy()` and
`reftable_addition_close()`. Both of these are trying to tear down their
respective structures, and while doing so they try to unlink some of the
tables they have been keeping alive. Any earlier attempts to do that may
fail on Windows because it keeps us from deleting such tables while they
are still open, and thus we re-try on close. It's okay and even expected
that this can fail when the tables are still open by another process, so
we handle the allocation failures gracefully and just skip over any file
whose name we couldn't figure out.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agoreftable/record: adapt `reftable_record_key()` to handle allocation failures
Patrick Steinhardt [Thu, 17 Oct 2024 04:54:08 +0000 (06:54 +0200)] 
reftable/record: adapt `reftable_record_key()` to handle allocation failures

The `reftable_record_key()` function cannot pass any errors to the
caller as it has a `void` return type. Adapt it and its callers such
that we can handle errors and start handling allocation failures.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agoreftable/stack: adapt `format_name()` to handle allocation failures
Patrick Steinhardt [Thu, 17 Oct 2024 04:54:05 +0000 (06:54 +0200)] 
reftable/stack: adapt `format_name()` to handle allocation failures

The `format_name()` function cannot pass any errors to the caller as it
has a `void` return type. Adapt it and its callers such that we can
handle errors and start handling allocation failures.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agot/unit-tests: check for `reftable_buf` allocation errors
Patrick Steinhardt [Thu, 17 Oct 2024 04:54:02 +0000 (06:54 +0200)] 
t/unit-tests: check for `reftable_buf` allocation errors

Adapt our unit tests to check for allocations errors.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agoreftable/blocksource: adapt interface name
Patrick Steinhardt [Thu, 17 Oct 2024 04:53:59 +0000 (06:53 +0200)] 
reftable/blocksource: adapt interface name

Adapt the name of the `strbuf` block source to no longer relate to this
interface, but instead to the `reftable_buf` interface.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agoreftable: convert from `strbuf` to `reftable_buf`
Patrick Steinhardt [Thu, 17 Oct 2024 04:53:56 +0000 (06:53 +0200)] 
reftable: convert from `strbuf` to `reftable_buf`

Convert the reftable library to use the `reftable_buf` interface instead
of the `strbuf` interface. This is mostly a mechanical change via sed(1)
with some manual fixes where functions for `strbuf` and `reftable_buf`
differ. The converted code does not yet handle allocation failures. This
will be handled in subsequent commits.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agoreftable/basics: provide new `reftable_buf` interface
Patrick Steinhardt [Thu, 17 Oct 2024 04:53:50 +0000 (06:53 +0200)] 
reftable/basics: provide new `reftable_buf` interface

Implement a new `reftable_buf` interface that will replace Git's own
`strbuf` interface. This is done due to three reasons:

  - The `strbuf` interfaces do not handle memory allocation failures and
    instead causes us to die. This is okay in the context of Git, but is
    not in the context of the reftable library, which is supposed to be
    usable by third-party applications.

  - The `strbuf` interface is quite deeply tied into Git, which makes it
    hard to use the reftable library as a standalone library. Any
    dependent would have to carefully extract the relevant parts of it
    to make things work, which is not all that sensible.

  - The `strbuf` interface does not use the pluggable allocators that
    can be set up via `reftable_set_alloc()`.

So we have good reasons to use our own type, and the implementation is
rather trivial. Implement our own type. Conversion of the reftable
library will be handled in subsequent commits.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agoreftable: stop using `strbuf_addf()`
Patrick Steinhardt [Thu, 17 Oct 2024 04:53:47 +0000 (06:53 +0200)] 
reftable: stop using `strbuf_addf()`

We're about to introduce our own `reftable_buf` type to replace
`strbuf`. One function we'll have to convert is `strbuf_addf()`, which
is used in a handful of places. This function uses `snprintf()`
internally, which makes porting it a bit more involved:

  - It is not available on all platforms.

  - Some platforms like Windows have broken implementations.

So by using `snprintf()` we'd also push the burden on downstream users
of the reftable library to make available a properly working version of
it.

Most callsites of `strbuf_addf()` are trivial to convert to not using
it. We do end up using `snprintf()` in our unit tests, but that isn't
much of a problem for downstream users of the reftable library.

While at it, remove a useless call to `strbuf_reset()` in
`t_reftable_stack_auto_compaction_with_locked_tables()`. We don't write
to the buffer before this and initialize it with `STRBUF_INIT`, so there
is no need to reset anything.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agoreftable: stop using `strbuf_addbuf()`
Patrick Steinhardt [Thu, 17 Oct 2024 04:53:45 +0000 (06:53 +0200)] 
reftable: stop using `strbuf_addbuf()`

We're about to introduce our own `reftable_buf` type to replace
`strbuf`. Get rid of the seldomly-used `strbuf_addbuf()` function such
that we have to reimplement one less function.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agot: fix typos
Andrew Kreimer [Thu, 17 Oct 2024 11:28:35 +0000 (14:28 +0300)] 
t: fix typos

Fix typos in documentation, comments, etc.

Via codespell.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agobuiltin/shortlog: explicitly set hash algo when there is no repo
Wolfgang Müller [Thu, 17 Oct 2024 09:35:28 +0000 (11:35 +0200)] 
builtin/shortlog: explicitly set hash algo when there is no repo

Whilst git-shortlog(1) does not explicitly need any repository
information when run without reference to one, it still parses some of
its arguments with parse_revision_opt() which assumes that the hash
algorithm is set. However, in c8aed5e8da (repository: stop setting SHA1
as the default object hash, 2024-05-07) we stopped setting up a default
hash algorithm and instead require commands to set it up explicitly.

This was done for most other commands like in ab274909d4 (builtin/diff:
explicitly set hash algo when there is no repo, 2024-05-07) but was
missed for builtin/shortlog, making git-shortlog(1) segfault outside of
a repository when given arguments like --author that trigger a call to
parse_revision_opt().

Fix this for now by explicitly setting the hash algorithm to SHA1. Also
add a regression test for the segfault.

Thanks-to: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Wolfgang Müller <wolf@oriole.systems>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agomingw.c: Fix complier warnings for a 64 bit msvc
Sören Krecker [Thu, 17 Oct 2024 17:18:20 +0000 (19:18 +0200)] 
mingw.c: Fix complier warnings for a 64 bit msvc

Remove some complier warnings from msvc in compat/mingw.c for value
truncation from 64 bit to 32 bit integers.

Compiling compat/mingw.c under a 64 bit version of msvc produces
warnings. An "int" is 32 bit, and ssize_t or size_t should be 64 bit
long. Prepare compat/vcbuild/include/unistd.h to have a 64 bit type
_ssize_t, when _WIN64 is defined and 32 bit otherwise.

Further down in this include file, as before, ssize_t is defined as
_ssize_t, if needed.

Use size_t instead of int for all variables that hold the result of
strlen() or wcslen() (which cannot be negative).

Use ssize_t to hold the return value of read().

Signed-off-by: Sören Krecker <soekkle@freenet.de>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agohttp: fix build error on FreeBSD
Patrick Steinhardt [Wed, 16 Oct 2024 08:13:18 +0000 (10:13 +0200)] 
http: fix build error on FreeBSD

The `result` parameter passed to `http_request_reauth()` may either
point to a `struct strbuf` or a `FILE *`, where the `target` parameter
tells us which of either it actually is. To accommodate for both types
the pointer is a `void *`, which we then pass directly to functions
without doing a cast.

This is fine on most platforms, but it breaks on FreeBSD because
`fileno()` is implemented as a macro that tries to directly access the
`FILE *` structure.

Fix this issue by storing the `FILE *` in a local variable before we
pass it on to other functions.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agobuiltin/credential-cache: fix missing parameter for stub function
Patrick Steinhardt [Wed, 16 Oct 2024 08:13:15 +0000 (10:13 +0200)] 
builtin/credential-cache: fix missing parameter for stub function

When not compiling the credential cache we may use a stub function for
`cmd_credential_cache()`. With commit 9b1cb5070f (builtin: add a
repository parameter for builtin functions, 2024-09-13), we have added a
new parameter to all of those top-level `cmd_*()` functions, and did
indeed adapt the non-stubbed-out `cmd_credential_cache()`. But we didn't
adapt the stubbed-out variant, so the code does not compile.

Fix this by adding the missing parameter.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agot7300: work around platform-specific behaviour with long paths on MinGW
Patrick Steinhardt [Wed, 16 Oct 2024 08:13:13 +0000 (10:13 +0200)] 
t7300: work around platform-specific behaviour with long paths on MinGW

Windows by default has a restriction in place to only allow paths up to
260 characters. This restriction can nowadays be lifted by setting a
registry key, but is still active by default.

In t7300 we have one test that exercises the behaviour of git-clean(1)
with such long paths. Interestingly enough, this test fails on my system
that uses Windows 10 with mingw-w64 installed via MSYS2: instead of
observing ENAMETOOLONG, we observe ENOENT. This behaviour is consistent
across multiple different environments I have tried.

I cannot say why exactly we observe a different error here, but I would
not be surprised if this was either dependent on the Windows version,
the version of MinGW, the current working directory of Git or any kind
of combination of these.

Work around the issue by handling both errors.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agot5500, t5601: skip tests which exercise paths with '[::1]' on Cygwin
Patrick Steinhardt [Wed, 16 Oct 2024 08:13:10 +0000 (10:13 +0200)] 
t5500, t5601: skip tests which exercise paths with '[::1]' on Cygwin

Parsing repositories which contain '[::1]' is broken on Cygwin. It seems
as if Cygwin is confusing those as drive letter prefixes or something
like this, but I couldn't deduce the actual root cause.

Mark those tests as broken for now.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agot3404: work around platform-specific behaviour on macOS 10.15
Patrick Steinhardt [Wed, 16 Oct 2024 08:13:07 +0000 (10:13 +0200)] 
t3404: work around platform-specific behaviour on macOS 10.15

Two of our tests in t3404 use indented HERE docs where leading tabs on
some of the lines are actually relevant. The tabs do get removed though,
and we try to fix this up by using sed(1) to replace leading tabs in the
actual output, as well. But macOS 10.15 uses an oldish version of sed(1)
that has BSD lineage, which does not understand "\t", and thus we fail
to strip those leading tabs and fail the test.

Address this issue by using `q_to_tab` such that we do not have to strip
leading tabs from the actual output.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agot1401: make invocation of tar(1) work with Win32-provided one
Patrick Steinhardt [Wed, 16 Oct 2024 08:13:04 +0000 (10:13 +0200)] 
t1401: make invocation of tar(1) work with Win32-provided one

Windows nowadays provides a tar(1) binary in "C:\Windows\system32". This
version of tar(1) doesn't seem to handle the case where directory paths
end with a trailing forward slash. And as we do that in t1401 the result
is that the test fails.

Drop the trailing slash. Other tests that use tar(1) work alright, this
is the only instance where it has been failing.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agot/lib-gpg: fix setup of GNUPGHOME in MinGW
Patrick Steinhardt [Wed, 16 Oct 2024 08:12:59 +0000 (10:12 +0200)] 
t/lib-gpg: fix setup of GNUPGHOME in MinGW

In "t/lib-gpg.sh" we set up the "GNUPGHOME" environment variable to
point to a test-specific directory. This is done by using "$PWD/gpghome"
as value, where "$PWD" is the current test's trash directory.

This is broken for MinGW though because "$PWD" will use Windows-style
paths that contain drive letters. What we really want in this context is
a Unix-style path, which we can get by using `$(pwd)` instead. It is
somewhat puzzling that nobody ever hit this issue, but it may easily be
that nobody ever tests on Windows with GnuPG installed, which would make
us skip those tests.

Adapt the code accordingly to fix tests using this library.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agot/lib-gitweb: test against the build version of gitweb
Patrick Steinhardt [Wed, 16 Oct 2024 08:12:56 +0000 (10:12 +0200)] 
t/lib-gitweb: test against the build version of gitweb

When testing gitweb we set up the CGI script as "gitweb.perl", which is
the source file of the build target "gitweb.cgi". This file doesn't have
a patched shebang and still contains `++REPLACEMENT++` markers, but
things generally work because we replace the configuration with our own
test configuration.

But this only works as long as "$GIT_BUILD_DIR" actually points to the
source tree, because "gitweb.cgi" and "gitweb.perl" happen to sit next
to each other. This is not the case though once you have out-of-tree
builds like with CMake, where the source and built versions live in
different directories. Consequently, "$GIT_BUILD_DIR/gitweb/gitweb.perl"
won't exist there.

While we could ask build systems with out-of-tree builds to instead set
up GITWEB_TEST_INSTALLED, which allows us to override the location of
the script, it goes against the spirit of this environment variable. We
_don't_ want to test against an installed version, we want to use the
version we have just built.

Fix this by using "gitweb.cgi" instead. This means that you cannot run
test scripts without building that file, but in general we do expect
developers to build stuff before they test it anyway.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agot/test-lib: wire up NO_ICONV prerequisite
Patrick Steinhardt [Wed, 16 Oct 2024 08:12:53 +0000 (10:12 +0200)] 
t/test-lib: wire up NO_ICONV prerequisite

The iconv library is used by Git to reencode files, commit messages and
other things. As such it is a rather integral part, but given that many
platforms nowadays use UTF-8 everywhere you can live without support for
reencoding in many situations. It is thus optional to build Git with
iconv, and some of our platforms wired up in "config.mak.uname" disable
it. But while we support building without it, running our test suite
with "NO_ICONV=Yes" causes many test failures.

Wire up a new test prerequisite ICONV that gets populated via our
GIT-BUILD-OPTIONS. Annotate failing tests accordingly.

Note that this commit does not do a deep dive into every single test to
assess whether the failure is expected or not. Most of the tests do
smell like the expected kind of failure though.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agot/test-lib: fix quoting of TEST_RESULTS_SAN_FILE
Patrick Steinhardt [Wed, 16 Oct 2024 08:12:51 +0000 (10:12 +0200)] 
t/test-lib: fix quoting of TEST_RESULTS_SAN_FILE

When assembling our LSAN_OPTIONS that configure the leak sanitizer we
end up prepending the string with various different colon-separated
options via calls to `prepend_var`. One of the settings we add is the
path where the sanitizer should store logs, which can be an arbitrary
filesystem path.

Naturally, filesystem paths may contain whitespace characters. And while
it does seem as if we were quoting the value, we use escaped quotes and
consequently split up the value if it does contain spaces. This leads to
the following error in t0000 when having a value with whitespaces:

    .../t/test-lib.sh: eval: line 64: unexpected EOF while looking for matching `"'
    ++ return 1
    error: last command exited with $?=1
    not ok 5 - subtest: 3 passing tests

The error itself is a bit puzzling at first. The basic problem is that
the code sees the leading escaped quote during eval, but because we
truncate everything after the space character it doesn't see the
trailing escaped quote and thus fails to parse the string.

Properly quote the value to fix the issue while using single-quotes to
quote the inner value passed to eval. The issue can be reproduced by
t0000 with such a path that contains spaces.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agoThe second batch
Taylor Blau [Tue, 15 Oct 2024 21:12:40 +0000 (17:12 -0400)] 
The second batch

Signed-off-by: Taylor Blau <me@ttaylorr.com>
9 months agoMerge branch 'jk/fsmonitor-event-listener-race-fix'
Taylor Blau [Tue, 15 Oct 2024 20:56:43 +0000 (16:56 -0400)] 
Merge branch 'jk/fsmonitor-event-listener-race-fix'

On macOS, fsmonitor can fall into a race condition that results in
a client waiting forever to be notified for an event that have
already happened.  This problem has been corrected.

* jk/fsmonitor-event-listener-race-fix:
  fsmonitor: initialize fs event listener before accepting clients
  simple-ipc: split async server initialization and running

9 months agoMerge branch 'xx/remote-server-option-config'
Taylor Blau [Tue, 15 Oct 2024 20:56:43 +0000 (16:56 -0400)] 
Merge branch 'xx/remote-server-option-config'

A new configuration variable remote.<name>.serverOption makes the
transport layer act as if the --serverOption=<value> option is
given from the command line.

* xx/remote-server-option-config:
  ls-remote: leakfix for not clearing server_options
  fetch: respect --server-option when fetching multiple remotes
  transport.c::handshake: make use of server options from remote
  remote: introduce remote.<name>.serverOption configuration
  transport: introduce parse_transport_option() method

9 months agoMerge branch 'js/doc-platform-support-link-fix'
Taylor Blau [Tue, 15 Oct 2024 20:56:43 +0000 (16:56 -0400)] 
Merge branch 'js/doc-platform-support-link-fix'

Docfix.

* js/doc-platform-support-link-fix:
  docs: fix the `maintain-git` links in `technical/platform-support`

9 months agoMerge branch 'jh/config-unset-doc-fix'
Taylor Blau [Tue, 15 Oct 2024 20:56:43 +0000 (16:56 -0400)] 
Merge branch 'jh/config-unset-doc-fix'

Docfix.

* jh/config-unset-doc-fix:
  git-config.1: remove value from positional args in unset usage

10 months agoBreakingChanges: early adopter option
Junio C Hamano [Fri, 11 Oct 2024 21:49:39 +0000 (14:49 -0700)] 
BreakingChanges: early adopter option

Discussing the desire to make breaking changes, declaring that
breaking changes are made at a certain version boundary, and
recording these decisions in this document, are necessary but not
sufficient.  We need to make sure that we can implement, test, and
deploy such impactful changes.

Earlier we considered to guard the breaking changes with a run-time
check of the `feature.git<version>` configuration to allow brave
users and developers to opt into them as early adoptors.  But the
engineering cost to support such a run-time switch, covering new and
disappearing git subcommands and how "git help" would adjust the
documentation to the run-time switch, would be unrealistically high
to be worth it.

Formalize the mechanism based on a compile-time switch to allow
early adopters to opt into the breaking change in a version of Git
before the planned version for the breaking change.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot/README: add missing value for GIT_TEST_DEFAULT_REF_FORMAT
Bence Ferdinandy [Fri, 11 Oct 2024 19:11:33 +0000 (21:11 +0200)] 
t/README: add missing value for GIT_TEST_DEFAULT_REF_FORMAT

The documentation only lists "files" as a possible value, but
"reftable" is also valid.

Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoMakefile: fix dependency for $(UNIT_TEST_DIR)/clar/clar.o
Philippe Blain [Fri, 11 Oct 2024 17:29:47 +0000 (17:29 +0000)] 
Makefile: fix dependency for $(UNIT_TEST_DIR)/clar/clar.o

The clar source file '$(UNIT_TEST_DIR)/clar/clar.c' includes the
generated 'clar.suite', but this dependency is not taken into account by
our Makefile, so that it is possible for a parallel build to fail if
Make tries to build 'clar.o' before 'clar.suite' is generated.

Correctly specify the dependency.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoarchive: remove the_repository global variable
John Cai [Thu, 10 Oct 2024 21:13:48 +0000 (21:13 +0000)] 
archive: remove the_repository global variable

As part of the effort to get rid of global state due to the global
the_repository variable, replace the_repository with the repository
argument that gets passed down through the builtin function.

The repo might be NULL, but we should be safe in write_archive() because
it detects if we are outside of a repository and calls
setup_git_directory() which will error.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoannotate: remove usage of the_repository global
John Cai [Thu, 10 Oct 2024 21:13:47 +0000 (21:13 +0000)] 
annotate: remove usage of the_repository global

As part of the effort to get rid of global state due to the_repository
variable, remove the the_repository with the repository argument that
gets passed down through the builtin function.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agogit: pass in repo to builtin based on setup_git_directory_gently
John Cai [Thu, 10 Oct 2024 21:13:46 +0000 (21:13 +0000)] 
git: pass in repo to builtin based on setup_git_directory_gently

The current code in run_builtin() passes in a repository to the builtin
based on whether cmd_struct's option flag has RUN_SETUP.

This is incorrect, however, since some builtins that only have
RUN_SETUP_GENTLY can potentially take a repository.
setup_git_directory_gently() tells us whether or not a command is being
run inside of a repository.

Use the output of setup_git_directory_gently() to help determine whether
or not there is a repository to pass to the builtin. If not, then we
just pass NULL.

As part of this patch, we need to modify add to check for a NULL repo
before calling repo_git_config(), since add -h can be run outside of a
repository.

Signed-off-by: John Cai <johncai86@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoStart the 2.48 cycle
Junio C Hamano [Thu, 10 Oct 2024 21:22:07 +0000 (14:22 -0700)] 
Start the 2.48 cycle

Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoMerge branch 'jk/output-prefix-cleanup'
Junio C Hamano [Thu, 10 Oct 2024 21:22:29 +0000 (14:22 -0700)] 
Merge branch 'jk/output-prefix-cleanup'

Code clean-up.

* jk/output-prefix-cleanup:
  diff: store graph prefix buf in git_graph struct
  diff: return line_prefix directly when possible
  diff: return const char from output_prefix callback
  diff: drop line_prefix_length field
  line-log: use diff_line_prefix() instead of custom helper

10 months agoMerge branch 'ps/leakfixes-part-8'
Junio C Hamano [Thu, 10 Oct 2024 21:22:27 +0000 (14:22 -0700)] 
Merge branch 'ps/leakfixes-part-8'

More leakfixes.

* ps/leakfixes-part-8: (23 commits)
  builtin/send-pack: fix leaking list of push options
  remote: fix leaking push reports
  t/helper: fix leaks in proc-receive helper
  pack-write: fix return parameter of `write_rev_file_order()`
  revision: fix leaking saved parents
  revision: fix memory leaks when rewriting parents
  midx-write: fix leaking buffer
  pack-bitmap-write: fix leaking OID array
  pseudo-merge: fix leaking strmap keys
  pseudo-merge: fix various memory leaks
  line-log: fix several memory leaks
  diff: improve lifecycle management of diff queues
  builtin/revert: fix leaking `gpg_sign` and `strategy` config
  t/helper: fix leaking repository in partial-clone helper
  builtin/clone: fix leaking repo state when cloning with bundle URIs
  builtin/pack-redundant: fix various memory leaks
  builtin/stash: fix leaking `pathspec_from_file`
  submodule: fix leaking submodule entry list
  wt-status: fix leaking buffer with sparse directories
  shell: fix leaking strings
  ...

10 months agoMerge branch 'ds/line-log-asan-fix'
Junio C Hamano [Thu, 10 Oct 2024 21:22:27 +0000 (14:22 -0700)] 
Merge branch 'ds/line-log-asan-fix'

Use after free and double freeing at the end in "git log -L... -p"
had been identified and fixed.

* ds/line-log-asan-fix:
  line-log: protect inner strbuf from free

10 months agoMerge branch 'sk/doc-maintenance-schedule'
Junio C Hamano [Thu, 10 Oct 2024 21:22:26 +0000 (14:22 -0700)] 
Merge branch 'sk/doc-maintenance-schedule'

Doc update to clarify how periodical maintenance are scheduled,
spread across time to avoid thundering hurds.

* sk/doc-maintenance-schedule:
  doc: add a note about staggering of maintenance

10 months agoMerge branch 'tb/notes-amlog-doc'
Junio C Hamano [Thu, 10 Oct 2024 21:22:25 +0000 (14:22 -0700)] 
Merge branch 'tb/notes-amlog-doc'

Document "amlog" notes.

* tb/notes-amlog-doc:
  Documentation: mention the amlog in howto/maintain-git.txt

10 months agoMerge branch 'ps/reftable-alloc-failures'
Junio C Hamano [Thu, 10 Oct 2024 21:22:24 +0000 (14:22 -0700)] 
Merge branch 'ps/reftable-alloc-failures'

The reftable library is now prepared to expect that the memory
allocation function given to it may fail to allocate and to deal
with such an error.

* ps/reftable-alloc-failures: (26 commits)
  reftable/basics: fix segfault when growing `names` array fails
  reftable/basics: ban standard allocator functions
  reftable: introduce `REFTABLE_FREE_AND_NULL()`
  reftable: fix calls to free(3P)
  reftable: handle trivial allocation failures
  reftable/tree: handle allocation failures
  reftable/pq: handle allocation failures when adding entries
  reftable/block: handle allocation failures
  reftable/blocksource: handle allocation failures
  reftable/iter: handle allocation failures when creating indexed table iter
  reftable/stack: handle allocation failures in auto compaction
  reftable/stack: handle allocation failures in `stack_compact_range()`
  reftable/stack: handle allocation failures in `reftable_new_stack()`
  reftable/stack: handle allocation failures on reload
  reftable/reader: handle allocation failures in `reader_init_iter()`
  reftable/reader: handle allocation failures for unindexed reader
  reftable/merged: handle allocation failures in `merged_table_init_iter()`
  reftable/writer: handle allocation failures in `reftable_new_writer()`
  reftable/writer: handle allocation failures in `writer_index_hash()`
  reftable/record: handle allocation failures when decoding records
  ...

10 months agoMerge branch 'ja/doc-synopsis-markup'
Junio C Hamano [Thu, 10 Oct 2024 21:22:24 +0000 (14:22 -0700)] 
Merge branch 'ja/doc-synopsis-markup'

The way AsciiDoc is used for SYNOPSIS part of the manual pages has
been revamped.  The sources, at least for the simple cases, got
vastly pleasant to work with.

* ja/doc-synopsis-markup:
  doc: apply synopsis simplification on git-clone and git-init
  doc: update the guidelines to reflect the current formatting rules
  doc: introduce a synopsis typesetting

10 months agot: fix typos
Andrew Kreimer [Thu, 10 Oct 2024 15:11:22 +0000 (18:11 +0300)] 
t: fix typos

Fix typos via codespell.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot/helper: fix a typo
Andrew Kreimer [Thu, 10 Oct 2024 15:11:25 +0000 (18:11 +0300)] 
t/helper: fix a typo

Fix a typo in comments: bellow -> below.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot/perf: fix typos
Andrew Kreimer [Thu, 10 Oct 2024 15:11:23 +0000 (18:11 +0300)] 
t/perf: fix typos

Fix typos via codespell.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot/unit-tests: fix typos
Andrew Kreimer [Thu, 10 Oct 2024 15:11:24 +0000 (18:11 +0300)] 
t/unit-tests: fix typos

Fix typos via codespell.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agocontrib: fix typos
Andrew Kreimer [Thu, 10 Oct 2024 15:11:20 +0000 (18:11 +0300)] 
contrib: fix typos

Fix typos via codespell.

Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agocompat: fix typos
Andrew Kreimer [Thu, 10 Oct 2024 15:11:19 +0000 (18:11 +0300)] 
compat: fix typos

Fix typos and grammar.

Reported-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Andrew Kreimer <algonell@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agocheckout: refer to other-worktree branch, not ref
Kristoffer Haugsbakk [Thu, 10 Oct 2024 18:39:29 +0000 (20:39 +0200)] 
checkout: refer to other-worktree branch, not ref

We can only check out commits or branches, not refs in general.  And the
problem here is if another worktree is using the branch that we want to
check out.

Let’s be more direct and just talk about branches instead of refs.

Also replace “be held” with “in use”.  Further, “in use” is not
restricted to a branch being checked out (e.g. the branch could be busy
on a rebase), hence generalize to “or otherwise in use” in the option
description.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoDocumentation/gitprotocol-v2.txt: fix a slight inconsistency in format
Xing Xin [Thu, 10 Oct 2024 13:20:42 +0000 (13:20 +0000)] 
Documentation/gitprotocol-v2.txt: fix a slight inconsistency in format

Signed-off-by: Xing Xin <xingxin.xx@bytedance.com>
Acked-by: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agobundle-uri: plug leak in unbundle_from_file()
Toon Claes [Thu, 10 Oct 2024 09:12:49 +0000 (11:12 +0200)] 
bundle-uri: plug leak in unbundle_from_file()

The function `unbundle_from_file()` has two memory leaks:

  - We do not release the `struct bundle_header header` when hitting
    errors because we return early without any cleanup.

  - We do not release the `struct strbuf bundle_ref` at all.

Plug these leaks by creating a common exit path where both of these
variables are released.

While at it, refactor the code such that the variable assignments do not
happen inside the conditional statement itself according to our coding
style.

Signed-off-by: Toon Claes <toon@iotcl.com>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agobuiltin/gc: fix crash when running `git maintenance start`
Patrick Steinhardt [Thu, 10 Oct 2024 05:33:01 +0000 (07:33 +0200)] 
builtin/gc: fix crash when running `git maintenance start`

It was reported on the mailing list that running `git maintenance start`
immediately segfaults starting with b6c3f8e12c (builtin/maintenance: fix
leak in `get_schedule_cmd()`, 2024-09-26). And indeed, this segfault is
trivial to reproduce up to a point where one is scratching their head
why we didn't catch this regression in our test suite.

The root cause of this error is `get_schedule_cmd()`, which does not
populate the `out` parameter in all cases anymore starting with the
mentioned commit. Callers do assume it to always be populated though and
will e.g. call `strvec_split()` on the returned value, which will of
course segfault when the variable is uninitialized.

So why didn't we catch this trivial regression? The reason is that our
tests always set up the "GIT_TEST_MAINT_SCHEDULER" environment variable
via "t/test-lib.sh", which allows us to override the scheduler command
with a custom one so that we don't accidentally modify the developer's
system. But the faulty code where we don't set the `out` parameter will
only get hit in case that environment variable is _not_ set, which is
never the case when executing our tests.

Fix the regression by again unconditionally allocating the value in the
`out` parameter, if provided. Add a test that unsets the environment
variable to catch future regressions in this area.

Reported-by: Shubham Kanodia <shubham.kanodia10@gmail.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agodoc: clarify <src> in refspec syntax
Junio C Hamano [Tue, 1 Oct 2024 18:36:52 +0000 (11:36 -0700)] 
doc: clarify <src> in refspec syntax

We explicitly avoid saying "ref <src>" when introducing the source
side of a refspec, because it can be a fully-spelled hexadecimal
object name, and it also can be a pattern that is not quite a "ref".

But we are loose when we introduce <dst> and say "ref <dst>", even
though it can also be a pattern.  Let's omit "ref" also from the
destination side.

Clarify that <src> can be a ref, a (limited glob) pattern, or an
object name.

Even though the very original design of refspec expected that '*'
was used only at the end (e.g., "refs/heads/*" was expected, but not
"refs/heads/*-wip"), the code and its use evolved to handle a single
'*' anywhere in the pattern.  Update the text to remove the mention
of "the same prefix".  Anything that matches the pattern are named
by such a (limited glob) pattern in <src>.

Also put a bit more stress on the fact that we accept only one '*'
in the pattern by saying "one and only one `*`".

Helped-by: Monika Kairaitytė <monika@kibit.lt>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot7300-clean.sh: use test_path_* helper functions for error logging
Abraham Samuel Adekunle [Wed, 9 Oct 2024 18:22:02 +0000 (18:22 +0000)] 
t7300-clean.sh: use test_path_* helper functions for error logging

This test script uses "test - [def]", but when a test fails because
the file passed to it does not exist,
it fails silently without an error message.
Use test_path_* helper functions, which are designed to give better
error messages when their expectations are not met.

I have added a mechanical validation that applies the same transformation
done in this patch, when the test script is passed to a sed script as shown
below.

sed -e 's/^\( *\)test -f /\1test_path_is_file /' \
    -e 's/^\( *\)test -d /\1test_path_is_dir /' \
    -e 's/^\( *\)test -e /\1test_path_exists /' \
    -e 's/^\( *\)! test -[edf] /\1test_path_is_missing /' \
    -e 's/^\( *\)test ! -[edf] /\1test_path_is_missing /' \
       "$1" >foo.sh

Reviewers can use the sed script to tranform the original test script and
compare the result in foo.sh with the results of applying the patch.
You will see an instance of "!(test -e 3)" which was manually replaced with
""test_path_is_missing 3", and everything else should match.

Careful and deliberate observation was done to check instances where
"test ! - [df] foo" was used in the test script to make sure that the test
instances were expecting foo to EITHER be a file or a directory, and NOT a
possibility of being both as this would make replacing "test ! -f foo" with
"test_path_is_missing foo" unreasonable.

In the tests control flow, foo has been created as EITHER a
reguar file OR a directory and should NOT exist
after "git clean" or "git clean -d", as the case maybe, has been called.
This made it reasonable to replace
"test ! -[df] foo" with "test_path_is_missing foo".

Signed-off-by: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoloose: don't rely on repository global state
Karthik Nayak [Wed, 9 Oct 2024 09:58:59 +0000 (02:58 -0700)] 
loose: don't rely on repository global state

In `loose.c`, we rely on the global variable `the_hash_algo`. As such we
have guarded the file with the 'USE_THE_REPOSITORY_VARIABLE' definition.
Let's derive the hash algorithm from the available repository variable
and remove this guard. This brings us one step closer to removing the
global 'the_repository' variable.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agogitlab-ci: exercise Git on Windows
Patrick Steinhardt [Wed, 9 Oct 2024 13:25:29 +0000 (15:25 +0200)] 
gitlab-ci: exercise Git on Windows

Add jobs that exercise Git on Windows. Unfortunately, building and
especially testing Git on Windows is inherently slower compared to other
Unix-like systems, mostly because spawning processes is way slower. We
thus use the same layout as we use in GitHub Actions, where we have one
build job, and then pass on the resulting build artifacts to ten test
jobs that split up the work across each other.

Unfortunately, the GitLab runners for Windows machines are embarassingly
slow by themselves. So while this strategy leads to around 20 minutes of
build time in GitHub Actions, the same pipeline takes around an hour in
GitLab CI. Still, having late coverage is certainly better than having
none at all.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agogitlab-ci: introduce stages and dependencies
Patrick Steinhardt [Wed, 9 Oct 2024 13:25:26 +0000 (15:25 +0200)] 
gitlab-ci: introduce stages and dependencies

We're about to add a couple of jobs for Windows. As the Windows runners
are quite slow, we will split those up across two stages: one stage to
build the artifacts, and one stage that runs test slices in parallel.

Introduce stages and "needs" dependencies for the preexisting jobs as a
preparatory step. The stages will lead to a more natural representation
of jobs in the UI, whereas the "needs" dependency ensures that jobs do
not have to wait for all jobs in the preceding stage to finish.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoci: handle Windows-based CI jobs in GitLab CI
Patrick Steinhardt [Wed, 9 Oct 2024 13:25:23 +0000 (15:25 +0200)] 
ci: handle Windows-based CI jobs in GitLab CI

We try to abstract away any differences between different CI platforms
in "ci/lib.sh", such that knowledge specific to e.g. GitHub Actions or
GitLab CI is neatly encapsulated in a single place. Next to some generic
variables, we also set up some variables that are specific to the actual
platform that the CI operates on, e.g. Linux or macOS.

We do not yet support Windows runners on GitLab CI. Unfortunately, those
systems do not use the same "CI_JOB_IMAGE" environment variable as both
Linux and macOS do. Instead, we can use the "OS" variable, which should
have a value of "Windows_NT" on Windows platforms.

Handle the combination of "$OS,$CI_JOB_IMAGE" and introduce support for
Windows.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agoci: create script to set up Git for Windows SDK
Patrick Steinhardt [Wed, 9 Oct 2024 13:25:21 +0000 (15:25 +0200)] 
ci: create script to set up Git for Windows SDK

In order to build and test Git, we have to first set up the Git for
Windows SDK, which contains various required tools and libraries. The
SDK is basically a clone of [1], but that repository is quite large due
to all the binaries it contains. We thus use both shallow clones and
sparse checkouts to speed up the setup. To handle this complexity we use
a GitHub action that is hosted externally at [2].

Unfortunately, this makes it rather hard to reuse the logic for CI
platforms other than GitHub Actions. After chatting with Johannes
Schindelin we came to the conclusion that it would be nice if the Git
for Windows SDK would regularly publish releases that one can easily
download and extract, thus moving all of the complexity into that single
step. Like this, all that a CI job needs to do is to fetch and extract
the resulting archive. This published release comes in the form of a new
"ci-artifacts" tag that gets updated regularly [3].

Implement a new script that knows how to fetch and extract that script
and convert GitHub Actions to use it.

[1]: https://github.com/git-for-windows/git-sdk-64/
[2]: https://github.com/git-for-windows/setup-git-for-windows-sdk/
[3]: https://github.com/git-for-windows/git-sdk-64/releases/tag/ci-artifacts/

Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agot7300: work around platform-specific behaviour with long paths on MinGW
Patrick Steinhardt [Wed, 9 Oct 2024 13:25:18 +0000 (15:25 +0200)] 
t7300: work around platform-specific behaviour with long paths on MinGW

Windows by default has a restriction in place to only allow paths up to
260 characters. This restriction can nowadays be lifted by setting a
registry key, but is still active by default.

In t7300 we have one test that exercises the behaviour of git-clean(1)
with such long paths. Interestingly enough, this test fails on my system
that uses Windows 10 with mingw-w64 installed via MSYS2: instead of
observing ENAMETOOLONG, we observe ENOENT. This behaviour is consistent
across multiple different environments I have tried.

I cannot say why exactly we observe a different error here, but I would
not be surprised if this was either dependent on the Windows version,
the version of MinGW, the current working directory of Git or any kind
of combination of these.

Work around the issue by handling both errors.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agorebase-merges: try and use branch names as labels
Nicolas Guichard [Wed, 9 Oct 2024 07:58:20 +0000 (07:58 +0000)] 
rebase-merges: try and use branch names as labels

When interactively rebasing merge commits, the commit message is parsed to
extract a probably meaningful label name. For instance if the merge commit
is “Merge branch 'feature0'”, then the rebase script will have thes lines:
```
label feature0

merge -C $sha feature0 # “Merge branch 'feature0'
```

This heuristic fails in the case of octopus merges or when the merge commit
message is actually unrelated to the parent commits.

An example that combines both is:
```
*---.   967bfa4 (HEAD -> integration) Integration
|\ \ \
| | | * 2135be1 (feature2, feat2) Feature 2
| |_|/
|/| |
| | * c88b01a Feature 1
| |/
|/|
| * 75f3139 (feat0) Feature 0
|/
25c86d0 (main) Initial commit
```
yields the labels Integration, Integration-2 and Integration-3.

Fix this by using a branch name for each merge commit's parent that is the
tip of at least one branch, and falling back to a label derived from the
merge commit message otherwise.
In the example above, the labels become feat0, Integration and feature2.

Signed-off-by: Nicolas Guichard <nicolas@guichard.eu>
Acked-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 months agorebase-update-refs: extract load_branch_decorations
Nicolas Guichard [Wed, 9 Oct 2024 07:58:19 +0000 (07:58 +0000)] 
rebase-update-refs: extract load_branch_decorations

Extract load_branch_decorations from todo_list_add_update_ref_commands so
it can be re-used in make_script_with_merges.

Since it can now be called multiple times, use non-static lists and place
it next to load_ref_decorations to re-use the decoration_loaded guard.

Signed-off-by: Nicolas Guichard <nicolas@guichard.eu>
Acked-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>