Commit Graph

3759 Commits

Author SHA1 Message Date
Edward Thomson
d08f2867a5 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-17 13:26:55 +00:00
Edward Thomson
219730325e clar: update to latest 2026-01-10 20:17:08 +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
6a41fb7870 tests: update to latest clar 2026-01-08 01:03:42 +00: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
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
Ł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
cfed471032 Merge pull request #7102 from pks-gitlab/pks-refformat-extension
Introduction of the "refFormat" extension
2025-12-06 16:58:16 +00:00
Edward Thomson
7ed8f12087 ssh_exec: use GIT_SSH_COMMAND in tests
We specify additional arguments to the ssh executable; as a result, we
specify arguments with `GIT_SSH_COMMAND`.
2025-12-01 21:44:36 +00:00
Edward Thomson
4c9134e501 str: allow escaping with prefix and suffix
Allow `git_str_puts_escaped` to take an escaping prefix and an escaping
suffix; this allows for more options, including the ability to better
support escaping executed paths.
2025-12-01 21:44:36 +00:00
Edward Thomson
2ad709e77c process: resolve paths for win32
When using `git_process_new` on win32, resolve the path to the
application in the same way that we do on POSIX.

Search `PATH` for command to execute (unless the given executable is
fully qualified). In addition, better match Windows executable lookup
behavior itself (allowing the command to be `foo`, and looking for a
matching `foo.exe` or `foo.cmd`.)
2025-12-01 21:44:36 +00:00
Edward Thomson
ed39bcee40 fs: improved executable-in-path location tests
Ensure that our `find_executable` behaves as expected:

* When the executable contains a fully- or partially-qualified filename
  component (eg, `foo/bar`) that `PATH` is not searched; these paths are
  relative to the current working directory.
* An empty segment in `PATH` (on POSIX systems) is treated as the
  current directory; this is for compatibility with Bourne shells.
* When a file exists in `PATH`, it is actually executable (on POSIX)
2025-11-29 12:50:44 +00:00
Łukasz Langa
269427b2bb test: check the correct filesystem for case-sensitivity
It's certainly possible for the root filesystem to be case-sensitive
while /tmp is not, or vice versa. One example where this might happen
is when running Docker containers (like ci/docker/fedora) on macOS with
the repository checkout on AppleFS (not case sensitive) while the
container's /tmp is case sensitive.

This fix allows the test to pass under those circumstances as well.
2025-10-23 14:05:31 +02:00
Robert Hensing
76314a893a refs: honor REFSPEC_SHORTHAND for multi-segment refs
GIT_REFERENCE_FORMAT_REFSPEC_SHORTHAND is documented to "interpret the
name as part of a refspec in shorthand form so the ONELEVEL naming rules
aren't enforced and 'master' becomes a valid name."

However, the multi-segment pseudoref check was not respecting this flag,
rejecting valid refspecs like "A/b" and "HEAD/feature" even when
SHORTHAND was set.

The single-segment check at line 1015 already honors this flag. This
change makes the multi-segment check at line 1021 consistent with that
behavior and with the documented intent.

Git itself accepts these refspec patterns without issue.
2025-10-15 17:53:22 +02:00
Sergei Zimmerman
aaef091960 refspec: Detect DEL character in is_valid_name
Prior to this patch the code correctly barfed on
control characters with values lower than \040 (space),
but failed to account for DEL.

This patch fixes the behavior to be consistent with git [1]:

> They cannot have ASCII control characters (i.e. bytes whose values are
> lower than \040, or \177 DEL)

[1]: https://git-scm.com/docs/git-check-ref-format#_description
2025-08-13 12:13:50 +00:00
Patrick Steinhardt
f3a4619bbc tests: refactor test to not circumvent the refdb when writing HEAD
In our tests for "onbranch" config conditionals we set HEAD to point to
various different branches via `git_repository_create_head()`. This
function circumvents the refdb though and directly writes to the "HEAD"
file. While this works now, it will create problems once we have
multiple refdb backends.

