16323 Commits

Author SHA1 Message Date
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
Edward Thomson
6460642539 Merge pull request #7173 from libgit2/ethomson/clar-update
tests: update to latest clar
2026-01-08 14:32:33 +00:00
Edward Thomson
6a41fb7870 tests: update to latest clar 2026-01-08 01:03:42 +00:00
Edward Thomson
2c3ce41c60 Merge pull request #7166 from bakersdozen123/main
Add swift-libgit2 language binding to README
2026-01-07 23:01:57 +00:00
Edward Thomson
9ced0a3731 Merge pull request #7175 from qaqland/main
examples: correct `git_commit_time` comment
2026-01-07 22:59:17 +00:00
Alf Henrik Sauge
73b8b4eb74 Use git_oid_raw_cmp instead of custom loop in git_oid_is_zero
Since git_oid_raw_cmp uses memcmp, it's far easier to optimise more aggressively.
Given that it's static const and used inlined, it seems reasonable to assume that git_oid_zero will be optimised away in release. 
This is at least the case with x86-64 and GCC 15.2.1.
2026-01-06 20:20:46 +01:00
Weihang Lo
e15479a7dc fix(smart): keep caps across RPC stream resets
Preserve ref-advertised capabilities when only the stream is reset.

This prevents losing `object-format` before `git_remote_oid_type()`
and fixes SHA256 clone pack trailer mismatch.

Fixes libgit2/libgit2#7182
2026-01-03 22:02:42 -05:00
Martin Marmsoler
0e3200a8fc fix wrong comment 2026-01-03 17:02:51 +01:00
Weihang Lo
e1cd4f6595 fix(sha256): pass correct oid type
These are SHA256 TODO leftover.
In the surrounding context they all have the required oid type around,
so I just picked up them and pass in.

