]> git.ipfire.org Git - thirdparty/git.git/log
thirdparty/git.git
5 months agoreftable: fix allocation count on realloc error
René Scharfe [Sat, 28 Dec 2024 09:48:00 +0000 (10:48 +0100)] 
reftable: fix allocation count on realloc error

When realloc(3) fails, it returns NULL and keeps the original allocation
intact.  REFTABLE_ALLOC_GROW overwrites both the original pointer and
the allocation count variable in that case, simultaneously leaking the
original allocation and misrepresenting the number of storable items.

parse_names() avoids the leak by keeping the original pointer if
reallocation fails, but still increase the allocation count in such a
case as if it succeeded.  That's OK, because the error handling code
just frees everything and doesn't look at names_cap anymore.

reftable_buf_add() does the same, but here it is a problem as it leaves
the reftable_buf in a broken state, with ->alloc being roughly twice as
big as the actually allocated memory, allowing out-of-bounds writes in
subsequent calls.

Reimplement REFTABLE_ALLOC_GROW to avoid leaks, keep allocation counts
in sync and still signal failures to callers while avoiding code
duplication in callers.  Make it an expression that evaluates to 0 if no
reallocation is needed or it succeeded and 1 on failure while keeping
the original pointer and allocation counter values.

Adjust REFTABLE_ALLOC_GROW_OR_NULL to the new calling convention for
REFTABLE_ALLOC_GROW, but keep its support for non-size_t alloc variables
for now.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoreftable: avoid leaks on realloc error
René Scharfe [Sat, 28 Dec 2024 09:47:05 +0000 (10:47 +0100)] 
reftable: avoid leaks on realloc error

When realloc(3) fails, it returns NULL and keeps the original allocation
intact.  REFTABLE_ALLOC_GROW overwrites both the original pointer and
the allocation count variable in that case, simultaneously leaking the
original allocation and misrepresenting the number of storable items.

parse_names() and reftable_buf_add() avoid leaking by restoring the
original pointer value on failure, but all other callers seem to be OK
with losing the old allocation.  Add a new variant of the macro,
REFTABLE_ALLOC_GROW_OR_NULL, which plugs the leak and zeros the
allocation counter.  Use it for those callers.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 months agoMerge https://github.com/j6t/git-gui
Junio C Hamano [Thu, 26 Dec 2024 16:02:23 +0000 (08:02 -0800)] 
Merge https://github.com/j6t/git-gui

* 'master' of https://github.com/j6t/git-gui:
  git-gui: use system encoding to show console output
  git-gui: Remove forced rescan of stat-dirty files.

6 months agoHopefully the final batch before 2.48-rc1
Junio C Hamano [Mon, 23 Dec 2024 16:45:57 +0000 (08:45 -0800)] 
Hopefully the final batch before 2.48-rc1

Let's wait for git-gui, gitk, and possibly po/ and delay the tagging
of the -rc1.  Many people are already offline for the end-of-year
holidays and it is a slow week, and 'master' front has too many new
things graduated from 'next' a bit too early for me to feel
comfortable.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoMerge branch 'kn/reflog-migration'
Junio C Hamano [Mon, 23 Dec 2024 17:32:29 +0000 (09:32 -0800)] 
Merge branch 'kn/reflog-migration'

"git refs migrate" learned to also migrate the reflog data across
backends.

* kn/reflog-migration:
  refs: mark invalid refname message for translation
  refs: add support for migrating reflogs
  refs: allow multiple reflog entries for the same refname
  refs: introduce the `ref_transaction_update_reflog` function
  refs: add `committer_info` to `ref_transaction_add_update()`
  refs: extract out refname verification in transactions
  refs/files: add count field to ref_lock
  refs: add `index` field to `struct ref_udpate`
  refs: include committer info in `ref_update` struct

6 months agoMerge branch 'ma/asciidoctor-build-fixes'
Junio C Hamano [Mon, 23 Dec 2024 17:32:27 +0000 (09:32 -0800)] 
Merge branch 'ma/asciidoctor-build-fixes'

A topic to optionally build with meson, which has graduated to
'master' recently, broke Documentation pipeline with asciidoctor
for the normal Makefile build as well as meson-based one, which
have been corrected.

* ma/asciidoctor-build-fixes:
  asciidoctor-extensions.rb.in: inject GIT_DATE
  asciidoctor-extensions.rb.in: add missing word
  asciidoctor-extensions.rb.in: delete existing <refmiscinfo/>

6 months agoMerge branch 'ps/build-hotfix'
Junio C Hamano [Mon, 23 Dec 2024 17:32:26 +0000 (09:32 -0800)] 
Merge branch 'ps/build-hotfix'

A topic to optionally build with meson, which has graduated to
'master' recently, has regressed the normal Makefile build, which
is being corrected.

* ps/build-hotfix:
  meson: add options to override build information
  GIT-VERSION-GEN: fix overriding GIT_BUILT_FROM_COMMIT and GIT_DATE
  GIT-VERSION-GEN: fix overriding GIT_VERSION
  Makefile: introduce template for GIT-VERSION-GEN
  Makefile: drop unneeded indirection for GIT-VERSION-GEN outputs
  Makefile: stop including "GIT-VERSION-FILE" in docs

6 months agoMerge branch 'ps/ci-meson'
Junio C Hamano [Mon, 23 Dec 2024 17:32:24 +0000 (09:32 -0800)] 
Merge branch 'ps/ci-meson'

The meson-build procedure is integrated into CI to catch and
prevent bitrotting.

* ps/ci-meson:
  ci: wire up Meson builds
  t: introduce compatibility options to clar-based tests
  t: fix out-of-tree tests for some git-p4 tests
  Makefile: detect missing Meson tests
  meson: detect missing tests at configure time
  t/unit-tests: rename clar-based unit tests to have a common prefix
  Makefile: drop -DSUPPRESS_ANNOTATED_LEAKS
  ci/lib: support custom output directories when creating test artifacts

6 months agoMerge branch 'kl/doc-build-fix'
Junio C Hamano [Mon, 23 Dec 2024 17:32:23 +0000 (09:32 -0800)] 
Merge branch 'kl/doc-build-fix'

Build fix.

* kl/doc-build-fix:
  doc: remove extra quotes in generated docs

6 months agoMerge branch 'tb/bitmap-fix-pack-reuse'
Junio C Hamano [Mon, 23 Dec 2024 17:32:22 +0000 (09:32 -0800)] 
Merge branch 'tb/bitmap-fix-pack-reuse'

Code to reuse objects based on bitmap contents have been tightened
to avoid race condition even when multiple packs are involved.

* tb/bitmap-fix-pack-reuse:
  pack-bitmap.c: ensure pack validity for all reuse packs

6 months agoMerge branch 'jk/prio-queue-sign-compare-fix'
Junio C Hamano [Mon, 23 Dec 2024 17:32:20 +0000 (09:32 -0800)] 
Merge branch 'jk/prio-queue-sign-compare-fix'

Type clean-up.

* jk/prio-queue-sign-compare-fix:
  prio-queue: use size_t rather than int for size

6 months agoMerge branch 'ps/build-meson-gitweb'
Junio C Hamano [Mon, 23 Dec 2024 17:32:19 +0000 (09:32 -0800)] 
Merge branch 'ps/build-meson-gitweb'

meson-based build still tried to build and install gitweb even when
Perl is disabled, which has been corrected.

* ps/build-meson-gitweb:
  meson: skip gitweb build when Perl is disabled

6 months agoMerge branch 'sk/calloc-not-malloc-plus-memset'
Junio C Hamano [Mon, 23 Dec 2024 17:32:18 +0000 (09:32 -0800)] 
Merge branch 'sk/calloc-not-malloc-plus-memset'

Code clean-up.

* sk/calloc-not-malloc-plus-memset:
  git: use calloc instead of malloc + memset where possible

6 months agoMerge branch 'js/range-diff-diff-merges'
Junio C Hamano [Mon, 23 Dec 2024 17:32:17 +0000 (09:32 -0800)] 
Merge branch 'js/range-diff-diff-merges'

"git range-diff" learned to optionally show and compare merge
commits in the ranges being compared, with the --diff-merges
option.

* js/range-diff-diff-merges:
  range-diff: introduce the convenience option `--remerge-diff`
  range-diff: optionally include merge commits' diffs in the analysis

6 months agoMerge branch 'js/mingw-rename-fix'
Junio C Hamano [Mon, 23 Dec 2024 17:32:16 +0000 (09:32 -0800)] 
Merge branch 'js/mingw-rename-fix'

Update the way rename() emulation on Windows handle directories to
correct an earlier attempt to do the same.

* js/mingw-rename-fix:
  mingw_rename: do support directory renames

6 months agoMerge branch 'js/github-windows-setup-fix'
Junio C Hamano [Mon, 23 Dec 2024 17:32:14 +0000 (09:32 -0800)] 
Merge branch 'js/github-windows-setup-fix'

Revert recent changes to the way windows environment is set up for
GitHub CI.

* js/github-windows-setup-fix:
  GitHub ci(windows): speed up initializing Git for Windows' minimal SDK again

