Commit 76b15cb18a0c153639bf156482e0a0ad57c0c8c8

schu 2011-06-05T20:47:30

Raise GIT_EEXISTS in case of conflicting ref names instead of passing the error returned by the subsystem; clarify error message. Fix tiny typo. Signed-off-by: schu <schu-github@schulog.org>

diff --git a/src/refs.c b/src/refs.c
index 83f2994..a533d6e 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -1084,7 +1084,7 @@ static int reference_available(git_repository *repo, const char *ref, const char
 
 	git_vector_free(&refs);
 
-	return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Reference `%s` already exists", ref);
+	return error == GIT_SUCCESS ? GIT_SUCCESS : git__throw(GIT_EEXISTS, "Reference name `%s` conflicts with existing reference", ref);
 }
 
 /*
@@ -1124,7 +1124,7 @@ static int reference_rename(git_reference *ref, const char *new_name, int force)
 	    error != GIT_ENOTFOUND)
 		return git__rethrow(error, "Failed to rename reference");
 
-	if ((error == reference_available(ref->owner, new_name, ref->name)) < GIT_SUCCESS)
+	if ((error = reference_available(ref->owner, new_name, ref->name)) < GIT_SUCCESS)
 		return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to rename reference. Reference already exists");
 
 	old_name = ref->name;