{"thread":{"id":"64363","subject":"[PATCH] add-patch: fully document option P","startedAt":"2025-10-21T18:03:01Z","lastAt":"2025-10-21T21:37:00Z","messageCount":2,"participants":["René Scharfe","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"529308","messageId":"0188c766-d788-476d-a4d4-f95a6f59b31b@web.de","threadId":"64363","inReplyTo":null,"subject":"[PATCH] add-patch: fully document option P","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2025-10-21T18:02:53Z","receivedAt":"2025-10-21T18:03:01Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Show option P in the prompt and explain it properly on a dedicated line\nin online help and documentation.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n Documentation/git-add.adoc |  1 +\n add-patch.c                |  5 +++--\n t/t3701-add-interactive.sh | 44 +++++++++++++++++++-------------------\n 3 files changed, 26 insertions(+), 24 deletions(-)\n\ndiff --git a/Documentation/git-add.adoc b/Documentation/git-add.adoc\nindex 3116a2cac5..6192daeb03 100644\n--- a/Documentation/git-add.adoc\n+++ b/Documentation/git-add.adoc\n@@ -349,6 +349,7 @@ patch::\n        s - split the current hunk into smaller hunks\n        e - manually edit the current hunk\n        p - print the current hunk\n+       P - print the current hunk using the pager\n        ? - print help\n +\n After deciding the fate for all hunks, if there is any hunk\ndiff --git a/add-patch.c b/add-patch.c\nindex 9402dc71bc..ae9a20d8f2 100644\n--- a/add-patch.c\n+++ b/add-patch.c\n@@ -1416,7 +1416,8 @@ N_(\"j - go to the next undecided hunk, roll over at the bottom\\n\"\n    \"/ - search for a hunk matching the given regex\\n\"\n    \"s - split the current hunk into smaller hunks\\n\"\n    \"e - manually edit the current hunk\\n\"\n-   \"p - print the current hunk, 'P' to use the pager\\n\"\n+   \"p - print the current hunk\\n\"\n+   \"P - print the current hunk using the pager\\n\"\n    \"? - print help\\n\");\n \n static size_t dec_mod(size_t a, size_t m)\n@@ -1547,7 +1548,7 @@ static int patch_update_file(struct add_p_state *s,\n \t\t\t\tpermitted |= ALLOW_EDIT;\n \t\t\t\tstrbuf_addstr(&s->buf, \",e\");\n \t\t\t}\n-\t\t\tstrbuf_addstr(&s->buf, \",p\");\n+\t\t\tstrbuf_addstr(&s->buf, \",p,P\");\n \t\t}\n \t\tif (file_diff->deleted)\n \t\t\tprompt_mode_type = PROMPT_DELETION;\ndiff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\nindex b5e6edcb9e..851ca6dd91 100755\n--- a/t/t3701-add-interactive.sh\n+++ b/t/t3701-add-interactive.sh\n@@ -48,8 +48,8 @@ test_expect_success 'unknown command' '\n \tgit add -N command &&\n \tgit diff command >expect &&\n \tcat >>expect <<-EOF &&\n-\t(1/1) Stage addition [y,n,q,a,d,e,p,?]? Unknown command ${SQ}W${SQ} (use ${SQ}?${SQ} for help)\n-\t(1/1) Stage addition [y,n,q,a,d,e,p,?]?$SP\n+\t(1/1) Stage addition [y,n,q,a,d,e,p,P,?]? Unknown command ${SQ}W${SQ} (use ${SQ}?${SQ} for help)\n+\t(1/1) Stage addition [y,n,q,a,d,e,p,P,?]?$SP\n \tEOF\n \tgit add -p -- command <command >actual 2>&1 &&\n \ttest_cmp expect actual\n@@ -332,9 +332,9 @@ test_expect_success 'different prompts for mode change/deleted' '\n \tgit -c core.filemode=true add -p >actual &&\n \tsed -n \"s/^\\(([0-9/]*) Stage .*?\\).*/\\1/p\" actual >actual.filtered &&\n \tcat >expect <<-\\EOF &&\n-\t(1/1) Stage deletion [y,n,q,a,d,p,?]?\n-\t(1/2) Stage mode change [y,n,q,a,d,k,K,j,J,g,/,p,?]?\n-\t(2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,p,?]?\n+\t(1/1) Stage deletion [y,n,q,a,d,p,P,?]?\n+\t(1/2) Stage mode change [y,n,q,a,d,k,K,j,J,g,/,p,P,?]?\n+\t(2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,p,P,?]?\n \tEOF\n \ttest_cmp expect actual.filtered\n '\n@@ -521,13 +521,13 @@ test_expect_success 'split hunk setup' '\n test_expect_success 'goto hunk 1 with \"g 1\"' '\n \ttest_when_finished \"git reset\" &&\n \ttr _ \" \" >expect <<-EOF &&\n-\t(2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,p,?]? + 1:  -1,2 +1,3          +15\n+\t(2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,p,P,?]? + 1:  -1,2 +1,3          +15\n \t_ 2:  -2,4 +3,8          +21\n \tgo to which hunk? @@ -1,2 +1,3 @@\n \t_10\n \t+15\n \t_20\n-\t(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]?_\n+\t(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]?_\n \tEOF\n \ttest_write_lines s y g 1 | git add -p >actual &&\n \ttail -n 7 <actual >actual.trimmed &&\n@@ -540,7 +540,7 @@ test_expect_success 'goto hunk 1 with \"g1\"' '\n \t_10\n \t+15\n \t_20\n-\t(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]?_\n+\t(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]?_\n \tEOF\n \ttest_write_lines s y g1 | git add -p >actual &&\n \ttail -n 4 <actual >actual.trimmed &&\n@@ -550,11 +550,11 @@ test_expect_success 'goto hunk 1 with \"g1\"' '\n test_expect_success 'navigate to hunk via regex /pattern' '\n \ttest_when_finished \"git reset\" &&\n \ttr _ \" \" >expect <<-EOF &&\n-\t(2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,p,?]? @@ -1,2 +1,3 @@\n+\t(2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,p,P,?]? @@ -1,2 +1,3 @@\n \t_10\n \t+15\n \t_20\n-\t(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]?_\n+\t(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]?_\n \tEOF\n \ttest_write_lines s y /1,2 | git add -p >actual &&\n \ttail -n 5 <actual >actual.trimmed &&\n@@ -567,7 +567,7 @@ test_expect_success 'navigate to hunk via regex / pattern' '\n \t_10\n \t+15\n \t_20\n-\t(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]?_\n+\t(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]?_\n \tEOF\n \ttest_write_lines s y / 1,2 | git add -p >actual &&\n \ttail -n 4 <actual >actual.trimmed &&\n@@ -579,11 +579,11 @@ test_expect_success 'print again the hunk' '\n \ttr _ \" \" >expect <<-EOF &&\n \t+15\n \t 20\n-\t(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]? @@ -1,2 +1,3 @@\n+\t(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]? @@ -1,2 +1,3 @@\n \t 10\n \t+15\n \t 20\n-\t(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]?_\n+\t(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]?_\n \tEOF\n \ttest_write_lines s y g 1 p | git add -p >actual &&\n \ttail -n 7 <actual >actual.trimmed &&\n@@ -595,11 +595,11 @@ test_expect_success TTY 'print again the hunk (PAGER)' '\n \tcat >expect <<-EOF &&\n \t<GREEN>+<RESET><GREEN>15<RESET>\n \t 20<RESET>\n-\t<BOLD;BLUE>(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]? <RESET>PAGER <CYAN>@@ -1,2 +1,3 @@<RESET>\n+\t<BOLD;BLUE>(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]? <RESET>PAGER <CYAN>@@ -1,2 +1,3 @@<RESET>\n \tPAGER  10<RESET>\n \tPAGER <GREEN>+<RESET><GREEN>15<RESET>\n \tPAGER  20<RESET>\n-\t<BOLD;BLUE>(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]? <RESET>\n+\t<BOLD;BLUE>(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]? <RESET>\n \tEOF\n \ttest_write_lines s y g 1 P |\n \t(\n@@ -796,21 +796,21 @@ test_expect_success 'colors can be overridden' '\n \t<BLUE>+<RESET><BLUE>new<RESET>\n \t<CYAN> more-context<RESET>\n \t<BLUE>+<RESET><BLUE>another-one<RESET>\n-\t<YELLOW>(1/1) Stage this hunk [y,n,q,a,d,s,e,p,?]? <RESET><BOLD>Split into 2 hunks.<RESET>\n+\t<YELLOW>(1/1) Stage this hunk [y,n,q,a,d,s,e,p,P,?]? <RESET><BOLD>Split into 2 hunks.<RESET>\n \t<MAGENTA>@@ -1,3 +1,3 @@<RESET>\n \t<CYAN> context<RESET>\n \t<BOLD>-old<RESET>\n \t<BLUE>+<RESET><BLUE>new<RESET>\n \t<CYAN> more-context<RESET>\n-\t<YELLOW>(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]? <RESET><MAGENTA>@@ -3 +3,2 @@<RESET>\n+\t<YELLOW>(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]? <RESET><MAGENTA>@@ -3 +3,2 @@<RESET>\n \t<CYAN> more-context<RESET>\n \t<BLUE>+<RESET><BLUE>another-one<RESET>\n-\t<YELLOW>(2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,p,?]? <RESET><MAGENTA>@@ -1,3 +1,3 @@<RESET>\n+\t<YELLOW>(2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,p,P,?]? <RESET><MAGENTA>@@ -1,3 +1,3 @@<RESET>\n \t<CYAN> context<RESET>\n \t<BOLD>-old<RESET>\n \t<BLUE>+new<RESET>\n \t<CYAN> more-context<RESET>\n-\t<YELLOW>(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]? <RESET>\n+\t<YELLOW>(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]? <RESET>\n \tEOF\n \ttest_cmp expect actual\n '\n@@ -1424,9 +1424,9 @@ test_expect_success 'invalid option s is rejected' '\n \ttest_write_lines j s q | git add -p >out &&\n \tsed -ne \"s/ @@.*//\" -e \"s/ \\$//\" -e \"/^(/p\" <out >actual &&\n \tcat >expect <<-EOF &&\n-\t(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,s,e,p,?]?\n-\t(2/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]? Sorry, cannot split this hunk\n-\t(2/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]?\n+\t(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,s,e,p,P,?]?\n+\t(2/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]? Sorry, cannot split this hunk\n+\t(2/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]?\n \tEOF\n \ttest_cmp expect actual\n '\n-- \n2.51.1\n"},{"id":"529334","messageId":"xmqq5xc8szr9.fsf@gitster.g","threadId":"64363","inReplyTo":"0188c766-d788-476d-a4d4-f95a6f59b31b@web.de","subject":"Re: [PATCH] add-patch: fully document option P","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-10-21T21:36:58Z","receivedAt":"2025-10-21T21:37:00Z","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> Show option P in the prompt and explain it properly on a dedicated line\n> in online help and documentation.\n>\n> Signed-off-by: René Scharfe <l.s.r@web.de>\n> ---\n>  Documentation/git-add.adoc |  1 +\n>  add-patch.c                |  5 +++--\n>  t/t3701-add-interactive.sh | 44 +++++++++++++++++++-------------------\n>  3 files changed, 26 insertions(+), 24 deletions(-)\n\nNice.  I do not recall why we decided to hide \"P\" behind \"p\" like\nthis, but I think making it clear like this patch does does make\nsense.\n"}]}