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

Re: [PATCH v3 0/6] use the pager in 'add -p'

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 2, 2024, 17:11 UTC
Message-ID
<xmqqttib8e22.fsf@gitster.g>
In-Reply-To
<xmqqwmn79u98.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
> The 'g' and '/' commands take _mandatory_ arguments, but we do not
> even mention it in the help text.  But we need to say something for
> this new thing, because it is _optional_ and if you do not give a
> program, it does not ask.

By the way, although I personally do not have much sympathy to those who set it, in the presence of interactive.singleKey configuration variable, a command that takes optional argument may turn out to be a mistake, as the user cannot give the argument even if they wanted to, when the configuration variable is set to true. To help them, we'd probably need something like the following to allow them to optionally set their own program, like the following:

 1. read the command, notice that it begins with '|'.
 2. if it has <program> after it, call it <program> and jump to 5.
 3. if it does not have <program> after it, but if single key
    operation is in effect, give the user a chance to give <program>
    by prompting.  Call the answer to the prompt <program>.  If it
    is not an empty string, jump to 5.
 4. at this point, we have <program> that is empty as given by the
    user.  Replace the <program> with the value we remembered from
    step 6. during the last use of the '|' command.
 5. if <program> is all whitespace, replace it with an empty string.
 6. remember the value of <program> (so that you can reuse it next
    time the user says '|' and without <program>), and call the
    "set-custom-pager" thing with <program> (this design assumes
    that "set-custom-pager" thing uses the GIT_PAGER when fed an
    empty string).
 7. spawn the program set by "set-custom-pager", and feed our output
    to it.
So the end-user observable behaviour would become
 * There is the "default" program, initially their pager, but after
   they use the '|' command, we remember the last program they used
   during the session and reuse it when they tell us to do so.
 * For singlekey folks, typing '|' will give them a prompt.  They
   can give an empty string and spawn the "default" thing.  They can
   give " " plus <RET> to reset the "default" to GIT_PAGER and use
   it.  Or they can give <program> plus <RET> to use it and update
   the "default".
 * For the rest of us, typing "|" plus <RET> will spawn the
   "default" thing.  Typing "|<program>" plus <RET> will use the
   <program> and update the "default".  Typing "| " plus <RET> will
   reset the "default" to GIT_PAGER and use it.

which is quite straight-forward and consistent between the two camps.

