Commit Graph

2613 Commits

Author SHA1 Message Date
Edward Thomson
f8823e4e11 commit: add headers and signature to create_from
The `create_from` and `amend_from` APIs use a slightly different options
structure. They should both allow extra headers and signature callbacks.
2026-06-01 21:23:59 +01:00
Edward Thomson
05c4b5cf95 commit: introduce git_commit_amend_from_...
Similar to the `git_commit_create_from_...` APIs, a simple amend
function that uses smart defaults and amends HEAD from the staged
changes or a given tree.
2026-06-01 21:23:59 +01:00
Edward Thomson
16b12ff3c5 commit: introduce git_commit_create_from_tree
Similar to the `git_commit_create_from_stage` function, a batteries-
included commit creation function that uses smart defaults and commits a
given tree.
2026-06-01 21:23:59 +01:00
Edward Thomson
096cc6f76d commit: introduce a signing callback
Callers can now introduce a commit signing callback instead of needing
to call a specialized commit buffer creation function.
2026-06-01 21:23:59 +01:00
Edward Thomson
a7786fcd7e commit: support custom user-specified headers
Some clients (eg GitButler) are storing additional information in custom
user-specified commit headers. We should make this a first-class
concept.
2026-06-01 21:23:59 +01:00
Edward Thomson
cf02e92b54 commit: introduce commit creation options
Introduce `git_commit_create_ext` and an options structure for
extensibility. Non-default arguments (message encoding, reference
updates) are in the options structure.

This simplifies the complex self-service commit creation APIs and allows
for future sustainable improvements.
2026-06-01 21:23:59 +01:00
Edward Thomson
a7e1eb2638 Merge pull request #7245 from mrdimidium/main 2026-05-30 18:56:01 +01:00
Edward Thomson
3c7234e3a0 Update filter.h 2026-05-30 18:52:36 +01:00
yoni_ash
3f1d5c1fa9 Fix a small documentation error 2026-05-29 14:52:16 +04:00
Edward Thomson
e490b18b70 Merge pull request #7157 from OlekRaymond/main
Update GIT_DIFF_OPTIONS_INIT macro
2026-05-25 22:01:06 +01:00
Edward Thomson
0808a4b650 Apply suggestion from @ethomson 2026-05-25 22:00:50 +01:00
Daniel Scherzer
1b4eaa3309 commit.h: remove stray * in git_commit_amend() docs 2026-05-16 18:29:53 -07:00
Edward Thomson
af1e2fa3d0 Merge pull request #7117 from pks-gitlab/pks/reftables-support
Reftables support
2026-05-06 22:02:32 +01:00
Edward Thomson
7a12070f5a Merge pull request #7121 from yonathan-ashebir/main
Adding missing includes in public header files
2026-05-06 22:01:18 +01:00
Nikolay Govorov
dac34eeecd Add build flag for disable http transport 2026-05-03 12:41:49 +01:00
Edward Thomson
63c0757b4f odb: deprecate git_odb_hash
Hash generation is not a concern of the object database; deprecate
`git_odb_hash`.
2026-05-02 14:17:21 +01:00
Edward Thomson
2dd70bc196 object: introduce git_object_id_from... APIs
Introduce APIs within the `git_object` namespace to calculate the IDs
of objects based on their raw content.
2026-05-02 14:17:21 +01:00
Edward Thomson
643b7e1038 merge_files: some simplification 2026-05-02 08:24:18 +01:00
Daniel Scherzer
9e78ec20bb GIT_REMOTE_DOWNLOAD_TAGS_ALL: remove stray "the" in docs 2026-04-22 16:27:54 -07: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
yoni_ash
ee63fad343 Add missing includes in public header files 2026-02-05 09:46:46 +04: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
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
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
e2105f3a8b Merge pull request #7181 from Murmele/wrong_comment
fix wrong comment
2026-01-10 13:32:58 +00:00
Martin Marmsoler
0e3200a8fc fix wrong comment 2026-01-03 17:02:51 +01:00
Edward Thomson
80cc5c6bd6 Merge pull request #7119 from ehuss/cert_cb-always-called
Update documentation to clarify that cert cb is always called
2025-12-06 17:25:38 +00:00
Olek Raymond
d30270e3cc Update GIT_DIFF_OPTIONS_INIT macro with new fields 2025-11-11 20:31:17 +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
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
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
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
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
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
Yuriy Chernyshov
60fdf919e7 Fix circular includes between types.h and oid.h 2025-03-31 13:04:34 +03:00
Edward Thomson
3822833a7a Merge pull request #7007 from libgit2/ethomson/buildinfo
Introduce git_libgit2_buildinfo
2025-02-03 17:20:55 +00:00
Edward Thomson
24b5096712 Include common.h in version.h
Fixes #7027
2025-01-23 00:22:34 +00:00
Edward Thomson
1509637751 Introduce git_libgit2_buildinfo
Track some information about the compilation at compile time, and allow
consumers to query it.
2025-01-15 09:28:26 +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
Florian Pircher
2fa13adf09 include: Fix code comment termination 2025-01-02 17:19:58 +01: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
Edward Thomson
56e2a85643 sha256: simplify API changes for sha256 support
There are several places where users may want to specify the type of
object IDs (sha1 or sha256) that should be used, for example, when
dealing with repositories, indexes, etc.

However, given that sha256 support remains disappointingly uncommon in
the wild, we should avoid hard API breaks when possible. Instead, update
these APIs to have an "extended" format (eg, `git_odb_open_ext`) that
provides an options structure with oid type information.

This allows callers who do care about sha256 to use it, and callers who
do not to avoid gratuitous API breakage.
2025-01-02 13:13:59 +00:00
Edward Thomson
ca2a241e4c repo: workdir_path implies no dotgit in init
When specifying a separate working directory path, the given repository
path should never have a `.git` directory created beneath it. That
simply doesn't make sense.

As a result, the `GIT_REPOSITORY_INIT_NO_DOTGIT_DIR` now _also_ no
longer makes sense. It would only ever be a sensible option when one
wanted a separate `.git` directory and working directory, otherwise the
git files and working directory files would be comingled. Remove the
option entirely.
2024-12-30 20:36:13 +00:00
Edward Thomson
3aeb5bd0f6 meta: revert soname version update
Changing our SONAME / ABI version update policy without an announcement
is a breaking change. Provide time to announce a policy update.
2024-12-28 08:30:39 +00:00
Edward Thomson
c536fcbb85 v1.9: update version numbers
Update the library's (API) version number to v1.9.0. Also update the
soname version number to 2.0, since we've had breaking ABI changes
to the library.
2024-12-28 01:00:19 +00:00
Edward Thomson
ccc202802c Merge pull request #6962 from ryan-ph/ryanpham/negative-refspec/remote
remote: Handle fetching negative refspecs
2024-12-24 23:55:06 +00:00
Edward Thomson
67900a0fcb options: update X509 cert constant
By placing the X509 cert constant option in the middle of the existing
options, it renumbers everything unnecessarily. Move it to the end in
to avoid breaking changes.
2024-12-23 09:47:03 +00:00