From: Dragan Simic <dsimic@manjaro.org>
To: "Rubén Justo" <rjusto@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
Phillip Wood <phillip.wood123@gmail.com>,
Git List <git@vger.kernel.org>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH v2 0/2] improve interactive-patch
Date: Fri, 29 Mar 2024 20:48:18 +0100 [thread overview]
Message-ID: <c9fc1de0f499a35d8dcc34666167050f@manjaro.org> (raw)
In-Reply-To: <c19f444c-f4ad-497b-a82d-4f6195b44fce@gmail.com>
On 2024-03-29 20:26, Rubén Justo wrote:
> On Tue, Mar 26, 2024 at 12:13:46PM -0700, Junio C Hamano wrote:
>> > On Tue, Mar 26, 2024 at 08:31:41AM -0700, Junio C Hamano wrote:
>> >
>> >> 'r'edisplay may work well (and I wonder "r | less" or
>> >> piping the hunk display to anything in general would be a useful
>> >> future enhancement).
>> >
>>
>> It would be more like tweaking fputs() of a strbuf that
>> was filled by render_hunk() to instead spawn a pager and feed the
>> same strbuf to it, or something. IOW, we already have the payload
>> to show. We just want a pager involved in its showing so that users
>> with a huge hunk that does not fit on a page can use "less" on it.
>
> I do not plan to address this in this series, but while the topic is
> warm; Perhaps?:
As a note, I find that having chunks displayed through the pager
would be really nice.
> --- >8 ---
> diff --git a/add-patch.c b/add-patch.c
> index 778f168298..cb74fe84f5 100644
> --- a/add-patch.c
> +++ b/add-patch.c
> @@ -5,6 +5,7 @@
> #include "environment.h"
> #include "gettext.h"
> #include "object-name.h"
> +#include "pager.h"
> #include "read-cache-ll.h"
> #include "repository.h"
> #include "strbuf.h"
> @@ -1450,7 +1451,7 @@ static int patch_update_file(struct add_p_state
> *s,
> if (file_diff->hunk_nr) {
> if (rendered_hunk_index != hunk_index) {
> render_hunk(s, hunk, 0, colored, &s->buf);
> - fputs(s->buf.buf, stdout);
> + fputs_to_pager(s->buf.buf);
> rendered_hunk_index = hunk_index;
> }
>
> diff --git a/pager.c b/pager.c
> index b8822a9381..f00fc87a67 100644
> --- a/pager.c
> +++ b/pager.c
> @@ -264,3 +264,30 @@ int check_pager_config(const char *cmd)
> pager_program = data.value;
> return data.want;
> }
> +
> +void fputs_to_pager(const char* s)
> +{
> + struct child_process process;
> + FILE* pager_stdin;
> + const char *pager = git_pager(isatty(1));
> +
> + if (!pager) {
> + fputs(s, stdout);
> + return;
> + }
> +
> + child_process_init(&process);
> +
> + prepare_pager_args(&pager_process, pager);
> + pager_process.in = -1;
> + strvec_push(&pager_process.env, "GIT_PAGER_IN_USE");
> + if (start_command(&pager_process))
> + return;
> +
> + pager_stdin = fdopen(pager_process.in, "w");
> + fputs(s, pager_stdin);
> + fflush(pager_stdin);
> +
> + close(pager_process.in);
> + finish_command(&pager_process);
> +}
> diff --git a/pager.h b/pager.h
> index b77433026d..dcccfa632b 100644
> --- a/pager.h
> +++ b/pager.h
> @@ -11,6 +11,7 @@ void term_clear_line(void);
> int decimal_width(uintmax_t);
> int check_pager_config(const char *cmd);
> void prepare_pager_args(struct child_process *, const char *pager);
> +void fputs_to_pager(const char* s);
>
> extern int pager_use_color;
next prev parent reply other threads:[~2024-03-29 19:48 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-25 20:59 [PATCH 0/2] improve interactive-patch Rubén Justo
2024-03-25 21:05 ` [PATCH 1/2] add-patch: introduce 'p' in interactive-patch Rubén Justo
2024-03-25 21:38 ` Junio C Hamano
2024-03-25 23:15 ` Rubén Justo
2024-03-25 23:42 ` Junio C Hamano
2024-03-25 21:07 ` [PATCH 2/2] add-patch: do not print hunks repeatedly Rubén Justo
2024-03-25 21:34 ` Junio C Hamano
2024-03-26 0:15 ` [PATCH v2 0/2] improve interactive-patch Rubén Justo
2024-03-26 0:17 ` [PATCH v2 1/2] add-patch: introduce 'p' in interactive-patch Rubén Justo
2024-03-26 14:38 ` Phillip Wood
2024-03-26 18:40 ` Rubén Justo
2024-03-27 10:55 ` Phillip Wood
2024-03-26 0:17 ` [PATCH v2 2/2] add-patch: do not print hunks repeatedly Rubén Justo
2024-03-26 14:39 ` Phillip Wood
2024-03-26 18:46 ` Rubén Justo
2024-03-27 11:06 ` Phillip Wood
2024-03-28 0:39 ` Rubén Justo
2024-03-26 14:37 ` [PATCH v2 0/2] improve interactive-patch Phillip Wood
2024-03-26 15:31 ` Junio C Hamano
2024-03-26 18:48 ` Rubén Justo
2024-03-26 19:13 ` Junio C Hamano
2024-03-26 20:26 ` Rubén Justo
2024-03-29 19:26 ` Rubén Justo
2024-03-29 19:48 ` Dragan Simic [this message]
2024-03-30 13:49 ` Rubén Justo
2024-03-30 17:06 ` Junio C Hamano
2024-03-27 11:14 ` Phillip Wood
2024-03-27 15:43 ` Junio C Hamano
2024-03-27 16:14 ` Phillip Wood
2024-03-28 1:03 ` Rubén Justo
2024-03-26 18:46 ` Rubén Justo
2024-03-28 1:10 ` [PATCH v3 " Rubén Justo
2024-03-28 1:12 ` [PATCH v3 1/2] add-patch: introduce 'p' in interactive-patch Rubén Justo
2024-03-28 14:45 ` Junio C Hamano
2024-03-28 1:12 ` [PATCH v3 2/2] add-patch: do not print hunks repeatedly Rubén Justo
2024-03-28 14:46 ` Junio C Hamano
2024-03-29 3:49 ` Rubén Justo
2024-03-29 3:56 ` [PATCH v4 0/2] improve interactive-patch Rubén Justo
2024-03-29 3:58 ` [PATCH v4 1/2] add-patch: introduce 'p' in interactive-patch Rubén Justo
2024-03-29 3:58 ` [PATCH v4 2/2] add-patch: do not print hunks repeatedly Rubén Justo
2024-03-29 10:41 ` phillip.wood123
2024-03-29 11:37 ` 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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c9fc1de0f499a35d8dcc34666167050f@manjaro.org \
--to=dsimic@manjaro.org \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=phillip.wood123@gmail.com \
--cc=rjusto@gmail.com \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).