Re:Ask HN: Do you write tests before the implementation?
by roblabla on Friday November 15, 2019 @07:32AM
(#21544291)
Keeping it separate allows ensuring the test works easily: just revert the fix keeping only the patch for the test and make sure the test fails.
My workflow tend to be to keep them separate, and write a big description in the merge commit rather than the individual commits (those have a small description of the local change).
There's tradeoffs to both approach though, and as you mention, it's easier to keep track of the provenance of a fix in the git blame when it's unified in a single commit message.
I don't think this is compelling argument. Normally the test and the fix are looked at together and are already sufficiently separated in the code.
It makes more sense to me to use a single commit so the fix can be described in a single commit message, keeping the history clean.