Skip to content

Commit 65e25ae

Browse files
committed
Merge branch 'jc/branch-in-use-error-message'
"git branch -f X" to repoint the branch X said that X was "checked out" in another worktree, even when branch X was not and instead being bisected or rebased. The message was reworded to say the branch was "in use". * jc/branch-in-use-error-message: branch: update the message to refuse touching a branch in-use
2 parents f4a7c24 + 4970bed commit 65e25ae

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ int validate_new_branchname(const char *name, struct strbuf *ref, int force)
471471

472472
if ((path = branch_checked_out(ref->buf)))
473473
die(_("cannot force update the branch '%s' "
474-
"checked out at '%s'"),
474+
"used by worktree at '%s'"),
475475
ref->buf + strlen("refs/heads/"), path);
476476

477477
return 1;

t/t2407-worktree-heads.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ test_expect_success !SANITIZE_LEAK 'refuse to overwrite: worktree in bisect' '
5858
git -C wt-4 bisect good wt-1 &&
5959
6060
test_must_fail git branch -f wt-4 HEAD 2>err &&
61-
grep "cannot force update the branch '\''wt-4'\'' checked out at.*wt-4" err
61+
grep "cannot force update the branch '\''wt-4'\'' used by worktree at.*wt-4" err
6262
'
6363

6464
test_expect_success !SANITIZE_LEAK 'refuse to overwrite: worktree in rebase (apply)' '
@@ -68,7 +68,7 @@ test_expect_success !SANITIZE_LEAK 'refuse to overwrite: worktree in rebase (app
6868
test_must_fail git -C wt-2 rebase --apply conflict-2 &&
6969
7070
test_must_fail git branch -f wt-2 HEAD 2>err &&
71-
grep "cannot force update the branch '\''wt-2'\'' checked out at.*wt-2" err
71+
grep "cannot force update the branch '\''wt-2'\'' used by worktree at.*wt-2" err
7272
'
7373

7474
test_expect_success !SANITIZE_LEAK 'refuse to overwrite: worktree in rebase (merge)' '
@@ -78,7 +78,7 @@ test_expect_success !SANITIZE_LEAK 'refuse to overwrite: worktree in rebase (mer
7878
test_must_fail git -C wt-2 rebase conflict-2 &&
7979
8080
test_must_fail git branch -f wt-2 HEAD 2>err &&
81-
grep "cannot force update the branch '\''wt-2'\'' checked out at.*wt-2" err
81+
grep "cannot force update the branch '\''wt-2'\'' used by worktree at.*wt-2" err
8282
'
8383

8484
test_expect_success !SANITIZE_LEAK 'refuse to overwrite: worktree in rebase with --update-refs' '
@@ -90,7 +90,7 @@ test_expect_success !SANITIZE_LEAK 'refuse to overwrite: worktree in rebase with
9090
for i in 3 4
9191
do
9292
test_must_fail git branch -f can-be-updated HEAD 2>err &&
93-
grep "cannot force update the branch '\''can-be-updated'\'' checked out at.*wt-3" err ||
93+
grep "cannot force update the branch '\''can-be-updated'\'' used by worktree at.*wt-3" err ||
9494
return 1
9595
done
9696
'
@@ -150,7 +150,7 @@ test_expect_success 'refuse to overwrite when in error states' '
150150
for i in 1 2
151151
do
152152
test_must_fail git branch -f fake-$i HEAD 2>err &&
153-
grep "cannot force update the branch '\''fake-$i'\'' checked out at" err ||
153+
grep "cannot force update the branch '\''fake-$i'\'' used by worktree at" err ||
154154
return 1
155155
done
156156
'

0 commit comments

Comments
 (0)