{"thread":{"id":"60078","subject":"[PATCH 0/2] branch: update error messages","startedAt":"2023-08-07T20:40:23Z","lastAt":"2023-08-07T22:49:16Z","messageCount":6,"participants":["Rubén Justo","Junio C Hamano","Taylor Blau"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"480257","messageId":"7710c002-0832-d8f6-59b8-30119bd5efe6@gmail.com","threadId":"60078","inReplyTo":null,"subject":"[PATCH 0/2] branch: update error messages","fromName":"Rubén Justo","fromEmail":"rjusto@gmail.com","sentAt":"2023-08-07T20:38:38Z","receivedAt":"2023-08-07T20:40:23Z","isPatch":true,"sender":{"key":"rjusto@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5685487?v=4"},"body":"A message like \"branch 'frog' checked out at ...\" may be confusing to\nthe user if the branch 'frog' is not the currently checked out branch,\nwhich may occur while rebasing, bisecting or other operations.\n\nLet's reword those messages as it has been done in 4970bedef2 (branch:\nupdate the message to refuse touching a branch in-use, 2023-07-21).\n\nRubén Justo (2):\n  branch: error message deleting a branch in use\n  branch: error message checking out a branch in use\n\n branch.c                |  2 +-\n builtin/branch.c        |  2 +-\n t/t2400-worktree-add.sh |  3 ++-\n t/t3200-branch.sh       | 14 +++++++++++++-\n t/t3400-rebase.sh       |  2 +-\n 5 files changed, 18 insertions(+), 5 deletions(-)\n\n-- \n2.42.0.rc0.2.gbb987841e8\n\n"},{"id":"480258","messageId":"329ecf0a-46a6-84c8-e96f-f92a398063d9@gmail.com","threadId":"60078","inReplyTo":"7710c002-0832-d8f6-59b8-30119bd5efe6@gmail.com","subject":"[PATCH 1/2] branch: error message deleting a branch in use","fromName":"Rubén Justo","fromEmail":"rjusto@gmail.com","sentAt":"2023-08-07T20:42:36Z","receivedAt":"2023-08-07T20:42:47Z","isPatch":true,"sender":{"key":"rjusto@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5685487?v=4"},"body":"Let's update the error message we show when the user tries to delete a\nbranch which is being used in another worktree, following the guideline\nreasoned in 4970bedef2 (branch: update the message to refuse touching a\nbranch in-use, 2023-07-21).\n\nSigned-off-by: Rubén Justo <rjusto@gmail.com>\n---\n builtin/branch.c  |  2 +-\n t/t3200-branch.sh | 14 +++++++++++++-\n 2 files changed, 14 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 08da650516..2ec190b14a 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -261,7 +261,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,\n \t\t\tconst char *path;\n \t\t\tif ((path = branch_checked_out(name))) {\n \t\t\t\terror(_(\"Cannot delete branch '%s' \"\n-\t\t\t\t\t\"checked out at '%s'\"),\n+\t\t\t\t\t\"used by worktree at '%s'\"),\n \t\t\t\t      bname.buf, path);\n \t\t\t\tret = 1;\n \t\t\t\tcontinue;\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex daf1666df7..080e4f24a6 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -942,7 +942,19 @@ test_expect_success 'test deleting branch without config' '\n test_expect_success 'deleting currently checked out branch fails' '\n \tgit worktree add -b my7 my7 &&\n \ttest_must_fail git -C my7 branch -d my7 &&\n-\ttest_must_fail git branch -d my7 &&\n+\ttest_must_fail git branch -d my7 2>actual &&\n+\tgrep \"^error: Cannot delete branch .my7. used by worktree at \" actual &&\n+\trm -r my7 &&\n+\tgit worktree prune\n+'\n+\n+test_expect_success 'deleting in-use branch fails' '\n+\tgit worktree add my7 &&\n+\ttest_commit -C my7 bt7 &&\n+\tgit -C my7 bisect start HEAD HEAD~2 &&\n+\ttest_must_fail git -C my7 branch -d my7 &&\n+\ttest_must_fail git branch -d my7 2>actual &&\n+\tgrep \"^error: Cannot delete branch .my7. used by worktree at \" actual &&\n \trm -r my7 &&\n \tgit worktree prune\n '\n-- \n2.42.0.rc0.2.gbb987841e8\n"},{"id":"480259","messageId":"d217d15f-ddef-d9bf-07fa-464b4025ab3c@gmail.com","threadId":"60078","inReplyTo":"7710c002-0832-d8f6-59b8-30119bd5efe6@gmail.com","subject":"[PATCH 2/2] branch: error message checking out a branch in use","fromName":"Rubén Justo","fromEmail":"rjusto@gmail.com","sentAt":"2023-08-07T20:42:40Z","receivedAt":"2023-08-07T20:42:48Z","isPatch":true,"sender":{"key":"rjusto@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5685487?v=4"},"body":"Let's update the error message we show when the user tries to check out\na branch which is being used in another worktree, following the\nguideline reasoned in 4970bedef2 (branch: update the message to refuse\ntouching a branch in-use, 2023-07-21).\n\nSigned-off-by: Rubén Justo <rjusto@gmail.com>\n---\n branch.c                | 2 +-\n t/t2400-worktree-add.sh | 3 ++-\n t/t3400-rebase.sh       | 2 +-\n 3 files changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex 3e4684f79f..98c199f7b7 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -838,7 +838,7 @@ void die_if_checked_out(const char *branch, int ignore_current_worktree)\n \n \t\tif (is_shared_symref(worktrees[i], \"HEAD\", branch)) {\n \t\t\tskip_prefix(branch, \"refs/heads/\", &branch);\n-\t\t\tdie(_(\"'%s' is already checked out at '%s'\"),\n+\t\t\tdie(_(\"'%s' already used by worktree at '%s'\"),\n \t\t\t\tbranch, worktrees[i]->path);\n \t\t}\n \t}\ndiff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh\nindex 051363acbb..89447a4a0c 100755\n--- a/t/t2400-worktree-add.sh\n+++ b/t/t2400-worktree-add.sh\n@@ -121,7 +121,8 @@ test_expect_success '\"add\" worktree creating new branch' '\n test_expect_success 'die the same branch is already checked out' '\n \t(\n \t\tcd here &&\n-\t\ttest_must_fail git checkout newmain\n+\t\ttest_must_fail git checkout newmain 2> actual &&\n+\t\tgrep \"already used by worktree at\" actual\n \t)\n '\n \ndiff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh\nindex 3ce918fdb8..d3df19a51f 100755\n--- a/t/t3400-rebase.sh\n+++ b/t/t3400-rebase.sh\n@@ -421,7 +421,7 @@ test_expect_success 'refuse to switch to branch checked out elsewhere' '\n \tgit checkout main &&\n \tgit worktree add wt &&\n \ttest_must_fail git -C wt rebase main main 2>err &&\n-\ttest_i18ngrep \"already checked out\" err\n+\ttest_i18ngrep \"already used by worktree at\" err\n '\n \n test_expect_success MINGW,SYMLINKS_WINDOWS 'rebase when .git/logs is a symlink' '\n-- \n2.42.0.rc0.2.gbb987841e8\n"},{"id":"480263","messageId":"xmqqy1imblgp.fsf@gitster.g","threadId":"60078","inReplyTo":"7710c002-0832-d8f6-59b8-30119bd5efe6@gmail.com","subject":"Re: [PATCH 0/2] branch: update error messages","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-08-07T21:18:14Z","receivedAt":"2023-08-07T21:18:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Rubén Justo <rjusto@gmail.com> writes:\n\n> A message like \"branch 'frog' checked out at ...\" may be confusing to\n> the user if the branch 'frog' is not the currently checked out branch,\n> which may occur while rebasing, bisecting or other operations.\n\nMakes sense.  Will queue.\n\n\n>\n> Let's reword those messages as it has been done in 4970bedef2 (branch:\n> update the message to refuse touching a branch in-use, 2023-07-21).\n>\n> Rubén Justo (2):\n>   branch: error message deleting a branch in use\n>   branch: error message checking out a branch in use\n>\n>  branch.c                |  2 +-\n>  builtin/branch.c        |  2 +-\n>  t/t2400-worktree-add.sh |  3 ++-\n>  t/t3200-branch.sh       | 14 +++++++++++++-\n>  t/t3400-rebase.sh       |  2 +-\n>  5 files changed, 18 insertions(+), 5 deletions(-)\n"},{"id":"480268","messageId":"ZNFjZD4ImMz2mnrT@nand.local","threadId":"60078","inReplyTo":"d217d15f-ddef-d9bf-07fa-464b4025ab3c@gmail.com","subject":"Re: [PATCH 2/2] branch: error message checking out a branch in use","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2023-08-07T21:34:28Z","receivedAt":"2023-08-07T21:34:34Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Mon, Aug 07, 2023 at 10:42:40PM +0200, Rubén Justo wrote:\n> Let's update the error message we show when the user tries to check out\n> a branch which is being used in another worktree, following the\n> guideline reasoned in 4970bedef2 (branch: update the message to refuse\n> touching a branch in-use, 2023-07-21).\n>\n> Signed-off-by: Rubén Justo <rjusto@gmail.com>\n> ---\n>  branch.c                | 2 +-\n>  t/t2400-worktree-add.sh | 3 ++-\n>  t/t3400-rebase.sh       | 2 +-\n>  3 files changed, 4 insertions(+), 3 deletions(-)\n>\n> diff --git a/branch.c b/branch.c\n> index 3e4684f79f..98c199f7b7 100644\n> --- a/branch.c\n> +++ b/branch.c\n> @@ -838,7 +838,7 @@ void die_if_checked_out(const char *branch, int ignore_current_worktree)\n>\n>  \t\tif (is_shared_symref(worktrees[i], \"HEAD\", branch)) {\n>  \t\t\tskip_prefix(branch, \"refs/heads/\", &branch);\n> -\t\t\tdie(_(\"'%s' is already checked out at '%s'\"),\n> +\t\t\tdie(_(\"'%s' already used by worktree at '%s'\"),\n\nI wonder if \"'%s' is already used by ...\" (with the additional \"is\"\nbetween the branch name and \"already\") would be clearer / more natural.\n\nThanks,\nTaylor\n"},{"id":"480270","messageId":"01c1418e-a879-b778-f6d4-b76bef3e33b7@gmail.com","threadId":"60078","inReplyTo":"ZNFjZD4ImMz2mnrT@nand.local","subject":"Re: [PATCH 2/2] branch: error message checking out a branch in use","fromName":"Rubén Justo","fromEmail":"rjusto@gmail.com","sentAt":"2023-08-07T22:49:09Z","receivedAt":"2023-08-07T22:49:16Z","isPatch":true,"sender":{"key":"rjusto@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5685487?v=4"},"body":"On 7/8/23 23:34, Taylor Blau wrote:\n> On Mon, Aug 07, 2023 at 10:42:40PM +0200, Rubén Justo wrote:\n>> Let's update the error message we show when the user tries to check out\n>> a branch which is being used in another worktree, following the\n>> guideline reasoned in 4970bedef2 (branch: update the message to refuse\n>> touching a branch in-use, 2023-07-21).\n>>\n>> Signed-off-by: Rubén Justo <rjusto@gmail.com>\n>> ---\n>>  branch.c                | 2 +-\n>>  t/t2400-worktree-add.sh | 3 ++-\n>>  t/t3400-rebase.sh       | 2 +-\n>>  3 files changed, 4 insertions(+), 3 deletions(-)\n>>\n>> diff --git a/branch.c b/branch.c\n>> index 3e4684f79f..98c199f7b7 100644\n>> --- a/branch.c\n>> +++ b/branch.c\n>> @@ -838,7 +838,7 @@ void die_if_checked_out(const char *branch, int ignore_current_worktree)\n>>\n>>  \t\tif (is_shared_symref(worktrees[i], \"HEAD\", branch)) {\n>>  \t\t\tskip_prefix(branch, \"refs/heads/\", &branch);\n>> -\t\t\tdie(_(\"'%s' is already checked out at '%s'\"),\n>> +\t\t\tdie(_(\"'%s' already used by worktree at '%s'\"),\n> \n> I wonder if \"'%s' is already used by ...\" (with the additional \"is\"\n> between the branch name and \"already\") would be clearer / more natural.\n\nI have no problem with that change.  I think I was trying to keep the message\nsort ... the tests does not need to be adjusted.\n\n> \n> Thanks,\n> Taylor\n> \n\nThanks for reading carefully.\n\n"}]}