summaryrefslogtreecommitdiff
path: root/src/clone.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-05-19 14:15:40 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2014-05-19 14:24:43 +0200
commit32332fccc9f1e316bcecf3ab5133331315e31871 (patch)
tree2a67ac98614cc5ff3889be8d7ae31375aecebb98 /src/clone.c
parent3c607685da2cf9a22559f53fd7670e1c4cad45e4 (diff)
downloadlibgit2-32332fccc9f1e316bcecf3ab5133331315e31871.tar.gz
clone: don't error out if the branch already existscmn/clone-into-mirror
We set up the current branch after we fetch from the remote. This means that the user's refspec may have already created this reference. It is therefore not an error if we cannot create the branch because it already exists. This allows for the user to replicate git-clone's --mirror option.
Diffstat (limited to 'src/clone.c')
-rw-r--r--src/clone.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/clone.c b/src/clone.c
index c627edbc0..24f1cae59 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -171,6 +171,10 @@ static int update_head_to_new_branch(
git_reference_free(tracking_branch);
+ /* if it already existed, then the user's refspec created it for us, ignore it' */
+ if (error == GIT_EEXISTS)
+ error = 0;
+
return error;
}