Skip to content
Novus Examples
diff1018 B

Unified Diff - Pasted Into an Email Body

A patch as it actually arrives in a mailing-list message: prose above it, a sign-off and an email signature below it, and a signature separator that looks like the start of a deletion. Extractors must find the diff without swallowing the surrounding text.

Preview — first 36 linesdiff
Hi Priya — here is the change we discussed on the call. It applies on top of
4.2.0. Let me know if you would rather I split the rounding fix out.

--- a/internal/ledger/apply.go	2026-03-02 09:14:03.000000000 +0000
+++ b/internal/ledger/apply.go	2026-03-02 10:41:55.000000000 +0000
@@ -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
 }

Thanks,
Ada

-- 
Ada Fernsby | Ledger team | ada.fernsby@example.invalid

Specifications

Seed
20260807
Diff Format
unified
Files
1
Leading Prose Lines
3
Trailing Prose Lines
7
Line Endings
LF
Encoding
UTF-8

Testing contract

Expected to pass
Scenario
Recover the applicable patch from a message body that surrounds it with prose and a signature block.
Expected result
Only the ---/+++/@@ region is extracted; the '-- ' signature separator and the following lines are discarded, not treated as deletions.

What is a .diff file?

A .diff file records the difference between two versions of one or more text files. The unified format — the default almost everywhere — names the old and new files on `---` and `+++` lines, then lists hunks introduced by `@@ -old,count +new,count @@` in which context lines are unprefixed and changed lines are prefixed with `-` or `+`. Older context and normal diff formats exist but are rarely produced today.

How to use this file

Use an example .diff file to test diff parsers, syntax highlighters, and merge tooling — verifying hunk-offset arithmetic, correct handling of context lines that begin with a space, and behaviour on files whose changes include trailing-whitespace or line-ending differences.

How to use this file for testing

“Unified Diff - Pasted Into an Email Body” is a deterministic Novus Examples fixture for Error handling, Visual diff / regression, Code parsing. Deliberately corrupt and invalid files, clearly labelled, for testing how your tool fails.

Documented properties for this file: seed 20260807 · UTF-8 · 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.

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