6 months agoMerge branch 'js/ps-build-cmake-fixup'
Junio C Hamano [Mon, 23 Dec 2024 17:32:13 +0000 (09:32 -0800)] 
Merge branch 'js/ps-build-cmake-fixup'

Build fixes for Windows.

* js/ps-build-cmake-fixup:
  cmake/vcxproj: stop special-casing `remote-ext`
  cmake: put the Perl modules into the correct location again
  cmake: use the correct file name for the Perl header
  cmake(mergetools): better support for out-of-tree builds
  cmake: better support for out-of-tree builds follow-up

6 months agoMerge branch 'as/show-index-uninitialized-hash'
Junio C Hamano [Mon, 23 Dec 2024 17:32:12 +0000 (09:32 -0800)] 
Merge branch 'as/show-index-uninitialized-hash'

Regression fix for 'show-index' when run outside of a repository.

* as/show-index-uninitialized-hash:
  t5300: add test for 'show-index --object-format'
  show-index: fix uninitialized hash function

6 months agoMerge branch 'ps/build-sign-compare'
Junio C Hamano [Mon, 23 Dec 2024 17:32:10 +0000 (09:32 -0800)] 
Merge branch 'ps/build-sign-compare'

Start working to make the codebase buildable with -Wsign-compare.

* ps/build-sign-compare:
  t/helper: don't depend on implicit wraparound
  scalar: address -Wsign-compare warnings
  builtin/patch-id: fix type of `get_one_patchid()`
  builtin/blame: fix type of `length` variable when emitting object ID
  gpg-interface: address -Wsign-comparison warnings
  daemon: fix type of `max_connections`
  daemon: fix loops that have mismatching integer types
  global: trivial conversions to fix `-Wsign-compare` warnings
  pkt-line: fix -Wsign-compare warning on 32 bit platform
  csum-file: fix -Wsign-compare warning on 32-bit platform
  diff.h: fix index used to loop through unsigned integer
  config.mak.dev: drop `-Wno-sign-compare`
  global: mark code units that generate warnings with `-Wsign-compare`
  compat/win32: fix -Wsign-compare warning in "wWinMain()"
  compat/regex: explicitly ignore "-Wsign-compare" warnings
  git-compat-util: introduce macros to disable "-Wsign-compare" warnings

6 months agoMerge branch 'kn/reftable-writer-log-write-verify'
Junio C Hamano [Mon, 23 Dec 2024 17:32:08 +0000 (09:32 -0800)] 
Merge branch 'kn/reftable-writer-log-write-verify'

Reftable backend adds check for upper limit of log's update_index.

* kn/reftable-writer-log-write-verify:
  reftable/writer: ensure valid range for log's update_index

6 months agoMerge branch 'ps/ci-gitlab-update'
Junio C Hamano [Mon, 23 Dec 2024 17:32:07 +0000 (09:32 -0800)] 
Merge branch 'ps/ci-gitlab-update'

GitLab CI updates.

* ps/ci-gitlab-update:
  ci/lib: fix "CI setup" sections with GitLab CI
  ci/lib: do not interpret escape sequences in `group ()` arguments
  ci/lib: remove duplicate trap to end "CI setup" group
  gitlab-ci: update macOS images to Sonoma

6 months agoMerge branch 'ps/reftable-alloc-failures-zalloc-fix'
Junio C Hamano [Mon, 23 Dec 2024 17:32:06 +0000 (09:32 -0800)] 
Merge branch 'ps/reftable-alloc-failures-zalloc-fix'

Recent reftable updates mistook a NULL return from a request for
0-byte allocation as OOM and died unnecessarily, which has been
corrected.

* ps/reftable-alloc-failures-zalloc-fix:
  reftable/basics: return NULL on zero-sized allocations
  reftable/stack: fix zero-sized allocation when there are no readers
  reftable/merged: fix zero-sized allocation when there are no readers
  reftable/stack: don't perform auto-compaction with less than two tables

6 months agoreftable/basics: return NULL on zero-sized allocations
Patrick Steinhardt [Sun, 22 Dec 2024 07:24:31 +0000 (08:24 +0100)] 
reftable/basics: return NULL on zero-sized allocations

In the preceding commits we have fixed a couple of issues when
allocating zero-sized objects. These issues were masked by
implementation-defined behaviour. Quoting malloc(3p):

  If size is 0, either:

    * A null pointer shall be returned and errno may be set to an
      implementation-defined value, or

    * A pointer to the allocated space shall be returned. The
      application shall ensure that the pointer is not used to access an
      object.

So it is perfectly valid that implementations of this function may or
may not return a NULL pointer in such a case.

Adapt both `reftable_malloc()` and `reftable_realloc()` so that they
return NULL pointers on zero-sized allocations. This should remove any
implementation-defined behaviour in our allocators and thus allows us to
detect such platform-specific issues more easily going forward.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoreftable/stack: fix zero-sized allocation when there are no readers
Patrick Steinhardt [Sun, 22 Dec 2024 07:24:30 +0000 (08:24 +0100)] 
reftable/stack: fix zero-sized allocation when there are no readers

Similar as the preceding commit, we may try to do a zero-sized
allocation when reloading a reftable stack that ain't got any tables.
It is implementation-defined whether malloc(3p) returns a NULL pointer
in that case or a zero-sized object. In case it does return a NULL
pointer though it causes us to think we have run into an out-of-memory
situation, and thus we return an error.

Fix this by only allocating arrays when they have at least one entry.

Reported-by: Randall S. Becker <rsbecker@nexbridge.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoreftable/merged: fix zero-sized allocation when there are no readers
Patrick Steinhardt [Sun, 22 Dec 2024 07:24:29 +0000 (08:24 +0100)] 
reftable/merged: fix zero-sized allocation when there are no readers

It was reported [1] that Git started to fail with an out-of-memory error
when initializing repositories with the reftable backend on NonStop
platforms. A bisect led to 802c0646ac (reftable/merged: handle
allocation failures in `merged_table_init_iter()`, 2024-10-02), which
changed how we allocate memory when initializing a merged table.

The root cause of this seems to be that NonStop returns a `NULL` pointer
when doing a zero-sized allocation. This would've already happened
before the above change, but we never noticed because we did not check
the result. Now we do notice and thus return an out-of-memory error to
the caller.

Fix the issue by skipping the allocation altogether in case there are no
readers.

[1]: <00ad01db5017$aa9ce340$ffd6a9c0$@nexbridge.com>

Reported-by: Randall S. Becker <rsbecker@nexbridge.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoreftable/stack: don't perform auto-compaction with less than two tables
Patrick Steinhardt [Sun, 22 Dec 2024 07:24:28 +0000 (08:24 +0100)] 
reftable/stack: don't perform auto-compaction with less than two tables

In order to compact tables we need at least two tables. Bail out early
from `reftable_stack_auto_compact()` in case we have less than two
tables.

In the original, `stack_table_sizes_for_compaction()` yields an array
that has the same length as the number of tables. This array is then
passed on to `suggest_compaction_segment()`, which returns an empty
segment in case we have less than two tables. The segment is then passed
to `segment_size()`, which will return `0` because both start and end of
the segment are `0`. And because we only call `stack_compact_range()` in
case we have a positive segment size we don't perform auto-compaction at
all. Consequently, this change does not result in a user-visible change
in behaviour when called with a single table.

But when called with no tables this protects us against a potential
out-of-memory error: `stack_table_sizes_for_compaction()` would try to
allocate a zero-byte object when there aren't any tables, and that may
lead to a `NULL` pointer on some platforms like NonStop which causes us
to bail out with an out-of-memory error.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoMerge branch 'js/no-rescan-on-empty-diff'
Johannes Sixt [Sat, 21 Dec 2024 13:05:43 +0000 (14:05 +0100)] 
Merge branch 'js/no-rescan-on-empty-diff'

* js/no-rescan-on-empty-diff:
  git-gui: Remove forced rescan of stat-dirty files.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
6 months agoasciidoctor-extensions.rb.in: inject GIT_DATE
Martin Ågren [Fri, 20 Dec 2024 23:18:18 +0000 (00:18 +0100)] 
asciidoctor-extensions.rb.in: inject GIT_DATE

After a38edab7c8 (Makefile: generate doc versions via GIT-VERSION-GEN,
2024-12-06), we no longer inject GIT_DATE when building with
Asciidoctor.

Replace the <date/> tag in the XML to inject the value of GIT_DATE.
Unlike <refmiscinfo/> as handled in a recent commit, we have no reason
to expect that this tag might be missing, so there's no need for "maybe
remove, then add" and we can just outright replace the one that
Asciidoctor has generated based on the mtime of the source file.

Compared to pre-a38edab7c8, we now end up injecting this also in the
build of Git.3pm, which until now has been using the mtime of Git.pm.
That is arguably even a good change since it results in more
reproducible builds.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoasciidoctor-extensions.rb.in: add missing word
Martin Ågren [Fri, 20 Dec 2024 23:18:17 +0000 (00:18 +0100)] 
asciidoctor-extensions.rb.in: add missing word

