16323 Commits

Author SHA1 Message Date
Patrick Steinhardt
5c6cba5142 tests: wire up reftable tests
Wire up reftable tests so that they can be executed by setting the
`CLAR_REF_FORMAT` environment variable. This only catches tests that use
`cl_git_sandbox_init()`, but that should cover most of our tests. So
this infrastructure isn't perfect, but for now it's good enough. We may
want to iterate on it in the future.
2026-04-16 14:56:46 +02:00
Patrick Steinhardt
415f3fbdb0 tests: generate test resources for reftables
Generate test resources for reftables. These resources are basically the
Git repositories we already have, but converted to use the "reftable"
format. For most of the part, this conversion is done by executing `git
refs migrate`.

A couple notes:

  - This require a recent Git upstream version with not-yet-upstreamed
    patches due to a bug in `git refs migrate` with reflogs.

  - The migration command does not yet support repositories with
    worktrees. Those were converted by first removing the worktrees,
    migrating the refs and then recreating them.

  - The HEAD_TRACKER reference in testrepo.git is not recognized as a
    root ref and is thus not automatically migrated.

  - testrepo.git has an empty reflog for refs/heads/with-empty-log that
    does not get migrated.
2026-04-16 14:56:46 +02:00
Patrick Steinhardt
ee0972cac8 refdb: wire up "reftable" storage format
Wire up the "reftable" storage format via the newly implemented reftable
backend.
2026-04-16 14:56:46 +02:00
Patrick Steinhardt
6701e02f1c refdb: implement reftable backend
Implement the reftable backend that is used to read and write reftables.
The backend is not yet used anywhere after this commit.
2026-04-16 14:56:46 +02:00
Patrick Steinhardt
61c7ff026b refs: provide git_reference__is_per_worktree_ref()
Extract the function `is_per_worktree_ref()` from the "files" backend
and expose it via "refs.h". This function will be reused by the
"reftable" backend.
2026-04-16 14:56:46 +02:00
Patrick Steinhardt
641a43c90d deps/reftable: wire up library with CMake
Wire up the reftable library with CMake. At the current point in time
the library is not yet plugged into libgit2 itself.
2026-04-16 14:56:46 +02:00
Patrick Steinhardt
9e3b00acfb deps/reftable: implement system compatibility code
While the reftable library is mostly decoupled from the Git codebase,
some specific functionality intentionally taps into Git subsystems. To
make porting of the reftable library easier all of these are contained
in "system.h" and "system.c".

Reimplement those compatibility shims so that they work for libgit2.
2026-04-16 14:56:46 +02:00
Patrick Steinhardt
623a3783bb deps: import reftable library
Import the reftable library from commit 4fee6ff3b2 (Merge branch
'ps/reftable-portability', 2026-04-08). This is an exact copy of the
reftable library.

The library will be wired into libgit2 over the next couple of commits.
2026-04-09 06:48:35 +02:00
Patrick Steinhardt
a7ab02aefc util/git2_util.h: expose GIT_INLINE_KEYWORD macro
In our util headers we expose the `GIT_INLINE()` macro to declare a
function as inline, but we don't provide a way to access the keyword
directly.

Expose a new `GIT_INLINE_KEYWORD` to fill this gap. This define will be
used in a subsequent commit.
2026-04-02 08:42:10 +02:00
Edward Thomson
1f34e2a57a Merge pull request #7113 from pks-gitlab/pks-test-fixes-for-reftables
Test fixes to prepare for the reftable backend
2026-03-31 20:34:06 +01:00
Patrick Steinhardt
1888a166e4 tests/libgit2: conditional checks for the "files"-backend
We have a bunch of checks for properties of the "files" reference
backend:

  - Whether a specific reference has been packed or whether it still
    exists as a loose reference.

  - Whether empty ref directories get pruned.

  - Whether we properly fsync data to disk.

These checks continue to be sensible for that backend, but for any other
backend they plain don't work. Adapt the tests so that we only run them
in case the repository uses the "files" backend.
2026-03-30 07:54:12 +02:00
Patrick Steinhardt
1030b68f3d tests/libgit2: don't overwrite config when testing conditionals
When testing conditional includes we overwrite the repository's config
file with the relevant conditions. This causes us to fully overwrite all
repository configuration, including the repository format version and
any extensions. While the test repository used in this test does not
have any extensions, we will add a reftable-enabled repository that does
rely on the "refStorage" extension eventually.

