mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-06 13:25:18 +00:00
Do not write tagopt configuration option on clone by default
This commit is contained in:
parent
dfec726bba
commit
6f748f3885
56
src/clone.c
56
src/clone.c
@ -358,31 +358,41 @@ static int setup_remotes_and_fetch(
|
|||||||
git_remote *origin;
|
git_remote *origin;
|
||||||
|
|
||||||
/* Construct an origin remote */
|
/* Construct an origin remote */
|
||||||
if (!create_and_configure_origin(&origin, repo, url, options)) {
|
if ((retcode = create_and_configure_origin(&origin, repo, url, options)) < 0)
|
||||||
|
goto on_error;
|
||||||
|
|
||||||
git_remote_set_update_fetchhead(origin, 0);
|
git_remote_set_update_fetchhead(origin, 0);
|
||||||
|
|
||||||
/* Connect and download everything */
|
/* If the download_tags value has not been specified, then make sure to
|
||||||
if (!git_remote_connect(origin, GIT_DIRECTION_FETCH)) {
|
* download tags as well. It is set here because we want to download tags
|
||||||
if (!(retcode = git_remote_download(origin, options->fetch_progress_cb,
|
* on the initial clone, but do not want to persist the value in the
|
||||||
options->fetch_progress_payload))) {
|
* configuration file.
|
||||||
/* Create "origin/foo" branches for all remote branches */
|
*/
|
||||||
if (!git_remote_update_tips(origin)) {
|
if (origin->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_AUTO &&
|
||||||
/* Point HEAD to the requested branch */
|
((retcode = git_remote_add_fetch(origin, "refs/tags/*:refs/tags/*")) < 0))
|
||||||
if (options->checkout_branch) {
|
goto on_error;
|
||||||
if (!update_head_to_branch(repo, options))
|
|
||||||
retcode = 0;
|
|
||||||
}
|
|
||||||
/* Point HEAD to the same ref as the remote's head */
|
|
||||||
else if (!update_head_to_remote(repo, origin)) {
|
|
||||||
retcode = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
git_remote_disconnect(origin);
|
|
||||||
}
|
|
||||||
git_remote_free(origin);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/* Connect and download everything */
|
||||||
|
if ((retcode = git_remote_connect(origin, GIT_DIRECTION_FETCH)) < 0)
|
||||||
|
goto on_error;
|
||||||
|
|
||||||
|
if ((retcode = git_remote_download(origin, options->fetch_progress_cb,
|
||||||
|
options->fetch_progress_payload)) < 0)
|
||||||
|
goto on_error;
|
||||||
|
|
||||||
|
/* Create "origin/foo" branches for all remote branches */
|
||||||
|
if ((retcode = git_remote_update_tips(origin)) < 0)
|
||||||
|
goto on_error;
|
||||||
|
|
||||||
|
/* Point HEAD to the requested branch */
|
||||||
|
if (options->checkout_branch)
|
||||||
|
retcode = update_head_to_branch(repo, options);
|
||||||
|
/* Point HEAD to the same ref as the remote's head */
|
||||||
|
else
|
||||||
|
retcode = update_head_to_remote(repo, origin);
|
||||||
|
|
||||||
|
on_error:
|
||||||
|
git_remote_free(origin);
|
||||||
return retcode;
|
return retcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,7 +435,7 @@ static void normalize_options(git_clone_options *dst, const git_clone_options *s
|
|||||||
|
|
||||||
/* Provide defaults for null pointers */
|
/* Provide defaults for null pointers */
|
||||||
if (!dst->remote_name) dst->remote_name = "origin";
|
if (!dst->remote_name) dst->remote_name = "origin";
|
||||||
if (!dst->remote_autotag) dst->remote_autotag = GIT_REMOTE_DOWNLOAD_TAGS_ALL;
|
if (!dst->remote_autotag) dst->remote_autotag = GIT_REMOTE_DOWNLOAD_TAGS_AUTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
int git_clone(
|
int git_clone(
|
||||||
|
@ -172,6 +172,7 @@ void test_clone_nonetwork__custom_push_spec(void)
|
|||||||
|
|
||||||
void test_clone_nonetwork__custom_autotag(void)
|
void test_clone_nonetwork__custom_autotag(void)
|
||||||
{
|
{
|
||||||
|
git_remote *origin;
|
||||||
git_strarray tags = {0};
|
git_strarray tags = {0};
|
||||||
|
|
||||||
g_options.remote_autotag = GIT_REMOTE_DOWNLOAD_TAGS_NONE;
|
g_options.remote_autotag = GIT_REMOTE_DOWNLOAD_TAGS_NONE;
|
||||||
@ -180,6 +181,23 @@ void test_clone_nonetwork__custom_autotag(void)
|
|||||||
cl_git_pass(git_tag_list(&tags, g_repo));
|
cl_git_pass(git_tag_list(&tags, g_repo));
|
||||||
cl_assert_equal_sz(0, tags.count);
|
cl_assert_equal_sz(0, tags.count);
|
||||||
|
|
||||||
|
cl_git_pass(git_remote_load(&origin, g_repo, "origin"));
|
||||||
|
cl_assert_equal_i(GIT_REMOTE_DOWNLOAD_TAGS_NONE, origin->download_tags);
|
||||||
|
|
||||||
|
git_strarray_free(&tags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_clone_nonetwork__custom_autotag_tags_all(void)
|
||||||
|
{
|
||||||
|
git_strarray tags = {0};
|
||||||
|
git_remote *origin;
|
||||||
|
|
||||||
|
g_options.remote_autotag = GIT_REMOTE_DOWNLOAD_TAGS_ALL;
|
||||||
|
cl_git_pass(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", &g_options));
|
||||||
|
|
||||||
|
cl_git_pass(git_remote_load(&origin, g_repo, "origin"));
|
||||||
|
cl_assert_equal_i(GIT_REMOTE_DOWNLOAD_TAGS_ALL, origin->download_tags);
|
||||||
|
|
||||||
git_strarray_free(&tags);
|
git_strarray_free(&tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "git2/clone.h"
|
#include "git2/clone.h"
|
||||||
#include "git2/cred_helpers.h"
|
#include "git2/cred_helpers.h"
|
||||||
#include "repository.h"
|
#include "repository.h"
|
||||||
|
#include "remote.h"
|
||||||
|
|
||||||
#define LIVE_REPO_URL "http://github.com/libgit2/TestGitRepository"
|
#define LIVE_REPO_URL "http://github.com/libgit2/TestGitRepository"
|
||||||
#define LIVE_EMPTYREPO_URL "http://github.com/libgit2/TestEmptyRepository"
|
#define LIVE_EMPTYREPO_URL "http://github.com/libgit2/TestEmptyRepository"
|
||||||
@ -42,6 +43,8 @@ void test_online_clone__network_full(void)
|
|||||||
cl_assert(!git_repository_is_bare(g_repo));
|
cl_assert(!git_repository_is_bare(g_repo));
|
||||||
cl_git_pass(git_remote_load(&origin, g_repo, "origin"));
|
cl_git_pass(git_remote_load(&origin, g_repo, "origin"));
|
||||||
|
|
||||||
|
cl_assert_equal_i(GIT_REMOTE_DOWNLOAD_TAGS_AUTO, origin->download_tags);
|
||||||
|
|
||||||
git_remote_free(origin);
|
git_remote_free(origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user