From: phillip.wood123@gmail.com Date: Sat, 13 Jul 2024 13:17:49 GMT Subject: Re: [PATCH 4/4] add-patch: render hunks through the pager Message-ID: <9a2feb36-f8c4-4ea6-91a6-a3a24f359a6e@gmail.com> In-Reply-To: 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 && >>> + +22 >>> + +23 >>> + +24 >>> + 30 >>> + 40 >>> + 50 >>> + (1/1) Stage this hunk [y,n,q,a,d,s,e,p,?]? >>> + EOF >>> + test_write_lines P | >>> + ( >>> + GIT_PAGER="head -1" && >>> + export GIT_PAGER && >>> + test_terminal git add -p >actual >>> + ) && >>> + tail -n 7 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 && > +frotz > (1/1) Stage addition [y,n,q,a,d,e,p,?]? @@ -0,0 +1,2 @@ > (1/1) Stage addition [y,n,q,a,d,e,p,?]? > EOF > test_write_lines P q | > ( > GIT_PAGER="head -1" && > export GIT_PAGER && > test_terminal git add -p >actual > ) && > tail -n 3 actual.trimmed && > test_cmp expect actual.trimmed > ' > >> >> Thanks > > Thank you.