@@ -677,8 +677,8 @@ static int reference__rename(git_reference **out, git_reference *ref, const char
677
677
{
678
678
git_repository * repo ;
679
679
git_refname_t normalized ;
680
- bool should_head_be_updated = false;
681
680
int error = 0 ;
681
+ rename_cb_data payload ;
682
682
683
683
assert (ref && new_name && signature );
684
684
@@ -688,27 +688,13 @@ static int reference__rename(git_reference **out, git_reference *ref, const char
688
688
normalized , repo , new_name , true)) < 0 )
689
689
return error ;
690
690
691
- /* Check if we have to update HEAD. */
692
- if ((error = git_branch_is_head (ref )) < 0 )
693
- return error ;
694
-
695
- should_head_be_updated = (error > 0 );
696
-
697
691
if ((error = git_refdb_rename (out , ref -> db , ref -> name , normalized , force , signature , message )) < 0 )
698
692
return error ;
699
693
700
- /* Update HEAD if it was pointing to the reference being renamed */
701
- if (should_head_be_updated ) {
702
- error = git_repository_set_head (ref -> db -> repo , normalized );
703
- } else {
704
- rename_cb_data payload ;
705
- payload .old_name = ref -> name ;
706
- memcpy (& payload .new_name , & normalized , sizeof (normalized ));
694
+ payload .old_name = ref -> name ;
695
+ memcpy (& payload .new_name , & normalized , sizeof (normalized ));
707
696
708
- error = git_repository_foreach_head (repo , update_wt_heads , & payload );
709
- }
710
-
711
- return error ;
697
+ return git_repository_foreach_head (repo , update_wt_heads , & payload );
712
698
}
713
699
714
700
0 commit comments