Git Patch - RFC 2047 Encoded-Word Subject and Author
Non-ASCII in the author name and the subject, so both are Q-encoded into `=?UTF-8?q?...?=` words and the subject is folded across two lines with a leading space. The body is left as raw UTF-8, which means one message needs two different decoders.
From 61490f2b8ca2fcea948781ef5546ad90f5baa2ac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ana=C3=AFs_Lef=C3=A8vre?= <anais.lefevre@example.invalid>
Date: Tue, 10 Mar 2026 13:22:41 +0100
Subject: [PATCH] =?UTF-8?q?fix=28rounding=29=3A_d=C3=A9tecter_les_?=
=?UTF-8?q?arrondis_n=C3=A9gatifs?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Les montants négatifs étaient arrondis vers zéro.
The commit body is UTF-8 8-bit while the headers are RFC 2047 encoded words.
---
internal/ledger/apply.go | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/internal/ledger/apply.go b/internal/ledger/apply.go
index 95f499d..ce501c6 100644
--- a/internal/ledger/apply.go
+++ b/internal/ledger/apply.go
@@ -1,14 +1,21 @@
package ledger
-import "errors"
+import (
+ "errors"
+ "fmt"
+)
// ErrShortBalance is returned when a posting would drive the balance negative.
var ErrShortBalance = errors.New("ledger: insufficient balance")
// Apply posts one delta against the running balance and returns the new total.
+// A zero delta is a no-op and never reports an error.
func Apply(balance, delta int64) (int64, error) {
+ if delta == 0 {
+ return balance, nil
+ }
if balance+delta < 0 {
- return balance, ErrShortBalance
+ return balance, fmt.Errorf("%w: balance %d, requested %d", ErrShortBalance, balance, delta)
}
return balance + delta, nil
}
--
2.43.0
Specifications
- Seed
- 20260807
- Header Encoding
- RFC 2047 Q
- Body Encoding
- UTF-8 8bit
- Folded Subject
- true
- Files
- 1
- Line Endings
- LF
Testing contract
Expected to pass- Scenario
- Decode the author and subject of a patch whose headers are RFC 2047 encoded words and whose body is raw UTF-8.
- Expected result
- Subject decodes to 'fix(rounding): détecter les arrondis négatifs' across the folded continuation, and the author name decodes to 'Anaïs Lefèvre'.
What is a .patch file?
A .patch file is a unified diff packaged for transmission, most often as produced by `git format-patch`. Beyond the diff itself it carries an email-style header with the author, date, and commit subject, a commit message body, per-file `diff --git` headers recording renames and mode changes, and hunk headers of the form `@@ -old,count +new,count @@`. Applying it reconstructs a specific change against a specific before-state.
How to use this file
Use an example .patch file to test patch application, code-review renderers, and diff parsers — exercising renames, mode changes, binary hunks, added and deleted files, and the `\ No newline at end of file` marker that naive parsers silently drop.
How to use this file for testing
“Git Patch - RFC 2047 Encoded-Word Subject and Author” is a deterministic Novus Examples fixture for Encoding detection, Visual diff / regression, Email parsing. UTF-8, UTF-8-BOM, UTF-16, and Latin-1 files with documented encodings and line endings for testing charset detection.
Documented properties for this file: seed 20260807 · LF. Compare results against paired or grouped companions on this page when present (clean↔damaged, searchable↔scanned, or format twins) so scores stay reproducible across runs.
Download the file once, keep the path stable in CI or local scripts, and treat the spec table as the contract: dimensions, seeds, field lists, and roles are intentional. Corrupt or invalid samples are labelled as such — expect parsers to fail loudly rather than silently accept them.
Diff and patch fixtures name their target paths and the exact edge case they exercise — rename, mode change, binary hunk, CRLF↔LF, or missing trailing newline. Apply or render them against the documented before-state; every author, path, and hash is fictional.
Related files
- mboxGit Format-Patch Series - All Four Messages as One MboxThe same four messages concatenated into a single mbox, which is exactly what `git format-patch --stdout` produces and what `git am` consumes. The From_ separator lines use git's fixed sentinel date, so a splitter cannot rely on the timestamp being real.

- patchGit Patch - CRLF Line Endings ThroughoutThe whole patch file uses CRLF terminators, as it would after a round trip through a Windows editor or a mail client. `git am` needs `--keep-cr` to be told the CRs belong to the patch rather than to the content, and the `-- ` signature line now ends with space-CR-LF.

- patchGit Patch - LF Line Endings ThroughoutThe LF half of the patch twin pair, identical in text content to the CRLF fixture. Diff the two downloads to get a change that is invisible in every renderer and fatal to a byte comparison.

- patchGit Patch - Scissors Line Above the Real Commit MessageA patch sent as a reply: the mail subject starts with `Re:`, quoted text sits above a `-- >8 --` scissors line, and the real commit subject and body sit below it. `git am --scissors` discards everything above the cut; a parser that trusts the mail Subject header records 'Re: [PATCH] ...' as the commit title.

- diffUnified Diff - CRLF Line Endings ThroughoutByte-for-byte the same diff as its LF twin except that every line ends CR LF, which is what a diff produced or saved on Windows looks like. Readers that compare a hunk line against expected content without stripping the CR find that no line matches.

- diffUnified Diff - LF Line Endings ThroughoutThe LF half of the line-ending twin pair: identical text content to the CRLF fixture, differing only in the terminator bytes. Diff the two downloads to see nothing but line-ending changes, and use the pair to score end-of-line normalisation.

Generated by generation/version_control.py. Free for any use, no attribution required — license.