Skip to content

Commit 32332fc

Browse files
committed
clone: don't error out if the branch already exists
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.
1 parent 3c60768 commit 32332fc

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/clone.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ static int update_head_to_new_branch(
171171

172172
git_reference_free(tracking_branch);
173173

174+
/* if it already existed, then the user's refspec created it for us, ignore it' */
175+
if (error == GIT_EEXISTS)
176+
error = 0;
177+
174178
return error;
175179
}
176180

0 commit comments

Comments
 (0)