Commit 73294339 by schu

reference_rename: fix flaw in force-renaming

reference_rename didn't respect the force flag. Fixed.

Reported-by: nulltoken <emeric.fermas@gmail.com>
Signed-off-by: schu <schu-github@schulog.org>
parent 6d4f090d
......@@ -1309,8 +1309,12 @@ int git_reference_rename(git_reference *ref, const char *new_name, int force)
new_name = normalized;
error = git_reference_lookup(&new_ref, ref->owner, new_name);
if (error == GIT_SUCCESS && !force)
return git__throw(GIT_EEXISTS, "Failed to rename reference. Reference already exists");
if (error == GIT_SUCCESS) {
if (!force)
return git__throw(GIT_EEXISTS, "Failed to rename reference. Reference already exists");
error = git_reference_delete(new_ref);
}
if (error < GIT_SUCCESS && error != GIT_ENOTFOUND)
goto cleanup;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment