filter_buffer_or_fd(): ignore EPIPE

We are explicitly ignoring SIGPIPE, as we fully expect that the filter program may not read our output fully. Ignore EPIPE that may come from writing to it as well. A new test was stolen from Jeff's suggestion. Helped-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed May 19, 2015 at 11:08 UTC 0c4dd67a048b39470b9b95912e4912fecc405a85
2 files changed +16 -1
convert.c
+6 -1
@@ -356,9 +356,14 @@ static int filter_buffer_or_fd(int in, int out, void *data)
356 sigchain_push(SIGPIPE, SIG_IGN);
357
358 if (params->src) {
359 - write_err = (write_in_full(child_process.in, params->src, params->size) < 0);
359 + write_err = (write_in_full(child_process.in,
360 + params->src, params->size) < 0);
361 + if (errno == EPIPE)
362 + write_err = 0;
363 } else {
364 write_err = copy_fd(params->fd, child_process.in);
365 + if (write_err == COPY_WRITE_ERROR && errno == EPIPE)
366 + write_err = 0;
367 }
368
369 if (close(child_process.in))
t/t0021-conversion.sh
+10
@@ -204,6 +204,16 @@ test_expect_success 'filtering large input to small output should use little mem
204 GIT_MMAP_LIMIT=1m GIT_ALLOC_LIMIT=1m git add 30MB
205 '
206
207 +test_expect_success 'filter that does not read is fine' '
208 + test-genrandom foo $((128 * 1024 + 1)) >big &&
209 + echo "big filter=epipe" >.gitattributes &&
210 + git config filter.epipe.clean "echo xyzzy" &&
211 + git add big &&
212 + git cat-file blob :big >actual &&
213 + echo xyzzy >expect &&
214 + test_cmp expect actual
215 +'
216 +
217 test_expect_success EXPENSIVE 'filter large file' '
218 git config filter.largefile.smudge cat &&
219 git config filter.largefile.clean cat &&