Commit Graph

16145 Commits

Author SHA1 Message Date
Weihang Lo
735bb2e2f5 fix(refs): attach refdb owner to loose pseudorefs
Pseudoref lookup now reads `FETCH_HEAD` directly as a loose ref,
but callers still expect looked-up references to know their owning
repository.

Attach the repo's refdb after the loose pseudoref is read so
owner-dependent ops such as peeling can safely resolve objects.
2026-04-22 17:50:23 -04:00
Weihang Lo
c0a5341635 test(refs): cover pseudoref owner regression from b17ecb23e
b17ecb23e changed pseudoref lookup to read loose refs directly,
bypassing refdb lookup.

This documents the resulting buggy behavior:
a looked-up `FETCH_HEAD` pseudoref has no owning refdb attached.
2026-04-22 17:50:14 -04: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
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
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
Edward Thomson
e9cfa20206 Merge pull request #7192 from bakersdozen123/main
Fix `git_index_entry` documentation
2026-01-16 22:23:44 +00: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
Edward Thomson
53eca10648 Merge pull request #7185 from weihanglo/remote-oid-type
feat(remote): expose `git_remote_oid_type`
2026-01-11 00:58:10 +00:00
Edward Thomson
77c217f173 Merge pull request #7183 from weihanglo/smart
fix(smart): keep caps across RPC stream resets
2026-01-11 00:55:29 +00:00
Edward Thomson
0f07d810fe Merge pull request #7189 from libgit2/ethomson/clar-update
clar: update to latest
2026-01-10 20:42:52 +00:00
Edward Thomson
219730325e clar: update to latest 2026-01-10 20:17:08 +00:00
Weihang Lo
6893894f4b feat(remote): expose git_remote_oid_type
This would be useful for user to determine whether they want to proceed
or bail further remote operations. Particularily useful for downstream
libgit2 bindings and applications to experiment SHA256 support behind a
runtime feature flag.

For example, `cargo` could compile with sha256 support unconditionally,
but reject SHA256 usage at runtime if the `-Zgit=sha256` nightly flag
was not on. Cargo would leverage this new API to determine if users are
trying to fetch a SHA256 remote repository and bail when needed before
any fetches happen.

Note that this is not gated behind `GIT_EXPERIMENTAL_SHA256` as the
oid_type is sha1 and available always.
2026-01-10 10:59:47 -05:00
Edward Thomson
b154967667 Merge pull request #7186 from AHSauge/fix/optimise-git-oid-is-zero
Use git_oid_raw_cmp instead of custom loop in git_oid_is_zero
2026-01-10 13:33:58 +00:00
Edward Thomson
e2105f3a8b Merge pull request #7181 from Murmele/wrong_comment
fix wrong comment
2026-01-10 13:32:58 +00:00
Edward Thomson
dff04d9dcc Merge pull request #7187 from libgit2/ethomson/nsec
index: support USE_NSEC=OFF
2026-01-08 23:04:55 +00:00
Edward Thomson
a09440a4f5 index: support USE_NSEC=OFF
Ideally, nobody should be building without nanosecond precision. But
support them if they do.
2026-01-08 22:39:56 +00:00
Edward Thomson
c5105a07dd Merge pull request #7172 from Oblivionsage/main
delta: fix undefined behavior in hdr_sz varint parsing
2026-01-08 21:25:44 +00:00
Edward Thomson
28b244aa40 Merge pull request #7179 from weihanglo/sha256
fix(sha256): pass correct oid type
2026-01-08 14:33:25 +00:00