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.