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

[PATCH v2 0/4] use the pager in 'add -p'

From
Rubén Justo <rjusto@gmail.com>
Date
Jul 13, 2024, 16:26 UTC
Message-ID
<ebcba08f-3fbb-4130-93eb-d0e62bfe0a8a@gmail.com>
In-Reply-To
<2653fb37-c8a8-49b1-a804-4be6654a2cad@gmail.com>
Rubén Justo (4):
  add-patch: test for 'p' command
  pager: do not close fd 2 unnecessarily
  pager: introduce wait_for_pager
  add-patch: render hunks through the pager
 add-patch.c                | 18 ++++++++++++---
 pager.c                    | 45 +++++++++++++++++++++++++++++++++-----
 pager.h                    |  1 +
 t/t3701-add-interactive.sh | 44 +++++++++++++++++++++++++++++++++++++
 4 files changed, 100 insertions(+), 8 deletions(-)
Range-diff against v1:
1:  4a5b6e6815 = 1:  6b37507ddd add-patch: test for 'p' command
2:  bf8a68ac37 = 2:  5497fa020b pager: do not close fd 2 unnecessarily
3:  aabd7da4d6 = 3:  30e772cf7c pager: introduce wait_for_pager
4:  ff51cc32bd ! 4:  f7cb00b654 add-patch: render hunks through the pager
    @@ Metadata
      ## Commit message ##
         add-patch: render hunks through the pager
     
    -    Make the print command to trigger the pager when invoked using a capital
    +    Make the print command trigger the pager when invoked using a capital
         'P', to make it easier for the user to review long hunks.
     
    +    Note that if the PAGER ends unexpectedly before we've been able to send
    +    the payload, perhaps because the user is not interested in the whole
    +    thing, we might receive a SIGPIPE, which would abruptly and unexpectedly
    +    terminate the interactive session for the user.
    +
    +    Therefore, we need to ignore a possible SIGPIPE signal.  Add a test for
    +    this, in addition to the test for normal operation.
    +
    +    For the SIGPIPE test, we need to make sure that we completely fill the
    +    operating system's buffer, otherwise we might not trigger the SIGPIPE
    +    signal.  The normal size of this buffer in different OSs varies from a
    +    few KBs to 1MB.  Use a payload large enough to guarantee that we exceed
    +    this limit.
    +
         Signed-off-by: Rubén Justo <rjusto@gmail.com>
     
      ## add-patch.c ##
    @@ t/t3701-add-interactive.sh: test_expect_success 'print again the hunk' '
     +	test_cmp expect actual.trimmed
     +'
     +
    -+test_expect_success TTY 'P does not break if pager ends unexpectly' '
    ++test_expect_success TTY 'P does not break if pager ends unexpectedly' '
     +	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
    ++	test_write_lines P q | GIT_PAGER="head -c 1" test_terminal git add -p >actual
     +'
     +
      test_expect_success 'split hunk "add -p (edit)"' '
