Commit 6f748f38 by Jameson Miller

Do not write tagopt configuration option on clone by default

parent dfec726b
...@@ -358,31 +358,41 @@ static int setup_remotes_and_fetch( ...@@ -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)
git_remote_set_update_fetchhead(origin, 0); goto on_error;
/* Connect and download everything */ git_remote_set_update_fetchhead(origin, 0);
if (!git_remote_connect(origin, GIT_DIRECTION_FETCH)) {
if (!(retcode = git_remote_download(origin, options->fetch_progress_cb, /* If the download_tags value has not been specified, then make sure to
options->fetch_progress_payload))) { * download tags as well. It is set here because we want to download tags
/* Create "origin/foo" branches for all remote branches */ * on the initial clone, but do not want to persist the value in the
if (!git_remote_update_tips(origin)) { * configuration file.
/* Point HEAD to the requested branch */ */
if (options->checkout_branch) { if (origin->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_AUTO &&
if (!update_head_to_branch(repo, options)) ((retcode = git_remote_add_fetch(origin, "refs/tags/*:refs/tags/*")) < 0))
retcode = 0; goto on_error;
}
/* Point HEAD to the same ref as the remote's head */ /* Connect and download everything */
else if (!update_head_to_remote(repo, origin)) { if ((retcode = git_remote_connect(origin, GIT_DIRECTION_FETCH)) < 0)
retcode = 0; goto on_error;
}
}
}
git_remote_disconnect(origin);
}
git_remote_free(origin);
}
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 ...@@ -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) ...@@ -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) ...@@ -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 @@ ...@@ -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) ...@@ -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);
} }
......
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