From: "Rubén Justo" <rjusto@gmail.com>
To: Git List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 1/2] branch: error message deleting a branch in use
Date: Mon, 7 Aug 2023 22:42:36 +0200 [thread overview]
Message-ID: <329ecf0a-46a6-84c8-e96f-f92a398063d9@gmail.com> (raw)
In-Reply-To: <7710c002-0832-d8f6-59b8-30119bd5efe6@gmail.com>
Let's update the error message we show when the user tries to delete 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>
---
builtin/branch.c | 2 +-
t/t3200-branch.sh | 14 +++++++++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/builtin/branch.c b/builtin/branch.c
index 08da650516..2ec190b14a 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -261,7 +261,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
const char *path;
if ((path = branch_checked_out(name))) {
error(_("Cannot delete branch '%s' "
- "checked out at '%s'"),
+ "used by worktree at '%s'"),
bname.buf, path);
ret = 1;
continue;
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index daf1666df7..080e4f24a6 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -942,7 +942,19 @@ test_expect_success 'test deleting branch without config' '
test_expect_success 'deleting currently checked out branch fails' '
git worktree add -b my7 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 &&
git worktree prune
'
--
2.42.0.rc0.2.gbb987841e8
next prev parent reply other threads:[~2023-08-07 20:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-07 20:38 [PATCH 0/2] branch: update error messages Rubén Justo
2023-08-07 20:42 ` Rubén Justo [this message]
2023-08-07 20:42 ` [PATCH 2/2] branch: error message checking out a branch in use Rubén Justo
2023-08-07 21:34 ` Taylor Blau
2023-08-07 22:49 ` Rubén Justo
2023-08-07 21:18 ` [PATCH 0/2] branch: update error messages Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=329ecf0a-46a6-84c8-e96f-f92a398063d9@gmail.com \
--to=rjusto@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).