mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
Merge branch 'rs/add-patch-document-p-for-pager'
Show 'P'ipe command in "git add -p". * rs/add-patch-document-p-for-pager: add-patch: fully document option P
This commit is contained in:
@@ -349,6 +349,7 @@ patch::
|
|||||||
s - split the current hunk into smaller hunks
|
s - split the current hunk into smaller hunks
|
||||||
e - manually edit the current hunk
|
e - manually edit the current hunk
|
||||||
p - print the current hunk
|
p - print the current hunk
|
||||||
|
P - print the current hunk using the pager
|
||||||
? - print help
|
? - print help
|
||||||
+
|
+
|
||||||
After deciding the fate for all hunks, if there is any hunk
|
After deciding the fate for all hunks, if there is any hunk
|
||||||
|
|||||||
@@ -1416,7 +1416,8 @@ N_("j - go to the next undecided hunk, roll over at the bottom\n"
|
|||||||
"/ - search for a hunk matching the given regex\n"
|
"/ - search for a hunk matching the given regex\n"
|
||||||
"s - split the current hunk into smaller hunks\n"
|
"s - split the current hunk into smaller hunks\n"
|
||||||
"e - manually edit the current hunk\n"
|
"e - manually edit the current hunk\n"
|
||||||
"p - print the current hunk, 'P' to use the pager\n"
|
"p - print the current hunk\n"
|
||||||
|
"P - print the current hunk using the pager\n"
|
||||||
"? - print help\n");
|
"? - print help\n");
|
||||||
|
|
||||||
static size_t dec_mod(size_t a, size_t m)
|
static size_t dec_mod(size_t a, size_t m)
|
||||||
@@ -1547,7 +1548,7 @@ static int patch_update_file(struct add_p_state *s,
|
|||||||
permitted |= ALLOW_EDIT;
|
permitted |= ALLOW_EDIT;
|
||||||
strbuf_addstr(&s->buf, ",e");
|
strbuf_addstr(&s->buf, ",e");
|
||||||
}
|
}
|
||||||
strbuf_addstr(&s->buf, ",p");
|
strbuf_addstr(&s->buf, ",p,P");
|
||||||
}
|
}
|
||||||
if (file_diff->deleted)
|
if (file_diff->deleted)
|
||||||
prompt_mode_type = PROMPT_DELETION;
|
prompt_mode_type = PROMPT_DELETION;
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ test_expect_success 'unknown command' '
|
|||||||
git add -N command &&
|
git add -N command &&
|
||||||
git diff command >expect &&
|
git diff command >expect &&
|
||||||
cat >>expect <<-EOF &&
|
cat >>expect <<-EOF &&
|
||||||
(1/1) Stage addition [y,n,q,a,d,e,p,?]? Unknown command ${SQ}W${SQ} (use ${SQ}?${SQ} for help)
|
(1/1) Stage addition [y,n,q,a,d,e,p,P,?]? Unknown command ${SQ}W${SQ} (use ${SQ}?${SQ} for help)
|
||||||
(1/1) Stage addition [y,n,q,a,d,e,p,?]?$SP
|
(1/1) Stage addition [y,n,q,a,d,e,p,P,?]?$SP
|
||||||
EOF
|
EOF
|
||||||
git add -p -- command <command >actual 2>&1 &&
|
git add -p -- command <command >actual 2>&1 &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
@@ -332,9 +332,9 @@ test_expect_success 'different prompts for mode change/deleted' '
|
|||||||
git -c core.filemode=true add -p >actual &&
|
git -c core.filemode=true add -p >actual &&
|
||||||
sed -n "s/^\(([0-9/]*) Stage .*?\).*/\1/p" actual >actual.filtered &&
|
sed -n "s/^\(([0-9/]*) Stage .*?\).*/\1/p" actual >actual.filtered &&
|
||||||
cat >expect <<-\EOF &&
|
cat >expect <<-\EOF &&
|
||||||
(1/1) Stage deletion [y,n,q,a,d,p,?]?
|
(1/1) Stage deletion [y,n,q,a,d,p,P,?]?
|
||||||
(1/2) Stage mode change [y,n,q,a,d,k,K,j,J,g,/,p,?]?
|
(1/2) Stage mode change [y,n,q,a,d,k,K,j,J,g,/,p,P,?]?
|
||||||
(2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,p,?]?
|
(2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,p,P,?]?
|
||||||
EOF
|
EOF
|
||||||
test_cmp expect actual.filtered
|
test_cmp expect actual.filtered
|
||||||
'
|
'
|
||||||
@@ -521,13 +521,13 @@ test_expect_success 'split hunk setup' '
|
|||||||
test_expect_success 'goto hunk 1 with "g 1"' '
|
test_expect_success 'goto hunk 1 with "g 1"' '
|
||||||
test_when_finished "git reset" &&
|
test_when_finished "git reset" &&
|
||||||
tr _ " " >expect <<-EOF &&
|
tr _ " " >expect <<-EOF &&
|
||||||
(2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,p,?]? + 1: -1,2 +1,3 +15
|
(2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,p,P,?]? + 1: -1,2 +1,3 +15
|
||||||
_ 2: -2,4 +3,8 +21
|
_ 2: -2,4 +3,8 +21
|
||||||
go to which hunk? @@ -1,2 +1,3 @@
|
go to which hunk? @@ -1,2 +1,3 @@
|
||||||
_10
|
_10
|
||||||
+15
|
+15
|
||||||
_20
|
_20
|
||||||
(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]?_
|
(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]?_
|
||||||
EOF
|
EOF
|
||||||
test_write_lines s y g 1 | git add -p >actual &&
|
test_write_lines s y g 1 | git add -p >actual &&
|
||||||
tail -n 7 <actual >actual.trimmed &&
|
tail -n 7 <actual >actual.trimmed &&
|
||||||
@@ -540,7 +540,7 @@ test_expect_success 'goto hunk 1 with "g1"' '
|
|||||||
_10
|
_10
|
||||||
+15
|
+15
|
||||||
_20
|
_20
|
||||||
(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]?_
|
(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]?_
|
||||||
EOF
|
EOF
|
||||||
test_write_lines s y g1 | git add -p >actual &&
|
test_write_lines s y g1 | git add -p >actual &&
|
||||||
tail -n 4 <actual >actual.trimmed &&
|
tail -n 4 <actual >actual.trimmed &&
|
||||||
@@ -550,11 +550,11 @@ test_expect_success 'goto hunk 1 with "g1"' '
|
|||||||
test_expect_success 'navigate to hunk via regex /pattern' '
|
test_expect_success 'navigate to hunk via regex /pattern' '
|
||||||
test_when_finished "git reset" &&
|
test_when_finished "git reset" &&
|
||||||
tr _ " " >expect <<-EOF &&
|
tr _ " " >expect <<-EOF &&
|
||||||
(2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,p,?]? @@ -1,2 +1,3 @@
|
(2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,p,P,?]? @@ -1,2 +1,3 @@
|
||||||
_10
|
_10
|
||||||
+15
|
+15
|
||||||
_20
|
_20
|
||||||
(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]?_
|
(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]?_
|
||||||
EOF
|
EOF
|
||||||
test_write_lines s y /1,2 | git add -p >actual &&
|
test_write_lines s y /1,2 | git add -p >actual &&
|
||||||
tail -n 5 <actual >actual.trimmed &&
|
tail -n 5 <actual >actual.trimmed &&
|
||||||
@@ -567,7 +567,7 @@ test_expect_success 'navigate to hunk via regex / pattern' '
|
|||||||
_10
|
_10
|
||||||
+15
|
+15
|
||||||
_20
|
_20
|
||||||
(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]?_
|
(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]?_
|
||||||
EOF
|
EOF
|
||||||
test_write_lines s y / 1,2 | git add -p >actual &&
|
test_write_lines s y / 1,2 | git add -p >actual &&
|
||||||
tail -n 4 <actual >actual.trimmed &&
|
tail -n 4 <actual >actual.trimmed &&
|
||||||
@@ -579,11 +579,11 @@ test_expect_success 'print again the hunk' '
|
|||||||
tr _ " " >expect <<-EOF &&
|
tr _ " " >expect <<-EOF &&
|
||||||
+15
|
+15
|
||||||
20
|
20
|
||||||
(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]? @@ -1,2 +1,3 @@
|
(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]? @@ -1,2 +1,3 @@
|
||||||
10
|
10
|
||||||
+15
|
+15
|
||||||
20
|
20
|
||||||
(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]?_
|
(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]?_
|
||||||
EOF
|
EOF
|
||||||
test_write_lines s y g 1 p | git add -p >actual &&
|
test_write_lines s y g 1 p | git add -p >actual &&
|
||||||
tail -n 7 <actual >actual.trimmed &&
|
tail -n 7 <actual >actual.trimmed &&
|
||||||
@@ -595,11 +595,11 @@ test_expect_success TTY 'print again the hunk (PAGER)' '
|
|||||||
cat >expect <<-EOF &&
|
cat >expect <<-EOF &&
|
||||||
<GREEN>+<RESET><GREEN>15<RESET>
|
<GREEN>+<RESET><GREEN>15<RESET>
|
||||||
20<RESET>
|
20<RESET>
|
||||||
<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>
|
<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>
|
||||||
PAGER 10<RESET>
|
PAGER 10<RESET>
|
||||||
PAGER <GREEN>+<RESET><GREEN>15<RESET>
|
PAGER <GREEN>+<RESET><GREEN>15<RESET>
|
||||||
PAGER 20<RESET>
|
PAGER 20<RESET>
|
||||||
<BOLD;BLUE>(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]? <RESET>
|
<BOLD;BLUE>(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]? <RESET>
|
||||||
EOF
|
EOF
|
||||||
test_write_lines s y g 1 P |
|
test_write_lines s y g 1 P |
|
||||||
(
|
(
|
||||||
@@ -796,21 +796,21 @@ test_expect_success 'colors can be overridden' '
|
|||||||
<BLUE>+<RESET><BLUE>new<RESET>
|
<BLUE>+<RESET><BLUE>new<RESET>
|
||||||
<CYAN> more-context<RESET>
|
<CYAN> more-context<RESET>
|
||||||
<BLUE>+<RESET><BLUE>another-one<RESET>
|
<BLUE>+<RESET><BLUE>another-one<RESET>
|
||||||
<YELLOW>(1/1) Stage this hunk [y,n,q,a,d,s,e,p,?]? <RESET><BOLD>Split into 2 hunks.<RESET>
|
<YELLOW>(1/1) Stage this hunk [y,n,q,a,d,s,e,p,P,?]? <RESET><BOLD>Split into 2 hunks.<RESET>
|
||||||
<MAGENTA>@@ -1,3 +1,3 @@<RESET>
|
<MAGENTA>@@ -1,3 +1,3 @@<RESET>
|
||||||
<CYAN> context<RESET>
|
<CYAN> context<RESET>
|
||||||
<BOLD>-old<RESET>
|
<BOLD>-old<RESET>
|
||||||
<BLUE>+<RESET><BLUE>new<RESET>
|
<BLUE>+<RESET><BLUE>new<RESET>
|
||||||
<CYAN> more-context<RESET>
|
<CYAN> more-context<RESET>
|
||||||
<YELLOW>(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]? <RESET><MAGENTA>@@ -3 +3,2 @@<RESET>
|
<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>
|
||||||
<CYAN> more-context<RESET>
|
<CYAN> more-context<RESET>
|
||||||
<BLUE>+<RESET><BLUE>another-one<RESET>
|
<BLUE>+<RESET><BLUE>another-one<RESET>
|
||||||
<YELLOW>(2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,p,?]? <RESET><MAGENTA>@@ -1,3 +1,3 @@<RESET>
|
<YELLOW>(2/2) Stage this hunk [y,n,q,a,d,K,J,g,/,e,p,P,?]? <RESET><MAGENTA>@@ -1,3 +1,3 @@<RESET>
|
||||||
<CYAN> context<RESET>
|
<CYAN> context<RESET>
|
||||||
<BOLD>-old<RESET>
|
<BOLD>-old<RESET>
|
||||||
<BLUE>+new<RESET>
|
<BLUE>+new<RESET>
|
||||||
<CYAN> more-context<RESET>
|
<CYAN> more-context<RESET>
|
||||||
<YELLOW>(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]? <RESET>
|
<YELLOW>(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]? <RESET>
|
||||||
EOF
|
EOF
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
@@ -1424,9 +1424,9 @@ test_expect_success 'invalid option s is rejected' '
|
|||||||
test_write_lines j s q | git add -p >out &&
|
test_write_lines j s q | git add -p >out &&
|
||||||
sed -ne "s/ @@.*//" -e "s/ \$//" -e "/^(/p" <out >actual &&
|
sed -ne "s/ @@.*//" -e "s/ \$//" -e "/^(/p" <out >actual &&
|
||||||
cat >expect <<-EOF &&
|
cat >expect <<-EOF &&
|
||||||
(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,s,e,p,?]?
|
(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,s,e,p,P,?]?
|
||||||
(2/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]? Sorry, cannot split this hunk
|
(2/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]? Sorry, cannot split this hunk
|
||||||
(2/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,?]?
|
(2/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,e,p,P,?]?
|
||||||
EOF
|
EOF
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|||||||
Reference in New Issue
Block a user