Re: [PATCH v2] sha1_file: pass empty buffer to index empty file
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 16, 2015, 18:48 UTC
- Message-ID
- <xmqqa8x4fjf5.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <20150515233153.GA4157@gadabout.domain.actdsltmp>
Jim Hill <gjthill@gmail.com> writes:
> So, so long as we're testing empty-file filters, I figured I'd add real > empty-file filter tests, I think that covers it. > > So is this better instead?
I wouldn't use "---in-repo-header--" as that extra string. Feeding anything that begins with '-' to 'echo' gives me portability worries for one thing. A single word "Extra" would suffice.
Be careful and consistent wrt redirection operator and its file; we do not write SP there but some of yours do and some others don't.
Do not attempt to align && with excess SPs; other tests don't.
Other than that, yeah, I think that is an improvement.
Thanks.
Show 48 quoted lines
> > diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh > index 5986bb0..fc2c644 100755 > --- a/t/t0021-conversion.sh > +++ b/t/t0021-conversion.sh > @@ -216,15 +216,33 @@ test_expect_success EXPENSIVE 'filter large file' ' > ! test -s err > ' > > -test_expect_success "filtering empty file should not produce complaints" ' > - echo "emptyfile filter=cat" >>.gitattributes && > - git config filter.cat.clean cat && > - git config filter.cat.smudge cat && > - git add . && > - git commit -m "cat filter for emptyfile" && > - > emptyfile && > - git add emptyfile 2>err && > - ! grep -Fiqs "bad file descriptor" err > +test_expect_success "filter: clean empty file" ' > + header=---in-repo-header--- && > + git config filter.in-repo-header.clean "echo $header && cat" && > + git config filter.in-repo-header.smudge "sed 1d" && > + > + echo "empty-in-worktree filter=in-repo-header" >>.gitattributes && > + > empty-in-worktree && > + > + echo $header > expected && > + git add empty-in-worktree && > + git show :empty-in-worktree > actual && > + test_cmp expected actual > +' > + > +test_expect_success "filter: smudge empty file" ' > + git config filter.empty-in-repo.smudge "echo smudge added line && cat" && > + git config filter.empty-in-repo.clean true && > + > + echo "empty-in-repo filter=empty-in-repo" >>.gitattributes && > + > + echo dead data walking > empty-in-repo && > + git add empty-in-repo && > + > + : > expected && > + git show :empty-in-repo > actual && > + test_cmp expected actual > ' > > test_done > +