Re: [PATCH v3] sha1_file: pass empty buffer to index empty file
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 17, 2015, 17:37 UTC
- Message-ID
- <xmqqegmfds1n.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <1431806796-28902-1-git-send-email-gjthill@gmail.com>
Jim Hill <gjthill@gmail.com> writes:
> +test_expect_success "filter: smudge empty file" ' > + git config filter.empty-in-repo.clean true &&
But this one is correct but tricky ;-)
If the contents to be cleaned is small enough (i.e. the one-liner file used in this test) to fit in the pipe buffer and we feed the pipe before 'true' exits, we won't see any problem. Otherwise we may get SIGPIPE when we attempt to write to the 'true' (non-)filter, but because we explicitly ignore SIGPIPE, 'true' still is a "black hole" filter.
"cat >/dev/null" may have been a more naive and straight-forward way to write this "black hole" filter, but what you did is fine.
Show 9 quoted lines
> + git config filter.empty-in-repo.smudge "echo smudged && cat" && > + > + echo "empty-in-repo filter=empty-in-repo" >>.gitattributes && > + echo dead data walking >empty-in-repo && > + git add empty-in-repo && > + > + echo smudged >expected && > + git checkout-index --prefix=filtered- empty-in-repo && > + test_cmp expected filtered-empty-in-repo
This is also correct but tricky.
rm -f empty-in-repo && git checkout empty-in-repo
may have been more straight-forward, but this exercises the same codepath and perfectly fine.
Will queue and let's merge this to 'next' soonish.
Thanks.
> +' > + > test_done