Commit Graph

16080 Commits

Author SHA1 Message Date
Sam Altier
7684a617bf docs: update link to git.git-authors 2025-09-24 14:50:24 -04:00
Orgad Shaneh
d6486af3e9 Fix potential access to uninitialized variables
opt_usage.c:214:59: warning: 'required' may be used uninitialized [-Wmaybe-uninitialized]
  214 |                     ((spec->usage & CLI_OPT_USAGE_CHOICE) && required));
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~

diff_driver.c:343:17: warning: 'drv' may be used uninitialized [-Wmaybe-uninitialized]
  343 |         if (drv && drv != *out)
      |             ~~~~^~~~~~~~~~~~~~
2025-09-17 10:24:55 +03: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
Eric Huss
b4ad6ffae6 Update documentation to clarify that cert cb is always called
This removes the phrase "if cert verification fails" because the
certificate callback is *always* called whether it fails or not. This
was changed in
17491f6e56,
but presumably this piece of documentation was not updated.
2025-08-12 10:12:59 -07:00
Patrick Steinhardt
58d9363f02 Merge pull request #7091 from emmanuel-ferdman/main
Update `racy.c` reference
2025-08-11 11:13:31 +02:00
Patrick Steinhardt
72e29b9b00 refdb: initialize on-disk data structures via the backend
The initialization of the on-disk state of refdbs is currently not
handled by the actual refdb backend, but it's implemented ad-hoc where
needed. This is problematic once we have multiple different refdbs as
the filesystem structure is of course not the same.

Introduce a new callback function `git_refdb_backend::init()`. If set,
this callback can be invoked via `git_refdb_init()` to initialize the
on-disk state of a refdb. Like this, each backend can decide for itself
how exactly to do this.

Note that the initialization of the refdb is a bit intricate. A
repository is only recognized as such when it has a "HEAD" file as well
as a "refs/" directory. Consequently, regardless of which refdb format
we use, those files must always be present. This also proves to be
problematic for us, as we cannot access the repository and thus don't
have access to the refdb if those files didn't exist.

To work around the issue we thus handle the creation of those files
outside of the refdb-specific logic. We actually use the same strategy
as Git does, and write the invalid reference "ref: refs/heads/.invalid"
into "HEAD". This looks almost like a ref, but the name of that ref
is not valid and should thus trip up Git clients that try to read that
ref in a repository that really uses a different format.

So while that invalid "HEAD" reference will of course get rewritten by
the "files" backend, other backends should just retain it as-is.
2025-08-04 16:34:02 +02: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
b1ac78ecb9 repository: allow initialization with a specific refdb type
While we only support initializing repositories with the "files"
reference backend right now, we are in the process of implementing a
second backend with the "reftable" format. And while we already have the
infrastructure to decide which format a repository should use when we
open it, we do not have infrastructure yet to create new repositories
with a different reference format.

Introduce a new field `git_repository_init_options::refdb_type`. If
unset, we'll default to the "files" backend. Otherwise though, if set to
a valid `git_refdb_t`, we will use that new format to initialize the
repostiory.

Note that for now the only thing we do is to write the "refStorage"
extension accordingly. What we explicitly don't yet do is to also handle
the backend-specific logic to initialize the refdb on disk. This will be
implemented in subsequent commits.
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
Patrick Steinhardt
38382ce3bc repository: only consider repo-level config to read repo format
When we read the repository format information we do so by using the
full configuration of that repository. This configuration not only
includes the repository-level configuration though, but it also includes
the global- and system-level configuration. These configurations should
in practice never contain information about which format a specific
repository uses.

Despite this obvious conceptual error there's also a more subtle issue:
reading the full configuration may require us to evaluate conditional
includes. Those conditional includes may themselves require that the
repository format is already populated though. This is for example the
case with the "onbranch" condition: we need to populate the refdb to
evaluate that condition, but to populate the refdb we need to first know
about the repository format.

