Commit Graph

2561 Commits

Author SHA1 Message Date
Edward Thomson
9f3406163b Merge pull request #6804 from libgit2/ethomson/config_entry
config: remove `free` ptr from `git_config_entry`
2024-09-25 11:24:48 +02:00
Robert Hensing
ab1b7aded5 Make packbuilder interruptible using progress callback
Specifically, forward errors from packbuilder->progress_cb

This allows the callback to gracefully terminate long-running
operations when the application is interrupted.

Interruption could be ^C in the terminal, but this could be any
other condition or event, as this is up to the callback function
to implement.
2024-09-02 17:09:13 +02:00
Anatol Pomozov
1f83c4652c Remove duplicating declaration of git_email_create_from_diff()
Exactly the same function already declared in include/git2/email.h
2024-07-10 17:16:32 -07:00
Anatol Pomozov
0c39ee1b1f Use typedef type for git_odb
This makes the function signature consistent with other cases
2024-07-10 17:14:09 -07:00
Edward Thomson
f3518eee26 Merge pull request #6706 from u-quark/signature-use-env-vars
Use environment variables when creating signatures
2024-07-10 08:31:15 +01:00
Eric Huss
ca1e3dbb06 Fix docs for git_odb_stream_read return value. 2024-06-22 12:59:37 -07:00
Edward Thomson
649ef1cca6 signature: add git_signature_default_from_env
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.
2024-06-14 14:55:37 +02:00
Edward Thomson
e9d56b0b14 v1.8.2: update version numbers 2024-06-13 19:43:46 +02:00
Edward Thomson
49d3fadfca Revert "commit: fix const declaration"
This reverts commit cf19ddc522, which
was breaking for several projects.
2024-06-13 15:20:40 +02:00
Edward Thomson
834ec0f52f v1.8.1: update version numbers 2024-05-16 00:49:40 +01:00
Edward Thomson
2d649ccd23 remote: drop bitfields in git_remote_fetch_options
In attempting to make a clever change that added fetch options as flags,
while keeping ABI and API compatibility, we screwed up. Bitfields in
structs are implementation-specific and are not necessarily ABI
compatible across compilers.

Make `update_fetchhead` a flags value which is weirdly named, but
that's a future problem. This removes the `report_unchanged` option from
API.
2024-05-06 15:46:21 +01:00
Edward Thomson
aa093c4b07 config: remove free ptr from git_config_entry
This is a leftover leaky abstraction. If consumers aren't meant to
_call_ the `free` function then they shouldn't _see_ the free function.
Move it out into a `git_config_backend_entry` that is, well, produced by
the config backends.

This makes our code messier but is an improvement for consumers.
2024-04-29 22:58:09 +01:00
Edward Thomson
9ddf612a00 Merge pull request #6788 from libgit2/ethomson/user_agent
Allow more control over the user-agent
2024-04-18 21:02:59 +01:00
Edward Thomson
cc2a01524d docs: document git_remote_capability_t 2024-04-02 22:14:51 +01:00
Edward Thomson
6122f008c6 docs: it's _return_ not _returns_ 2024-04-02 22:14:51 +01:00
Edward Thomson
6bed71e05d docs: update includes
Update our headers so that they can include the necessary definitions.
Docs generators (in particular, `clang -Xclang -ast-dump`) were unable
to see the necessary definitions.
2024-04-02 22:14:47 +01:00
Edward Thomson
4839f4fbfc http: allow users more control over user-agent
Users can now override the "product" portion of the user-agent (via
GIT_OPT_SET_USER_AGENT_PRODUCT). This continues to default to "git/2.0",
but users may define their own string, or may opt out of sending a
user-agent entirely (by passing an empty string). Similarly, users may
now also opt-out of sending any additional "comment" information by
setting the GIT_OPT_SET_USER_AGENT value to an empty string.
2024-03-28 10:10:50 +00:00
Edward Thomson
5aa3ce7225 v1.8: update version numbers 2024-03-20 08:19:09 +00:00
Edward Thomson
dd35af37d8 repository: rearrange git_repository_item_t values
Update the ordering of `GIT_REPOSITORY_ITEM_WORKTREE_CONFIG` to avoid
breaking the ABI unnecessarily.
2024-03-17 21:52:11 +00:00
Edward Thomson
2eb3fecd03 fetch: avoid API breaking-changes from v1.7
Update `git_fetch_options` to break out the fetch options into
individual options. This prevents creating an API breaking change from
v1.7.0. `git_remote_update_tips` retains the `update_flags` to also
avoid an API breaking change.
2024-03-17 21:26:27 +00:00
Edward Thomson
cb4b61770f Merge branch 'main' into ethomson/worktree-config 2024-03-11 22:41:25 +00:00
Edward Thomson
b454eba9a7 errors: introduce GIT_ENOTSUPPORTED
libgit2 lacks many of the things that git supports. Give a reasonable
error code for these cases.
2024-03-11 21:07:21 +00:00
Edward Thomson
fb187bd003 config: return GIT_EREADONLY on read-only configs
Introduce `GIT_EREADONLY` and return it when a read-only configuration
is attempted to be mutated. This is preferred over the prior
`GIT_ENOTFOUND` which is not accurate.
2024-03-10 21:35:24 +00:00
Edward Thomson
b499a3465c config: introduce a writers list
Configuration read order and write order should be separated. For
example: configuration readers have a worktree level that is higher
priority than the local configuration _for reads_. Despite that, the
worktree configuration is not written to by default.

