diff options
| author | yuangli <yuangli@mathworks.com> | 2022-08-02 13:15:22 +0100 |
|---|---|---|
| committer | yuangli <yuangli@mathworks.com> | 2022-08-02 13:15:22 +0100 |
| commit | 2d33fe78858354c508afb77d80f32a5a747b801e (patch) | |
| tree | 1391d47cfcf0f5798ab8705841db47680858a342 /src/libgit2 | |
| parent | e7294e870398d72b79a436b628170ffcaaa1713c (diff) | |
| download | libgit2-2d33fe78858354c508afb77d80f32a5a747b801e.tar.gz | |
refactor git_fetch_option.depth and usage
Diffstat (limited to 'src/libgit2')
| -rw-r--r-- | src/libgit2/clone.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libgit2/clone.c b/src/libgit2/clone.c index ee1f2b892..95bddeae6 100644 --- a/src/libgit2/clone.c +++ b/src/libgit2/clone.c @@ -389,6 +389,11 @@ static int checkout_branch(git_repository *repo, git_remote *remote, const git_c return error; } +static int git_fetch_is_shallow(git_fetch_options *opts) +{ + return opts->depth > 0; +} + static int clone_into(git_repository *repo, git_remote *_remote, const git_fetch_options *opts, const git_checkout_options *co_opts, const char *branch) { int error; @@ -409,8 +414,10 @@ static int clone_into(git_repository *repo, git_remote *_remote, const git_fetch memcpy(&fetch_opts, opts, sizeof(git_fetch_options)); fetch_opts.update_fetchhead = 0; - if (fetch_opts.depth == -1) + + if (!git_fetch_is_shallow(opts)) fetch_opts.download_tags = GIT_REMOTE_DOWNLOAD_TAGS_ALL; + git_str_printf(&reflog_message, "clone: from %s", git_remote_url(remote)); if ((error = git_remote_fetch(remote, NULL, &fetch_opts, git_str_cstr(&reflog_message))) != 0) |