Commit a38edab7c8 (Makefile: generate doc versions via GIT-VERSION-GEN,
2024-12-06) stopped providing an attribute value "Git $(GIT_VERSION)" to
asciidoc/Asciidoctor over the command line. Instead, we now provide the
attribute to asciidoc through a generated asciidoc.conf, where the value
is generated as "Git @GIT_VERSION@".

In the similar mechanism for Asciidoctor, we forgot the "Git" prefix.
Restore it.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoasciidoctor-extensions.rb.in: delete existing <refmiscinfo/>
Martin Ågren [Fri, 20 Dec 2024 23:18:16 +0000 (00:18 +0100)] 
asciidoctor-extensions.rb.in: delete existing <refmiscinfo/>

After the recent a38edab7c8 (Makefile: generate doc versions via
GIT-VERSION-GEN, 2024-12-06), building with Asciidoctor results in
manpages where the headers no longer contain "Git Manual" and the
footers no longer identify the built Git version.

Before a38edab7c8, we used to just provide a few attributes to
Asciidoctor (and asciidoc). Commit 7a30134358 (asciidoctor-extensions:
provide `<refmiscinfo/>`, 2019-09-16) noted that older versions of
Asciidoctor didn't propagate those attributes into the built XML files,
so we started injecting them ourselves from this script. With newer
versions of Asciidoctor, we'd end up with some harmless duplication
among the tags in the final XML.

Post-a38edab7c8, we don't provide these attributes and Asciidoctor
inserts empty-ish values. After our additions from 7a30134358, we get

  <refmiscinfo class="source">&#160;</refmiscinfo>
  <refmiscinfo class="manual">&#160;</refmiscinfo>
  <refmiscinfo class="source">2.47.1.[...]</refmiscinfo>
  <refmiscinfo class="manual">Git Manual</refmiscinfo>

When these are handled, it appears to be first come first served,
meaning that our additions have no effect and we regress as described in
the first paragraph.

Remove existing "source" or "manual" <refmiscinfo/> tags before adding
ours. I considered removing all <refmiscinfo/> to get a nice clean
slate, instead of just those two that we want to replace to be a bit
more precise. I opted for the latter. Maybe one day, Asciidoctor learns
to insert something useful there which `xmlto` can pick up and make good
use of -- let's not interfere.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoMerge branch 'ps/build-hotfix' into ma/asciidoctor-build-fixes
Junio C Hamano [Sat, 21 Dec 2024 01:34:25 +0000 (17:34 -0800)] 
Merge branch 'ps/build-hotfix' into ma/asciidoctor-build-fixes

* ps/build-hotfix:
  meson: add options to override build information
  GIT-VERSION-GEN: fix overriding GIT_BUILT_FROM_COMMIT and GIT_DATE
  GIT-VERSION-GEN: fix overriding GIT_VERSION
  Makefile: introduce template for GIT-VERSION-GEN
  Makefile: drop unneeded indirection for GIT-VERSION-GEN outputs
  Makefile: stop including "GIT-VERSION-FILE" in docs

6 months agomeson: add options to override build information
Patrick Steinhardt [Fri, 20 Dec 2024 19:44:26 +0000 (20:44 +0100)] 
meson: add options to override build information

We inject various different kinds of build information into build
artifacts, like the version string or the commit from which Git was
built. Add options to let users explicitly override this information
with Meson.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoGIT-VERSION-GEN: fix overriding GIT_BUILT_FROM_COMMIT and GIT_DATE
Patrick Steinhardt [Fri, 20 Dec 2024 19:44:25 +0000 (20:44 +0100)] 
GIT-VERSION-GEN: fix overriding GIT_BUILT_FROM_COMMIT and GIT_DATE

Same as with the preceding commit, neither GIT_BUILT_FROM_COMMIT nor
GIT_DATE can be overridden via the environment. Especially the latter is
of importance given that we set it in our own "Documentation/doc-diff"
script.

Make the values of both variables overridable. Luckily we don't pull in
these values via any included Makefiles, so the fix is trivial compared
to the fix for GIT_VERSON.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoGIT-VERSION-GEN: fix overriding GIT_VERSION
Patrick Steinhardt [Fri, 20 Dec 2024 19:44:24 +0000 (20:44 +0100)] 
GIT-VERSION-GEN: fix overriding GIT_VERSION

GIT-VERSION-GEN tries to derive the version that Git is being built from
via multiple different sources in the following order:

  1. A file called "version" in the source tree's root directory, if it
     exists.

  2. The current commit in case Git is built from a Git repository.

  3. Otherwise, we use a fallback version stored in a variable which is
     bumped whenever a new Git version is getting tagged.

It used to be possible to override the version by overriding the
`GIT_VERSION` Makefile variable (e.g. `make GIT_VERSION=foo`). This
worked somewhat by chance, only: `GIT-VERSION-GEN` would write the
actual Git version into `GIT-VERSION-FILE`, not the overridden value,
but when including the file into our Makefile we would not override the
`GIT_VERSION` variable because it has already been set by the user. And
because our Makefile used the variable to propagate the version to our
build tools instead of using `GIT-VERSION-FILE` the resulting build
artifacts used the overridden version.

But that subtle mechanism broke with 4838deab65 (Makefile: refactor
GIT-VERSION-GEN to be reusable, 2024-12-06) and subsequent commits
because the version information is not propagated via the Makefile
variable anymore, but instead via the files that `GIT-VERSION-GEN`
started to write. And as the script never knew about the `GIT_VERSION`
environment variable in the first place it uses one of the values listed
above instead of the overridden value.

Fix this issue by making `GIT-VERSION-GEN` handle the case where
`GIT_VERSION` has been set via the environment.

Note that this requires us to introduce a new GIT_VERSION_OVERRIDE
variable that stores a potential user-provided value, either via the
environment or via "config.mak". Ideally we wouldn't need it and could
just continue to use GIT_VERSION for this. But unfortunately, Makefiles
will first include all sub-Makefiles before figuring out whether it
needs to re-make any of them [1]. Consequently, if there already is a
GIT-VERSION-FILE, we would have slurped in its value of GIT_VERSION
before we call GIT-VERSION-GEN, and because GIT-VERSION-GEN now uses
that value as an override it would mean that the first generated value
for GIT_VERSION will remain unchanged.

Furthermore we have to move the include for "GIT-VERSION-FILE" after the
includes for "config.mak" and related so that GIT_VERSION_OVERRIDE can
be set to the value provided by "config.mak".

[1]: https://www.gnu.org/software/make/manual/html_node/Remaking-Makefiles.html

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoMakefile: introduce template for GIT-VERSION-GEN
Patrick Steinhardt [Fri, 20 Dec 2024 19:44:23 +0000 (20:44 +0100)] 
Makefile: introduce template for GIT-VERSION-GEN

Introduce a new template to call GIT-VERSION-GEN. This will allow us to
iterate on how exactly the script is called in subsequent commits
without having to adapt all call sites every time.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoMakefile: drop unneeded indirection for GIT-VERSION-GEN outputs
Patrick Steinhardt [Fri, 20 Dec 2024 19:44:22 +0000 (20:44 +0100)] 
Makefile: drop unneeded indirection for GIT-VERSION-GEN outputs

Some of the callsites of GIT-VERSION-GEN generate the target file with a
"+" suffix first and then move the file into place when the new contents
are different compared to the old contents. This allows us to avoid a
needless rebuild by not updating timestamps of the target file when its
contents will remain unchanged anyway.

In fact though, this exact logic is already handled in GIT-VERSION-GEN,
so doing this manually is pointless. This is a leftover from an earlier
version of 4838deab65 (Makefile: refactor GIT-VERSION-GEN to be
reusable, 2024-12-06), where the script didn't handle that logic for us.

Drop the needless indirection.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoMakefile: stop including "GIT-VERSION-FILE" in docs
Patrick Steinhardt [Fri, 20 Dec 2024 19:44:21 +0000 (20:44 +0100)] 
Makefile: stop including "GIT-VERSION-FILE" in docs

We include "GIT-VERSION-FILE" in our docs Makefile, but don't actually
use the "GIT_VERSION" variable that it provides. This is a leftover from
the conversion to make "GIT-VERSION-GEN" generate version information
in-place by substituting placeholders in 4838deab65 (Makefile: refactor
GIT-VERSION-GEN to be reusable, 2024-12-06) and subsequent commits,
where all usages of the variable were removed.

Stop including the file.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agomeson: skip gitweb build when Perl is disabled
Patrick Steinhardt [Fri, 20 Dec 2024 16:30:35 +0000 (17:30 +0100)] 
meson: skip gitweb build when Perl is disabled

It is possible to configure a Git build without Perl when disabling both
our test suite and all Perl-based features. In Meson, this can be
achieved with `meson setup -Dperl=disabled -Dtests=false`.

It was reported by a user that this breaks the Meson build because
gitweb gets built even if Perl was not discovered in such a build:

    $ meson setup .. -Dtests=false -Dperl=disabled
    ...
    ../gitweb/meson.build:2:43: ERROR: Unable to get the path of a not-found external program

Fix this issue by introducing a new feature-option that allows the user
to configure whether or not to build Gitweb. The feature is set to
'auto' by default and will be disabled automatically in case Perl was
not found on the system.

