Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2013-10-30 16:44:22 +0400
committerCarlos Martín Nieto <cmn@dwim.me>2013-11-11 01:21:25 +0400
commit266af6d81960144334c16e061f1d30f94f8a1b46 (patch)
tree6b24f1f135c6931dae8a87621e618eaf3ad37d76 /src/clone.c
parentaf613ecd445bf0abfda81769e7a2d763413dfd04 (diff)
remote: don't allow such direct access to the refspecs
Removing arbitrary refspecs makes things more complex to reason about. Instead, let the user set the fetch and push refspec list to whatever they want it to be.
Diffstat (limited to 'src/clone.c')
-rw-r--r--src/clone.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/clone.c b/src/clone.c
index 657243945..f9338b746 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -349,7 +349,7 @@ static bool should_checkout(
int git_clone_into(git_repository *repo, git_remote *remote, const git_checkout_opts *co_opts, const char *branch)
{
int error = 0, old_fetchhead;
- size_t nspecs;
+ git_strarray refspecs;
assert(repo && remote);
@@ -358,6 +358,10 @@ int git_clone_into(git_repository *repo, git_remote *remote, const git_checkout_
return -1;
}
+
+ if ((error = git_remote_get_fetch_refspecs(&refspecs, remote)) < 0)
+ return error;
+
if ((error = git_remote_add_fetch(remote, "refs/tags/*:refs/tags/*")) < 0)
return error;
@@ -378,9 +382,13 @@ int git_clone_into(git_repository *repo, git_remote *remote, const git_checkout_
cleanup:
git_remote_set_update_fetchhead(remote, old_fetchhead);
- /* Remove the tags refspec */
- nspecs = git_remote_refspec_count(remote);
- git_remote_remove_refspec(remote, nspecs);
+ /* Go back to the original refspecs */
+ if (git_remote_set_fetch_refspecs(remote, &refspecs) < 0) {
+ git_strarray_free(&refspecs);
+ return -1;
+ }
+
+ git_strarray_free(&refspecs);
return error;
}