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.
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.
Users can now set up cmake with -DC_STANDARD=... or -DC_EXTENSIONS=...
We default to C90 with C_EXTENSIONS=OFF, but callers can override if
they desire.
This PR ensures and enforces C90 conformance for all files C, including tests.
* Modify CMakeLists.txt to mandate C90 conformance (for better compiler compatibility)
* Update deps/ntlmclient/utf8.h to latest version
* Modify two tests and one header to use C comments instead of C++ comments
People who are doing a commit expect a unified timestamp between
author and committer information when we're using the current timestamp.
Provide a single function that returns both author and committer
information so that they can have an identical timestamp when none is
specified in the environment.
When creating an action signature (e.g. for a commit author and
committer) read the following environment variables that can override
the configuration options:
* `GIT_AUTHOR_NAME` is the human-readable name in the "author" field.
* `GIT_AUTHOR_EMAIL` is the email for the "author" field.
* `GIT_AUTHOR_DATE` is the timestamp used for the "author" field.
* `GIT_COMMITTER_NAME` sets the human name for the "committer" field.
* `GIT_COMMITTER_EMAIL` is the email address for the "committer" field.
* `GIT_COMMITTER_DATE` is used for the timestamp in the "committer"
field.
* `EMAIL` is the fallback email address in case the user.email
configuration value isn't set. If this isn't set, Git falls back to
the system user and host names.
This is taken from the git documentation chapter "10.8 Environment
Variables":
https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables
This PR adds support for reading these environment variables by adding
two new functions `git_signature_default_author` and
`git_signature_default_committer` and deprecates the
`git_signature_default` function.
Fixes: https://github.com/libgit2/libgit2/issues/3751
Prior work:
* https://github.com/libgit2/libgit2/pull/4409
* https://github.com/libgit2/libgit2/pull/5479
* https://github.com/libgit2/libgit2/pull/6290
The index's checksum is not an object ID, so we should not use the
`git_oid` type. Use a byte array for checksum calculation and storage.
Deprecate the `git_indexer_hash` function. Callers should use the new
`git_indexer_name` function which provides a unique packfile name.
libgit2 has two distinct requirements that were previously solved by
`git_buf`. We require:
1. A general purpose string class that provides a number of utility APIs
for manipulating data (eg, concatenating, truncating, etc).
2. A structure that we can use to return strings to callers that they
can take ownership of.
By using a single class (`git_buf`) for both of these purposes, we have
confused the API to the point that refactorings are difficult and
reasoning about correctness is also difficult.
Move the utility class `git_buf` to be called `git_str`: this represents
its general purpose, as an internal string buffer class. The name also
is an homage to Junio Hamano ("gitstr").
The public API remains `git_buf`, and has a much smaller footprint. It
is generally only used as an "out" param with strict requirements that
follow the documentation. (Exceptions exist for some legacy APIs to
avoid breaking callers unnecessarily.)
Utility functions exist to convert a user-specified `git_buf` to a
`git_str` so that we can call internal functions, then converting it
back again.
This adds basic support for user/password and SSH authentication to the
push example. Authentication is implemented by using the cred_acquire_cb
credential callback defined in examples/common.c.
Co-authored-by: Marius Knaust <marius.knaust@gmail.com>