Use a new list, `writers`, to identify the write target.

To do this, we need another level of indirection between backend
instances (which are refcounted and shared amongst different git_config
instances) and the config reader/writer list (since each of those
different git_config instances can have different read/write
priorities).
2024-03-10 21:35:24 +00:00
Edward Thomson
85f5aec13e Merge remote-tracking branch 'origin/main' into worktree 2024-03-05 09:44:16 +00:00
Edward Thomson
885744a77e worktree: keep version number at 1
We aren't upgrading options struct version numbers when we make ABI
changes. This is a future (v2.0+) plan for libgit2. In the meantime,
keep the version numbers at 1.
2024-03-05 09:23:03 +00:00
Edward Thomson
70ab821607 config: improve documentation for config levels 2024-03-02 09:06:46 +00:00
Sean Allred
c4df10285e config: load worktree config from disk
Now that GIT_CONFIG_LEVEL_WORKTREE exists logically, define and load
$GIT_DIR/config.worktree into that level.
2024-02-20 11:30:34 -06:00
Sean Allred
aa31120f7c config: introduce GIT_CONFIG_LEVEL_WORKTREE
Introduce the logical concept of a worktree-level config.  The new
value sits between _LOCAL and _APP to allow `git_config_get_*` to
'just work'.

The assumption of how `git_config_get_*` works was tested
experimentally by setting _WORKTREE to some nonsense value (like -3)
and watching the new test fail.
2024-02-20 11:30:34 -06:00
Edward Thomson
39669956fb push: "push_options" are now "remote_push_options"
Since we use `git_push_options` as the options structure to our
`git_push` command, much like we do everywhere else, "push_options"
becomes ambiguous. "remote_options" isn't much better for us. Call them
"remote_push_options", which is still quite bad, and not particularly
insightful for end users, but at least something that we can discuss
unambiguously.
2024-02-06 20:40:26 +00:00
Edward Thomson
b4263c2303 Merge remote-tracking branch 'origin/main' into push-options 2024-02-06 20:38:55 +00:00
Edward Thomson
802f08c696 Merge pull request #6721 from vafada/ssh-timeout
set SSH timeout
2024-02-05 11:54:55 +00:00
Edward Thomson
c3dc87b0c8 docs: update documentation for timeout
The connect timeout *does* apply to SSH connections (at least libssh2),
so update the documentation appropriately.
2024-02-05 10:16:17 +00:00
Mark
7be7c0c0e0 use git_socket_stream__timeout 2024-01-26 13:37:23 -05:00
Mark
392e380463 set SSH timeout 2024-01-18 23:13:14 -05:00
Edward Thomson
55381816e8 commit: support specifying encoding for message 2024-01-15 15:53:19 +00:00
Edward Thomson
67a4d04b59 commit: introduce git_commit_create_from_stage
Provide a simple helper method that allows users to create a commit from
the current index with minimal information.
2024-01-15 15:53:19 +00:00
Edward Thomson
cf19ddc522 commit: fix const declaration
commit functions should take an array of const pointers, not a const
array.
2024-01-15 00:15:10 +00:00
u_quark
48cb38a1b8 Remove deprecated annotation 2024-01-14 12:22:26 +00:00
u_quark
080248352b Address review comments
Also fix some comment formatting.
2024-01-14 12:13:25 +00:00
u_quark
f62abd00db Use environment variables when creating signatures
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
2024-01-14 11:07:13 +00:00
DavHau
d6454dd467 docs: fix mistake in attr.h
Also fix indentation
2024-01-11 16:34:36 +07:00
Edward Thomson
98075baed2 fixup! commit: introduce git_repository_commit_parents 2023-12-23 15:30:31 +00:00
Edward Thomson
0572884693 commit: introduce git_repository_commit_parents
Emulating `git commit` is clunky - identifying your commit's parents is
part of the problem. Provide a helper to give you the parents given the
current repository state.
2023-12-23 14:11:26 +00:00
Edward Thomson
d1bdf2a8b9 Merge pull request #6678 from libgit2/ethomson/compat_fixes
Several compatibility fixes
2023-12-14 20:57:22 +00:00
Edward Thomson
b882e9e7a6 stream: use an unsigned int for a bitmask 2023-12-14 13:42:12 +00:00
Kevin Saul
731af14be3 repo: add oid type support to git_repository_new 2023-12-14 16:59:59 +13:00
Edward Thomson
95e517bee5 remote: optionally report unchanged tips 2023-10-15 14:15:20 +01:00
Edward Thomson
f78ae89bf1 errors: move systems things into the sys includes
Most callers only need to _get_ error messages. Only callers implemented
more complicated functions (like a custom ODB for example) need to set
them.

(Callback users should likely ferry their own error information in their
callback payload.)
2023-09-03 14:00:35 +01:00
Edward Thomson
3618a2aa45 errors: never return a NULL error
Callers want to be able to simply call `git_error_last()->message`,
not have to worry about whether `git_error_last()` returns NULL or not.
2023-09-03 14:00:35 +01:00