Previous: Junio C HamanoNext: Rubén Justo
Message 55 of 113 in “use the pager in 'add -p'”
  1. 0/5 use the pager in 'add -p'Rubén Justo, May 19, 2024
  2. 1/5 add-patch: test for 'p' commandRubén Justo, May 19, 2024
  3. 2/5 pager: do not close fd 2 unnecessarilyRubén Justo, May 19, 2024
  4. Junio C HamanoMay 20, 2024
  5. Rubén JustoMay 20, 2024
  6. Junio C HamanoMay 21, 2024
  7. Rubén JustoMay 21, 2024
  8. Junio C HamanoMay 21, 2024
  9. Rubén JustoMay 22, 2024
  10. Junio C HamanoMay 22, 2024
  11. Rubén JustoMay 26, 2024
  12. Junio C HamanoMay 26, 2024
  13. 3/5 pager: introduce wait_for_pagerRubén Justo, May 19, 2024
  14. 4/5 test-terminal: introduce --no-stdin-ptyRubén Justo, May 19, 2024
  15. 5/5 add-patch: render hunks through the pagerRubén Justo, May 19, 2024
  16. Junio C HamanoMay 20, 2024
  17. Dragan SimicMay 20, 2024
  18. Rubén JustoMay 20, 2024
  19. Dragan SimicMay 20, 2024
  20. Rubén JustoMay 21, 2024
  21. Jeff KingMay 21, 2024
  22. Rubén JustoMay 21, 2024
  23. Jeff KingMay 23, 2024
  24. Junio C HamanoMay 23, 2024
  25. Dragan SimicMay 23, 2024
  26. Junio C HamanoMay 23, 2024
  27. Dragan SimicMay 23, 2024
  28. Dragan SimicMay 23, 2024
  29. Junio C HamanoMay 23, 2024
  30. Dragan SimicMay 23, 2024
  31. Jeff KingMay 25, 2024
  32. Rubén JustoMay 23, 2024
  33. Dragan SimicMay 23, 2024
  34. Rubén JustoMay 20, 2024
  35. Junio C HamanoMay 20, 2024
  36. Rubén JustoMay 20, 2024
  37. 0/5 use the pager in 'add -p'Rubén Justo, May 21, 2024
  38. 1/5 add-patch: test for 'p' commandRubén Justo, May 21, 2024
  39. 2/5 pager: do not close fd 2 unnecessarilyRubén Justo, May 21, 2024
  40. 3/5 pager: introduce wait_for_pagerRubén Justo, May 21, 2024
  41. 4/5 test-terminal: introduce --no-stdin-ptyRubén Justo, May 21, 2024
  42. 5/5 add-patch: render hunks through the pagerRubén Justo, May 21, 2024
  43. Dragan SimicMay 22, 2024
  44. Junio C HamanoMay 22, 2024
  45. Rubén JustoMay 22, 2024
  46. Dragan SimicMay 22, 2024
  47. 0/6 use the pager in 'add -p'Rubén Justo, Jun 2, 2024
  48. 1/6 add-patch: test for 'p' commandRubén Justo, Jun 2, 2024
  49. 2/6 pager: do not close fd 2 unnecessarilyRubén Justo, Jun 2, 2024
  50. 3/6 pager: introduce wait_for_pagerRubén Justo, Jun 2, 2024
  51. 4/6 pager: introduce setup_custom_pagerRubén Justo, Jun 2, 2024
  52. 5/6 test-terminal: introduce --no-stdin-ptyRubén Justo, Jun 2, 2024
  53. 6/6 add-patch: introduce the command '|'Rubén Justo, Jun 2, 2024
  54. Junio C HamanoJun 2, 2024
  55. Junio C HamanoJun 2, 2024
  56. Rubén JustoJun 2, 2024
  57. Rubén JustoJun 2, 2024
  58. Dragan SimicJun 2, 2024
  59. Junio C HamanoJun 3, 2024
  60. Dragan SimicJun 3, 2024
  61. Junio C HamanoJun 3, 2024
  62. Dragan SimicJun 4, 2024
  63. Dragan SimicJun 2, 2024
  64. Junio C HamanoJun 3, 2024
  65. Dragan SimicJun 4, 2024
  66. Dragan SimicJun 4, 2024
  67. Rubén JustoJun 3, 2024
  68. Dragan SimicJun 4, 2024
  69. 0/6 use the pager in 'add -p'Rubén Justo, Jun 3, 2024
  70. 1/6 add-patch: test for 'p' commandRubén Justo, Jun 3, 2024
  71. 2/6 pager: do not close fd 2 unnecessarilyRubén Justo, Jun 3, 2024
  72. Junio C HamanoJun 4, 2024
  73. 3/6 pager: introduce wait_for_pagerRubén Justo, Jun 3, 2024
  74. Phillip WoodJun 4, 2024
  75. Junio C HamanoJun 4, 2024
  76. Rubén JustoJun 5, 2024
  77. Junio C HamanoJun 4, 2024
  78. 4/6 pager: introduce setup_custom_pagerRubén Justo, Jun 3, 2024
  79. Junio C HamanoJun 4, 2024
  80. 5/6 test-terminal: introduce --no-stdin-ptyRubén Justo, Jun 3, 2024
  81. Phillip WoodJun 4, 2024
  82. Jeff KingJun 4, 2024
  83. Junio C HamanoJun 5, 2024
  84. Jeff KingJun 6, 2024
  85. Rubén JustoJun 5, 2024
  86. Jeff KingJun 6, 2024
  87. Rubén JustoJun 9, 2024
  88. 6/6 add-patch: introduce the command '|'Rubén Justo, Jun 3, 2024
  89. Junio C HamanoJun 4, 2024
  90. Dragan SimicJun 4, 2024
  91. Junio C HamanoJun 5, 2024
  92. Jeff KingJun 4, 2024
  93. Junio C HamanoJun 4, 2024
  94. Jeff KingJun 5, 2024
  95. Phillip WoodJun 5, 2024
  96. Dragan SimicJun 8, 2024
  97. Rubén JustoJun 9, 2024
  98. Dragan SimicJun 9, 2024
  99. Rubén JustoJun 10, 2024
  100. Dragan SimicJun 10, 2024
  101. Phillip WoodJun 10, 2024
  102. Junio C HamanoJun 10, 2024
  103. Rubén JustoJun 10, 2024
  104. Junio C HamanoJun 10, 2024
  105. Dragan SimicJun 10, 2024
  106. Dragan SimicJun 10, 2024
  107. Junio C HamanoJun 10, 2024
  108. Dragan SimicJun 10, 2024
  109. phillip.wood123@gmail.comJun 9, 2024
  110. Dragan SimicJun 9, 2024
  111. Phillip WoodJun 10, 2024
  112. Dragan SimicJun 10, 2024
  113. Junio C HamanoJun 5, 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.