diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2023-04-25 09:31:34 +0100 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2023-05-08 15:06:41 +0100 |
commit | 3388f5ba1b821e9683d21ca41c34ed752d2db222 (patch) | |
tree | 4657ecd30c87c40b66a8be7339e9507e627f58af /src | |
parent | 7d7f3059decbd6b4730bfd09da54726c1b3ed8ea (diff) | |
download | libgit2-3388f5ba1b821e9683d21ca41c34ed752d2db222.tar.gz |
shallow: don't default to -1 for depth
Depth of `0` should indicate full depth. Disallow negative values (they
may have a future meaning) and use `0` as the default.
Diffstat (limited to 'src')
-rw-r--r-- | src/libgit2/clone.c | 2 | ||||
-rw-r--r-- | src/libgit2/fetch.c | 13 |
2 files changed, 6 insertions, 9 deletions
diff --git a/src/libgit2/clone.c b/src/libgit2/clone.c index 43341a493..fca0ca0cc 100644 --- a/src/libgit2/clone.c +++ b/src/libgit2/clone.c @@ -421,7 +421,7 @@ static int clone_into( memcpy(&fetch_opts, opts, sizeof(git_fetch_options)); fetch_opts.update_fetchhead = 0; - if (opts->depth <= 0) + if (!opts->depth) fetch_opts.download_tags = GIT_REMOTE_DOWNLOAD_TAGS_ALL; if ((error = git_remote_connect_options__from_fetch_opts(&connect_opts, remote, &fetch_opts)) < 0) diff --git a/src/libgit2/fetch.c b/src/libgit2/fetch.c index d66892ca0..86b650a60 100644 --- a/src/libgit2/fetch.c +++ b/src/libgit2/fetch.c @@ -172,10 +172,12 @@ int git_fetch_negotiate(git_remote *remote, const git_fetch_options *opts) remote->need_pack = 0; - if (!opts) - remote->nego.depth = -1; - else + 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; + } if (filter_wants(remote, opts) < 0) return -1; @@ -184,11 +186,6 @@ int git_fetch_negotiate(git_remote *remote, const git_fetch_options *opts) if (!remote->need_pack) return 0; - if (opts && opts->unshallow && opts->depth > 0) { - git_error_set(GIT_ERROR_INVALID, "options '--depth' and '--unshallow' cannot be used together"); - return -1; - } - /* * Now we have everything set up so we can start tell the * server what we want and what we have. |