mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-09 15:00:04 +00:00
Merge pull request #2673 from swisspol/2672
Fixed GIT_REMOTE_DOWNLOAD_TAGS_ALL to behave like git 1.9.0+
This commit is contained in:
commit
4865cc3f06
@ -118,3 +118,7 @@ v0.21 + 1
|
|||||||
|
|
||||||
* git_status_file now takes an exact path. Use git_status_list_new if
|
* git_status_file now takes an exact path. Use git_status_list_new if
|
||||||
pathspec searching is needed.
|
pathspec searching is needed.
|
||||||
|
|
||||||
|
* The fetch behavior of remotes with autotag set to GIT_REMOTE_DOWNLOAD_TAGS_ALL
|
||||||
|
has been changed to match git 1.9.0 and later. In this mode, libgit2 now
|
||||||
|
fetches all tags in addition to whatever else needs to be fetched.
|
||||||
|
12
src/fetch.c
12
src/fetch.c
@ -28,15 +28,15 @@ static int maybe_want(git_remote *remote, git_remote_head *head, git_odb *odb, g
|
|||||||
|
|
||||||
if (remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
|
if (remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
|
||||||
/*
|
/*
|
||||||
* If tagopt is --tags, then we only use the default
|
* If tagopt is --tags, always request tags
|
||||||
* tags refspec and ignore the remote's
|
* in addition to the remote's refspecs
|
||||||
*/
|
*/
|
||||||
if (git_refspec_src_matches(tagspec, head->name))
|
if (git_refspec_src_matches(tagspec, head->name))
|
||||||
match = 1;
|
match = 1;
|
||||||
else
|
}
|
||||||
return 0;
|
|
||||||
} else if (git_remote__matching_refspec(remote, head->name))
|
if (!match && git_remote__matching_refspec(remote, head->name))
|
||||||
match = 1;
|
match = 1;
|
||||||
|
|
||||||
if (!match)
|
if (!match)
|
||||||
return 0;
|
return 0;
|
||||||
|
26
src/remote.c
26
src/remote.c
@ -1098,24 +1098,26 @@ static int update_tips_for_spec(
|
|||||||
if (!git_reference_is_valid_name(head->name))
|
if (!git_reference_is_valid_name(head->name))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (git_refspec_src_matches(spec, head->name) && spec->dst) {
|
if (git_refspec_src_matches(&tagspec, head->name)) {
|
||||||
if (git_refspec_transform(&refname, spec, head->name) < 0)
|
if (remote->download_tags != GIT_REMOTE_DOWNLOAD_TAGS_NONE) {
|
||||||
goto on_error;
|
|
||||||
} else if (remote->download_tags != GIT_REMOTE_DOWNLOAD_TAGS_NONE) {
|
|
||||||
|
|
||||||
if (remote->download_tags != GIT_REMOTE_DOWNLOAD_TAGS_ALL)
|
if (remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_AUTO)
|
||||||
autotag = 1;
|
autotag = 1;
|
||||||
|
|
||||||
if (!git_refspec_src_matches(&tagspec, head->name))
|
git_buf_clear(&refname);
|
||||||
|
if (git_buf_puts(&refname, head->name) < 0)
|
||||||
|
goto on_error;
|
||||||
|
} else {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
git_buf_clear(&refname);
|
} else if (git_refspec_src_matches(spec, head->name) && spec->dst) {
|
||||||
if (git_buf_puts(&refname, head->name) < 0)
|
if (git_refspec_transform(&refname, spec, head->name) < 0)
|
||||||
goto on_error;
|
goto on_error;
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* In autotag mode, only create tags for objects already in db */
|
||||||
if (autotag && !git_odb_exists(odb, &head->oid))
|
if (autotag && !git_odb_exists(odb, &head->oid))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -1276,8 +1278,8 @@ int git_remote_update_tips(
|
|||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
|
if (remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
|
||||||
error = update_tips_for_spec(remote, &tagspec, &refs, signature, reflog_message);
|
if ((error = update_tips_for_spec(remote, &tagspec, &refs, signature, reflog_message)) < 0)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
git_vector_foreach(&remote->active_refspecs, i, spec) {
|
git_vector_foreach(&remote->active_refspecs, i, spec) {
|
||||||
|
@ -171,7 +171,7 @@ void test_network_remote_local__tagopt(void)
|
|||||||
git_remote_set_autotag(remote, GIT_REMOTE_DOWNLOAD_TAGS_ALL);
|
git_remote_set_autotag(remote, GIT_REMOTE_DOWNLOAD_TAGS_ALL);
|
||||||
cl_git_pass(git_remote_fetch(remote, NULL, NULL, NULL));
|
cl_git_pass(git_remote_fetch(remote, NULL, NULL, NULL));
|
||||||
|
|
||||||
cl_git_fail(git_reference_lookup(&ref, repo, "refs/remotes/tagopt/master"));
|
cl_git_pass(git_reference_lookup(&ref, repo, "refs/remotes/tagopt/master"));
|
||||||
cl_git_pass(git_reference_lookup(&ref, repo, "refs/tags/hard_tag"));
|
cl_git_pass(git_reference_lookup(&ref, repo, "refs/tags/hard_tag"));
|
||||||
git_reference_free(ref);
|
git_reference_free(ref);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user