git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] add -p: fix worktree patch mode prompts

From
René Scharfe <l.s.r@web.de>
Date
Sep 14, 2022, 09:47 UTC
Message-ID
<2463c4b9-313b-032f-9313-d1421f71f111@web.de>
In-Reply-To
<CAJXaddZwqGabdjmgc22eCYCdBw6nxcPbPfom26PwG3xvKEN93w@mail.gmail.com>

cee6cb7300 (built-in add -p: implement the "worktree" patch modes, 2019-12-21) added the worktree patch modes to the built-in add -p. Its commit message claims to be a port of 2f0896ec3ad4 (restore: support --patch, 2019-04-25), which did the same for the script git-add--interactive.perl.

The script mentioned only the worktree in its prompt messages in worktree mode, while the built-in mentions the worktree and also the index, even though the command doesn't actually affect the index.

2c8bd8471a (checkout -p: handle new files correctly, 2020-05-27) added new prompt messages for addition that also mention the index in worktree mode in the built-in, but not in the script.

Correct these prompts to state that only the worktree will be affected.
Reported-by: David Plumpton <david.plumpton@gmail.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
---
Patch created using --function-context for easier review.  Note that
help_patch_text is already correct.
 add-patch.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/add-patch.c b/add-patch.c
index 29f9456df3..33ecd8398a 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -188,22 +188,22 @@ static struct patch_mode patch_mode_checkout_nothead = {
 static struct patch_mode patch_mode_worktree_head = {
 	.diff_cmd = { "diff-index", NULL },
 	.apply_args = { "-R", NULL },
 	.apply_check_args = { "-R", NULL },
 	.is_reverse = 1,
 	.prompt_mode = {
-		N_("Discard mode change from index and worktree [y,n,q,a,d%s,?]? "),
-		N_("Discard deletion from index and worktree [y,n,q,a,d%s,?]? "),
-		N_("Discard addition from index and worktree [y,n,q,a,d%s,?]? "),
-		N_("Discard this hunk from index and worktree [y,n,q,a,d%s,?]? "),
+		N_("Discard mode change from worktree [y,n,q,a,d%s,?]? "),
+		N_("Discard deletion from worktree [y,n,q,a,d%s,?]? "),
+		N_("Discard addition from worktree [y,n,q,a,d%s,?]? "),
+		N_("Discard this hunk from worktree [y,n,q,a,d%s,?]? "),
 	},
 	.edit_hunk_hint = N_("If the patch applies cleanly, the edited hunk "
 			     "will immediately be marked for discarding."),
 	.help_patch_text =
 		N_("y - discard this hunk from worktree\n"
 		   "n - do not discard this hunk from worktree\n"
 		   "q - quit; do not discard this hunk or any of the remaining "
 			"ones\n"
 		   "a - discard this hunk and all later hunks in the file\n"
 		   "d - do not discard this hunk or any of the later hunks in "
 			"the file\n"),
 };
@@ -211,21 +211,21 @@ static struct patch_mode patch_mode_worktree_head = {
 static struct patch_mode patch_mode_worktree_nothead = {
 	.diff_cmd = { "diff-index", "-R", NULL },
 	.apply_args = { NULL },
 	.apply_check_args = { NULL },
 	.prompt_mode = {
-		N_("Apply mode change to index and worktree [y,n,q,a,d%s,?]? "),
-		N_("Apply deletion to index and worktree [y,n,q,a,d%s,?]? "),
-		N_("Apply addition to index and worktree [y,n,q,a,d%s,?]? "),
-		N_("Apply this hunk to index and worktree [y,n,q,a,d%s,?]? "),
+		N_("Apply mode change to worktree [y,n,q,a,d%s,?]? "),
+		N_("Apply deletion to worktree [y,n,q,a,d%s,?]? "),
+		N_("Apply addition to worktree [y,n,q,a,d%s,?]? "),
+		N_("Apply this hunk to worktree [y,n,q,a,d%s,?]? "),
 	},
 	.edit_hunk_hint = N_("If the patch applies cleanly, the edited hunk "
 			     "will immediately be marked for applying."),
 	.help_patch_text =
 		N_("y - apply this hunk to worktree\n"
 		   "n - do not apply this hunk to worktree\n"
 		   "q - quit; do not apply this hunk or any of the remaining "
 			"ones\n"
 		   "a - apply this hunk and all later hunks in the file\n"
 		   "d - do not apply this hunk or any of the later hunks in "
 			"the file\n"),
 };
--
2.37.2
Previous: David PlumptonNext: Junio C Hamano
Message 2 of 3 in “Small bug report in git restore -p prompt”
  1. David PlumptonSep 14, 2022
  2. add -p: fix worktree patch mode promptsRené Scharfe, Sep 14, 2022
  3. Junio C HamanoSep 15, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.