remote: move the tagopt setting to the fetch options · nodegit/libgit2@35a8a8c · GitHub
Skip to content

Commit 35a8a8c

Browse files
committed
remote: move the tagopt setting to the fetch options
This is another option which we should not be keeping in the remote, but is specific to each particular operation.
1 parent 3eff2a5 commit 35a8a8c

8 files changed

Lines changed: 136 additions & 94 deletions

File tree

‎include/git2/remote.h‎

Lines changed: 45 additions & 18 deletions

‎src/fetch.c‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
#include "repository.h"
2020
#include "refs.h"
2121

22-
static int maybe_want(git_remote *remote, git_remote_head *head, git_odb *odb, git_refspec *tagspec)
22+
static int maybe_want(git_remote *remote, git_remote_head *head, git_odb *odb, git_refspec *tagspec, git_remote_autotag_option_t tagopt)
2323
{
2424
int match = 0;
2525

2626
if (!git_reference_is_valid_name(head->name))
2727
return 0;
2828

29-
if (remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
29+
if (tagopt == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
3030
/*
3131
* If tagopt is --tags, always request tags
3232
* in addition to the remote's refspecs
@@ -51,13 +51,17 @@ static int maybe_want(git_remote *remote, git_remote_head *head, git_odb *odb, g
5151
return git_vector_insert(&remote->refs, head);
5252
}
5353

54-
static int filter_wants(git_remote *remote)
54+
static int filter_wants(git_remote *remote, const git_fetch_options *opts)
5555
{
5656
git_remote_head **heads;
5757
git_refspec tagspec, head;
5858
int error = 0;
5959
git_odb *odb;
6060
size_t i, heads_len;
61+
git_remote_autotag_option_t tagopt = remote->download_tags;
62+
63+
if (opts && opts->download_tags != GIT_REMOTE_DOWNLOAD_TAGS_FALLBACK)
64+
tagopt = opts->download_tags;
6165

6266
git_vector_clear(&remote->refs);
6367
if ((error = git_refspec__parse(&tagspec, GIT_REFSPEC_TAGS, true)) < 0)
@@ -87,7 +91,7 @@ static int filter_wants(git_remote *remote)
8791
goto cleanup;
8892

8993
for (i = 0; i < heads_len; i++) {
90-
if ((error = maybe_want(remote, heads[i], odb, &tagspec)) < 0)
94+
if ((error = maybe_want(remote, heads[i], odb, &tagspec, tagopt)) < 0)
9195
break;
9296
}
9397

@@ -102,13 +106,13 @@ static int filter_wants(git_remote *remote)
102106
* them out. When we get an ACK we hide that commit and continue
103107
* traversing until we're done
104108
*/
105-
int git_fetch_negotiate(git_remote *remote)
109+
int git_fetch_negotiate(git_remote *remote, const git_fetch_options *opts)
106110
{
107111
git_transport *t = remote->transport;
108112

109-
remote->need_pack = 0;
113+
remote->need_pack = 0;
110114

111-
if (filter_wants(remote) < 0) {
115+
if (filter_wants(remote, opts) < 0) {
112116
giterr_set(GITERR_NET, "Failed to filter the reference list for wants");
113117
return -1;
114118
}

‎src/fetch.h‎

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)