{"thread":{"id":"58430","subject":"Small bug report in git restore -p prompt","startedAt":"2022-09-14T06:57:08Z","lastAt":"2022-09-15T02:27:16Z","messageCount":3,"participants":["David Plumpton","René Scharfe","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"463013","messageId":"CAJXaddZwqGabdjmgc22eCYCdBw6nxcPbPfom26PwG3xvKEN93w@mail.gmail.com","threadId":"58430","inReplyTo":null,"subject":"Small bug report in git restore -p prompt","fromName":"David Plumpton","fromEmail":"david.plumpton@gmail.com","sentAt":"2022-09-14T06:56:49Z","receivedAt":"2022-09-14T06:57:08Z","isPatch":false,"sender":{"key":"david.plumpton@gmail.com","avatar":null},"body":"What did you do before the bug happened? (Steps to reproduce your issue)\ngit restore -p -s <hash>\n\nWhat did you expect to happen? (Expected behavior)\nPrompt should say \"Apply this hunk to worktree...\"\n\nWhat happened instead? (Actual behavior)\nPrompt said \"Apply this hunk to index and worktree...\"\n\nWhat's different between what you expected and what actually happened?\nFor git restore the prompt should not mention applying hunk to index.\n\nAnything else you want to add:\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.37.3\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nfeature: fsmonitor--daemon\nuname: Darwin 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10\nPDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64 x86_64\ncompiler info: clang: 13.1.6 (clang-1316.0.21.2.5)\nlibc info: no libc information available\n$SHELL (typically, interactive shell): /bin/zsh\n\n\n[Enabled Hooks]\n\n\n-- \nDavid P.\n"},{"id":"463016","messageId":"2463c4b9-313b-032f-9313-d1421f71f111@web.de","threadId":"58430","inReplyTo":"CAJXaddZwqGabdjmgc22eCYCdBw6nxcPbPfom26PwG3xvKEN93w@mail.gmail.com","subject":"[PATCH] add -p: fix worktree patch mode prompts","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2022-09-14T09:47:33Z","receivedAt":"2022-09-14T09:47:40Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"cee6cb7300 (built-in add -p: implement the \"worktree\" patch modes,\n2019-12-21) added the worktree patch modes to the built-in add -p.\nIts commit message claims to be a port of 2f0896ec3ad4 (restore:\nsupport --patch, 2019-04-25), which did the same for the script\ngit-add--interactive.perl.\n\nThe script mentioned only the worktree in its prompt messages in\nworktree mode, while the built-in mentions the worktree and also the\nindex, even though the command doesn't actually affect the index.\n\n2c8bd8471a (checkout -p: handle new files correctly, 2020-05-27)\nadded new prompt messages for addition that also mention the index in\nworktree mode in the built-in, but not in the script.\n\nCorrect these prompts to state that only the worktree will be affected.\n\nReported-by: David Plumpton <david.plumpton@gmail.com>\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\nPatch created using --function-context for easier review.  Note that\nhelp_patch_text is already correct.\n\n add-patch.c | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/add-patch.c b/add-patch.c\nindex 29f9456df3..33ecd8398a 100644\n--- a/add-patch.c\n+++ b/add-patch.c\n@@ -188,22 +188,22 @@ static struct patch_mode patch_mode_checkout_nothead = {\n static struct patch_mode patch_mode_worktree_head = {\n \t.diff_cmd = { \"diff-index\", NULL },\n \t.apply_args = { \"-R\", NULL },\n \t.apply_check_args = { \"-R\", NULL },\n \t.is_reverse = 1,\n \t.prompt_mode = {\n-\t\tN_(\"Discard mode change from index and worktree [y,n,q,a,d%s,?]? \"),\n-\t\tN_(\"Discard deletion from index and worktree [y,n,q,a,d%s,?]? \"),\n-\t\tN_(\"Discard addition from index and worktree [y,n,q,a,d%s,?]? \"),\n-\t\tN_(\"Discard this hunk from index and worktree [y,n,q,a,d%s,?]? \"),\n+\t\tN_(\"Discard mode change from worktree [y,n,q,a,d%s,?]? \"),\n+\t\tN_(\"Discard deletion from worktree [y,n,q,a,d%s,?]? \"),\n+\t\tN_(\"Discard addition from worktree [y,n,q,a,d%s,?]? \"),\n+\t\tN_(\"Discard this hunk from worktree [y,n,q,a,d%s,?]? \"),\n \t},\n \t.edit_hunk_hint = N_(\"If the patch applies cleanly, the edited hunk \"\n \t\t\t     \"will immediately be marked for discarding.\"),\n \t.help_patch_text =\n \t\tN_(\"y - discard this hunk from worktree\\n\"\n \t\t   \"n - do not discard this hunk from worktree\\n\"\n \t\t   \"q - quit; do not discard this hunk or any of the remaining \"\n \t\t\t\"ones\\n\"\n \t\t   \"a - discard this hunk and all later hunks in the file\\n\"\n \t\t   \"d - do not discard this hunk or any of the later hunks in \"\n \t\t\t\"the file\\n\"),\n };\n@@ -211,21 +211,21 @@ static struct patch_mode patch_mode_worktree_head = {\n static struct patch_mode patch_mode_worktree_nothead = {\n \t.diff_cmd = { \"diff-index\", \"-R\", NULL },\n \t.apply_args = { NULL },\n \t.apply_check_args = { NULL },\n \t.prompt_mode = {\n-\t\tN_(\"Apply mode change to index and worktree [y,n,q,a,d%s,?]? \"),\n-\t\tN_(\"Apply deletion to index and worktree [y,n,q,a,d%s,?]? \"),\n-\t\tN_(\"Apply addition to index and worktree [y,n,q,a,d%s,?]? \"),\n-\t\tN_(\"Apply this hunk to index and worktree [y,n,q,a,d%s,?]? \"),\n+\t\tN_(\"Apply mode change to worktree [y,n,q,a,d%s,?]? \"),\n+\t\tN_(\"Apply deletion to worktree [y,n,q,a,d%s,?]? \"),\n+\t\tN_(\"Apply addition to worktree [y,n,q,a,d%s,?]? \"),\n+\t\tN_(\"Apply this hunk to worktree [y,n,q,a,d%s,?]? \"),\n \t},\n \t.edit_hunk_hint = N_(\"If the patch applies cleanly, the edited hunk \"\n \t\t\t     \"will immediately be marked for applying.\"),\n \t.help_patch_text =\n \t\tN_(\"y - apply this hunk to worktree\\n\"\n \t\t   \"n - do not apply this hunk to worktree\\n\"\n \t\t   \"q - quit; do not apply this hunk or any of the remaining \"\n \t\t\t\"ones\\n\"\n \t\t   \"a - apply this hunk and all later hunks in the file\\n\"\n \t\t   \"d - do not apply this hunk or any of the later hunks in \"\n \t\t\t\"the file\\n\"),\n };\n--\n2.37.2\n"},{"id":"463027","messageId":"xmqqy1ulpe2s.fsf@gitster.g","threadId":"58430","inReplyTo":"2463c4b9-313b-032f-9313-d1421f71f111@web.de","subject":"Re: [PATCH] add -p: fix worktree patch mode prompts","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-09-15T02:27:07Z","receivedAt":"2022-09-15T02:27:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"René Scharfe <l.s.r@web.de> writes:\n\n> cee6cb7300 (built-in add -p: implement the \"worktree\" patch modes,\n> 2019-12-21) added the worktree patch modes to the built-in add -p.\n> Its commit message claims to be a port of 2f0896ec3ad4 (restore:\n> support --patch, 2019-04-25), which did the same for the script\n> git-add--interactive.perl.\n>\n> The script mentioned only the worktree in its prompt messages in\n> worktree mode, while the built-in mentions the worktree and also the\n> index, even though the command doesn't actually affect the index.\n>\n> 2c8bd8471a (checkout -p: handle new files correctly, 2020-05-27)\n> added new prompt messages for addition that also mention the index in\n> worktree mode in the built-in, but not in the script.\n>\n> Correct these prompts to state that only the worktree will be affected.\n>\n> Reported-by: David Plumpton <david.plumpton@gmail.com>\n> Signed-off-by: René Scharfe <l.s.r@web.de>\n> ---\n> Patch created using --function-context for easier review.  Note that\n> help_patch_text is already correct.\n\nThanks, both of you.\n\nQueued.\n\n\n\n>\n>  add-patch.c | 16 ++++++++--------\n>  1 file changed, 8 insertions(+), 8 deletions(-)\n>\n> diff --git a/add-patch.c b/add-patch.c\n> index 29f9456df3..33ecd8398a 100644\n> --- a/add-patch.c\n> +++ b/add-patch.c\n> @@ -188,22 +188,22 @@ static struct patch_mode patch_mode_checkout_nothead = {\n>  static struct patch_mode patch_mode_worktree_head = {\n>  \t.diff_cmd = { \"diff-index\", NULL },\n>  \t.apply_args = { \"-R\", NULL },\n>  \t.apply_check_args = { \"-R\", NULL },\n>  \t.is_reverse = 1,\n>  \t.prompt_mode = {\n> -\t\tN_(\"Discard mode change from index and worktree [y,n,q,a,d%s,?]? \"),\n> -\t\tN_(\"Discard deletion from index and worktree [y,n,q,a,d%s,?]? \"),\n> -\t\tN_(\"Discard addition from index and worktree [y,n,q,a,d%s,?]? \"),\n> -\t\tN_(\"Discard this hunk from index and worktree [y,n,q,a,d%s,?]? \"),\n> +\t\tN_(\"Discard mode change from worktree [y,n,q,a,d%s,?]? \"),\n> +\t\tN_(\"Discard deletion from worktree [y,n,q,a,d%s,?]? \"),\n> +\t\tN_(\"Discard addition from worktree [y,n,q,a,d%s,?]? \"),\n> +\t\tN_(\"Discard this hunk from worktree [y,n,q,a,d%s,?]? \"),\n>  \t},\n>  \t.edit_hunk_hint = N_(\"If the patch applies cleanly, the edited hunk \"\n>  \t\t\t     \"will immediately be marked for discarding.\"),\n>  \t.help_patch_text =\n>  \t\tN_(\"y - discard this hunk from worktree\\n\"\n>  \t\t   \"n - do not discard this hunk from worktree\\n\"\n>  \t\t   \"q - quit; do not discard this hunk or any of the remaining \"\n>  \t\t\t\"ones\\n\"\n>  \t\t   \"a - discard this hunk and all later hunks in the file\\n\"\n>  \t\t   \"d - do not discard this hunk or any of the later hunks in \"\n>  \t\t\t\"the file\\n\"),\n>  };\n> @@ -211,21 +211,21 @@ static struct patch_mode patch_mode_worktree_head = {\n>  static struct patch_mode patch_mode_worktree_nothead = {\n>  \t.diff_cmd = { \"diff-index\", \"-R\", NULL },\n>  \t.apply_args = { NULL },\n>  \t.apply_check_args = { NULL },\n>  \t.prompt_mode = {\n> -\t\tN_(\"Apply mode change to index and worktree [y,n,q,a,d%s,?]? \"),\n> -\t\tN_(\"Apply deletion to index and worktree [y,n,q,a,d%s,?]? \"),\n> -\t\tN_(\"Apply addition to index and worktree [y,n,q,a,d%s,?]? \"),\n> -\t\tN_(\"Apply this hunk to index and worktree [y,n,q,a,d%s,?]? \"),\n> +\t\tN_(\"Apply mode change to worktree [y,n,q,a,d%s,?]? \"),\n> +\t\tN_(\"Apply deletion to worktree [y,n,q,a,d%s,?]? \"),\n> +\t\tN_(\"Apply addition to worktree [y,n,q,a,d%s,?]? \"),\n> +\t\tN_(\"Apply this hunk to worktree [y,n,q,a,d%s,?]? \"),\n>  \t},\n>  \t.edit_hunk_hint = N_(\"If the patch applies cleanly, the edited hunk \"\n>  \t\t\t     \"will immediately be marked for applying.\"),\n>  \t.help_patch_text =\n>  \t\tN_(\"y - apply this hunk to worktree\\n\"\n>  \t\t   \"n - do not apply this hunk to worktree\\n\"\n>  \t\t   \"q - quit; do not apply this hunk or any of the remaining \"\n>  \t\t\t\"ones\\n\"\n>  \t\t   \"a - apply this hunk and all later hunks in the file\\n\"\n>  \t\t   \"d - do not apply this hunk or any of the later hunks in \"\n>  \t\t\t\"the file\\n\"),\n>  };\n> --\n> 2.37.2\n"}]}