Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> writes: > Add a helper function to make the tests which check for patterns with > \0 in them more succinct. Right now this isn't a big win, but > subsequent commits will add a lot more of these tests. > > The helper is based on the match() function in t3070-wildmatch.sh. > > Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> > --- > t/t7008-grep-binary.sh | 58 +++++++++++++++++++++++++------------------------- > 1 file changed, 29 insertions(+), 29 deletions(-) > > diff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh > index 9c9c378119..6c1952eafa 100755 > --- a/t/t7008-grep-binary.sh > +++ b/t/t7008-grep-binary.sh > @@ -4,6 +4,29 @@ test_description='git grep in binary files' > > . ./test-lib.sh > > +nul_match() { Micronit: "nul_match () {" > + status=$1 > + flags=$2 > + pattern=$3 > + pattern_human=$(echo $pattern | sed 's/Q/<NUL>/g') Double quote around "$pattern"? > + > + if test $status = "1" Double quote around "$status" and drop double quote around "1" (which is clearly a literal string without any funnies) instead? > + then > + test_expect_success "git grep -f f $flags '$pattern_human' a" " > + printf '$pattern' | q_to_nul >f && > + git grep -f f $flags a > + " > + elif test $status = "0" > + then > + test_expect_success "git grep -f f $flags '$pattern_human' a" " > + printf '$pattern' | q_to_nul >f && > + test_must_fail git grep -f f $flags a > + " It somehow was unintuitive that 0 expected failure and 1 expected success, but it probably was just me.