Commit e2d42622 by nulltoken Committed by Vicent Marti

Fix reference renaming to prevent duplicated names

parent de05ff6c
......@@ -1124,9 +1124,19 @@ int git_reference_rename(git_reference *ref, const char *new_name)
int error;
char *old_name;
char old_path[GIT_PATH_MAX], new_path[GIT_PATH_MAX];
git_reference *looked_up_ref;
assert(ref);
/* Ensure we're not going to overwrite an existing reference */
error = git_repository_lookup_ref(&looked_up_ref, ref->owner, new_name);
if (error == GIT_SUCCESS)
return GIT_EINVALIDREFNAME;
if (error != GIT_ENOTFOUND)
return error;
old_name = ref->name;
ref->name = git__strdup(new_name);
......
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