Fix this by only modifying the relevant config keys.
2026-03-30 07:54:12 +02:00
Patrick Steinhardt
5c5db73e3e tests/libgit2: don't access refs via filesystem
There are a bunch of tests where we read or write references via the
filesystem directly. This only works with the "files" backend, but
naturally breaks if we supported any other reference format.

Refactor these tests to instead use the refdb to access those.
2026-03-30 07:54:09 +02:00
Patrick Steinhardt
5e058b54ee tests/clar: introduce cl_repo_has_ref_format()
Introduce a function that reads the "refStorage" extension so that we
can easily figure out whether a specific repository uses the "files" or
any other reference format. While we don't support other formats yet, we
are about to add support for the "reftable" format.
2026-03-30 07:50:44 +02:00
Edward Thomson
079379ee96 Merge pull request #7111 from pks-gitlab/pks-refdb-pseudorefs
Fix handling of pseudorefs with different refdb backends
2026-03-29 14:00:44 +01:00
Edward Thomson
ffb0a2c47e Merge pull request #7218 from KoviRobi/main
revparse: Allow `HEAD` abbreviation `@`
2026-03-24 21:13:54 +00:00
Edward Thomson
7b33412006 Merge pull request #7211 from cehoffman/fix-o-fsync-undefined-behavior
futils: fix undefined behavior in O_FSYNC fallback definition
2026-03-24 20:57:58 +00:00
Chris Hoffman
46208be836 futils: fix undefined behavior in O_FSYNC fallback definition
The fallback definition of O_FSYNC uses `(1 << 31)`, which is undefined
behavior in C. The literal `1` is a signed int, and left-shifting into
the sign bit of a signed integer is undefined per the C standard.

This causes crashes on arm64 Linux with musl libc (which doesn't define
O_FSYNC), manifesting as:

    thread panic: left shift of 1 by 31 places cannot be represented
    in type 'int'

Fall back to O_SYNC when available, since it is the POSIX standard name
for the same flag. On platforms where neither is defined (e.g. Windows),
use (1 << 30) as a sentinel value that avoids the sign bit.
2026-03-17 20:05:42 -05:00
Edward Thomson
d78c1eb08f Merge pull request #7215 from carlosmn/cmn/ssh2-pc-requires
camke: include libssh2 in `Requires.private` in the PC file
2026-03-14 14:13:40 +00:00
Edward Thomson
bb63f769d1 ci: local and global build options
Allow for "local" build options and "global" build options, so that
we can simplify the build scripts.
2026-03-14 14:06:18 +00:00
Kovacsics Robert
828f60337c revparse: Allow HEAD abbreviation @
The `@` alone (without predeeding refname in `<refname>@`) is an
alias for HEAD, and can then be used with other modifiers for example
`HEAD^{/...}`
2026-03-01 21:03:26 +00:00
Carlos Martín Nieto
873bf4794a camke: include libssh2 in Requires.private in the PC file
We need this in order for `pkg-config` to be able to tell what you should link
against when building libgit2 statically. We do include libssh2 in
`Libs.private` but not in `Requires.private`. The difference is a bit subtle but
has become important.

You can call `pkg-config --libs --static ${build}/libgit2.pc` and it will give
you what is in the Libs line, and also what the packages from the Requires field
have in theirs. This is what e.g. `rugged` does and it has been working until
recently. An update to openssl to require zstd now means that using `--libs
--static` returns `-lzstd` as well as many others. This means that those who
want to link using that command now need to have the development packages for
zstd installed, which should not be necessary as libgit2 itself doesn't want to
use anything from it.

A better command to use here seems to be `pkg-config --libs --static --pure
${build}/libgit2.pc`. The manpage and help output are not very precise but what
this does is limit the list of dependencies to a single layer, which is what we
want as we would only want to link statically against libgit2 and not the rest
of the libraries.

But trying to do so breaks building with libssh2 as it's included in the Libs
field rather than the Requires, so that command excludes any linking to libssh2.

Put libssh2 in the `Requires.private` field so we correctly express we need to
link to it when linking statically.