Furthermore, the function is about to go away in the next commit. So
let's prepare for that and use `git_reference_symbolic_create()`
instead.
2025-08-04 16:34:02 +02:00
Patrick Steinhardt
806a0062fd repository: wire up refStorage extension
To support multiple different reference backend implementations,
Git introduced a "refStorage" extension that stores the reference
storage format a Git client should try to use.

Wire up the logic to read this new extension when we open a repository
from disk. For now, only the "files" backend is supported by us. When
trying to open a repository that has a refstorage format that we don't
understand we now error out.

There are two functions that create a new repository that doesn't really
have references. While those are mostly non-functional when it comes to
references, we do expect that you can access the refdb, even if it's not
yielding any refs. For now we mark those to use the "files" backend, so
that the status quo is retained. Eventually though it might not be the
worst idea to introduce an explicit "in-memory" reference database. But
that is outside the scope of this patch series.
2025-08-04 16:34:02 +02:00
Edward Thomson
d0da6819ec Merge pull request #7057 from kivikakk/diff-stat-alignment
diff: correct diff stat alignment in presence of renames w/ common prefix.
2025-06-05 13:53:57 +01:00
Sven Strickroth
3dc766a875 tag: Refuse to use HEAD as a tagname
Sync with vanilla Git, cf. https://github.com/git/git/commit/bbd445d5efd415

