Skip to content

Commit

Permalink
clone: don't error out if the branch already exists
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
carlosmn committed May 19, 2014
1 parent 3c60768 commit 32332fc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 32332fc

Please sign in to comment.