Skip to content

Commit e5cd238

Browse files
committed
refs: updating HEAD is done by the refdb now
1 parent 7ce6f4a commit e5cd238

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

src/refs.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,8 @@ static int reference__rename(git_reference **out, git_reference *ref, const char
677677
{
678678
git_repository *repo;
679679
git_refname_t normalized;
680-
bool should_head_be_updated = false;
681680
int error = 0;
681+
rename_cb_data payload;
682682

683683
assert(ref && new_name && signature);
684684

@@ -688,27 +688,13 @@ static int reference__rename(git_reference **out, git_reference *ref, const char
688688
normalized, repo, new_name, true)) < 0)
689689
return error;
690690

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-
697691
if ((error = git_refdb_rename(out, ref->db, ref->name, normalized, force, signature, message)) < 0)
698692
return error;
699693

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));
707696

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);
712698
}
713699

714700

0 commit comments

Comments
 (0)