Reported-by: Daniel Engberg <daniel.engberg.lists@pyret.net>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agorefs: mark invalid refname message for translation
Karthik Nayak [Fri, 20 Dec 2024 12:58:37 +0000 (13:58 +0100)] 
refs: mark invalid refname message for translation

The error message produced by `transaction_refname_valid()` changes based
on whether the update is a ref update or a reflog update, with the use
of a ternary operator. This breaks translation since the sub-msg is not
marked for translation. Fix this by setting the entire message using a
`if {} else {}` block and marking each message for translation.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoprio-queue: use size_t rather than int for size
Jeff King [Fri, 20 Dec 2024 08:49:49 +0000 (03:49 -0500)] 
prio-queue: use size_t rather than int for size

The alloc and nr fields of a prio-queue tell us how much memory is
allocated and used in the array. So the natural type for them is size_t,
which prevents overflow on 64-bit systems where "int" is still 32 bits.

This is unlikely to happen in practice, as we typically use it for
storing commits, and having 2^31 of those is rather a lot. But it's good
to keep our generic data structures as flexible as possible. And as we
start to enforce -Wsign-compare, it means that callers need to use
"int", too, and the problem proliferates. Let's fix it at the source.

The changes here can be put into a few groups:

  1. Changing the alloc/nr fields in the struct to size_t. This requires
     swapping out int for size_t in negotiator/skipping.c, as well as
     in prio_queue_get(), because those all iterate over the array.
     Building with -Wsign-compare complains about these.

  2. Other code that assigns or passes around indexes into the array
     (e.g., the swap() and compare() functions) won't trigger
     -Wsign-compare because we are simply truncating the values. These
     are caught by -Wconversion, but I've adjusted them here to
     future-proof us.

  3. In prio_queue_reverse() we compute "queue->nr - 1" without checking
     if anything is in the queue, which underflows now that nr is
     unsigned. We can fix that by returning early when the queue is
     empty (there is nothing to reverse).

  4. The insertion_ctr variable is currently unsigned, but can likewise
     grow (it is actually worse, because adding and removing an element
     many times will keep increasing the counter, even though "nr" does
     not). I've bumped that to size_t here, as well.

     But -Wconversion notes that computing the "cmp" result by
     subtracting the counters and assigning to "int" is a potential
     problem. And that's true even before this patch, since we use an
     unsigned counter (imagine comparing "2^32-1" and "0", which should
     be a high positive value, but instead is "-1" as a signed int).

     Since we only care about the sign (and not the magnitude) of the
     result, we could fix this by swapping out the subtraction for a
     ternary comparison. Probably the performance impact would be
     negligible, since we just called into a custom compare function and
     branched on its result anyway. But it's easy enough to do a
     branchless version by subtracting the comparison results.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoFinishing touches before 2.48-rc1
Junio C Hamano [Thu, 19 Dec 2024 18:57:38 +0000 (10:57 -0800)] 
Finishing touches before 2.48-rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoMerge branch 'tc/bundle-with-tag-remove-workaround'
Junio C Hamano [Thu, 19 Dec 2024 18:58:33 +0000 (10:58 -0800)] 
Merge branch 'tc/bundle-with-tag-remove-workaround'

"git bundle create" with an annotated tag on the positive end of
the revision range had a workaround code for older limitation in
the revision walker, which has become unnecessary.

* tc/bundle-with-tag-remove-workaround:
  bundle: remove unneeded code

6 months agoMerge branch 'mh/doc-windows-home-env'
Junio C Hamano [Thu, 19 Dec 2024 18:58:32 +0000 (10:58 -0800)] 
Merge branch 'mh/doc-windows-home-env'

Doc update.

* mh/doc-windows-home-env:
  Document HOME environment variable

6 months agoMerge branch 'js/log-remerge-keep-ancestry'
Junio C Hamano [Thu, 19 Dec 2024 18:58:31 +0000 (10:58 -0800)] 
Merge branch 'js/log-remerge-keep-ancestry'

"git log -p --remerge-diff --reverse" was completely broken.

* js/log-remerge-keep-ancestry:
  log: --remerge-diff needs to keep around commit parents

6 months agoMerge branch 'bf/fetch-set-head-config'
Junio C Hamano [Thu, 19 Dec 2024 18:58:29 +0000 (10:58 -0800)] 
Merge branch 'bf/fetch-set-head-config'

"git fetch" honors "remote.<remote>.followRemoteHEAD" settings to
tweak the remote-tracking HEAD in "refs/remotes/<remote>/HEAD".

* bf/fetch-set-head-config:
  remote set-head: set followRemoteHEAD to "warn" if "always"
  fetch set_head: add warn-if-not-$branch option
  fetch set_head: move warn advice into advise_if_enabled
  fetch: add configuration for set_head behaviour

6 months agoMerge branch 'jc/set-head-symref-fix'
Junio C Hamano [Thu, 19 Dec 2024 18:58:28 +0000 (10:58 -0800)] 
Merge branch 'jc/set-head-symref-fix'

"git fetch" from a configured remote learned to update a missing
remote-tracking HEAD but it asked the remote about their HEAD even
when it did not need to, which has been corrected.  Incidentally,
this also corrects "git fetch --tags $URL" which was broken by the
new feature in an unspecified way.

* jc/set-head-symref-fix:
  fetch: do not ask for HEAD unnecessarily

6 months agoMerge branch 'bf/set-head-symref'
Junio C Hamano [Thu, 19 Dec 2024 18:58:27 +0000 (10:58 -0800)] 
Merge branch 'bf/set-head-symref'

When "git fetch $remote" notices that refs/remotes/$remote/HEAD is
missing and discovers what branch the other side points with its
HEAD, refs/remotes/$remote/HEAD is updated to point to it.

* bf/set-head-symref:
  fetch set_head: handle mirrored bare repositories
  fetch: set remote/HEAD if it does not exist
  refs: add create_only option to refs_update_symref_extended
  refs: add TRANSACTION_CREATE_EXISTS error
  remote set-head: better output for --auto
  remote set-head: refactor for readability
  refs: atomically record overwritten ref in update_symref
  refs: standardize output of refs_read_symbolic_ref
  t/t5505-remote: test failure of set-head
  t/t5505-remote: set default branch to main

6 months agogit: use calloc instead of malloc + memset where possible
Seija Kijin [Wed, 18 Dec 2024 16:48:32 +0000 (16:48 +0000)] 
git: use calloc instead of malloc + memset where possible

Avoid calling malloc + memset by calling calloc.

Signed-off-by: Seija Kijin <doremylover123@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agopack-bitmap.c: ensure pack validity for all reuse packs
Taylor Blau [Fri, 13 Dec 2024 19:20:02 +0000 (14:20 -0500)] 
pack-bitmap.c: ensure pack validity for all reuse packs

Commit 44f9fd6496 (pack-bitmap.c: check preferred pack validity when
opening MIDX bitmap, 2022-05-24) prevents a race condition whereby the
preferred pack disappears between opening the MIDX bitmap and attempting
verbatim reuse out of its packs.

That commit forces open_midx_bitmap_1() to ensure the validity of the
MIDX's preferred pack, meaning that we have an open file handle on the
*.pack, ensuring that we can reuse bytes out of verbatim later on in the
process[^1].

But 44f9fd6496 was not extended to cover multi-pack reuse, meaning that
this same race condition exists for non-preferred packs during verbatim
reuse. Work around that race in the same way by only marking valid packs
as reuse-able. For packs that aren't reusable, skip over them but
include the number of objects they have to ensure we allocate a large
enough 'reuse' bitmap (e.g. if a pack in the middle of the MIDX
disappeared but we still want to reuse later packs).

Since we're ensuring the validity of these packs within the verbatim
reuse code, we no longer have to special-case the preferred pack and
open it within the open_midx_bitmap_1() function.

An alternative approach to the one taken here would be to open all
MIDX'd packs from within open_midx_bitmap_1(). But that would be both
slower and make the bitmaps less useful, since we can still perform some
pack reuse among the packs that still exist when the *.bitmap is opened.

After applying this patch, we can simulate the new behavior after
instrumenting Git like so:

    diff --git a/packfile.c b/packfile.c
    index 9560f0a33c..aedce72524 100644
    --- a/packfile.c
    +++ b/packfile.c
    @@ -557,6 +557,11 @@ static int open_packed_git_1(struct packed_git *p)
      ; /* nothing */

      p->pack_fd = git_open(p->pack_name);
    + {
    + const char *delete = getenv("GIT_RACILY_DELETE");
    + if (delete && !strcmp(delete, pack_basename(p)))
    + return -1;
    + }
      if (p->pack_fd < 0 || fstat(p->pack_fd, &st))
      return -1;
      pack_open_fds++;

