]> git.ipfire.org Git - thirdparty/git.git/commitdiff
branch: error message checking out a branch in use
authorRubén Justo <rjusto@gmail.com>
Mon, 7 Aug 2023 20:42:40 +0000 (22:42 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 9 Aug 2023 01:27:30 +0000 (18:27 -0700)
Let's update the error message we show when the user tries to check out
a branch which is being used in another worktree, following the
guideline reasoned in 4970bedef2 (branch: update the message to refuse
touching a branch in-use, 2023-07-21).

Signed-off-by: Rubén Justo <rjusto@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
branch.c
t/t2400-worktree-add.sh
t/t3400-rebase.sh

index 3e4684f79f693059a6272465dd983e149aee5eb9..06f7af9dd47260d87158ba672f90d2b5c37e558e 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -838,7 +838,7 @@ void die_if_checked_out(const char *branch, int ignore_current_worktree)
 
                if (is_shared_symref(worktrees[i], "HEAD", branch)) {
                        skip_prefix(branch, "refs/heads/", &branch);
-                       die(_("'%s' is already checked out at '%s'"),
+                       die(_("'%s' is already used by worktree at '%s'"),
                                branch, worktrees[i]->path);
                }
        }
index 0ac468e69e904f161abe3c96148a23607315cfac..a2483145fe38353813947602a4f0a5cd3092c61a 100755 (executable)
@@ -121,7 +121,8 @@ test_expect_success '"add" worktree creating new branch' '
 test_expect_success 'die the same branch is already checked out' '
        (
                cd here &&
-               test_must_fail git checkout newmain
+               test_must_fail git checkout newmain 2>actual &&
+               grep "already used by worktree at" actual
        )
 '
 
index 3ce918fdb8062fc5f720bb890ad58a2676547218..d3df19a51f83a9193916c3812d1ca152644b470f 100755 (executable)
@@ -421,7 +421,7 @@ test_expect_success 'refuse to switch to branch checked out elsewhere' '
        git checkout main &&
        git worktree add wt &&
        test_must_fail git -C wt rebase main main 2>err &&
-       test_i18ngrep "already checked out" err
+       test_i18ngrep "already used by worktree at" err
 '
 
 test_expect_success MINGW,SYMLINKS_WINDOWS 'rebase when .git/logs is a symlink' '