Commit Graph

236 Commits

Author SHA1 Message Date
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
6aa9bc4a97 midx: add options to writer function
Provide an options structure to MIDX writing. This allows us to
specify information (like OID type) during writer creation.
2024-12-18 16:27:46 +00:00
Edward Thomson
0738b054d3 commit_graph: add opts to open function
Provide an options structure to commit graph opening. This allows us to
specify information (like OID type) during opening.
2024-12-18 16:27:46 +00:00
Edward Thomson
54d666e5f7 commit_graph: move opts to new function
Instead of making the commit and dump functions take individual options
structures; provide the options structure to the writer creator. This
allows us to add additional information (like OID type) during
generation.
2024-12-18 16:27:46 +00:00
Edward Thomson
622035e6ad repo: take an options structure for repository_new
Future-proof the SHA256-ification of `git_repository_new` by taking an
options structure instead of an oid type.
2024-12-18 16:27:46 +00:00
Edward Thomson
4282cbd6d8 Merge remote-tracking branch 'main' into mempack_empty 2024-12-09 22:38:29 +00:00
Edward Thomson
4bb69b0827 odb_mempack: use an out param 2024-12-09 22:36:10 +00:00
Edward Thomson
88fee7af56 Documentation: update refdb_backend docs
Parameters are documented by `@param`, not `@arg`
2024-12-09 21:52:44 +00:00
Edward Thomson
338ceb93b6 Improve documentation 2024-11-26 21:44:09 +00:00
Edward Thomson
5353a2cc20 reflog: remove unused sys functions
The `git_reflog_entry__alloc` function is not actually defined, nor
used. Remove references to it in the headers. It is not clear why the
corresponding `__free` is, or should be, exported. Make it internal to
the library.
2024-11-26 21:22:10 +00:00
Vladyslav Yeremeichuk
b190162f3e Add the ability to get the number of objects in mempack
Implement git_mempack_object_count, which returns the number of
objects in mempack and -1 on error.
2024-10-22 13:58:10 +03:00
Vladyslav Yeremeichuk
d1be60bbe8 Add the ability to check if a mempack is empty
Implement git_mempack_empty, which returns 1 if the mempack is empty
and 0 otherwise.
2024-10-21 22:42:56 +03:00
Edward Thomson
9ddd72f22a Merge pull request #6875 from roberth/mempack-thin-packfile 2024-09-27 17:20:00 +02:00
Robert Hensing
f9c35fb509 Add git_mempack_write_thin_pack
Unlike existing functions, this produces a _thin_ packfile by
making use of the fact that only new objects appear in the
mempack Object Database.

A thin packfile only contains certain objects, but not its whole
closure of references. This makes it suitable for efficiently
writing sets of new objects to a local repository, by avoiding
many small I/O operations.

This relies on write_pack (e.g. git_packbuilder_write_buf) to
implement the "recency order" optimization step.

Basic measurements comparing against the writing of individual
objects show a speedup during when writing large amounts of
content on machines with comparatively slow I/O operations,
and little to no change on machines with fast I/O operations.
2024-09-27 12:39:05 +02: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
cc2a01524d docs: document git_remote_capability_t 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
b4263c2303 Merge remote-tracking branch 'origin/main' into push-options 2024-02-06 20:38:55 +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
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
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
Russell Sim
ecc6f2fb83 push: support push-options
Push options are an optional capability of a git server.  If they are
listed in the servers capabilities, when the client lists push-options
in it's list of capabilities, then the client sends it's list of push
options followed by a flush-pkt.

So, If we have any declared push options, then we will list it as a
client capability, and send the options.

If the request contains push options but the server has no push
options capability, then error.
2022-11-27 00:17:32 +01: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