and adding the following test:

    test_expect_success 'disappearing packs' '
            git init disappearing-packs &&
            (
                    cd disappearing-packs &&

                    git config pack.allowPackReuse multi &&

                    test_commit A &&
                    test_commit B &&
                    test_commit C &&

                    A="$(echo "A" | git pack-objects --revs $packdir/pack-A)" &&
                    B="$(echo "A..B" | git pack-objects --revs $packdir/pack-B)" &&
                    C="$(echo "B..C" | git pack-objects --revs $packdir/pack-C)" &&

                    git multi-pack-index write --bitmap --preferred-pack=pack-A-$A.idx &&

                    test_pack_objects_reused_all 9 3 &&

                    test_env GIT_RACILY_DELETE=pack-A-$A.pack \
                            test_pack_objects_reused_all 6 2 &&
                    test_env GIT_RACILY_DELETE=pack-B-$B.pack \
                            test_pack_objects_reused_all 6 2 &&
                    test_env GIT_RACILY_DELETE=pack-C-$C.pack \
                            test_pack_objects_reused_all 6 2

            )
    '

Note that we could relax the single-pack version of this which was most
recently addressed in dc1daacdcc (pack-bitmap: check pack validity when
opening bitmap, 2021-07-23), but only partially. Because we still need
to know the object count in the pack, we'd still have to open the pack's
*.idx, so the savings there are marginal.

Note likewise that we add a new "if (!packs_nr)" early return in the
pack reuse code to avoid a potentially expensive allocation on the
'reuse' bitmap in the case that no packs are available for reuse.

[^1]: Unless we run out of open file handles. If that happens and we are
  forced to close the only open file handle of a file that has been
  removed from underneath us, there is nothing we can do.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agodoc: remove extra quotes in generated docs
Kyle Lippincott [Wed, 18 Dec 2024 00:57:02 +0000 (00:57 +0000)] 
doc: remove extra quotes in generated docs

Commit a38edab7c8 (Makefile: generate doc versions via GIT-VERSION-GEN,
2024-12-06) moved these variables from the Makefile to asciidoc.conf.in.
When doing so, some extraneous quotes were added; these are visible in
the generated .xml files, at least, and possibly in other locations:

    --- a/tmp/orig-git-bisect.xml
    +++ b/Documentation/git-bisect.xml
    @@ -5,14 +5,14 @@
     <refentry lang="en">
     <refentryinfo>
 <title>git-bisect(1)</title>
    -    <date>2024-12-06</date>
    -<revhistory><revision><date>2024-12-06</date></revision></revhistory>
    +    <date>'2024-12-06'</date>^M
    +<revhistory><revision><date>'2024-12-06'</date></revision></revhistory>^M
     </refentryinfo>
     <refmeta>
     <refentrytitle>git-bisect</refentrytitle>
     <manvolnum>1</manvolnum>
    -<refmiscinfo class="source">Git 2.47.1.409.g9bb10d27e7</refmiscinfo>
    -<refmiscinfo class="manual">Git Manual</refmiscinfo>
    +<refmiscinfo class="source">'Git 2.47.1.410.ga38edab7c8'</refmiscinfo>^M
    +<refmiscinfo class="manual">'Git Manual'</refmiscinfo>^M
     </refmeta>
     <refnamediv>
 <refname>git-bisect</refname>

Signed-off-by: Kyle Lippincott <spectral@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoMerge https://github.com/j6t/gitk
Junio C Hamano [Wed, 18 Dec 2024 00:17:28 +0000 (16:17 -0800)] 
Merge https://github.com/j6t/gitk

* 'master' of https://github.com/j6t/gitk:
  gitk: offer "Copy commit ID to X11 selection" only on X11
  gitk: support auto-copy comit ID to primary clipboard
  gitk: prefs dialog: refine Auto-select UI
  gitk: UI text: change "SHA1 ID" to "Commit ID"
  gitk: add text wrapping preferences
  gitk: make headings of preferences bold
  gitk: check main window visibility before waiting for it to show
  gitk: sv.po: Update Swedish translation (323t)

6 months agoMerge branch 'ah/commit-id-to-clipboard'
Johannes Sixt [Tue, 17 Dec 2024 20:54:58 +0000 (21:54 +0100)] 
Merge branch 'ah/commit-id-to-clipboard'

* ah/commit-id-to-clipboard:
  gitk: offer "Copy commit ID to X11 selection" only on X11
  gitk: support auto-copy comit ID to primary clipboard
  gitk: prefs dialog: refine Auto-select UI
  gitk: UI text: change "SHA1 ID" to "Commit ID"

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
6 months agocmake/vcxproj: stop special-casing `remote-ext`
Johannes Schindelin [Tue, 17 Dec 2024 17:32:01 +0000 (17:32 +0000)] 
cmake/vcxproj: stop special-casing `remote-ext`

When the `vcxproj` target was introduced in `config.mak.uname` to allow
building Git with the Visual C toolchain, the `git remote-ext` command
was always executed in its dashed form. Therefore, it was impossible to
pass the test suite unless that command existed in its dashed form, and
we had to special-case this.

Later, when the `vcxproj` target got out of fashion because Visual
Studio gained native support for CMake builds, this special-casing was
copied without questioning it.

But as of 675df192c5f (transport-helper: do not run git-remote-ext etc.
in dashed form, 2020-08-26), the reason for this special-casing no
longer exists. So let's just drop it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agocmake: put the Perl modules into the correct location again
Johannes Schindelin [Tue, 17 Dec 2024 17:32:00 +0000 (17:32 +0000)] 
cmake: put the Perl modules into the correct location again

In ccfba9e0c45 (Makefile: use "generate-perl.sh" to massage Perl
library, 2024-12-06), the previous strategy (which avoided spawning a
shell script to transform the files) was replaced by the same
`generate-perl.sh` invocation as for the Makefile-based build.

The only difference is that now the transformation tries to handle the
Perl modules in-place (which ends up in empty files because the same
file is used as input and output via stdin/stdout redirection), and the
Perl script cannot find them anymore because they are not in the
expected place.

Let's put them into the expected place again, i.e. into
`perl/build/lib/` instead of `perl/`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agocmake: use the correct file name for the Perl header
Johannes Schindelin [Tue, 17 Dec 2024 17:31:59 +0000 (17:31 +0000)] 
cmake: use the correct file name for the Perl header

In e4b488049a5 (Makefile: extract script to massage Perl scripts,
2024-12-06), the code was refactored that is used to transform the Perl
scripts/modules to their final form.

Even the CMake-based build was adjusted, but the change used the file
name `PERL-HEADER` instead of the file name used by the Makefile-based
build (same name but with the `GIT-` prefix). Let's adjust the former to
the latter.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agocmake(mergetools): better support for out-of-tree builds
Johannes Schindelin [Tue, 17 Dec 2024 17:31:58 +0000 (17:31 +0000)] 
cmake(mergetools): better support for out-of-tree builds

In 7e0730c8baa (t: better support for out-of-tree builds, 2024-12-06)
the strategy was changed from letting `t7609-mergetool--lib.sh`
hard-code the directory where it expects to find the merge tools to
hard-coding that value in the placeholder `@GIT_TEST_MERGE_TOOLS_DIR@`
that is replaced during the build.

However, likely due to a copy/paste mistake (and reviewers missed this,
too), the CMake-based build was adjusted incorrectly, replacing that
placeholder not with the path to the merge tools, but with a Boolean
indicating whether to use a runtime-generated path prefix or not.

Let's fix that, addressing this CMake-build's symptom:

  Initialized empty Git repository in D:/a/git/git/t/trash directory.t7609-mergetool--lib/.git/
  ++ . true/vimdiff
  ./test-lib.sh: line 1021: true/vimdiff: No such file or directory

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agocmake: better support for out-of-tree builds follow-up
Johannes Schindelin [Tue, 17 Dec 2024 17:31:57 +0000 (17:31 +0000)] 
cmake: better support for out-of-tree builds follow-up

In 7e0730c8baa (t: better support for out-of-tree builds, 2024-12-06),
the `bin-wrappers/` strategy was changed so that it no longer hard-codes
the template directory to be `@BUILD_DIR@/templates/blt`, but instead
interpolates the `@TEMPLATE_DIR@` placeholder during the build.

However, this commit only adjusted the `Makefile`-based build.

Let's adjust the CMake-based build as well. This fixes t0000.15 which
would otherwise fail with:

  ++ echo ''\''t1234-verbose/err'\'' is not empty, it contains:'
  't1234-verbose/err' is not empty, it contains:
  ++ cat t1234-verbose/err
  warning: templates not found in @TEMPLATE_DIR@

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoGitHub ci(windows): speed up initializing Git for Windows' minimal SDK again
Johannes Schindelin [Tue, 17 Dec 2024 14:57:38 +0000 (14:57 +0000)] 
GitHub ci(windows): speed up initializing Git for Windows' minimal SDK again

It used to be the case that initializing the minimal SDK (i.e. a
radically slimmed-down subset of Git for Windows' development
environment intended to perform the CI builds and little else) took
a bit over one minute, would then be cached, and subsequent jobs would
take at most half a dozen seconds to initialize said minimal SDK.

It is important that this step is fast because we have to run the test
suite in parallel, in a set of matrix jobs, to offset the slowness of
the shell-based test suite, and each and every job has to initialize the
very same minimal SDK.