Found during SHA256 support integration with Rust git-rs binding
2026-01-03 10:12:12 -05:00
Rasheeq Azad
4f272981c2 Check object lengths against headers in read_loose
Avoid a buffer overrun when an object's header specifies a short length
but the body is longer (fix #7177). Take care to preserve the behavior
that too-short object bodies are not an error but get zero-padded.
2026-01-02 03:41:58 -05:00
qaqland
196c465995 examples: correct git_commit_time comment 2025-12-31 16:36:04 +08:00
Oblivionsage
4e6b493787 delta: fix undefined behavior in hdr_sz varint parsing
The expression (c & 0x7f) << shift in hdr_sz() causes undefined
behavior when shift >= 32, because (c & 0x7f) is an unsigned int
(32-bit type). A malicious delta with a long varint can trigger this.

Fix by:
1. Casting to size_t before shifting to support 64-bit shifts
2. Adding a shift limit check to reject overlong varints
2025-12-24 16:46:30 +01:00
Łukasz Langa
2528c88f50 ci: remove deprecated SSH config options
Remove deprecated OpenSSH configuration options from ci/test.sh:
- Protocol 2 (deprecated since OpenSSH 7.4)
- RSAAuthentication (deprecated since OpenSSH 7.4)
- ChallengeResponseAuthentication (deprecated since OpenSSH 9.6)
- HostCertificate pointing to .pub file (invalid configuration)
- Duplicate HostKey directive

These options were causing warnings with OpenSSH 10.0 in Fedora Rawhide
and preventing SSH tests from functioning properly.

Tested with OpenSSH 10.0p2 on Fedora Rawhide.
2025-12-23 16:44:24 +01:00
Łukasz Langa
0abde52675 fix: prevent SSH timeout infinite loop and enable TCP keepalive
This patch makes two improvements:
1. In case of LIBSSH2_ERROR_TIMEOUT, don't loop forever
2. Enable TCP keepalive on all sockets to detect dead connections

The added test demonstrates the hang without the patch.
2025-12-23 16:44:23 +01:00
Edward Thomson
3ac4c0adb1 Merge pull request #7148 from roberth/refs-shorthand-multi-segment
refs: honor REFSPEC_SHORTHAND for multi-segment refs
2025-12-20 13:08:02 +00:00
Edward Thomson
cd3ebc944e Merge pull request #7164 from ambv/fix-discarded-qualifiers
ci: Fix cases of -Werror=discarded-qualifiers raised by gcc 15.2
2025-12-20 13:05:42 +00:00
Edward Thomson
1fed8b2e95 Merge pull request #7167 from ambv/macos-14 2025-12-19 21:05:34 +00:00
Łukasz Langa
0bf4714508 (Another bump, this time github.com was not accessible from GitHub Actions) 2025-12-12 00:42:53 +01:00
Łukasz Langa
2b7114047e (bump CI as curl failed) 2025-12-11 19:01:19 +01:00
Łukasz Langa
81ba023838 Some versions of leaks want -exclude to not have a space 2025-12-11 18:11:50 +01:00
Łukasz Langa
ed1f2f7eb1 Exclude leaks in SSLHandshake 2025-12-11 17:05:48 +01:00
Łukasz Langa
a44b3257ba Also update nightlies 2025-12-11 12:29:56 +01:00
Łukasz Langa
c81b74fe76 Use macos-14 for experimental features, too 2025-12-11 12:28:44 +01:00
Łukasz Langa
97d17cced3 Switch to macos-14 as macos-13 runners are now retired 2025-12-11 12:28:30 +01:00
bakersdozen123
098a1a58bf Add swift-libgit2 language binding to README 2025-12-10 18:35:22 -08:00
Orgad Shaneh
6d63f4b63a config: Fix potential null value passed to %s
config.c:1448:59: warning: '%s' directive argument is null [-Wformat-overflow=]
 1448 |         git_error_set(GIT_ERROR_CONFIG, "failed to parse '%s' as a boolean value", value);
      |                                                           ^~
2025-12-09 12:09:20 +02:00
Patrick Steinhardt
b17ecb23e2 refs: always read pseudorefs as loose refs
Regardless of which reference storage format is used, pseudorefs will
always be looked up via the filesystem as loose refs. This is because
pseudorefs do not strictly follow the reference format and may contain
additional metadata that is not present in a normal reference.

We don't honor this in `git_reference_lookup()` though but instead defer
to the refdb to read such references. This obviously works just fine
with the "files" backend, but any other backend would have to grow
custom logic to handle reading pseudorefs.

Refactor `git_reference_lookup_resolved()` so that it knows to always
read pseudorefs as loose references. This allows refdb implementations
to not care about pseudoref handling at all.
2025-12-08 07:29:59 +01:00
Patrick Steinhardt
7f35dc5817 refdb_fs: expose function to read a loose ref
Expose a function to read a loose reference. This function will be used
in a subsequent commit to read pseudo-refs on the generic refdb layer.
2025-12-08 07:29:59 +01:00
Patrick Steinhardt
93d77d1cb5 config_file: use the refdb to evaluate "onbranch" condition
With the preceding commit we have refactored the "files" backend so that
it can be both instantiated and used to look up a reference without
reading any configuration. With this change in place we don't cause
infinite recursion anymore when using the refdb to evaluate "onbranch"
conditions.

Refactor the code to use the refdb to look up "HEAD". Note that we
cannot use `git_reference_lookup()` here, as that function itself tries
to normalize reference names, which in turn involves reading the Git
configuration. So instead, we use the lower-level `git_refdb_lookup()`
function, as we don't need the normalization anyway.
2025-12-08 07:29:59 +01:00
Patrick Steinhardt
d590e1f0f2 refdb_fs: defer reading the configuration
When initializing the "files" refdb we read a couple of values from the
Git configuration. Unfortunately, this causes a chicken-and-egg problem
when reading configuration with "includeIf.onbranch" conditionals: we
need to instantiate the refdb to evaluate the condition, but we need to
read the configuration to initialize the refdb.

We currently work around the issue by reading the "HEAD" file directly
when evaluating the conditional include. But while that works with the
"files" backend, any other backends that store "HEAD" anywhere else will
break.

Prepare for a fix by deferring reading the configuration. We really only
need to be able to execute `git_refdb_lookup()`, so all we need to
ensure is that we can look up a branch without triggering any config
reads.
2025-12-08 07:29:58 +01:00
Patrick Steinhardt
4686f10ecb refs: introduce GIT_HEAD_REF define
Introduce the GIT_HEAD_REF define so that we can clearly indicate that
we're talking about the "HEAD" reference and not necessarily a file.
Note that there still are a couple of places where GIT_HEAD_FILE is
being used:

  - `git_repository_create_head()`: This function is used to create HEAD
    when initializing a new repository. This should get fixed eventually
    so that we create HEAD via the refdb, but this is a more involved
    refactoring that will be handled in a separate patch series.

  - `repo_init_head()`: Likewise.

  - `conditional_match_onbranch()`: This function is used to decide
    whether or not an `includeIf.onbranch` condition matches. This will
    be fixed in subsequent commits.

Other than that there shouldn't be any more references to GIT_HEAD_FILE.
2025-12-08 07:27:24 +01:00
Patrick Steinhardt
cd45e55246 refs: rename GIT_STASH_FILE to indicate this is a ref
The GIT_STASH_FILE define contains the path to the stash reference.
While we know that this used to be a file with the "files" backend, it's
not a standalone file with the "reftable" backend anymore.

Rename the macro to GIT_STASH_REF to indicate that this is a proper ref.
2025-12-08 07:27:24 +01:00
Patrick Steinhardt
88229c53be refs: handle CHERRY_PICK_HEAD via the refdb
Fix handling of "CHERRY_PICK_HEAD" by exclusively reading and writing it
via the reference database.
2025-12-08 07:27:24 +01:00
Patrick Steinhardt
71bddb1744 refs: handle REVERT_HEAD via the refdb
Fix handling of "REVERT_HEAD" by exclusively reading and writing it via
the reference database.
2025-12-08 07:27:24 +01:00
Patrick Steinhardt
9554d2e3d3 refs: handle ORIG_HEAD via the refdb
We have a bunch of references that we treat like pseudo-refs. Those
references are (sometimes) read and written by going to the filesystem
directly, at other times they are read and written via the refdb. This
works alright with the "files" ref storage format given that any root
reference never gets packed into the "packed-refs" file, and thus they
would always be accessible a loose ref if present.

The behaviour is wrong though when considering alternate backends like
the "reftable" backend. All references except for pseudo-refs must be
read via the backend, and that includes root refs.

Historically this part of Git has been ill-defined, and it wasn't quite
clear which refs are considered pseudo-refs in the first place. This was
clarified in 6fd80375640 (Documentation/glossary: redefine pseudorefs as
special refs, 2024-05-15): there only are two pseudorefs, "FETCH_HEAD"
and "MERGE_HEAD". The reason why those two references are considered
special is that they may contain additional data that doesn't fit into
the normal reference format.

In any case, our current handling of a couple of root references is
broken in this new world.

Fix this for "ORIG_HEAD" by exclusively going through the refdb to read
and write that reference. Rename the define accordingly to clarify that
it is a reference and not a file.
2025-12-08 07:27:24 +01:00
Łukasz Langa
fadbef196e ci: Fix cases of -Werror=discarded-qualifiers raised by gcc 15.2 2025-12-06 23:02:39 +01:00
Edward Thomson
610dcaac06 Merge pull request #7153 from ambv/fix-iterator-index-case-folding-test-docker 2025-12-06 21:54:41 +00:00
Edward Thomson
ce0524670c Merge pull request #7120 from xokdvium/refspec-del
refspec: Detect DEL character in is_valid_name
2025-12-06 17:54:52 +00:00
Edward Thomson
a136eb0c8d Merge pull request #7130 from orgads/init-locals
Fix potential access to uninitialized variables
2025-12-06 17:48:28 +00:00
Edward Thomson
3c30b6fab3 Merge pull request #7138 from jar-of-salt/git-authors-docs-update
Fix Contributing Docs: Incorrect Git Authors Link
2025-12-06 17:46:10 +00:00