diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2023-05-09 20:38:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-09 20:38:04 +0100 |
commit | 2bbcdee6b666f34e83d1cf9ca9badc66258202d6 (patch) | |
tree | 26a9d405c75564de8e1a3dc8ac4dc1c8ec7421f7 /include | |
parent | 251408cfd4ff8112efaa5c82ec81c9574c4bf022 (diff) | |
parent | 437c5f5a0b6ae6068168081ac6422dba44cff31d (diff) | |
download | libgit2-2bbcdee6b666f34e83d1cf9ca9badc66258202d6.tar.gz |
Merge pull request #6557 from libgit2/ethomson/shallow
Shallow (#6396) with some fixes from review
Diffstat (limited to 'include')
-rw-r--r-- | include/git2/errors.h | 3 | ||||
-rw-r--r-- | include/git2/remote.h | 18 | ||||
-rw-r--r-- | include/git2/sys/transport.h | 21 |
3 files changed, 39 insertions, 3 deletions
diff --git a/include/git2/errors.h b/include/git2/errors.h index a61964bbb..e634a97c1 100644 --- a/include/git2/errors.h +++ b/include/git2/errors.h @@ -109,7 +109,8 @@ typedef enum { GIT_ERROR_WORKTREE, GIT_ERROR_SHA, GIT_ERROR_HTTP, - GIT_ERROR_INTERNAL + GIT_ERROR_INTERNAL, + GIT_ERROR_GRAFTS } git_error_t; /** diff --git a/include/git2/remote.h b/include/git2/remote.h index 8c9c26f3f..e9065b250 100644 --- a/include/git2/remote.h +++ b/include/git2/remote.h @@ -702,6 +702,15 @@ typedef enum { GIT_REMOTE_DOWNLOAD_TAGS_ALL } git_remote_autotag_option_t; +/** Constants for fetch depth (shallowness of fetch). */ +typedef enum { + /** The fetch is "full" (not shallow). This is the default. */ + GIT_FETCH_DEPTH_FULL = 0, + + /** The fetch should "unshallow" and fetch missing data. */ + GIT_FETCH_DEPTH_UNSHALLOW = 2147483647 +} git_fetch_depth_t; + /** * Fetch options structure. * @@ -744,6 +753,15 @@ typedef struct { git_proxy_options proxy_opts; /** + * Depth of the fetch to perform, or `GIT_FETCH_DEPTH_FULL` + * (or `0`) for full history, or `GIT_FETCH_DEPTH_UNSHALLOW` + * to "unshallow" a shallow repository. + * + * The default is full (`GIT_FETCH_DEPTH_FULL` or `0`). + */ + int depth; + + /** * Whether to allow off-site redirects. If this is not * specified, the `http.followRedirects` configuration setting * will be consulted. diff --git a/include/git2/sys/transport.h b/include/git2/sys/transport.h index b70582188..96a35d08c 100644 --- a/include/git2/sys/transport.h +++ b/include/git2/sys/transport.h @@ -25,6 +25,14 @@ GIT_BEGIN_DECL +typedef struct { + const git_remote_head * const *refs; + size_t refs_len; + git_oid *shallow_roots; + size_t shallow_roots_len; + int depth; +} git_fetch_negotiation; + struct git_transport { unsigned int version; /**< The struct version */ @@ -96,8 +104,17 @@ struct git_transport { int GIT_CALLBACK(negotiate_fetch)( git_transport *transport, git_repository *repo, - const git_remote_head * const *refs, - size_t count); + const git_fetch_negotiation *fetch_data); + + /** + * Return the shallow roots of the remote. + * + * This function may be called after a successful call to + * `negotiate_fetch`. + */ + int GIT_CALLBACK(shallow_roots)( + git_oidarray *out, + git_transport *transport); /** * Start downloading the packfile from the remote repository. |