Skip to content

Commit 3521c63

Browse files
rjustogitster
authored andcommitted
branch: avoid unnecessary worktrees traversals
When we rename a branch ref, we need to update any worktree that have its HEAD pointing to the branch ref being renamed, so to make it use the new ref name. If we know in advance that we're renaming a branch that is not currently checked out in any worktree, we can skip this step entirely. Let's do it so. Signed-off-by: Rubén Justo <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a675ad1 commit 3521c63

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int
617617
interpreted_oldname);
618618
}
619619

620-
if (!copy &&
620+
if (!copy && (oldref_usage & IS_HEAD) &&
621621
replace_each_worktree_head_symref(worktrees, oldref.buf, newref.buf,
622622
logmsg.buf))
623623
die(_("Branch renamed to %s, but HEAD is not updated!"), newname);

0 commit comments

Comments
 (0)