Commit Graph

2376 Commits

Author SHA1 Message Date
Josh Triplett
f45ff6c92d Omit trailing comma on enum
To accommodate less capable compilers.

Co-authored-by: Peter Pettersson <85582231+boretrk@users.noreply.github.com>
2021-11-08 17:33:35 +01:00
Josh Triplett
81662d432c Support checking for object existence without refresh
Looking up a non-existent object currently always invokes
`git_odb_refresh`. If looking up a large batch of objects, many of which
may legitimately not exist, this will repeatedly refresh the ODB to no
avail.

Add a `git_odb_exists_ext` that accepts flags controlling the ODB
lookup, and add a flag to suppress the refresh. This allows the user to
control if and when they refresh (for instance, refreshing once before
starting the batch).
2021-11-08 14:59:01 +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
f0e693b18a str: introduce git_str for internal, git_buf is external
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.
2021-10-17 09:49:01 -04:00
Edward Thomson
1738f7320d diff: document updated rename limit 2021-10-13 11:36:07 -04:00
Edward Thomson
8c29885e02 Merge pull request #6076 from libgit2/ethomson/oidarray_dispose
oidarray: introduce `git_oidarray_dispose`
2021-09-27 08:57:03 -04:00
Edward Thomson
0bd132ab82 oidarray: introduce git_oidarray_dispose
Since users are disposing the _contents_ of the oidarray, not freeing
the oidarray itself, the proper cleanup function is
`git_oidarray_dispose`.  Deprecate `git_oidarray_free`.
2021-09-26 18:02:07 -04:00
Edward Thomson
0f4256b8d7 repository: improve hashfile for absolute paths
When `git_repository_hashfile` is handed an absolute path, it determines
whether the path is within the repository's working directory or not.
This is necessary when there is no `as_path` specified.

If the path is within the working directory, then the given path should
be used for attribute lookups (it is the effective `as_path`).  If it is
not within the working directory, then it is _not_ eligible.

Importantly, now we will _never_ pass an absolute path down to attribute
lookup functions.
2021-09-25 14:39:01 +01:00
Edward Thomson
e7437162ff v1.3: update version number 2021-09-22 08:49:24 -04:00
Edward Thomson
a5644b8090 Merge pull request #6068 from libgit2/ethomson/diff_enum
diff: update `GIT_DIFF_IGNORE_BLANK_LINES`
2021-09-22 08:48:17 -04:00
Edward Thomson
1ba7c32709 diff: update GIT_DIFF_IGNORE_BLANK_LINES
`GIT_DIFF_IGNORE_BLANK_LINES` needs to be within a (signed) int, per the
`enum` definition of ISO C.
2021-09-21 20:23:44 -04:00
Edward Thomson
90656858ce filter: use a git_oid in filter options, not a pointer
Using a `git_oid *` in filter options was a mistake; it is a deviation
from our typical pattern, and callers in some languages that GC may need
very special treatment in order to pass both an options structure and a
pointer outside of it.
2021-09-21 11:28:39 -04:00
Edward Thomson
ba01547d4a Merge pull request #6061 from libgit2/ethomson/email
Introduce `git_email_create`; deprecate `git_diff_format_email`
2021-09-20 21:45:10 -04:00
Edward Thomson
1396a9b556 Merge pull request #6020 from lolgear/refactoring/stdint_ifdef_condition_has_been_reverted
Stdint header condition has been reverted.
2021-09-20 12:36:56 -04:00
Edward Thomson
ba3595af0f diff: deprecate diff_format_email
`git_diff_format_email` is deprecated in favor of `git_email_create`.
2021-09-18 08:32:42 -04:00
Edward Thomson
67b1d019a8 email: include renames by default
`git format-patch` includes diffs with rename detection enabled by
default when creating emails.  Match this behavior.
2021-09-18 08:32:41 -04:00
Edward Thomson
323f222f7e email: include binary diffs by default
`git format-patch` includes binary diffs by default when creating
emails.  Match this behavior.
2021-09-18 08:32:41 -04: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
75d4676a64 email: introduce git_email_create_from_commit
Create `git_email_*` which will encapsulate email creation and
application, and `git_email_create_from_commit` in particular, which
creates an email for a single commit.
2021-09-18 08:32:41 -04:00
Edward Thomson
4f24a932f0 Merge pull request #6031 from libgit2/ethomson/extensions
Support custom git extensions
2021-09-14 07:45:50 -04:00
punkymaniac
379c46463c Fix coding style for pointer
Make some syntax change to follow coding style.
2021-09-09 19:49:04 +02:00
lhchavez
62ee779ea4 remote: Mark git_remote_name_is_valid as GIT_EXTERN
This change makes `git_remote_name_is_valid` be part of the public
interface of the library. This is needed for other language bindings to
be able to find this symbol (like in git2go, when linking against
libgit2 dynamically).
2021-09-04 18:02:17 -07:00
Edward Thomson
a24e656a4e common: support custom repository extensions
Allow users to specify additional repository extensions that they want
to support.  For example, callers can specify that they support
`preciousObjects` and then may open repositories that support
`extensions.preciousObjects`.