This is unfortunately an imperfect fix as now, if we did not find libssh2 via
pkg-config but rather via CMake's `find_package`, the combination of `--static
--pure` does not take `Libs.private` into account. However we only support this
as an edge case and we expect `pkg-config` to be available for the rest of our
dependencies.
2026-02-20 23:36:18 +01:00
yoni_ash
ee63fad343 Add missing includes in public header files 2026-02-05 09:46:46 +04:00
Edward Thomson
86c7738ca6 Merge pull request #7209 from libgit2/ethomson/ci 2026-01-31 14:40:08 +00:00
Edward Thomson
f4eee4fa9a Merge pull request #7208 from libgit2/ethomson/oidbench
ab tests: enable sha256
2026-01-31 14:07:26 +00:00
Edward Thomson
c84cf608f6 main: revert a/b test debugging changes 2026-01-31 14:06:48 +00:00
Edward Thomson
7ef512a828 ab tests: enable sha256 2026-01-31 13:58:52 +00:00
Edward Thomson
b1a826a7ff Merge pull request #7207 from libgit2/ethomson/oidbench
Benchmark the OID code
2026-01-26 23:41:43 +00:00
Edward Thomson
9935da4661 ci: optionally run benchmarks 2026-01-26 23:40:53 +00:00
Edward Thomson
c0f5c9bd80 ci: generate markdown results from benchmarks 2026-01-26 23:02:06 +00:00
Edward Thomson
928a81e872 microbenchmarks: benchmark the oid code
At present, the library's oid manipulation functions are slower when
built in SHA256 mode than when not. Add some microbenchmarks around the
oid compare and copy functions to understand this better.
2026-01-26 21:43:06 +00:00
Edward Thomson
d55ff3cd70 clar: fix remove unused 2026-01-26 21:43:06 +00:00
Edward Thomson
3ac6bf801c clar: avoid iterator clobbered by longjmp
If the iterator is moved to a register, it may be clobbered by the
longjmp. Avoid this by treating it as volatile.
2026-01-26 21:43:06 +00:00
Edward Thomson
1a0bbabe30 clar update for benchmarks 2026-01-26 21:43:06 +00:00
Edward Thomson
8fda867e46 benchmarks: move them to their own folder
Benchmarks aren't really tests, don't keep them in the `tests` folder.
2026-01-26 21:43:06 +00:00
Edward Thomson
1424585fb6 tests: move clar to deps
Clean up the `tests` folder to only contain _actual tests_. Since clar
is now a reasonably external project, move it to `deps`.
2026-01-26 21:43:06 +00:00
Edward Thomson
77028ee987 Merge pull request #7206 from libgit2/ethomson/nogcc
pcre: actually fix dangling-pointer warning
2026-01-26 21:39:17 +00:00
Edward Thomson
b8f6ff30ee pcre: actually fix dangling-pointer warning 2026-01-26 11:00:08 +00:00
Edward Thomson
02ac171a58 Merge pull request #7205 from libgit2/ethomson/nogcc
pcre: update cmake warnings for non-gcc
2026-01-26 10:33:12 +00:00
Edward Thomson
1114364b87 pcre: update cmake warnings for non-gcc 2026-01-26 09:57:40 +00:00
Edward Thomson
7983915250 Merge pull request #7203 from libgit2/ethomson/gcc
Fix some warnings with gcc
2026-01-25 17:12:43 +00:00
Edward Thomson
6720d66b2f hashmap: tests initialize to NULL to avoid warnings 2026-01-25 16:53:58 +00:00
Edward Thomson
ea87da84a8 config: tests set entry to NULL to avoid warnings 2026-01-25 16:53:58 +00:00
Edward Thomson
ba39ae2c59 pcre: avoid false positive dangling pointer warning
PCRE sets the contents of an external structure to a local pointer
temporarily. gcc warns about this. Silence that dangling pointer
warning.
2026-01-25 16:48:56 +00:00
Honeybunch
5b196e3f11 Fixing experimental headers install 2026-01-24 15:07:29 -08:00
Edward Thomson
e9cfa20206 Merge pull request #7192 from bakersdozen123/main
Fix `git_index_entry` documentation
2026-01-16 22:23:44 +00:00
bakersdozen123
5e1be0e184 Fix memory leak in git_revparse()
If an error occurs when calling `git_revparse_single()` with
`revspec->to`, `revspec->from` must be freed, since it was already
successfully allocated.
2026-01-11 18:59:55 -08:00
bakersdozen123
b4eb482bc9 Fix git_index_entry documentation
Change from "Documentation/technical/index-format.txt" to "Documentation/gitformat-index.adoc". Fixes #7115.
2026-01-11 18:07:28 -08:00
Edward Thomson
d908000464 Merge pull request #7190 from libgit2/ethomson/config
config: Fix potential null value passed to %s
2026-01-11 22:52:34 +00:00
Edward Thomson
8fe2c189e5 config: consistent error messages 2026-01-11 01:01:21 +00:00