Commit Graph

214 Commits

Author SHA1 Message Date
Edward Thomson
a8f3381719 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-08-18 14:20:28 +01:00
Edward Thomson
45647b721c Merge pull request #6615 from libgit2/ethomson/config_origin
config: provide an "origin" for config entries
2023-08-14 20:40:47 +01:00
David Runge
f7c746a2ef fix: Add missing include for oidarray.
Add a missing include for `git2/oidarray.h` so build doesn't fail on
using `git_oidarray` when using custom transports.

Fixes #6607
2023-07-21 16:18:39 +02:00
Edward Thomson
40ce52e51f config: provide two memory-backed config backends
Provide two memory-backed configuration backends -- one that takes a
string in config file format `[section] key=value` and one that takes a
list of strings in `section.key=value` format.
2023-07-21 11:18:44 +01:00
Edward Thomson
9dd1bfe81c alloc: simplify pluggable allocators
Remove the number of functions that custom allocator users need to
provide; nobody should need to implement `substrdup`. Keep it to the
basics that are actually _needed_ for allocation (malloc, realloc,
free) and reimplement the rest ourselves.

In addition, move the failure check and error setting _out_ of the
custom allocators and into a wrapper so that users don't need to deal
with this. This also allows us to call our allocator (without the
wrapper) early so that it does not try to set an error on failure, which
may be important for bootstrapping.
2023-05-14 14:52:15 +01:00
Edward Thomson
fad9042897 streams: sockets are non-blocking and can timeout
Make socket I/O non-blocking and add optional timeouts.

Users may now set `GIT_OPT_SET_SERVER_CONNECT_TIMEOUT` to set a shorter
connection timeout. (The connect timeout cannot be longer than the
operating system default.) Users may also now configure the socket read
and write timeouts with `GIT_OPT_SET_SERVER_TIMEOUT`.

By default, connects still timeout based on the operating system
defaults (typically 75 seconds) and socket read and writes block.

Add a test against our custom testing git server that ensures that we
can timeout reads against a slow server.
2023-05-13 16:42:04 +01:00
Edward Thomson
0a7e32b232 oid: use an oid array instead of shallowarray
Users should provide us an array of object ids; we don't need a separate
type. And especially, we should not be mutating user-providing values.
Instead, use `git_oid *` in the shallow code.
2023-05-09 17:14:08 +01:00
Edward Thomson
190a4c55df Merge remote-tracking branch 'origin/main' into shallow-clone-network 2023-04-22 23:17:32 +01:00
Edward Thomson
b899fda3d8 commit graph: support sha256 2023-04-10 14:21:16 +01:00
Edward Thomson
be484d355b midx: support sha256 2023-04-10 14:21:16 +01:00
lmcglash
d935773743 Remove unused git_transport_flags_t 2023-03-10 09:30:02 +00:00
lmcglash
570ef74a07 Merge commit 'd066d0d95c43e97df6624292f3f527f9372ca8fe' 2023-03-10 08:51:43 +00:00
Edward Thomson
53fcd5b8f5 transport: teach transports about oid types and SHA256 2023-02-12 22:02:00 +00:00
yuangli
68bbcefd35 Merge branch 'transportPR' into shallow-clone-network 2022-07-29 13:19:33 +01:00
yuangli
afa79ca058 Merge branch 'pr/tiennou/4747' into transportPR 2022-07-04 17:08:04 +01:00
Edward Thomson
dbc4ac1c76 oid: GIT_OID_*SZ is now GIT_OID_SHA1_*SIZE
In preparation for SHA256 support, `GIT_OID_RAWSZ` and `GIT_OID_HEXSZ`
need to indicate that they're the size of _SHA1_ OIDs.
2022-06-14 22:29:57 -04:00
Edward Thomson
cc4c37ca9e transport: remove git_transport_smart_proxy_options
Snuck in during refactoring; let's get rid of it.
2022-06-12 10:50:43 -04:00
lhchavez
a75416761c Apply suggestions from code review
Co-authored-by: Edward Thomson <ethomson@github.com>
2022-06-11 14:29:15 -07:00
lhchavez
1d88605ca9 transport: introduce git_transport_smart_remote_connect_options
6fc6eeb66c removed
`git_transport_smart_proxy_option`, and there was nothing added to
replace it. That made it hard for custom transports / smart
subtransports to know what remote connect options to use (e.g. proxy
options).

