rename: don't return early if the target ref exists

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
This commit is contained in:
Carlos Martín Nieto 2011-03-29 10:47:48 +02:00 committed by Vicent Marti
parent 591a9423f5
commit dad4a4d582

View File

@ -1050,12 +1050,14 @@ int git_reference_rename_internal(git_reference *ref, const char *new_name, int
if (error < GIT_SUCCESS)
return error;
/* Ensure we're not going to overwrite an existing reference */
/* Ensure we're not going to overwrite an existing reference
unless the user has allowed us */
error = git_reference_lookup(&looked_up_ref, ref->owner, new_name);
if (error == GIT_SUCCESS && !force)
return GIT_EEXISTS;
if (error != GIT_ENOTFOUND)
if (error < GIT_SUCCESS &&
error != GIT_ENOTFOUND)
return error;