---
name: counting-added-lines-with-plus-not-plus-drops-blank-lines
description: grep -c '^+[^+]' silently undercounts a diff's insertions by every blank added line — the denominator a zero is read against.
metadata:
  type: feedback
---

2026-09-10, releases#294 diag intake. Two agents counted the added lines of the SAME diff
(`a9e786b2..ef9c1599`) and got different denominators: doyle 510, me 516/521. Reconciled to the line,
each figure reproduced on my box:

| spelling | count | what it is |
|---|---|---|
| `grep -c '^+'` | 521 | insertions + the five `+++ b/...` file headers |
| `grep '^+' \| grep -vc '^+++ '` | **516** | correct — equals the diffstat's insertion count |
| `grep -c '^+[^+]'` | 510 | drops every BLANK added line (`^+$` = 6 here) |
| `grep -c '^++'` | 5 | the headers, confirming the 521 offset |

`^+[^+]` is the trap: the bracket requires a character after the `+`, so an added empty line matches
nothing and vanishes from the count. `510 + 6 = 516` with no remainder.

**Why:** the added-line count is usually being used as the DENOMINATOR that makes a zero meaningful
("0 treqs tags over 516 added lines"). A denominator produced by a regex with a blind spot is the
same defect as the vacuous zero it is supposed to guard against — and here it appeared in the very
message praising the blind-spot catch. It changed no conclusion that day; the next use could be a
census where the six dropped lines are the six that matter.

**How to apply:** count insertions as `git diff A..B | grep '^+' | grep -vc '^+++ '` and cross-check
it against `git diff --shortstat` — if the two disagree, the spelling is wrong, not the diff. When
two agents report different denominators, reproduce the other's exact command rather than conceding
or averaging: the gap has a mechanism and naming it is what makes the idiom retirable. Related:
[[a-zero-from-an-absence-grep-is-a-spelling-claim]], [[a-detector-must-pass-a-control-built-from-what-motivated-it]].