This change introduces `git_transport_smart_remote_connect_options` to
replace it.
2022-04-16 08:23:22 -07:00
Edward Thomson
37d98aaf44 transport: transports can indicate support for fetch by oid 2022-02-06 15:08:35 -05:00
Edward Thomson
923c16527c transport: add capabilities query function 2022-02-06 15:01:15 -05:00
Edward Thomson
6fc6eeb66c remote: introduce git_remote_connect_options
The existing mechanism for providing options to remote fetch/push calls,
and subsequently to transports, is unsatisfactory.  It requires an
options structure to avoid breaking the API and callback signatures.

1. Introduce `git_remote_connect_options` to satisfy those needs.

2. Add a new remote connection API, `git_remote_connect_ext` that will
   take this new options structure.  Existing `git_remote_connect` calls
   will proxy to that.  `git_remote_fetch` and `git_remote_push` will
   proxy their fetch/push options to that as well.

3. Define the interaction between `git_remote_connect` and fetch/push.
   Connect _may_ be called before fetch/push, but _need not_ be.  The
   semantics of which options would be used for these operations was
   not specified if you specify options for both connect _and_ fetch.
   Now these are defined that the fetch or push options will be used
   _if_ they were specified.  Otherwise, the connect options will be
   used if they were specified.  Otherwise, the library's defaults will
   be used.

4. Update the transports to understand `git_remote_connect_options`.
   This is a breaking change to the systems API.
2022-01-06 15:18:33 -05:00
Peter Pettersson
38c3449822 Make enum in includes C90 compliant by removing trailing comma. 2021-11-15 16:45:40 +01:00
Josh Triplett
3993e9aebc Update documentation for ODB backend refresh logic
Commit b1a6c316a6 moved auto-refresh into
the pack backend, and added a comment accordingly. Commit
43820f204e moved auto-refresh back *out*
of backends into the ODB layer, but didn't update the comment.
2021-11-08 14:01:14 +01:00
Edward Thomson
6aa3496679 email: introduce git_email_create_from_diff
Introduce a function to create an email from a diff and multiple inputs
about the source of the diff.

Creating an email from a diff requires many more inputs, and should be
discouraged in favor of building directly from a commit, and is thus in
the `sys` namespace.
2021-09-18 08:32:41 -04:00
Edward Thomson
98be5a1142 Merge branch 'cgraph-write' into main 2021-08-30 17:55:47 -04:00
Edward Thomson
34fa631142 commit graph: formatting fixes 2021-08-30 17:55:13 -04:00
Edward Thomson
b16a36e111 Merge pull request #6011 from libgit2/ethomson/filter_apply
filter: filter drivers stop taking git_buf as user input
2021-08-29 22:53:49 -04:00
lhchavez
7d9ebdc840 Merge remote-tracking branch 'origin/main' into cgraph-write 2021-08-29 18:50:49 -07:00
Edward Thomson
5bcef522f3 filter: deprecate apply function 2021-08-29 12:29:23 -04:00
Edward Thomson
a9a7bfb506 filter: add docs for git_filter_stream_fn 2021-08-27 15:06:32 -04:00
lhchavez
ea285904dc midx: Introduce git_odb_write_multi_pack_index()
This change introduces git_odb_write_multi_pack_index(), which creates a
`multi-pack-index` file from all the `.pack` files that have been loaded
in the ODB.

Fixes: #5399
2021-08-27 04:12:16 -07:00
lhchavez
9d117e3857 midx: Add a way to write multi-pack-index files
This change adds the git_midx_writer_* functions to allow to
write and create `multi-pack-index` files from `.idx`/`.pack` files.