Signed-off-by: Sven Strickroth <email@cs-ware.de>
2025-04-07 21:18:20 +02:00
Talya Connor
31f5c30999 test: failing diff stat test. 2025-03-29 18:16:45 +11:00
Edward Thomson
771ec303d4 benchmarks: introduce --admin flag for admin benchmarks
Some benchmarks require administrative privileges, namely the ones that
blow up the disk cache. Don't run them by default, to avoid obnoxious
sudo password prompts, etc. Users can specify `--admin` to run them.
2025-03-02 20:46:38 +00:00
Edward Thomson
8d8ab0b110 benchmarks: rename cache benchmarks
The default in the world is to have a disk cache; it's exceptional to
_not_. Flip our naming, so that the (exceptional) `nocache` tests are
called out explicitly.
2025-03-02 20:46:38 +00:00
Edward Thomson
48d031f6ab cli: fix benchmark commit interrogation
Don't fail the benchmark script if we can't identify the CLI commit.
2025-03-02 08:56:38 +00:00
Edward Thomson
1cd6872e8f Merge pull request #7008 from libgit2/ethomson/benchmark_version
benchmarks: report commit of build
2025-02-03 17:21:35 +00:00
Edward Thomson
72d49bb0de clar: update to latest version
Update to the latest version (in HEAD) of clar. This affords us improved
test directory creation, and the `cl_invoke` helper macro.
2025-01-23 10:32:52 +00:00
Edward Thomson
1b348a3134 Merge pull request #7026 from emilazy/push-npwwprvzrmmr
conflict tests: check `core.ignorecase`
2025-01-21 13:42:07 -08:00
Emily
96bdc04fbb conflict tests: check core.ignorecase
Not all filesystems on Apple and Windows platforms are
case‐insensitive; this test would previously fail on a
case‐sensitive APFS volume.
2025-01-21 21:19:32 +00:00
Edward Thomson
3eadce3d0b Merge pull request #7019 from vapier/main
alternates: allow relative paths in all repositories
2025-01-21 13:04:10 -08:00
Edward Thomson
99dbff8d7c Merge pull request #7025 from libgit2/ethomson/test_updates
Test updates
2025-01-21 05:10:01 -08:00
Edward Thomson
c48364cd6a filter: set a temporary sysdir in test
The filter tests mutate state, and should set a temporary sysdir to do
so.
2025-01-20 22:45:59 +00:00
Edward Thomson
21af9ec86c test: set a temporary PROGRAMDATA directory
Like we set temporary system and global configuration directories, we
need to set a programdata directory for safe test handling.
2025-01-20 22:45:53 +00:00
Mike Frysinger
17cbd2eae0 alternates: allow relative paths in all repositories
Git does not limit relative paths in alternates to the first
repository, so libgit2 shouldn't either.
2025-01-15 21:25:30 -05:00
Edward Thomson
906623b8f9 attr: honor ignorecase in attribute matching
`.gitattributes` is case-insensitive when `core.ignorecase=true`.
2025-01-15 22:44:51 +00:00
Edward Thomson
f9e9ddd884 flamegraph: theme for libgit2 benchmarks site 2025-01-14 12:48:28 +00:00
Edward Thomson
008c6f7984 benchmarks: optionally generate and publish flamegraphs 2025-01-13 21:23:02 +00:00
Edward Thomson
dfbdaa28a5 benchmark: introduce profiling support
Introduce `--profile` support to the benchmark helper script, which will
invoke `perf` on Linux. Additionally, add a `--flamegraph` output
option based on that.
2025-01-13 21:21:17 +00:00
Edward Thomson
6fedfd3237 Add benchmark for large-ish (250mb) index-pack 2025-01-11 21:58:19 +00:00
Edward Thomson
343c2cbae8 benchmarks: report commit of build
It can be useful to report the commit ID during benchmarks to track down
regressions; leverage the addition of that in `git version` during
benchmark runs.
2025-01-09 23:44:23 +00:00
Edward Thomson
436f4e7d96 benchmarks: update path to baseline cli
The `fullpath` function takes the cli, but doesn't keep the cli.
2025-01-09 21:45:11 +00:00
Edward Thomson
caa65e0e9f Merge pull request #7000 from libgit2/ethomson/object_type 2025-01-03 14:01:24 +00:00
Edward Thomson
23da3a8f3c object: remove OFS_DELTA and REF_DELTA values
Deltas are not objects, they're entries in a packfile. Remove them from
the object enum.
2025-01-03 13:28:19 +00:00
Edward Thomson
2d5942571c object: introduce type_is_valid
There's no such thing as a "loose object type" or a "packed object
type". There are only object types. Introduce `type_is_valid` and
deprecate `typeisloose`.
2025-01-03 13:28:19 +00:00
Edward Thomson
666bbed4d4 Merge pull request #6998 from peter15914/fix_check_calloc
FIx potential null dereference
2025-01-03 09:00:00 +00:00
Edward Thomson
dafe14ce65 Merge pull request #6346 from libgit2/ethomson/reference_cmp
refs: make `git_reference_cmp` consider the name
2025-01-02 23:14:40 +00:00
peter15914
01c16e6aa7 transport: сheck a pointer allocation result
GIT_ERROR_CHECK_ALLOC was added to check the return value of git__calloc().
2025-01-03 01:22:53 +05:00
Edward Thomson
a0d432660a Merge pull request #6994 from libgit2/ethomson/cmake 2025-01-02 17:56:41 +00:00
Edward Thomson
c26d8a8b54 sha256: further API simplifications for OID parsing
Introduce `git_oid_from_string`, `git_oid_from_prefix`, and
`git_oid_from_raw`, all of which take a `git_oid_t` that indicates what
type of OID should be parsed (SHA1 or SHA256).

This allows users to continue to use `git_oid_fromstr` without any code
changes, while remaining in a SHA1 world.

Note that these are not perfect analogs to the `fromstr` APIs.

* `git_oid_from_string` now takes a NUL terminated string, instead of
  allowing for non-NUL terminated strings. Adding a NUL check feels like
  an important safety consideration for C strings.
* `git_oid_from_prefix` should be used for an OID substring and length.

Previous usages of `git_oid_fromstr` with non-NUL terminated strings
should move to `git_oid_from_prefix` with the hexsize for the given OID
type.
2025-01-02 13:13:59 +00:00