Commit 437c5f5a by Edward Thomson

fetch: remove `unshallow` option

The `depth` field is suitable to specify unshallowing; provide an enum
to aide in specifying the `unshallow` value.
parent 0a7e32b2
...@@ -702,6 +702,15 @@ typedef enum { ...@@ -702,6 +702,15 @@ typedef enum {
GIT_REMOTE_DOWNLOAD_TAGS_ALL GIT_REMOTE_DOWNLOAD_TAGS_ALL
} git_remote_autotag_option_t; } 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. * Fetch options structure.
* *
...@@ -744,20 +753,15 @@ typedef struct { ...@@ -744,20 +753,15 @@ typedef struct {
git_proxy_options proxy_opts; 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; 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 * Whether to allow off-site redirects. If this is not
* specified, the `http.followRedirects` configuration setting * specified, the `http.followRedirects` configuration setting
* will be consulted. * will be consulted.
......
...@@ -174,10 +174,8 @@ int git_fetch_negotiate(git_remote *remote, const git_fetch_options *opts) ...@@ -174,10 +174,8 @@ int git_fetch_negotiate(git_remote *remote, const git_fetch_options *opts)
remote->need_pack = 0; remote->need_pack = 0;
if (opts) { if (opts) {
GIT_ASSERT_ARG(opts->unshallow == 0 || opts->depth == 0);
GIT_ASSERT_ARG(opts->depth >= 0); GIT_ASSERT_ARG(opts->depth >= 0);
remote->nego.depth = opts->depth;
remote->nego.depth = opts->unshallow ? INT_MAX : opts->depth;
} }
if (filter_wants(remote, opts) < 0) if (filter_wants(remote, opts) < 0)
......
...@@ -143,7 +143,7 @@ void test_online_shallow__unshallow(void) ...@@ -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_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)); 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_lookup(&origin, repo, "origin"));
cl_git_pass(git_remote_fetch(origin, NULL, &fetch_opts, NULL)); cl_git_pass(git_remote_fetch(origin, NULL, &fetch_opts, NULL));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment