git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] SubmittingPatches: avoid add-failing-test-then-fix anti-pattern

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 12, 2026, 14:34 UTC
Message-ID
<xmqq4ierasxy.fsf@gitster.g>
In-Reply-To
<20261012030029.12200-1-jon@jonsimons.org>
Jon Simons <jon@jonsimons.org> writes:
Show 12 quoted lines
> +A bugfix patch should include tests in test_expect_success() blocks that
> +demonstrate the breakage when the code change that implements the fix is
> +omitted.  Submit tests as `test_expect_success` in the same commit as
> +your code change that fixes the bug.  A separate commit that only changes
> +`test_expect_failure` to `test_expect_success` can leave the behavior
> +being tested out of the diff context, making the fix harder to review.
> +Reviewers who want to verify that your test reproduces the bug can
> +temporarily undo the code changes while keeping the test.
> +
>  Pushing to a fork of https://github.com/git/git will use their CI
>  integration to test your changes on Linux, Mac and Windows. See the
>  <<GHCI,GitHub CI>> section for details.

Doesn't the second sentence "Submit tests ..." merely repeat what the first sentence already says without adding much value? After re-reading them three times, I think "the same commit" is the only new point. I would condense the first two sentences down to

    A bugfix patch should add, in the same commit, code change and
    test_expect_success() blocks that demonstrate the breakage when
    the fix is omitted.
or something, if I were writing this from scratch.

By the way, I consider that the SubmittingPatches document is primarily about giving readers a set of rules they should follow, and not about teaching the reasoning behind a rule to such a deep level, unless the rule requires judgment on when or when not to apply it. We agreed we do not need "unless there is a strong reason not to", which means there is no judgment needed, so I was not expecting to see the latter half of the paragraph.

Having said all that, i will queue this version as-is because we are quickly reaching the point of diminishing returns. Thanks.

Previous: Jon Simons
Message 6 of 6 in “SubmittingPatches: avoid add-failing-test-then-fix anti-pattern”
  1. SubmittingPatches: avoid add-failing-test-then-fix anti-patternJon Simons, Oct 11, 2026
  2. Kristoffer HaugsbakkOct 11, 2026
  3. Junio C HamanoOct 11, 2026
  4. Jon SimonsOct 12, 2026
  5. SubmittingPatches: avoid add-failing-test-then-fix anti-patternJon Simons, Oct 12, 2026
  6. Junio C HamanoOct 12, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.