While it may sound as if parallelizing the jobs might only waste the
generously-provided build minutes but at least the _wallclock_ time
would pass quick, in reality it matters a lot: Frequently Git for
Windows' or GitGitGadget PRs get stuck waiting for quite a while before
CI builds start because other PRs' builds still spend substantial
amounts of time to run, blocking due to the concurrency limit being
reached.

Since 91839a88277 (ci: create script to set up Git for Windows SDK,
2024-10-09), the situation has worsened: every job that requires the
minimal Git for Windows SDK spends roughly two-and-a-half minutes doing
so.

With the switch away from the GitHub Action `setup-git-for-windows-sdk`,
we incurred more downsides:

- It is no longer possible for said Action to fix problems independently
  from the Git repository, e.g. when new rules about GitHub Actions
  require changes in the way the minimal SDK is initialized.

- The minimal SDK was installed specifically outside of the worktree so
  as not to clutter it nor incur an additional cost to verify that the
  worktree is clean.

Therefore, even if it would be nice to have a shared process between
GitHub and GitLab based CI builds, let's switch the GitHub-based CI back
to the tried-and-tested `setup-git-for-windows-sdk` Action.

This commit partially reverts 91839a88277 (ci: create script to set up
Git for Windows SDK, 2024-10-09).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agomingw_rename: do support directory renames
Johannes Schindelin [Tue, 17 Dec 2024 12:52:04 +0000 (12:52 +0000)] 
mingw_rename: do support directory renames

In 391bceae435 (compat/mingw: support POSIX semantics for atomic
renames, 2024-10-27), we taught the `mingw_rename()` function to respect
POSIX semantics, but we did so only as a fallback after `_wrename()`
fails.

This hid a bug in the implementation that was not caught by Git's test
suite: The `CreateFileW()` function _can_ open handles to directories,
but not when asked to use the `FILE_ATTRIBUTE_NORMAL` flag, as that flag
only is allowed for files.

Let's fix this by using the common `FILE_FLAG_BACKUP_SEMANTICS` flag
that can be used for opening handles to directories, too.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agorefs: add support for migrating reflogs
Karthik Nayak [Mon, 16 Dec 2024 16:44:33 +0000 (17:44 +0100)] 
refs: add support for migrating reflogs

The `git refs migrate` command was introduced in
25a0023f28 (builtin/refs: new command to migrate ref storage formats,
2024-06-06) to support migrating from one reference backend to another.

One limitation of the command was that it didn't support migrating
repositories which contained reflogs. A previous commit, added support
for adding reflog updates in ref transactions. Using the added
functionality bake in reflog support for `git refs migrate`.

To ensure that the order of the reflogs is maintained during the
migration, we add the index for each reflog update as we iterate over
the reflogs from the old reference backend. This is to ensure that the
order is maintained in the new backend.

Helped-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agorefs: allow multiple reflog entries for the same refname
Karthik Nayak [Mon, 16 Dec 2024 16:44:32 +0000 (17:44 +0100)] 
refs: allow multiple reflog entries for the same refname

The reference transaction only allows a single update for a given
reference to avoid conflicts. This, however, isn't an issue for reflogs.
There are no conflicts to be resolved in reflogs and when migrating
reflogs between backends we'd have multiple reflog entries for the same
refname.

So allow multiple reflog updates within a single transaction. Also the
reflog creation logic isn't exposed to the end user. While this might
change in the future, currently, this reduces the scope of issues to
think about.

In the reftable backend, the writer sorts all updates based on the
update_index before writing to the block. When there are multiple
reflogs for a given refname, it is essential that the order of the
reflogs is maintained. So add the `index` value to the `update_index`.
The `index` field is only set when multiple reflog entries for a given
refname are added and as such in most scenarios the old behavior
remains.

This is required to add reflog migration support to `git refs migrate`.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agorefs: introduce the `ref_transaction_update_reflog` function
Karthik Nayak [Mon, 16 Dec 2024 16:44:31 +0000 (17:44 +0100)] 
refs: introduce the `ref_transaction_update_reflog` function

Introduce a new function `ref_transaction_update_reflog`, for clients to
add a reflog update to a transaction. While the existing function
`ref_transaction_update` also allows clients to add a reflog entry, this
function does a few things more, It:
  - Enforces that only a reflog entry is added and does not update the
  ref itself.
  - Allows the users to also provide the committer information. This
  means clients can add reflog entries with custom committer
  information.

The `transaction_refname_valid()` function also modifies the error
message selectively based on the type of the update. This change also
affects reflog updates which go through `ref_transaction_update()`.

A follow up commit will utilize this function to add reflog support to
`git refs migrate`.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agorefs: add `committer_info` to `ref_transaction_add_update()`
Karthik Nayak [Mon, 16 Dec 2024 16:44:30 +0000 (17:44 +0100)] 
refs: add `committer_info` to `ref_transaction_add_update()`

The `ref_transaction_add_update()` creates the `ref_update` struct. To
facilitate addition of reflogs in the next commit, the function needs to
accommodate setting the `committer_info` field in the struct. So modify
the function to also take `committer_info` as an argument and set it
accordingly.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agorefs: extract out refname verification in transactions
Karthik Nayak [Mon, 16 Dec 2024 16:44:29 +0000 (17:44 +0100)] 
refs: extract out refname verification in transactions

Unless the `REF_SKIP_REFNAME_VERIFICATION` flag is set for an update,
the refname of the update is verified for:

  - Ensuring it is not a pseudoref.
  - Checking the refname format.

These checks will also be needed in a following commit where the
function to add reflog updates to the transaction is introduced. Extract
the code out into a new static function.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agorefs/files: add count field to ref_lock
Karthik Nayak [Mon, 16 Dec 2024 16:44:28 +0000 (17:44 +0100)] 
refs/files: add count field to ref_lock

When refs are updated in the files-backend, a lock is obtained for the
corresponding file path. This is the case even for reflogs, i.e. a lock
is obtained on the reference path instead of the reflog path. This
works, since generally, reflogs are updated alongside the ref.

The upcoming patches will add support for reflog updates in ref
transaction. This means, in a particular transaction we want to have ref
updates and reflog updates. For a given ref in a given transaction there
can be at most one update. But we can theoretically have multiple reflog
updates for a given ref in a given transaction. A great example of this
would be when migrating reflogs from one backend to another. There we
would batch all the reflog updates for a given reference in a single
transaction.

The current flow does not support this, because currently refs & reflogs
are treated as a single entity and capture the lock together. To
separate this, add a count field to ref_lock. With this, multiple
updates can hold onto a single ref_lock and the lock will only be
released when all of them release the lock.

This patch only adds the `count` field to `ref_lock` and adds the logic
to increment and decrement the lock. In a follow up commit, we'll
separate the reflog update logic from ref updates and utilize this
functionality.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agorefs: add `index` field to `struct ref_udpate`
Karthik Nayak [Mon, 16 Dec 2024 16:44:27 +0000 (17:44 +0100)] 
refs: add `index` field to `struct ref_udpate`

The reftable backend, sorts its updates by refname before applying them,
this ensures that the references are stored sorted. When migrating
reflogs from one backend to another, the order of the reflogs must be
maintained. Add a new `index` field to the `ref_update` struct to
facilitate this.

This field is used in the reftable backend's sort comparison function
`transaction_update_cmp`, to ensure that indexed fields maintain their
order.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agorefs: include committer info in `ref_update` struct
Karthik Nayak [Mon, 16 Dec 2024 16:44:26 +0000 (17:44 +0100)] 
refs: include committer info in `ref_update` struct

The reference backends obtain the committer information from
`git_committer_info(0)` when adding a reflog. The upcoming patches
introduce support for migrating reflogs between the reference backends.
This requires an interface to creating reflogs, including custom
committer information.

Add a new field `committer_info` to the `ref_update` struct, which is
then used by the reference backends. If there is no `committer_info`
provided, the reference backends default to using
`git_committer_info(0)`. The field itself cannot be set to
`git_committer_info(0)` since the values are dynamic and must be
obtained right when the reflog is being committed.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoGit 2.48-rc0 v2.48.0-rc0
Junio C Hamano [Mon, 16 Dec 2024 16:54:04 +0000 (08:54 -0800)] 
Git 2.48-rc0

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agorange-diff: introduce the convenience option `--remerge-diff`
Johannes Schindelin [Mon, 16 Dec 2024 14:11:22 +0000 (14:11 +0000)] 
range-diff: introduce the convenience option `--remerge-diff`

Just like `git log`, now also `git range-diff` has that option as a
shortcut for the common operation that would otherwise require the quite
unwieldy (if theoretically "more correct") `--diff-mode=remerge` option.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agorange-diff: optionally include merge commits' diffs in the analysis
Johannes Schindelin [Mon, 16 Dec 2024 14:11:21 +0000 (14:11 +0000)] 
range-diff: optionally include merge commits' diffs in the analysis

The `git log` command already offers support for including diffs for
merges, via the `--diff-merges=<format>` option.

Let's add corresponding support for `git range-diff`, too. This makes it
more convenient to spot differences between commit ranges that contain
merges.

