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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 30, 2024, 17:06 UTC
Message-ID
<xmqqsf07lkef.fsf@gitster.g>
In-Reply-To
<c19f444c-f4ad-497b-a82d-4f6195b44fce@gmail.com>
Rubén Justo <rjusto@gmail.com> writes:
Show 12 quoted lines
> I do not plan to address this in this series, but while the topic is
> warm;  Perhaps?:
>
> --- >8 ---
> @@ -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;
>  			}

For this particular application, such a "I have the whole thing in core, send it to the pater" API might be sufficient, but it may not be usable if the existing code sends its output in pieces already.

I was envisioning an API more along the lines of
	/*
	 * pager control data structure
	 */
	struct pager_control;
	/*
	 * Start a pager, from now on, what we write to our fd #0
	 * and stdout are fed to the pager.  The function returns
	 * 0 on success, or -1 on failure.
	 */
	int redirect_fd_to_pager(struct pager_control *);
	/*
	 * We have written everything we want to write to the
	 * pager.  Tell the pager that we are done.  Wait until
	 * the end-user quits the pager and then give us control
	 * back.  The fd #0 and stdout are restored.
	 */
	int wait_for_pager(struct pager_control *);

so that any subpart of existing code can be enclosed inside the two calls, keep writing to fd#0/stdout as before, and we'd page only that part of the output from the program without changing anything else.

Previous: Rubén JustoNext: Phillip Wood
Message 26 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.