mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-07 16:22:40 +00:00
Fix reference renaming to prevent duplicated names
This commit is contained in:
parent
de05ff6c78
commit
e2d426227f
10
src/refs.c
10
src/refs.c
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user