Merge branch 'rj/branch-in-use-error-message'
A message written in olden time prevented a branch from getting checked out saying it is already checked out elsewhere, but these days, we treat a branch that is being bisected or rebased just like a branch that is checked out and protect it. Rephrase the message to say that the branch is in use. * rj/branch-in-use-error-message: branch: error message checking out a branch in use branch: error message deleting a branch in use
This commit is contained in:
2
branch.c
2
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)) {
|
if (is_shared_symref(worktrees[i], "HEAD", branch)) {
|
||||||
skip_prefix(branch, "refs/heads/", &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);
|
branch, worktrees[i]->path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
|
|||||||
const char *path;
|
const char *path;
|
||||||
if ((path = branch_checked_out(name))) {
|
if ((path = branch_checked_out(name))) {
|
||||||
error(_("Cannot delete branch '%s' "
|
error(_("Cannot delete branch '%s' "
|
||||||
"checked out at '%s'"),
|
"used by worktree at '%s'"),
|
||||||
bname.buf, path);
|
bname.buf, path);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
continue;
|
continue;
|
||||||
|
@ -121,7 +121,8 @@ test_expect_success '"add" worktree creating new branch' '
|
|||||||
test_expect_success 'die the same branch is already checked out' '
|
test_expect_success 'die the same branch is already checked out' '
|
||||||
(
|
(
|
||||||
cd here &&
|
cd here &&
|
||||||
test_must_fail git checkout newmain
|
test_must_fail git checkout newmain 2>actual &&
|
||||||
|
grep "already used by worktree at" actual
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -942,7 +942,19 @@ test_expect_success 'test deleting branch without config' '
|
|||||||
test_expect_success 'deleting currently checked out branch fails' '
|
test_expect_success 'deleting currently checked out branch fails' '
|
||||||
git worktree add -b my7 my7 &&
|
git worktree add -b my7 my7 &&
|
||||||
test_must_fail git -C my7 branch -d my7 &&
|
test_must_fail git -C my7 branch -d my7 &&
|
||||||
test_must_fail git branch -d my7 &&
|
test_must_fail git branch -d my7 2>actual &&
|
||||||
|
grep "^error: Cannot delete branch .my7. used by worktree at " actual &&
|
||||||
|
rm -r my7 &&
|
||||||
|
git worktree prune
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'deleting in-use branch fails' '
|
||||||
|
git worktree add my7 &&
|
||||||
|
test_commit -C my7 bt7 &&
|
||||||
|
git -C my7 bisect start HEAD HEAD~2 &&
|
||||||
|
test_must_fail git -C my7 branch -d my7 &&
|
||||||
|
test_must_fail git branch -d my7 2>actual &&
|
||||||
|
grep "^error: Cannot delete branch .my7. used by worktree at " actual &&
|
||||||
rm -r my7 &&
|
rm -r my7 &&
|
||||||
git worktree prune
|
git worktree prune
|
||||||
'
|
'
|
||||||
|
@ -421,7 +421,7 @@ test_expect_success 'refuse to switch to branch checked out elsewhere' '
|
|||||||
git checkout main &&
|
git checkout main &&
|
||||||
git worktree add wt &&
|
git worktree add wt &&
|
||||||
test_must_fail git -C wt rebase main main 2>err &&
|
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' '
|
test_expect_success MINGW,SYMLINKS_WINDOWS 'rebase when .git/logs is a symlink' '
|
||||||
|
Reference in New Issue
Block a user