This is especially true in scenarios with non-trivial merges, i.e.
merges introducing changes other than, or in addition to, what merge ORT
would have produced. Merging a topic branch that changes a function
signature into a branch that added a caller of that function, for
example, would require the merge commit itself to adjust that caller to
the modified signature.

In my code reviews, I found the `--diff-merges=remerge` option
particularly useful.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoMerge branch 'js/log-remerge-keep-ancestry' into js/range-diff-diff-merges
Junio C Hamano [Mon, 16 Dec 2024 16:45:14 +0000 (08:45 -0800)] 
Merge branch 'js/log-remerge-keep-ancestry' into js/range-diff-diff-merges

* js/log-remerge-keep-ancestry:
  log: --remerge-diff needs to keep around commit parents

6 months agoMerge branch 'ps/build'
Junio C Hamano [Mon, 16 Dec 2024 01:54:32 +0000 (17:54 -0800)] 
Merge branch 'ps/build'

Build procedure update plus introduction of Meson based builds.

* ps/build: (24 commits)
  Introduce support for the Meson build system
  Documentation: add comparison of build systems
  t: allow overriding build dir
  t: better support for out-of-tree builds
  Documentation: extract script to generate a list of mergetools
  Documentation: teach "cmd-list.perl" about out-of-tree builds
  Documentation: allow sourcing generated includes from separate dir
  Makefile: simplify building of templates
  Makefile: write absolute program path into bin-wrappers
  Makefile: allow "bin-wrappers/" directory to exist
  Makefile: refactor generators to be PWD-independent
  Makefile: extract script to generate gitweb.js
  Makefile: extract script to generate gitweb.cgi
  Makefile: extract script to massage Python scripts
  Makefile: extract script to massage Shell scripts
  Makefile: use "generate-perl.sh" to massage Perl library
  Makefile: extract script to massage Perl scripts
  Makefile: consistently use PERL_PATH
  Makefile: generate doc versions via GIT-VERSION-GEN
  Makefile: generate "git.rc" via GIT-VERSION-GEN
  ...

6 months agoMerge branch 'jt/fix-fattening-promisor-fetch'
Junio C Hamano [Mon, 16 Dec 2024 01:54:31 +0000 (17:54 -0800)] 
Merge branch 'jt/fix-fattening-promisor-fetch'

Fix performance regression of a recent "fatten promisor pack with
local objects" protection against an unwanted gc.

* jt/fix-fattening-promisor-fetch:
  index-pack --promisor: also check commits' trees
  index-pack --promisor: don't check blobs
  index-pack --promisor: dedup before checking links

6 months agoMerge branch 'ps/commit-with-message-syntax-fix'
Junio C Hamano [Mon, 16 Dec 2024 01:54:30 +0000 (17:54 -0800)] 
Merge branch 'ps/commit-with-message-syntax-fix'

The syntax ":/<text>" to name the latest commit with the matching
text was broken with a recent change, which has been corrected.

* ps/commit-with-message-syntax-fix:
  object-name: fix reversed ordering with ":/<text>" revisions

6 months agoMerge branch 'rj/strvec-splice-fix'
Junio C Hamano [Mon, 16 Dec 2024 01:54:29 +0000 (17:54 -0800)] 
Merge branch 'rj/strvec-splice-fix'

Correct strvec_splice() that misbehaved when the strvec is empty.

* rj/strvec-splice-fix:
  strvec: `strvec_splice()` to a statically initialized vector

6 months agoMerge branch 'bf/explicit-config-set-in-advice-messages'
Junio C Hamano [Mon, 16 Dec 2024 01:54:27 +0000 (17:54 -0800)] 
Merge branch 'bf/explicit-config-set-in-advice-messages'

The advice messages now tell the newer 'git config set' command to
set the advice.token configuration variable to squelch a message.

* bf/explicit-config-set-in-advice-messages:
  advice: suggest using subcommand "git config set"

6 months agoMerge branch 'jc/forbid-head-as-tagname'
Junio C Hamano [Mon, 16 Dec 2024 01:54:26 +0000 (17:54 -0800)] 
Merge branch 'jc/forbid-head-as-tagname'

"git tag" has been taught to refuse to create refs/tags/HEAD
as such a tag will be confusing in the context of UI provided by
the Git Porcelain commands.

* jc/forbid-head-as-tagname:
  tag: "git tag" refuses to use HEAD as a tagname
  t5604: do not expect that HEAD can be a valid tagname
  refs: drop strbuf_ prefix from helpers
  refs: move ref name helpers around

6 months agoMerge branch 'jk/describe-perf'
Junio C Hamano [Mon, 16 Dec 2024 01:54:25 +0000 (17:54 -0800)] 
Merge branch 'jk/describe-perf'

"git describe" optimization.

* jk/describe-perf:
  describe: split "found all tags" and max_candidates logic
  describe: stop traversing when we run out of names
  describe: stop digging for max_candidates+1
  t/perf: add tests for git-describe
  t6120: demonstrate weakness in disjoint-root handling

6 months agoMerge branch 'kn/reftable-writer-log-write-verify' into kn/reflog-migration
Junio C Hamano [Sun, 15 Dec 2024 23:49:01 +0000 (15:49 -0800)] 
Merge branch 'kn/reftable-writer-log-write-verify' into kn/reflog-migration

* kn/reftable-writer-log-write-verify:
  reftable/writer: ensure valid range for log's update_index

6 months agogitk: offer "Copy commit ID to X11 selection" only on X11
Johannes Sixt [Sat, 14 Dec 2024 14:53:35 +0000 (15:53 +0100)] 
gitk: offer "Copy commit ID to X11 selection" only on X11

This option is only useful where a selection clipboard is available, which
is only the case on X11. Do not clutter the UI in other environments.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
6 months agoThe sixteenth batch
Junio C Hamano [Fri, 13 Dec 2024 15:33:05 +0000 (07:33 -0800)] 
The sixteenth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoMerge branch 'kk/doc-ancestry-path'
Junio C Hamano [Fri, 13 Dec 2024 15:33:46 +0000 (07:33 -0800)] 
Merge branch 'kk/doc-ancestry-path'

The --ancestry-path option is designed to be given a commit that is
on the path, which was not documented, which has been corrected.

* kk/doc-ancestry-path:
  doc: mention rev-list --ancestry-path restrictions

6 months agoMerge branch 'kn/midx-wo-the-repository'
Junio C Hamano [Fri, 13 Dec 2024 15:33:44 +0000 (07:33 -0800)] 
Merge branch 'kn/midx-wo-the-repository'

Yet another "pass the repository through the callchain" topic.

* kn/midx-wo-the-repository:
  midx: inline the `MIDX_MIN_SIZE` definition
  midx: pass down `hash_algo` to functions using global variables
  midx: pass `repository` to `load_multi_pack_index`
  midx: cleanup internal usage of `the_repository` and `the_hash_algo`
  midx-write: pass down repository to `write_midx_file[_only]`
  write-midx: add repository field to `write_midx_context`
  midx-write: use `revs->repo` inside `read_refs_snapshot`
  midx-write: pass down repository to static functions
  packfile.c: remove unnecessary prepare_packed_git() call
  midx: add repository to `multi_pack_index` struct
  config: make `packed_git_(limit|window_size)` non-global variables
  config: make `delta_base_cache_limit` a non-global variable
  packfile: pass down repository to `for_each_packed_object`
  packfile: pass down repository to `has_object[_kept]_pack`
  packfile: pass down repository to `odb_pack_name`
  packfile: pass `repository` to static function in the file
  packfile: use `repository` from `packed_git` directly
  packfile: add repository to struct `packed_git`

6 months agoMerge branch 'cw/worktree-extension'
Junio C Hamano [Fri, 13 Dec 2024 15:33:43 +0000 (07:33 -0800)] 
Merge branch 'cw/worktree-extension'

Introduce a new repository extension to prevent older Git versions
from mis-interpreting worktrees created with relative paths.

* cw/worktree-extension:
  worktree: refactor `repair_worktree_after_gitdir_move()`
  worktree: add relative cli/config options to `repair` command
  worktree: add relative cli/config options to `move` command
  worktree: add relative cli/config options to `add` command
  worktree: add `write_worktree_linking_files()` function
  worktree: refactor infer_backlink return
  worktree: add `relativeWorktrees` extension
  setup: correctly reinitialize repository version

6 months agoMerge branch 'es/oss-fuzz'
Junio C Hamano [Fri, 13 Dec 2024 15:33:41 +0000 (07:33 -0800)] 
Merge branch 'es/oss-fuzz'

Backport oss-fuzz tests for us to our codebase.

* es/oss-fuzz:
  fuzz: port fuzz-url-decode-mem from OSS-Fuzz
  fuzz: port fuzz-parse-attr-line from OSS-Fuzz
  fuzz: port fuzz-credential-from-url-gently from OSS-Fuzz

6 months agoMerge branch 'en/fast-import-verify-path'
Junio C Hamano [Fri, 13 Dec 2024 15:33:40 +0000 (07:33 -0800)] 
Merge branch 'en/fast-import-verify-path'

"git fast-import" learned to reject paths with ".."  and "." as
their components to avoid creating invalid tree objects.