Part of: #5399
2021-08-27 04:10:37 -07:00
lhchavez
63f08e4258 Make the defaultable fields defaultable
Also, add `git_commit_graph_writer_options_init`!
2021-08-26 05:29:34 -07:00
lhchavez
83862c8374 commit-graph: Add a way to write commit-graph files
This change adds the git_commit_graph_writer_* functions to allow to
write and create `commit-graph` files from `.idx`/`.pack` files or
`git_revwalk`s.

Part of: #5757
2021-07-27 16:00:19 -07:00
Edward Thomson
2370e49102 Merge pull request #5765 from lhchavez/cgraph-revwalks
commit-graph: Use the commit-graph in revwalks
2021-07-26 16:27:54 -04:00
Etienne Samson
3e17854782 docs: fix some missing includes that cause Docurium to error out 2021-05-27 16:26:38 +02:00
lhchavez
25b75cd9bc commit-graph: Create git_commit_graph as an abstraction for the file
This change does a medium-size refactor of the git_commit_graph_file and
the interaction with the ODB. Now instead of the ODB owning a direct
reference to the git_commit_graph_file, there will be an intermediate
git_commit_graph. The main advantage of that is that now end users can
explicitly set a git_commit_graph that is eagerly checked for errors,
while still being able to lazily use the commit-graph in a regular ODB,
if the file is present.
2021-03-10 07:09:47 -08:00
Patrick Steinhardt
3bbbe95a9f refdb_backend: improve callback documentation
The callbacks are currently sparsely documented, making it really hard
to implement a new backend without taking a look at the existing
refdb_fs backend. Add documentation to make this task hopefully easier
to achieve.
2020-03-26 10:09:05 +01:00
Patrick Steinhardt
aa4cd778b9 Merge pull request #5336 from libgit2/ethomson/credtype
cred: change enum to git_credential_t and GIT_CREDENTIAL_*
2020-01-30 10:40:44 +01:00
Edward Thomson
3f54ba8b61 credential: change git_cred to git_credential
We avoid abbreviations where possible; rename git_cred to
git_credential.

In addition, we have standardized on a trailing `_t` for enum types,
instead of using "type" in the name.  So `git_credtype_t` has become
`git_credential_t` and its members have become `GIT_CREDENTIAL` instead
of `GIT_CREDTYPE`.

Finally, the source and header files have been renamed to `credential`
instead of `cred`.

Keep previous name and values as deprecated, and include the new header
files from the previous ones.
2020-01-26 18:39:41 +00:00
Edward Thomson
82050fa1be mempack functions: return an int
Stop returning a void for functions, future-proofing them to allow them
to fail.
2020-01-24 15:12:56 -06:00
Edward Thomson
a3126a72d2 repository functions: return an int
Stop returning a void for functions, future-proofing them to allow them
to fail.
2020-01-24 15:12:56 -06:00
Edward Thomson
cb43274a6b index functions: return an int
Stop returning a void for functions, future-proofing them to allow them
to fail.
2020-01-24 15:12:56 -06:00
Laurence McGlashan
1bddbd02a6 merge: Return non-const git_repository from git_merge_driver_source_repo accessor. 2020-01-15 10:30:00 +00:00
Edward Thomson
fefefd1d39 odb: use git_object_size_t for object size
Instead of using a signed type (`off_t`) use a new `git_object_size_t`
for the sizes of objects.
2019-11-22 15:14:13 +11:00
Patrick Steinhardt
7032537066 Merge pull request #5106 from tiennou/fix/ref-api-fixes
git_refdb API fixes
2019-09-27 11:16:02 +02:00
Etienne Samson
8bf0f7eb26 cred: separate public interface from low-level details 2019-09-13 16:54:40 +02:00
Etienne Samson
8db9fd3b0d refdb: documentation 2019-09-05 10:26:38 +02:00
Patrick Steinhardt
b6625a3b6e Merge pull request #5128 from tiennou/fix/docs
More documentation
2019-06-27 10:12:16 +02:00