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

Re: [PATCH] pager: die when paging to non-existing command

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 20, 2024, 19:04 UTC
Message-ID
<xmqqsex7tp0c.fsf@gitster.g>
In-Reply-To
<f7106878-5ec5-4fe7-940b-2fb1d9707f7d@gmail.com>
Rubén Justo <rjusto@gmail.com> writes:
Show 7 quoted lines
> Finally, it's worth noting that we are not changing the behavior if the
> command specified in GIT_PAGER is a shell command.  In such cases, it
> is:
>
>     $ GIT_PAGER=:\;non-existent t/test-terminal.perl git log
>     :;non-existent: 1: non-existent: not found
>     died of signal 13 at t/test-terminal.perl line 33.

IOW, the behaviours between the case where pager is spawned via the shell and bypassing the shell are different , and the case where the shell is involved behaves in a way that is easier to realize the mistake, so change the other case to match. WHich makes sense.

This seems to be an ancient regression introduced in bfdd9ffd (Windows: Make the pager work., 2007-12-08), which did not really affect anybody but MinGW users, but ea27a18c (spawn pager via run_command interface, 2008-07-22) inherited the "if we failed to start the pager, just silently return" from it when non-MinGW code was unified to use the run_command() codepath (the latter is attributed to Peff, which I presume is the reason why you cc'ed him?).

Show 16 quoted lines
> Signed-off-by: Rubén Justo <rjusto@gmail.com>
> ---
>  pager.c          |  2 +-
>  t/t7006-pager.sh | 15 +++------------
>  2 files changed, 4 insertions(+), 13 deletions(-)
>
> diff --git a/pager.c b/pager.c
> index e9e121db69..e4291cd0aa 100644
> --- a/pager.c
> +++ b/pager.c
> @@ -137,7 +137,7 @@ void setup_pager(void)
>  	pager_process.in = -1;
>  	strvec_push(&pager_process.env, "GIT_PAGER_IN_USE");
>  	if (start_command(&pager_process))
> -		return;
> +		die("unable to start the pager: '%s'", pager);

If this error string is not used elsewhere, it probably is a good idea to "revert" to the original error message lost by ea27a18c, which was:

		die("unable to execute pager '%s'", pager);
But I do not think of a reason why we want to avoid dying here.

Just in case there is a reason why we should instead silently return on MinGW, I'll Cc the author of bfdd9ffd, though.

Will queue.  Thanks.
Previous: Rubén JustoNext: Rubén Justo
Message 2 of 17 in “pager: die when paging to non-existing command”
  1. pager: die when paging to non-existing commandRubén Justo, Jun 20, 2024
  2. Junio C HamanoJun 20, 2024
  3. Rubén JustoJun 20, 2024
  4. Junio C HamanoJun 20, 2024
  5. Johannes SixtJun 20, 2024
  6. Junio C HamanoJun 20, 2024
  7. Jeff KingJun 21, 2024
  8. Dragan SimicJun 21, 2024
  9. Johannes SchindelinJun 24, 2024
  10. Phillip WoodJun 21, 2024
  11. Junio C HamanoJun 21, 2024
  12. Jeff KingJun 21, 2024
  13. Rubén JustoJun 21, 2024
  14. pager: die when paging to non-existing commandRubén Justo, Jun 21, 2024
  15. pager: die when paging to non-existing commandRubén Justo, Jun 21, 2024
  16. Johannes SixtJun 22, 2024
  17. pager: die when paging to non-existing commandRubén Justo, Jun 23, 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.