diff --git a/src/refs.c b/src/refs.c index 9dc422e1b..1d73b2677 100644 --- a/src/refs.c +++ b/src/refs.c @@ -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. */ diff --git a/tests-clar/refs/rename.c b/tests-clar/refs/rename.c index 4b917ef6d..19bf875cd 100644 --- a/tests-clar/refs/rename.c +++ b/tests-clar/refs/rename.c @@ -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); +}