Skip to content

Commit 0c4dd67

Browse files
committed
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 00b7cbf commit 0c4dd67

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

convert.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,14 @@ static int filter_buffer_or_fd(int in, int out, void *data)
356356
sigchain_push(SIGPIPE, SIG_IGN);
357357

358358
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;
360363
} else {
361364
write_err = copy_fd(params->fd, child_process.in);
365+
if (write_err == COPY_WRITE_ERROR && errno == EPIPE)
366+
write_err = 0;
362367
}
363368

364369
if (close(child_process.in))

t/t0021-conversion.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,16 @@ test_expect_success 'filtering large input to small output should use little mem
204204
GIT_MMAP_LIMIT=1m GIT_ALLOC_LIMIT=1m git add 30MB
205205
'
206206

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+
207217
test_expect_success EXPENSIVE 'filter large file' '
208218
git config filter.largefile.smudge cat &&
209219
git config filter.largefile.clean cat &&

0 commit comments

Comments
 (0)