diff options
-rw-r--r-- | include/git2/remote.h | 22 | ||||
-rw-r--r-- | src/libgit2/fetch.c | 4 | ||||
-rw-r--r-- | tests/libgit2/online/shallow.c | 2 |
3 files changed, 15 insertions, 13 deletions
diff --git a/include/git2/remote.h b/include/git2/remote.h index 8d6127014..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,20 +753,15 @@ typedef struct { git_proxy_options proxy_opts; /** - * Depth of the fetch to perform, or 0 for full history. + * 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 0. + * The default is full (`GIT_FETCH_DEPTH_FULL` or `0`). */ int depth; /** - * Convert a shallow repository to a full repository. - * - * The default is 0, which means the flag is off. - */ - int unshallow; - - /** * Whether to allow off-site redirects. If this is not * specified, the `http.followRedirects` configuration setting * will be consulted. diff --git a/src/libgit2/fetch.c b/src/libgit2/fetch.c index b43425215..5bbef87f4 100644 --- a/src/libgit2/fetch.c +++ b/src/libgit2/fetch.c @@ -174,10 +174,8 @@ int git_fetch_negotiate(git_remote *remote, const git_fetch_options *opts) remote->need_pack = 0; if (opts) { - GIT_ASSERT_ARG(opts->unshallow == 0 || opts->depth == 0); GIT_ASSERT_ARG(opts->depth >= 0); - - remote->nego.depth = opts->unshallow ? INT_MAX : opts->depth; + remote->nego.depth = opts->depth; } if (filter_wants(remote, opts) < 0) diff --git a/tests/libgit2/online/shallow.c b/tests/libgit2/online/shallow.c index 12ef7748b..5c0e6565b 100644 --- a/tests/libgit2/online/shallow.c +++ b/tests/libgit2/online/shallow.c @@ -143,7 +143,7 @@ void test_online_shallow__unshallow(void) cl_git_pass(git_clone(&repo, "https://github.com/libgit2/TestGitRepository", git_str_cstr(&path), &clone_opts)); cl_assert_equal_b(true, git_repository_is_shallow(repo)); - fetch_opts.unshallow = 1; + fetch_opts.depth = GIT_FETCH_DEPTH_UNSHALLOW; cl_git_pass(git_remote_lookup(&origin, repo, "origin")); cl_git_pass(git_remote_fetch(origin, NULL, &fetch_opts, NULL)); |