diff options
| author | Michael Montalbo <mmontalbo@gmail.com> | 2026-07-06 05:01:58 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-07-06 13:27:00 -0700 |
| commit | be7112d1bb97a0f4c4d724484e8940193ab5366d (patch) | |
| tree | a3e9d1b74bea7e1256d2d86f4214a60cdfac9044 /git-commit-script | |
| parent | 47f79f619834acdd39d39bd1d3b33bf57f80d0a2 (diff) | |
t: add greplint to detect bare grep assertions
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>
Diffstat (limited to 'git-commit-script')
0 files changed, 0 insertions, 0 deletions
