Commit 64093ce5 by schu

reference_rename: make sure to rollback

Actually rollback when we can't create the new reference. Mark the
rolled back reference as loose.

Signed-off-by: schu <schu-github@schulog.org>
parent bdbdefac
......@@ -1352,7 +1352,7 @@ int git_reference_rename(git_reference *ref, const char *new_name, int force)
}
if (error < GIT_SUCCESS)
goto cleanup;
goto rollback;
/*
* Check if we have to update HEAD.
......@@ -1398,6 +1398,9 @@ rollback:
error = git_reference_create_oid(
NULL, ref->owner, ref->name, &ref->target.oid, 0);
/* The reference is no longer packed */
ref->flags &= ~GIT_REF_PACKED;
return error == GIT_SUCCESS ?
git__rethrow(GIT_ERROR, "Failed to rename reference. Did rollback") :
git__rethrow(error, "Failed to rename reference. Failed to rollback");
......
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