git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 0/2] improve interactive-patch

From
DSDragan Simic <dsimic@manjaro.org>
Date
Mar 29, 2024, 19:48 UTC
Message-ID
<c9fc1de0f499a35d8dcc34666167050f@manjaro.org>
In-Reply-To
<c19f444c-f4ad-497b-a82d-4f6195b44fce@gmail.com>
On 2024-03-29 20:26, Rubén Justo wrote:
Show 16 quoted lines
> 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.

Show 69 quoted lines
> --- >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;
Previous: Rubén JustoNext: Rubén Justo
Message 24 of 42 in “improve interactive-patch”
  1. 0/2 improve interactive-patchRubén Justo, Mar 25, 2024
  2. 1/2 add-patch: introduce 'p' in interactive-patchRubén Justo, Mar 25, 2024
  3. Junio C HamanoMar 25, 2024
  4. Rubén JustoMar 25, 2024
  5. Junio C HamanoMar 25, 2024
  6. 2/2 add-patch: do not print hunks repeatedlyRubén Justo, Mar 25, 2024
  7. Junio C HamanoMar 25, 2024
  8. 0/2 improve interactive-patchRubén Justo, Mar 26, 2024
  9. 1/2 add-patch: introduce 'p' in interactive-patchRubén Justo, Mar 26, 2024
  10. Phillip WoodMar 26, 2024
  11. Rubén JustoMar 26, 2024
  12. Phillip WoodMar 27, 2024
  13. 2/2 add-patch: do not print hunks repeatedlyRubén Justo, Mar 26, 2024
  14. Phillip WoodMar 26, 2024
  15. Rubén JustoMar 26, 2024
  16. Phillip WoodMar 27, 2024
  17. Rubén JustoMar 28, 2024
  18. Phillip WoodMar 26, 2024
  19. Junio C HamanoMar 26, 2024
  20. Rubén JustoMar 26, 2024
  21. Junio C HamanoMar 26, 2024
  22. Rubén JustoMar 26, 2024
  23. Rubén JustoMar 29, 2024
  24. Dragan SimicMar 29, 2024
  25. Rubén JustoMar 30, 2024
  26. Junio C HamanoMar 30, 2024
  27. Phillip WoodMar 27, 2024
  28. Junio C HamanoMar 27, 2024
  29. Phillip WoodMar 27, 2024
  30. Rubén JustoMar 28, 2024
  31. Rubén JustoMar 26, 2024
  32. 0/2 improve interactive-patchRubén Justo, Mar 28, 2024
  33. 1/2 add-patch: introduce 'p' in interactive-patchRubén Justo, Mar 28, 2024
  34. Junio C HamanoMar 28, 2024
  35. 2/2 add-patch: do not print hunks repeatedlyRubén Justo, Mar 28, 2024
  36. Junio C HamanoMar 28, 2024
  37. Rubén JustoMar 29, 2024
  38. 0/2 improve interactive-patchRubén Justo, Mar 29, 2024
  39. 1/2 add-patch: introduce 'p' in interactive-patchRubén Justo, Mar 29, 2024
  40. 2/2 add-patch: do not print hunks repeatedlyRubén Justo, Mar 29, 2024
  41. phillip.wood123@gmail.comMar 29, 2024
  42. Rubén JustoMar 29, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.