Commit 64093ce51879b5f9f6015b94fce095499c14159c

schu 2011-11-21T11:30:14

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>

diff --git a/src/refs.c b/src/refs.c
index 569efbf..d7396f2 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -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");