Merge branch 'rj/pager-die-upon-exec-failure'

When GIT_PAGER failed to spawn, depending on the code path taken,
we failed immediately (correct) or just spew the payload to the
standard output (incorrect).  The code now always fail immediately
when GIT_PAGER fails.

* rj/pager-die-upon-exec-failure:
  pager: die when paging to non-existing command
This commit is contained in:
Junio C Hamano 2024-07-08 14:53:08 -07:00
commit 4e18cd5ef7
2 changed files with 6 additions and 13 deletions

View File

@ -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 execute pager '%s'", pager);
/* original process continues, but writes to the pipe */
dup2(pager_process.in, 1);

View File

@ -725,18 +725,11 @@ test_expect_success TTY 'git discards pager non-zero exit without SIGPIPE' '
test_path_is_file pager-used
'
test_expect_success TTY 'git skips paging nonexisting command' '
test_when_finished "rm trace.normal" &&
test_expect_success TTY 'git errors when asked to execute nonexisting pager' '
test_when_finished "rm -f err" &&
test_config core.pager "does-not-exist" &&
GIT_TRACE2="$(pwd)/trace.normal" &&
export GIT_TRACE2 &&
test_when_finished "unset GIT_TRACE2" &&
test_terminal git log &&
grep child_exit trace.normal >child-exits &&
test_line_count = 1 child-exits &&
grep " code:-1 " child-exits
test_must_fail test_terminal git log 2>err &&
test_grep "unable to execute pager" err
'
test_expect_success TTY 'git returns SIGPIPE on propagated signals from pager' '
@ -762,7 +755,7 @@ test_expect_success TTY 'git returns SIGPIPE on propagated signals from pager' '
test_expect_success TTY 'non-existent pager doesnt cause crash' '
test_config pager.show invalid-pager &&
test_terminal git show
test_must_fail test_terminal git show
'
test_done