* en/fast-import-verify-path:
  t9300: test verification of renamed paths
  fast-import: disallow more path components
  fast-import: disallow "." and ".." path components

6 months agoMerge branch 'kh/doc-update-ref-grammofix'
Junio C Hamano [Fri, 13 Dec 2024 15:33:39 +0000 (07:33 -0800)] 
Merge branch 'kh/doc-update-ref-grammofix'

Grammofix.

* kh/doc-update-ref-grammofix:
  Documentation/git-update-ref.txt: add missing word

6 months agoMerge branch 'kh/doc-bundle-typofix'
Junio C Hamano [Fri, 13 Dec 2024 15:33:38 +0000 (07:33 -0800)] 
Merge branch 'kh/doc-bundle-typofix'

Typofix.

* kh/doc-bundle-typofix:
  Documentation/git-bundle.txt: fix word join typo

6 months agoMerge branch 'jc/doc-error-message-guidelines'
Junio C Hamano [Fri, 13 Dec 2024 15:33:37 +0000 (07:33 -0800)] 
Merge branch 'jc/doc-error-message-guidelines'

Developer documentation update.

* jc/doc-error-message-guidelines:
  CodingGuidelines: a handful of error message guidelines

6 months agoMerge branch 'jt/bundle-fsck'
Junio C Hamano [Fri, 13 Dec 2024 15:33:36 +0000 (07:33 -0800)] 
Merge branch 'jt/bundle-fsck'

"git bundle --unbundle" and "git clone" running on a bundle file
both learned to trigger fsck over the new objects with configurable
fck check levels.

* jt/bundle-fsck:
  transport: propagate fsck configuration during bundle fetch
  fetch-pack: split out fsck config parsing
  bundle: support fsck message configuration
  bundle: add bundle verification options type

6 months agolog: --remerge-diff needs to keep around commit parents
Johannes Schindelin [Thu, 12 Dec 2024 10:29:12 +0000 (10:29 +0000)] 
log: --remerge-diff needs to keep around commit parents

To show a remerge diff, the merge needs to be recreated. For that to
work, the merge base(s) need to be found, which means that the commits'
parents have to be traversed until common ancestors are found (if any).

However, one optimization that hails all the way back to cb115748ec0d
(Some more memory leak avoidance, 2006-06-17) is to release the commit's
list of parents immediately after showing it _and to set that parent
list to `NULL`_. This can break the merge base computation.

This problem is most obvious when traversing the commits in reverse: In
that instance, if a parent of a merge commit has been shown as part of
the `git log` command, by the time the merge commit's diff needs to be
computed, that parent commit's list of parent commits will have been set
to `NULL` and as a result no merge base will be found (even if one
should be found).

Traversing commits in reverse is far from the only circumstance in which
this problem occurs, though. There are many avenues to traversing at
least one commit in the revision walk that will later be part of a merge
base computation, for example when not even walking any revisions in
`git show <merge1> <merge2>` where `<merge1>` is part of the commit
graph between the parents of `<merge2>`.

Another way to force a scenario where a commit is traversed before it
has to be traversed again as part of a merge base computation is to
start with two revisions (where the first one is reachable from the
second but not in a first-parent ancestry) and show the commit log with
`--topo-order` and `--first-parent`.

Let's fix this by special-casing the `remerge_diff` mode, similar to
what we did with reflogs in f35650dff6a4 (log: do not free parents when
walking reflog, 2017-07-07).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoci: wire up Meson builds
Patrick Steinhardt [Fri, 13 Dec 2024 10:41:23 +0000 (11:41 +0100)] 
ci: wire up Meson builds

Wire up CI builds for both GitLab and GitHub that use the Meson build
system.

While the setup is mostly trivial, one gotcha is the test output
directory used to be in "t/", but now it is contained in the build
directory. To unify the logic across Makefile- and Meson-based builds we
explicitly set up the `TEST_OUTPUT_DIRECTORY` variable so that it is the
same for both build systems.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agot: introduce compatibility options to clar-based tests
Patrick Steinhardt [Fri, 13 Dec 2024 10:41:22 +0000 (11:41 +0100)] 
t: introduce compatibility options to clar-based tests

Our unit tests that don't yet use the clar unit testing framework ignore
any option that they do not understand. It is thus fine to just pass
test options we set up globally to those unit tests as they are simply
ignored. This makes our life easier because we don't have to special
case those options with Meson, where test options are set up globally
via `meson test --test-args=`.

But our clar-based unit testing framework is way stricter here and will
fail in case it is passed an unknown option. Stub out these options with
no-ops to make our life a bit easier.

Note that this also requires us to remove the `-x` short option for
`--exclude`. This is because `-x` has another meaning in our integration
tests, as it enables shell tracing. I doubt there are a lot of people
out there using it as we only got a small hand full of clar tests in the
first place. So better change it now so that we can in the long run
improve compatibility between the two different test drivers.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agot: fix out-of-tree tests for some git-p4 tests
Patrick Steinhardt [Fri, 13 Dec 2024 10:41:21 +0000 (11:41 +0100)] 
t: fix out-of-tree tests for some git-p4 tests

Both t9835 and t9836 exercise git-p4, but one exercises Python 2 whereas
the other one uses Python 3. These tests do not exercise "git p4", but
instead they use "git p4.py". This calls the unbuilt version of
"git-p4.py" that still has the "#!/usr/bin/env python" shebang, which
allows the test to modify which Python version comes first in $PATH,
making it possible to force a Python version.

But "git-p4.py" is not in our PATH during out-of-tree builds, and thus
we cannot locate "git-p4.py". The tests thus break with CMake and Meson.

Fix this by instead manually setting up script wrappers that invoke the
respective Python interpreter directly.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoMakefile: detect missing Meson tests
Patrick Steinhardt [Fri, 13 Dec 2024 10:41:20 +0000 (11:41 +0100)] 
Makefile: detect missing Meson tests

In the preceding commit, we have introduced consistency checks to Meson
to detect any discrepancies with missing or extraneous tests in its
build instructions. These checks only get executed in Meson though, so
any users of our Makefiles wouldn't be alerted of the fact that they
have to modify the Meson build instructions in case they add or remove
any tests.

Add a comparable test target to our Makefile to plug this gap.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agomeson: detect missing tests at configure time
Patrick Steinhardt [Fri, 13 Dec 2024 10:41:19 +0000 (11:41 +0100)] 
meson: detect missing tests at configure time

It is quite easy for the list of integration tests to go out-of-sync
without anybody noticing. Introduce a new configure-time check that
verifies that all tests are wired up properly.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agot/unit-tests: rename clar-based unit tests to have a common prefix
Patrick Steinhardt [Fri, 13 Dec 2024 10:41:18 +0000 (11:41 +0100)] 
t/unit-tests: rename clar-based unit tests to have a common prefix

All of the code files for unit tests using the self-grown unit testing
framework have a "t-" prefix to their name. This makes it easy to
identify them and use globbing in our Makefile and in other places. On
the other hand though, our clar-based unit tests have no prefix at all
and thus cannot easily be discerned from other files in the unit test
directory.

Introduce a new "u-" prefix for clar-based unit tests. This prefix will
be used in a subsequent commit to easily identify such tests.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoMakefile: drop -DSUPPRESS_ANNOTATED_LEAKS
Patrick Steinhardt [Fri, 13 Dec 2024 10:41:17 +0000 (11:41 +0100)] 
Makefile: drop -DSUPPRESS_ANNOTATED_LEAKS

The -DSUPPRESS_ANNOTATED_LEAKS preprocessor directive was used to enable
our `UNLEAK()` macro in the past, which marks memory as still-reachable
so that the leak sanitizer does not complain. Starting with 52c7dbd036
(git-compat-util: drop now-unused `UNLEAK()` macro, 2024-11-20) this
macro has been removed, and thus the preprocessor directive is not
required anymore, either.

Drop it.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agoci/lib: support custom output directories when creating test artifacts
Patrick Steinhardt [Fri, 13 Dec 2024 10:41:16 +0000 (11:41 +0100)] 
ci/lib: support custom output directories when creating test artifacts

Update `create_failed_test_artifacts ()` so that it can handle arbitrary
test output directories. This fixes creation of these artifacts for
macOS on GitLab CI, which uses a separate output directory already. This
will also be used by our out-of-tree builds with Meson.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 months agogitk: support auto-copy comit ID to primary clipboard
Avi Halachmi (:avih) [Wed, 11 Dec 2024 09:22:03 +0000 (11:22 +0200)] 
gitk: support auto-copy comit ID to primary clipboard

Auto-select ("Copy commit ID to X11 selection") is useful when a
selection cliboard exists, but otherwise generally meaningless, for
instance on Windows.

Add a similar pref and behavior which copies the commit ID to the
primary clipboard - for platforms without a selection clipboard, but
which can also be useful additionally on platforms with selection.

Note that while autoselect is enabled by default, autocopy isn't.

That's because the selection clipboard is typically dispensable, while
the primary clipboard can be considered a more precious resource,
which we don't want to (clear and) overwrite by default.

Signed-off-by: Avi Halachmi (:avih) <avihpit@yahoo.com>