@@ -656,4 +656,134 @@ test_expect_success TTY 'git tag with auto-columns ' '
656656 test_cmp expect actual
657657'
658658
659+ test_expect_success ' setup trace2' '
660+ GIT_TRACE2_BRIEF=1 &&
661+ export GIT_TRACE2_BRIEF
662+ '
663+
664+ test_expect_success TTY ' git returns SIGPIPE on early pager exit' '
665+ test_when_finished "rm pager-used trace.normal" &&
666+ test_config core.pager ">pager-used; head -n 1; exit 0" &&
667+ GIT_TRACE2="$(pwd)/trace.normal" &&
668+ export GIT_TRACE2 &&
669+ test_when_finished "unset GIT_TRACE2" &&
670+
671+ if test_have_prereq !MINGW
672+ then
673+ OUT=$( ((test_terminal git log; echo $? 1>&3) | :) 3>&1 ) &&
674+ test_match_signal 13 "$OUT"
675+ else
676+ test_terminal git log
677+ fi &&
678+
679+ grep child_exit trace.normal >child-exits &&
680+ test_line_count = 1 child-exits &&
681+ grep " code:0 " child-exits &&
682+ test_path_is_file pager-used
683+ '
684+
685+ test_expect_success TTY ' git returns SIGPIPE on early pager non-zero exit' '
686+ test_when_finished "rm pager-used trace.normal" &&
687+ test_config core.pager ">pager-used; head -n 1; exit 1" &&
688+ GIT_TRACE2="$(pwd)/trace.normal" &&
689+ export GIT_TRACE2 &&
690+ test_when_finished "unset GIT_TRACE2" &&
691+
692+ if test_have_prereq !MINGW
693+ then
694+ OUT=$( ((test_terminal git log; echo $? 1>&3) | :) 3>&1 ) &&
695+ test_match_signal 13 "$OUT"
696+ else
697+ test_terminal git log
698+ fi &&
699+
700+ grep child_exit trace.normal >child-exits &&
701+ test_line_count = 1 child-exits &&
702+ grep " code:1 " child-exits &&
703+ test_path_is_file pager-used
704+ '
705+
706+ test_expect_success TTY ' git discards pager non-zero exit without SIGPIPE' '
707+ test_when_finished "rm pager-used trace.normal" &&
708+ test_config core.pager "wc >pager-used; exit 1" &&
709+ GIT_TRACE2="$(pwd)/trace.normal" &&
710+ export GIT_TRACE2 &&
711+ test_when_finished "unset GIT_TRACE2" &&
712+
713+ if test_have_prereq !MINGW
714+ then
715+ OUT=$( ((test_terminal git log; echo $? 1>&3) | :) 3>&1 ) &&
716+ test "$OUT" -eq 0
717+ else
718+ test_terminal git log
719+ fi &&
720+
721+ grep child_exit trace.normal >child-exits &&
722+ test_line_count = 1 child-exits &&
723+ grep " code:1 " child-exits &&
724+ test_path_is_file pager-used
725+ '
726+
727+ test_expect_success TTY ' git discards nonexisting pager without SIGPIPE' '
728+ test_when_finished "rm pager-used trace.normal" &&
729+ test_config core.pager "wc >pager-used; does-not-exist" &&
730+ GIT_TRACE2="$(pwd)/trace.normal" &&
731+ export GIT_TRACE2 &&
732+ test_when_finished "unset GIT_TRACE2" &&
733+
734+ if test_have_prereq !MINGW
735+ then
736+ OUT=$( ((test_terminal git log; echo $? 1>&3) | :) 3>&1 ) &&
737+ test "$OUT" -eq 0
738+ else
739+ test_terminal git log
740+ fi &&
741+
742+ grep child_exit trace.normal >child-exits &&
743+ test_line_count = 1 child-exits &&
744+ grep " code:127 " child-exits &&
745+ test_path_is_file pager-used
746+ '
747+
748+ test_expect_success TTY ' git attempts to page to nonexisting pager command, gets SIGPIPE' '
749+ test_when_finished "rm trace.normal" &&
750+ test_config core.pager "does-not-exist" &&
751+ GIT_TRACE2="$(pwd)/trace.normal" &&
752+ export GIT_TRACE2 &&
753+ test_when_finished "unset GIT_TRACE2" &&
754+
755+ if test_have_prereq !MINGW
756+ then
757+ OUT=$( ((test_terminal git log; echo $? 1>&3) | :) 3>&1 ) &&
758+ test_match_signal 13 "$OUT"
759+ else
760+ test_terminal git log
761+ fi &&
762+
763+ grep child_exit trace.normal >child-exits &&
764+ test_line_count = 1 child-exits &&
765+ grep " code:-1 " child-exits
766+ '
767+
768+ test_expect_success TTY ' git returns SIGPIPE on propagated signals from pager' '
769+ test_when_finished "rm pager-used trace.normal" &&
770+ test_config core.pager ">pager-used; test-tool sigchain" &&
771+ GIT_TRACE2="$(pwd)/trace.normal" &&
772+ export GIT_TRACE2 &&
773+ test_when_finished "unset GIT_TRACE2" &&
774+
775+ if test_have_prereq !MINGW
776+ then
777+ OUT=$( ((test_terminal git log; echo $? 1>&3) | :) 3>&1 ) &&
778+ test_match_signal 13 "$OUT"
779+ else
780+ test_terminal git log
781+ fi &&
782+
783+ grep child_exit trace.normal >child-exits &&
784+ test_line_count = 1 child-exits &&
785+ grep " code:143 " child-exits &&
786+ test_path_is_file pager-used
787+ '
788+
659789test_done
0 commit comments