On 12/07/2024 17:24, Rubén Justo wrote:
On Fri, Jul 12, 2024 at 02:26:22PM +0100, Phillip Wood wrote:
+test_expect_success TTY 'P does not break if pager ends unexpectly' '
+ test_when_finished "rm -f huge_file; git reset" &&
+ printf "%2500000s" Y >huge_file &&
+ git add -N huge_file &&
+ cat >expect <<-EOF &&
+ <GREEN>+<RESET><GREEN>22<RESET>
+ <GREEN>+<RESET><GREEN>23<RESET>
+ <GREEN>+<RESET><GREEN>24<RESET>
+ 30<RESET>
+ 40<RESET>
+ 50<RESET>
+ <BOLD;BLUE>(1/1) Stage this hunk [y,n,q,a,d,s,e,p,?]? <RESET>
+ EOF
+ test_write_lines P |
+ (
+ GIT_PAGER="head -1" &&
+ export GIT_PAGER &&
+ test_terminal git add -p >actual
+ ) &&
+ tail -n 7 <actual | test_decode_color >actual.trimmed &&
+ test_cmp expect actual.trimmed
+'
What is huge_file doing and what happens to the single line of pager output?
The huge file is to make sure we are receiving a SIGPIPE. We don't
really care about the line "head -1" produces, only that we don't
break due to the SIGPIPE that occurs.
As Junio said it would help to explain that. I'm still confused why we
don't see any output from the pager - shouldn't the pager print the hunk
header as it does in the example below?
Maybe a test like this would be clearer?
I think explaining in the commit message would be best.
Thanks
Phillip
test_expect_success TTY 'P does not break if pager ends unexpectedly' '
test_when_finished "rm -f huge_file; git reset" &&
printf "%2500000s\nfrotz\n" Y >huge_file &&
git add -N huge_file &&
cat >expect <<-EOF &&
<GREEN>+<RESET><GREEN>frotz<RESET>
<BOLD;BLUE>(1/1) Stage addition [y,n,q,a,d,e,p,?]? <RESET><CYAN>@@ -0,0 +1,2 @@<RESET>
<BOLD;BLUE>(1/1) Stage addition [y,n,q,a,d,e,p,?]? <RESET>
EOF
test_write_lines P q |
(
GIT_PAGER="head -1" &&
export GIT_PAGER &&
test_terminal git add -p >actual
) &&
tail -n 3 <actual | test_decode_color >actual.trimmed &&
test_cmp expect actual.trimmed
'
Thanks
Thank you.