Fix this by using the repository-level configuration, only, to determine
the repository's format.
2025-08-04 16:34:02 +02:00
Patrick Steinhardt
9d5f1bacc2 Merge pull request #7114 from pks-gitlab/pks-msvc-different-enum-warnings
cmake: disable warnings for operands with different enum types
2025-08-04 16:30:00 +02:00
Patrick Steinhardt
5d78d634f2 cmake: disable warnings for operands with different enum types
With a recent upgrade to a newer version of MSVC we now get a bunch of
warnings when two operands use different enum types. While sensible in
theory, in practice we have a couple of non-public enums that extend
public enums, like for example with `GIT_SUBMODULE_STATUS`.

Let's for now disable this warning to unblock our builds. The
alternative would be to add casts all over the place, but that feels
rather cumbersome.
2025-08-01 08:48:59 +02:00
Emmanuel Ferdman
b87080c069 Update racy.c reference
Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
2025-06-14 04:11:54 -07:00
Edward Thomson
5ab90d3c27 Merge pull request #7087 from libgit2/ethomson/transport_register_docs 2025-06-06 22:36:09 +01:00
Edward Thomson
3fd47e36f7 Merge pull request #7086 from libgit2/ethomson/licenses 2025-06-06 22:35:40 +01:00
Edward Thomson
2643c31c37 Merge pull request #7085 from libgit2/ethomson/ssh_exec 2025-06-06 22:35:28 +01:00
Edward Thomson
a9ae10c32d transport: update registration docs
The documentation for `git_transport_register` erroneously stated that
the trailing `://` was required for the scheme. It is not.
2025-06-06 21:18:51 +01:00
Edward Thomson
516302bc53 openssl: update dynamic to OpenSSL 3.0 definitions
Use the definitions from OpenSSL 3.0 so that we can move to the OpenSSL
3.0 license (Apache).
2025-06-06 21:15:38 +01:00
Edward Thomson
bdb12e90d0 license: update wildmat license information
Our license claims that the wildmat code (originally from Rich $alz) is
is under a BSD license that requires attribution. However, the wildmat
documentation states that the code is available in the public domain
(https://github.com/richsalz/wildmat), and the author himself has
indicated that we can remove the acknowledgement clause
(https://github.com/libgit2/libgit2/issues/7050#issuecomment-2727028530).
2025-06-06 21:15:38 +01:00
Edward Thomson
a3248405fe ssh: use more compatible git commands over ssh
git runs commands as "git-upload-pack 'path-to-repo'", and some servers
enforce the single-quoted syntax. Emulate this.
2025-06-06 20:33:10 +01:00
Edward Thomson
dbc19dc08e Merge pull request #7077 from JohannesWilde/AvoidDuplicateDefinition
Avoid duplicate definition of git_http_auth_dummy.
2025-06-05 14:00:40 +01: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
Edward Thomson
de652db0e1 Merge pull request #7044 from nelhage/fix-fuzzer-build
fuzzers: Fix CFLAGS
2025-06-05 13:26:14 +01:00
Edward Thomson
dd65bfe181 Avoid duplicate definition of git_http_auth_dummy
Avoid defining `git_http_auth_ntlm` when not using ntlm; this will be
set to a dummy function instead.
2025-06-05 13:20:29 +01:00
Edward Thomson
3082736857 Merge pull request #7059 from georgthegreat/circular-includes
Fix circular includes between types.h and oid.h
2025-06-05 13:11:20 +01:00
Edward Thomson
29e4e1984d Merge pull request #7064 from wklatka/openssl-fips-memory-leak
Fix memory leak in openssl fips modes
2025-06-05 12:46:21 +01:00
Edward Thomson
c232aec6f3 Merge pull request #7076 from DominiqueFuchs/docfix-remote-url
docs: correct wrong docstring info for git_remote_url
2025-06-04 15:38:08 +01:00
Edward Thomson
a95181aed6 Merge pull request #7061 from csware/tag-head
tag: Refuse to use HEAD as a tagname
2025-06-04 15:29:29 +01:00
Edward Thomson
488560c270 Merge pull request #7079 from Faless/fix/static_linker_flags
Fix MSVC cross compilation
2025-06-04 10:29:09 +01:00
Fabio Alessandrelli
4c7bca5e2f Fix MSVC cross compilation
Currently, the DefaultCFlags.cmake overrides the
CMAKE_STATIC_LINKER_FLAGS to suppress linker warnings about files with
no symbols defined.

This has the side effect of breaking MSVC cross compilation (where
CMAKE_STATIC_LINKER_FLAGS is used to specify the /MACHINE:ARCH flag)

This commit make sure we append to CMAKE_STATIC_LINKER_FLAGS instead of
replacing its values
2025-05-27 19:00:09 +02:00
Johannes Wilde
c881632306 Avoid duplicate definition of git_http_auth_dummy.
src\libgit2\transports\auth_negotiate.h redefines git_http_auth_negotiate as git_http_auth_dummy if GIT_AUTH_NEGOTIATE is not defined, which thus leads to the uncommented code actually being a redifintion of git_http_auth_dummy. The linker complained [Windows 11, MSVC 2022 64bit].
2025-05-24 13:31:56 +02:00
Dominique Fuchs
00e1550a23 docs: correct docstring info for git_remote_url
Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
2025-05-16 15:00:53 +02:00
wklatka
4e8717fbc9 Fixed memory leak in openssl fips modes 2025-04-11 15:27:24 +02: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
Yuriy Chernyshov
60fdf919e7 Fix circular includes between types.h and oid.h 2025-03-31 13:04:34 +03:00
Talya Connor
d88347a89c AUTHORS: add self. 2025-03-29 18:51:33 +11:00
Talya Connor
9f93169473 diff: account for common prefix in max namelen. 2025-03-29 18:50:19 +11:00
Talya Connor
31f5c30999 test: failing diff stat test. 2025-03-29 18:16:45 +11:00
Nelson Elhage
1f4f900766 Don't use -fsanitizer for the standalone fuzzer build. 2025-03-03 23:47:41 +00:00
Nelson Elhage
4cd34f1d94 fuzzers: Fix CFLAGS
I'm seeing the current fuzzer build fail (during `cmake`) like so:

```
-- Performing Test IS_FSANITIZE_FUZZER_NO_LINK_SUPPORTED
-- Performing Test IS_FSANITIZE_FUZZER_NO_LINK_SUPPORTED - Failed
CMake Error at cmake/AddCFlagIfSupported.cmake:17 (message):
  Required flag -fsanitize=fuzzer-no-link is not supported
Call Stack (most recent call first):
  fuzzers/CMakeLists.txt:6 (add_c_flag)
```

The cmake log output contains something like so:

```
        /src/aflplusplus/libAFLDriver.a(aflpp_driver.o): in function `main':
        aflpp_driver.c:(.text+0x11b): undefined reference to `LLVMFuzzerTestOneInput'
        clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

I haven't figured out exactly what's happening, but I believe that
once line 5 has added `-fsanitize=fuzzer` to `CFLAGS`, future compile-
tests **also** use it during linking. This in turn pulls in the fuzzer
`main`, which expects an `LLVMFuzzerTestOneInput` symbol, and thus
fails.

Instead, just add `-fsanitize=fuzzer-no-link` to CFLAGS (as suggested
[by the documentation][libfuzzer]), and then use `-fsanitize=fuzzer`
only for linking the fuzzer targets. At least in my environment, this
results in a working fuzzer build.

[libfuzzer]: https://llvm.org/docs/LibFuzzer.html#fuzzer-usage
2025-03-03 22:51:52 +00:00
Edward Thomson
21a351b0ed Merge pull request #7043 from libgit2/ethomson/benchmark
Benchmarks: refactoring
2025-03-02 22:48:48 +01:00
Edward Thomson
2599c96d25 ci: run administrative benchmarks 2025-03-02 20:46:38 +00: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
1c485493cc Merge pull request #7042 from libgit2/ethomson/benchmark 2025-03-02 10:56:58 +01: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
eb22b60063 Merge pull request #7039 from ytnuf/stdint
Revert include path regression
2025-02-26 16:46:53 +01:00
ytnuf
a465da73a5 Revert include path regression 2025-02-13 11:10:45 +00:00
Edward Thomson
b042e57406 Merge pull request #7038 from libgit2/ethomson/ci
ci: update download-artifact version
2025-02-07 22:02:10 +00:00
Edward Thomson
1b3598c0c6 ci: update download-artifact version 2025-02-07 20:59:56 +00:00