refs: propagate EEXISTS upon renaming

This commit is contained in:
nulltoken 2012-10-11 14:00:26 +02:00
parent a75770febc
commit 3548fcf562
2 changed files with 13 additions and 2 deletions

View File

@ -1357,8 +1357,8 @@ int git_reference_rename(git_reference *ref, const char *new_name, int force)
normalization_flags) < 0)
return -1;
if (reference_can_write(ref->owner, normalized, ref->name, force) < 0)
return -1;
if ((result = reference_can_write(ref->owner, normalized, ref->name, force)) < 0)
return result;
/* Initialize path now so we won't get an allocation failure once
* we actually start removing things. */

View File

@ -337,3 +337,14 @@ void test_refs_rename__move_up(void)
git_reference_free(ref);
git_reference_free(looked_up_ref);
}
void test_refs_rename__propagate_eexists(void)
{
git_reference *ref;
cl_git_pass(git_reference_lookup(&ref, g_repo, packed_head_name));
cl_assert_equal_i(GIT_EEXISTS, git_reference_rename(ref, packed_test_head_name, 0));
git_reference_free(ref);
}