Commit 32332fccc9f1e316bcecf3ab5133331315e31871

Carlos Martín Nieto 2014-05-19T14:15:40

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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/src/clone.c b/src/clone.c
index c627edb..24f1cae 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;
 }