git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Small bug report in git restore -p prompt
@ 2022-09-14  6:56 David Plumpton
  2022-09-14  9:47 ` [PATCH] add -p: fix worktree patch mode prompts René Scharfe
  0 siblings, 1 reply; 3+ messages in thread
From: David Plumpton @ 2022-09-14  6:56 UTC (permalink / raw)
  To: git

What did you do before the bug happened? (Steps to reproduce your issue)
git restore -p -s <hash>

What did you expect to happen? (Expected behavior)
Prompt should say "Apply this hunk to worktree..."

What happened instead? (Actual behavior)
Prompt said "Apply this hunk to index and worktree..."

What's different between what you expected and what actually happened?
For git restore the prompt should not mention applying hunk to index.

Anything else you want to add:

Please review the rest of the bug report below.
You can delete any lines you don't wish to share.


[System Info]
git version:
git version 2.37.3
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
uname: Darwin 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10
PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64 x86_64
compiler info: clang: 13.1.6 (clang-1316.0.21.2.5)
libc info: no libc information available
$SHELL (typically, interactive shell): /bin/zsh


[Enabled Hooks]


-- 
David P.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] add -p: fix worktree patch mode prompts
  2022-09-14  6:56 Small bug report in git restore -p prompt David Plumpton
@ 2022-09-14  9:47 ` René Scharfe
  2022-09-15  2:27   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: René Scharfe @ 2022-09-14  9:47 UTC (permalink / raw)
  To: David Plumpton, git; +Cc: Johannes Schindelin

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] add -p: fix worktree patch mode prompts
  2022-09-14  9:47 ` [PATCH] add -p: fix worktree patch mode prompts René Scharfe
@ 2022-09-15  2:27   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2022-09-15  2:27 UTC (permalink / raw)
  To: René Scharfe; +Cc: David Plumpton, git, Johannes Schindelin

René Scharfe <l.s.r@web.de> writes:

> 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.

Thanks, both of you.

Queued.



>
>  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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-09-15  2:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-14  6:56 Small bug report in git restore -p prompt David Plumpton
2022-09-14  9:47 ` [PATCH] add -p: fix worktree patch mode prompts René Scharfe
2022-09-15  2:27   ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).