Commit 3388f5ba by Edward Thomson

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.
parent 7d7f3059
......@@ -744,9 +744,9 @@ typedef struct {
git_proxy_options proxy_opts;
/**
* Depth of the fetch to perform. Depth <= 0 fetches the full history.
* Depth of the fetch to perform, or 0 for full history.
*
* The default is -1.
* The default is 0.
*/
int depth;
......@@ -772,7 +772,7 @@ typedef struct {
#define GIT_FETCH_OPTIONS_VERSION 1
#define GIT_FETCH_OPTIONS_INIT { GIT_FETCH_OPTIONS_VERSION, GIT_REMOTE_CALLBACKS_INIT, GIT_FETCH_PRUNE_UNSPECIFIED, 1, \
GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED, GIT_PROXY_OPTIONS_INIT, -1, 0 }
GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED, GIT_PROXY_OPTIONS_INIT }
/**
* Initialize git_fetch_options structure
......
......@@ -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)
......
......@@ -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.
......
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