From: "Rubén Justo" <rjusto@gmail.com>
To: phillip.wood@dunelm.org.uk, Git List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>,
Dragan Simic <dsimic@manjaro.org>, Jeff King <peff@peff.net>
Subject: Re: [PATCH 4/4] add-patch: render hunks through the pager
Date: Sun, 14 Jul 2024 08:13:13 +0900 [thread overview]
Message-ID: <2ebcbe5e-a673-40ae-8326-65280dd6b18f@gmail.com> (raw)
In-Reply-To: <9a2feb36-f8c4-4ea6-91a6-a3a24f359a6e@gmail.com>
On Sat, Jul 13, 2024 at 02:17:49PM +0100, phillip.wood123@gmail.com wrote:
> 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?
> >
> [...]
>
> 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?
In the test above, we would need to use "tail -n 18" to capture the
header of the hunk.
In the test below, the "q" allows "tail -n 3" to capture it.
> > 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
> > '
I wonder if the following would be desirable:
--- a/add-patch.c
+++ b/add-patch.c
@@@ -1519,8 -1519,8 +1519,10 @@@ static int patch_update_file(struct add
if (*s->s.reset_color)
fputs(s->s.reset_color, stdout);
fflush(stdout);
-- if (read_single_character(s) == EOF)
++ if (read_single_character(s) == EOF) {
++ quit = 1;
break;
++ }
if (!s->answer.len)
continue;
next prev parent reply other threads:[~2024-07-13 23:13 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-12 0:57 [PATCH 0/4] use the pager in 'add -p' Rubén Justo
2024-07-12 1:00 ` [PATCH 1/4] add-patch: test for 'p' command Rubén Justo
2024-07-12 1:00 ` [PATCH 2/4] pager: do not close fd 2 unnecessarily Rubén Justo
2024-07-12 1:00 ` [PATCH 3/4] pager: introduce wait_for_pager Rubén Justo
2024-07-12 13:17 ` Phillip Wood
2024-07-12 1:00 ` [PATCH 4/4] add-patch: render hunks through the pager Rubén Justo
2024-07-12 8:58 ` Dragan Simic
2024-07-12 13:26 ` Phillip Wood
2024-07-12 16:24 ` Rubén Justo
2024-07-13 3:23 ` Rubén Justo
2024-07-13 9:12 ` Junio C Hamano
2024-07-13 13:17 ` phillip.wood123
2024-07-13 23:13 ` Rubén Justo [this message]
2024-07-12 8:56 ` [PATCH 0/4] use the pager in 'add -p' Dragan Simic
2024-07-13 16:26 ` [PATCH v2 " Rubén Justo
2024-07-13 16:29 ` [PATCH v2 1/4] add-patch: test for 'p' command Rubén Justo
2024-07-13 16:29 ` [PATCH v2 2/4] pager: do not close fd 2 unnecessarily Rubén Justo
2024-07-13 16:29 ` [PATCH v2 3/4] pager: introduce wait_for_pager Rubén Justo
2024-07-13 16:30 ` [PATCH v2 4/4] add-patch: render hunks through the pager Rubén Justo
2024-07-13 17:08 ` [PATCH v2 0/4] use the pager in 'add -p' Junio C Hamano
2024-07-13 23:21 ` Rubén Justo
2024-07-14 1:18 ` Junio C Hamano
2024-07-14 16:00 ` [PATCH v3 " Rubén Justo
2024-07-14 16:04 ` [PATCH v3 1/4] add-patch: test for 'p' command Rubén Justo
2024-07-14 16:04 ` [PATCH v3 2/4] pager: do not close fd 2 unnecessarily Rubén Justo
2024-07-14 16:04 ` [PATCH v3 4/4] add-patch: render hunks through the pager Rubén Justo
2024-07-15 14:10 ` Phillip Wood
2024-07-15 23:54 ` Junio C Hamano
2024-07-17 17:20 ` Rubén Justo
2024-07-17 19:39 ` phillip.wood123
2024-07-17 20:03 ` Junio C Hamano
2024-07-17 20:09 ` Eric Sunshine
2024-07-17 20:21 ` Junio C Hamano
2024-07-20 22:37 ` Rubén Justo
2024-07-22 7:18 ` Eric Sunshine
2024-07-22 14:53 ` Rubén Justo
2024-07-18 9:48 ` phillip.wood123
2024-07-17 20:31 ` Junio C Hamano
2024-07-18 9:56 ` phillip.wood123
2024-07-20 22:39 ` Rubén Justo
2024-07-20 22:29 ` Rubén Justo
2024-07-22 10:18 ` Phillip Wood
2024-07-22 16:45 ` Rubén Justo
2024-07-22 17:22 ` Junio C Hamano
2024-07-22 19:06 ` Rubén Justo
2024-07-22 19:27 ` Junio C Hamano
2024-07-22 21:06 ` Re* " Junio C Hamano
2024-07-22 22:00 ` Rubén Justo
2024-07-22 23:12 ` Kyle Lippincott
2024-07-22 23:28 ` Junio C Hamano
2024-07-23 2:31 ` Junio C Hamano
2024-07-22 21:25 ` Junio C Hamano
2024-07-22 23:20 ` Rubén Justo
2024-07-22 23:24 ` [PATCH 1/2] t3701: avoid one-shot export for shell functions Rubén Justo
2024-07-22 23:44 ` Junio C Hamano
2024-07-22 23:57 ` Junio C Hamano
2024-07-22 23:24 ` [PATCH 2/2] pager: make wait_for_pager a no-op for "cat" Rubén Justo
2024-07-22 23:54 ` Junio C Hamano
2024-07-18 9:58 ` [PATCH v3 4/4] add-patch: render hunks through the pager phillip.wood123
2024-07-20 22:45 ` Rubén Justo
2024-07-14 16:04 ` [PATCH v3 3/4] pager: introduce wait_for_pager Rubén Justo
2024-07-15 14:13 ` Phillip Wood
2024-07-15 20:04 ` Rubén Justo
2024-07-17 14:58 ` phillip.wood123
2024-07-15 20:16 ` [PATCH v4 0/4] add-patch: render hunks through the pager Rubén Justo
2024-07-15 20:20 ` [PATCH v4 1/4] add-patch: test for 'p' command Rubén Justo
2024-07-15 20:21 ` [PATCH v4 2/4] pager: do not close fd 2 unnecessarily Rubén Justo
2024-07-15 20:21 ` [PATCH v4 3/4] pager: introduce wait_for_pager Rubén Justo
2024-07-15 20:22 ` [PATCH v4 4/4] add-patch: render hunks through the pager Rubén Justo
-- strict thread matches above, loose matches on Subject: below --
2024-07-23 0:39 [PATCH v2 0/2] add-p P fixups Rubén Justo
2024-07-23 9:15 ` Phillip Wood
2024-07-23 22:08 ` Rubén Justo
2024-07-24 15:21 ` phillip.wood123
2024-07-24 16:12 ` Rubén Justo
2024-07-25 9:45 ` Phillip Wood
2024-07-25 12:16 ` Rubén Justo
2024-07-25 13:42 ` [PATCH 0/4] squash fixups in rj/add-p-pager Rubén Justo
2024-07-25 13:44 ` [PATCH 4/4] add-patch: render hunks through the pager Rubén Justo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2ebcbe5e-a673-40ae-8326-65280dd6b18f@gmail.com \
--to=rjusto@gmail.com \
--cc=dsimic@manjaro.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
--cc=phillip.wood@dunelm.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).