Similarly, callers may opt out of supporting extensions that the library
itself supports.
2021-09-04 13:00:18 -04:00
Edward Thomson
c811fc361b v1.2: update version information 2021-08-31 00:19:01 -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
Dmitry Lobanov
2bd3c80e7c include: stdint header condition has been reverted. 2021-08-30 11:41:11 +03:00
Edward Thomson
969a056cc5 Merge pull request #6017 from libgit2/ethomson/buf_is_readonly
buf: deprecate public git_buf writing functions
2021-08-29 22:54:01 -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
Edward Thomson
258115db3e Merge pull request #6016 from libgit2/ethomson/commit_create_cb
Introduce `create_commit_cb`, deprecate `signing_cb`
2021-08-29 22:53:38 -04:00
Edward Thomson
16a2e6676f Merge pull request #6012 from libgit2/ethomson/custom_url
remote: introduce remote_ready_cb, deprecate resolve_url callback
2021-08-29 22:53:28 -04:00
lhchavez
7d9ebdc840 Merge remote-tracking branch 'origin/main' into cgraph-write 2021-08-29 18:50:49 -07:00
Edward Thomson
2998a84ab6 Merge pull request #5841 from J0Nes90/features/checkout-dry-run
Checkout dry-run
2021-08-29 21:49:33 -04:00
Edward Thomson
aebdee8e3d Update include/git2/checkout.h 2021-08-29 21:49:26 -04:00
Edward Thomson
147b659f3b Merge pull request #5405 from lhchavez/multi-pack-index-odb-write
midx: Introduce git_odb_write_multi_pack_index()
2021-08-29 21:40:26 -04:00
Edward Thomson
18293385d0 Merge pull request #5395 from josharian/http-use-eauth
Use error code GIT_EAUTH for authentication failures
2021-08-29 21:40:16 -04:00
Edward Thomson
9937967efd Merge branch 'main' into http-use-eauth 2021-08-29 21:29:14 -04:00
Edward Thomson
d2316d5746 buf: deprecate public git_buf writing functions
A `git_buf` is now a read-only structure as far as callers are
concerned.  This is a mechanism that we can return data to callers
using memory that is owned by the library and can be cleaned up by
callers (using `git_buf_dispose`).

A `git_buf` can no longer be allocated by callers or provided to the
library.
2021-08-29 13:13:03 -04:00
Edward Thomson
5bcef522f3 filter: deprecate apply function 2021-08-29 12:29:23 -04:00
Edward Thomson
7442c000d9 remote: deprecate resolve_url callback
Using a callback to set a resolve_url is not particularly idiomatic.
Deprecate it in favor of the `set_instance_url` and
`set_instance_pushurl` functions which can now be called from the
`git_remote_ready_cb` callback.
2021-08-29 10:39:28 -04:00
Edward Thomson
72df17c659 remote: introduce git_remote_ready_cb
Introduce a new callback that fires when the remote is ready to connect.
2021-08-29 10:39:28 -04:00
Edward Thomson
ef03e15038 rebase: deprecate signing_cb
The signing callback should not be used; instead, callers should provide
a commit_create_cb, perform the signing and commit creation themselves.
2021-08-29 10:16:56 -04:00
Edward Thomson
d3bdf33b58 rebase: introduce git_commit_create_cb
Introduce a new mechanism for `git_rebase_commit` for callers to
customize the experience.  Instead of assuming that we produce the
commit for them, provide a commit creation callback that allows callers
to produce the commit themselves and return the resulting commit id.
2021-08-29 10:16:29 -04:00
Edward Thomson
a9a7bfb506 filter: add docs for git_filter_stream_fn 2021-08-27 15:06:32 -04:00
Edward Thomson
672406773e remote: introduce set_instance_url
Users may want to override the URL on a particular instance of a remote,
instead of updating the configuration.  Previously, users could use a
callback to do this, but this is not particularly idiomatic.
2021-08-27 11:26:49 -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
e66545e30f Merge remote-tracking branch 'origin/main' into multi-pack-index-write 2021-08-27 04:06:54 -07:00
lhchavez
47c70fc54e Merge remote-tracking branch 'origin/main' into cgraph-write 2021-08-26 05:40:20 -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