8000 fetch: remove `unshallow` option · libgit2/libgit2@b6cb1b3 · GitHub
[go: up one dir, main page]

Skip to content

Commit b6cb1b3

Browse files
committed
fetch: remove unshallow option
The `depth` field is suitable to specify unshallowing; provide an enum to aide in specifying the `unshallow` value.
1 parent b7ac98d commit b6cb1b3

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

include/git2/remote.h

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,15 @@ typedef enum {
702702
GIT_REMOTE_DOWNLOAD_TAGS_ALL
703703
} git_remote_autotag_option_t;
704704

705+
/** Constants for fetch depth (shallowness of fetch). */
706+
typedef enum {
707+
/** The fetch is "full" (not shallow). This is the default. */
708+
GIT_FETCH_DEPTH_FULL = 0,
709+
710+
/** The fetch should "unshallow" and fetch missing data. */
711+
GIT_FETCH_DEPTH_UNSHALLOW = 2147483647
< 8000 code>712+
} git_fetch_depth_t;
713+
705714
/**
706715
* Fetch options structure.
707716
*
@@ -744,19 +753,14 @@ typedef struct {
744753
git_proxy_options proxy_opts;
745754

746755
/**
747-
* Depth of the fetch to perform, or 0 for full history.
756+
* Depth of the fetch to perform, or `GIT_FETCH_DEPTH_FULL`
757+
* (or `0`) for full history, or `GIT_FETCH_DEPTH_UNSHALLOW`
758+
* to "unshallow" a shallow repository.
748759
*
749-
* The default is 0.
760+
* The default is full (`GIT_FETCH_DEPTH_FULL` or `0`).
750761
*/
751762
int depth;
752763

753-
/**
754-
* Convert a shallow repository to a full repository.
755-
*
756-
* The default is 0, which means the flag is off.
757-
*/
758-
int unshallow;
759-
760764
/**
761765
* Whether to allow off-site redirects. If this is not
762766
* specified, the `http.followRedirects` configuration setting

src/libgit2/fetch.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,8 @@ int git_fetch_negotiate(git_remote *remote, const git_fetch_options *opts)
174174
remote->need_pack = 0;
175175

176176
if (opts) {
177-
GIT_ASSERT_ARG(opts->unshallow == 0 || opts->depth == 0);
178177
GIT_ASSERT_ARG(opts->depth >= 0);
179-
180-
remote->nego.depth = opts->unshallow ? INT_MAX : opts->depth;
178+
remote->nego.depth = opts->depth;
181179
}
182180

183181
if (filter_wants(remote, opts) < 0)

tests/libgit2/online/shallow.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ void test_online_shallow__unshallow(void)
143143
cl_git_pass(git_clone(&repo, "https://github.com/libgit2/TestGitRepository", git_str_cstr(&path), &clone_opts));
144144
cl_assert_equal_b(true, git_repository_is_shallow(repo));
145145

146-
fetch_opts.unshallow = 1;
146+
fetch_opts.depth = GIT_FETCH_DEPTH_UNSHALLOW;
147147
cl_git_pass(git_remote_lookup(&origin, repo, "origin"));
148148

149149
cl_git_pass(git_remote_fetch(origin, NULL, &fetch_opts, NULL));

0 commit comments

Comments
 (0)
0