git/t/chainlint/loop-detect-failure.expect
Eric Sunshine e44f15ba3e chainlint: make error messages self-explanatory
The annotations emitted by chainlint to indicate detected problems are
overly terse, so much so that developers new to the project -- those who
should most benefit from the linting -- may find them baffling. For
instance, although the author of chainlint and seasoned Git developers
may understand that "?!AMP?!" is an abbreviation of "ampersand" and
indicates a break in the &&-chain, this may not be obvious to newcomers.

The "?!LOOP?!" case is particularly serious because that terse single
word does nothing to convey that the loop body should end with
"|| return 1" (or "|| exit 1" in a subshell) to ensure that a failing
command in the body aborts the loop immediately. Moreover, unlike
&&-chaining which is ubiquitous in Git tests, the "|| return 1" idiom is
relatively infrequent, thus may be harder for a newcomer to discover by
consulting nearby code.

Address these shortcomings by emitting human-readable messages which
both explain the problem and give a strong hint about how to correct it.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-09-10 10:01:40 -07:00

15 lines
352 B
Text

2 git init r1 &&
3 for n in 1 2 3 4 5
4 do
5 echo "This is file: $n" > r1/file.$n &&
6 git -C r1 add file.$n &&
7 git -C r1 commit -m "$n" || return 1
8 done &&
9
10 git init r2 &&
11 for n in 1000 10000
12 do
13 printf "%"$n"s" X > r2/large.$n &&
14 git -C r2 add large.$n &&
15 git -C r2 commit -m "$n" ?!LINT: missing '|| return 1'?!
16 done