summaryrefslogtreecommitdiff
path: root/src/refs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/refs.c')
-rw-r--r--src/refs.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/refs.c b/src/refs.c
index 3b33a3201..9dc422e1b 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -15,6 +15,7 @@
#include <git2/tag.h>
#include <git2/object.h>
#include <git2/oid.h>
+#include <git2/branch.h>
GIT__USE_STRMAP;
@@ -1345,9 +1346,6 @@ int git_reference_rename(git_reference *ref, const char *new_name, int force)
char normalized[GIT_REFNAME_MAX];
bool should_head_be_updated = false;
- const char *head_target = NULL;
- git_reference *head = NULL;
-
normalization_flags = ref->flags & GIT_REF_SYMBOLIC ?
GIT_REF_FORMAT_ALLOW_ONELEVEL
: GIT_REF_FORMAT_NORMAL;
@@ -1370,12 +1368,9 @@ int git_reference_rename(git_reference *ref, const char *new_name, int force)
/*
* Check if we have to update HEAD.
*/
- if (git_repository_head(&head, ref->owner) < 0)
+ if ((should_head_be_updated = git_branch_is_head(ref)) < 0)
goto cleanup;
- should_head_be_updated = !strcmp(git_reference_name(head), ref->name);
- git_reference_free(head);
-
/*
* Now delete the old ref and remove an possibly existing directory
* named `new_name`. Note that using the internal `reference_delete`