mirror of
https://github.com/git-for-windows/git.git
synced 2026-06-20 01:08:24 -05:00
Without a lint guard, bare grep assertions will creep back into tests over time, defeating the previous commit's conversion. Add greplint.pl to catch bare 'grep' used as a test assertion (where 'test_grep' should be used) and '! test_grep' (where 'test_grep !' should be used). greplint.pl reuses the shared shell parser from lib-shell-parser.pl to tokenize test bodies. The Lexer collapses heredocs, command substitutions, and quoted strings into single tokens, so 'grep' appearing inside these contexts is not flagged. A flat walk over the token stream tracks command position and pipeline state to distinguish assertion greps from filter greps. For double-quoted test bodies, a source-line walk counts backslash-continuation lines that the Lexer consumes without emitting into the body text, adjusting the reported line number accordingly. Add test fixtures in greplint/ (modeled on chainlint/) covering detection of bare grep assertions, correct skipping of filters, pipelines, redirects, command substitutions, and lint-ok annotations. Wire into the Makefile as: - test-greplint: runs greplint.pl on $(T) $(THELPERS) $(TPERF) - check-greplint: runs greplint.pl on fixtures, diffs against expected - clean-greplint: removes temp dir Add eol=lf entries in t/.gitattributes for greplint fixtures, matching chainlint, so that check-greplint passes on Windows where core.autocrlf would otherwise cause CRLF mismatches between expected and actual output. Signed-off-by: Michael Montalbo <mmontalbo@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
28 lines
572 B
Plaintext
28 lines
572 B
Plaintext
t[0-9][0-9][0-9][0-9]/* -whitespace
|
|
/chainlint/*.expect eol=lf -whitespace
|
|
/greplint/*.expect eol=lf -whitespace
|
|
/greplint/*.test eol=lf -whitespace
|
|
/t0110/url-* binary
|
|
/t3206/* eol=lf
|
|
/t3900/*.txt eol=lf
|
|
/t3901/*.txt eol=lf
|
|
/t4013/* eol=lf
|
|
/t4018/* eol=lf
|
|
/t4034/*/* eol=lf
|
|
/t4051/* eol=lf
|
|
/t4100/* eol=lf
|
|
/t4101/* eol=lf
|
|
/t4109/* eol=lf
|
|
/t4110/* eol=lf
|
|
/t4135/* eol=lf
|
|
/t4211/* eol=lf
|
|
/t4252/* eol=lf
|
|
/t4256/1/* eol=lf
|
|
/t5100/* eol=lf
|
|
/t5515/* eol=lf
|
|
/t556x_common eol=lf
|
|
/t7500/* eol=lf
|
|
/t8005/*.txt eol=lf
|
|
/t9*/*.dump eol=lf
|
|
/t0040*.sh whitespace=-indent-with-non-tab
|