-- 
2.45.2.831.g9e4974e3d4
Previous: Dragan SimicNext: Rubén Justo
Message 15 of 69 in “use the pager in 'add -p'”
  1. 0/4 use the pager in 'add -p'Rubén Justo, Jul 12, 2024
  2. 1/4 add-patch: test for 'p' commandRubén Justo, Jul 12, 2024
  3. 2/4 pager: do not close fd 2 unnecessarilyRubén Justo, Jul 12, 2024
  4. 3/4 pager: introduce wait_for_pagerRubén Justo, Jul 12, 2024
  5. Phillip WoodJul 12, 2024
  6. 4/4 add-patch: render hunks through the pagerRubén Justo, Jul 12, 2024
  7. Dragan SimicJul 12, 2024
  8. Phillip WoodJul 12, 2024
  9. Rubén JustoJul 12, 2024
  10. Rubén JustoJul 13, 2024
  11. Junio C HamanoJul 13, 2024
  12. phillip.wood123@gmail.comJul 13, 2024
  13. Rubén JustoJul 13, 2024
  14. Dragan SimicJul 12, 2024
  15. 0/4 use the pager in 'add -p'Rubén Justo, Jul 13, 2024
  16. 1/4 add-patch: test for 'p' commandRubén Justo, Jul 13, 2024
  17. 2/4 pager: do not close fd 2 unnecessarilyRubén Justo, Jul 13, 2024
  18. 3/4 pager: introduce wait_for_pagerRubén Justo, Jul 13, 2024
  19. 4/4 add-patch: render hunks through the pagerRubén Justo, Jul 13, 2024
  20. Junio C HamanoJul 13, 2024
  21. Rubén JustoJul 13, 2024
  22. Junio C HamanoJul 14, 2024
  23. 0/4 use the pager in 'add -p'Rubén Justo, Jul 14, 2024
  24. 1/4 add-patch: test for 'p' commandRubén Justo, Jul 14, 2024
  25. 2/4 pager: do not close fd 2 unnecessarilyRubén Justo, Jul 14, 2024
  26. 4/4 add-patch: render hunks through the pagerRubén Justo, Jul 14, 2024
  27. Phillip WoodJul 15, 2024
  28. Junio C HamanoJul 15, 2024
  29. Rubén JustoJul 17, 2024
  30. phillip.wood123@gmail.comJul 17, 2024
  31. Junio C HamanoJul 17, 2024
  32. Eric SunshineJul 17, 2024
  33. Junio C HamanoJul 17, 2024
  34. Rubén JustoJul 20, 2024
  35. Eric SunshineJul 22, 2024
  36. Rubén JustoJul 22, 2024
  37. phillip.wood123@gmail.comJul 18, 2024
  38. Junio C HamanoJul 17, 2024
  39. phillip.wood123@gmail.comJul 18, 2024
  40. Rubén JustoJul 20, 2024
  41. Rubén JustoJul 20, 2024
  42. Phillip WoodJul 22, 2024
  43. Rubén JustoJul 22, 2024
  44. Junio C HamanoJul 22, 2024
  45. Rubén JustoJul 22, 2024
  46. Junio C HamanoJul 22, 2024
  47. Re* [PATCH v3 4/4] add-patch: render hunks through the pagerJunio C Hamano, Jul 22, 2024
  48. Rubén JustoJul 22, 2024
  49. Kyle LippincottJul 22, 2024
  50. Junio C HamanoJul 22, 2024
  51. Junio C HamanoJul 23, 2024
  52. Junio C HamanoJul 22, 2024
  53. Rubén JustoJul 22, 2024
  54. 1/2 t3701: avoid one-shot export for shell functionsRubén Justo, Jul 22, 2024
  55. Junio C HamanoJul 22, 2024
  56. Junio C HamanoJul 22, 2024
  57. 2/2 pager: make wait_for_pager a no-op for "cat"Rubén Justo, Jul 22, 2024
  58. Junio C HamanoJul 22, 2024
  59. phillip.wood123@gmail.comJul 18, 2024
  60. Rubén JustoJul 20, 2024
  61. 3/4 pager: introduce wait_for_pagerRubén Justo, Jul 14, 2024
  62. Phillip WoodJul 15, 2024
  63. Rubén JustoJul 15, 2024
  64. phillip.wood123@gmail.comJul 17, 2024
  65. 0/4 add-patch: render hunks through the pagerRubén Justo, Jul 15, 2024
  66. 1/4 add-patch: test for 'p' commandRubén Justo, Jul 15, 2024
  67. 2/4 pager: do not close fd 2 unnecessarilyRubén Justo, Jul 15, 2024
  68. 3/4 pager: introduce wait_for_pagerRubén Justo, Jul 15, 2024
  69. 4/4 add-patch: render hunks through the pagerRubén Justo, Jul 15, 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.