On 17/07/2024 21:31, Junio C Hamano wrote:
phillip.wood123@xxxxxxxxx writes:
- test_write_lines P q | GIT_PAGER="head -n 1" test_terminal git add -p
+ test_write_lines P q |
+ (
+ GIT_PAGER="head -n 1" &&
+ export GIT_PAGER &&
+ test_terminal git add -p >actual
+ )
That's surprising, why does running git in a sub-shell stop it from
segfaulting?
Another difference besides the sub-shell is where the output from
test_terminal goes. If the above change fixes the issue for Rubén,
I wonder if it still works if ">actual" gets removed.
Yes that would be interesting to know. I do think we should be checking
the output here to make sure the test is doing what we think it is - all
we know at the moment is whether git exits successfully or not. If we
receive SIGPIPE then fputs() will see EPIPE which will set ferror()
which we should be clearing and checking that the prompt prints
correctly afterwards. I think it would be helpful to add
tail -n3 actual >actual.trimmed &&
cat >expect <<\EOF &&
\ No newline at end of file
(1/1) Stage addition [y,n,q,a,d,e,p,?]? @@ -0,0 +1,2 @@
(1/1) Stage addition [y,n,q,a,d,e,p,?]?
EOF
test_cmp expect actual.trimmed
to the test. That all still leaves me wondering about the segfault though
Best Wishes
Phillip