diff options
author | Junio C Hamano <gitster@pobox.com> | 2023-08-04 17:52:31 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-08-04 17:52:31 (GMT) |
commit | 65e25ae52298e9f1a8c7d94fd0ddffaf30cd944e (patch) | |
tree | 9cda3a2b3cec16652c2de790ca2ec431e13c42a2 | |
parent | f4a7c24c094cff87a4b5a02550b321591d847ca0 (diff) | |
parent | 4970bedef2e077f78baac5c6e825d17786be735b (diff) | |
download | git-65e25ae52298e9f1a8c7d94fd0ddffaf30cd944e.zip git-65e25ae52298e9f1a8c7d94fd0ddffaf30cd944e.tar.gz git-65e25ae52298e9f1a8c7d94fd0ddffaf30cd944e.tar.bz2 |
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
-rw-r--r-- | branch.c | 2 | ||||
-rwxr-xr-x | t/t2407-worktree-heads.sh | 10 |
2 files changed, 6 insertions, 6 deletions
@@ -471,7 +471,7 @@ int validate_new_branchname(const char *name, struct strbuf *ref, int force) if ((path = branch_checked_out(ref->buf))) die(_("cannot force update the branch '%s' " - "checked out at '%s'"), + "used by worktree at '%s'"), ref->buf + strlen("refs/heads/"), path); return 1; diff --git a/t/t2407-worktree-heads.sh b/t/t2407-worktree-heads.sh index 019a40d..469443d 100755 --- a/t/t2407-worktree-heads.sh +++ b/t/t2407-worktree-heads.sh @@ -58,7 +58,7 @@ test_expect_success !SANITIZE_LEAK 'refuse to overwrite: worktree in bisect' ' git -C wt-4 bisect good wt-1 && test_must_fail git branch -f wt-4 HEAD 2>err && - grep "cannot force update the branch '\''wt-4'\'' checked out at.*wt-4" err + grep "cannot force update the branch '\''wt-4'\'' used by worktree at.*wt-4" err ' 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 test_must_fail git -C wt-2 rebase --apply conflict-2 && test_must_fail git branch -f wt-2 HEAD 2>err && - grep "cannot force update the branch '\''wt-2'\'' checked out at.*wt-2" err + grep "cannot force update the branch '\''wt-2'\'' used by worktree at.*wt-2" err ' 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 test_must_fail git -C wt-2 rebase conflict-2 && test_must_fail git branch -f wt-2 HEAD 2>err && - grep "cannot force update the branch '\''wt-2'\'' checked out at.*wt-2" err + grep "cannot force update the branch '\''wt-2'\'' used by worktree at.*wt-2" err ' 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 for i in 3 4 do test_must_fail git branch -f can-be-updated HEAD 2>err && - grep "cannot force update the branch '\''can-be-updated'\'' checked out at.*wt-3" err || + grep "cannot force update the branch '\''can-be-updated'\'' used by worktree at.*wt-3" err || return 1 done ' @@ -150,7 +150,7 @@ test_expect_success 'refuse to overwrite when in error states' ' for i in 1 2 do test_must_fail git branch -f fake-$i HEAD 2>err && - grep "cannot force update the branch '\''fake-$i'\'' checked out at" err || + grep "cannot force update the branch '\''fake-$i'\'' used by worktree at" err || return 1 done ' |