Skip to content
Novus Examples
patch1 KB

Git Patch - new file mode Header

A file creation carried by the `new file mode 100644` extended header rather than by the paths alone. The mode is the authoritative signal: the `--- /dev/null` line tells you the old side is empty, but only the header tells you what permissions to create the file with.

Preview — first 39 linespatch
From f27ade02150fbbbfe7f493ad141de516e72cdcab Mon Sep 17 00:00:00 2001
From: Miguel Otero <miguel.otero@example.invalid>
Date: Wed, 4 Mar 2026 11:02:19 +0000
Subject: [PATCH] feat(ledger): add banker's rounding helper

Long runs of half-up rounding drift the balance upward by a cent
every few thousand postings.
---
 internal/ledger/rounding.go | 17 +++++++++++++++++
 1 file changed, 17 insertions(+), 0 deletions(-)
 create mode 100644 internal/ledger/rounding.go

diff --git a/internal/ledger/rounding.go b/internal/ledger/rounding.go
new file mode 100644
index 0000000..d6f0c19
--- /dev/null
+++ b/internal/ledger/rounding.go
@@ -0,0 +1,17 @@
+package ledger
+
+// HalfEven rounds a minor-unit amount to the nearest multiple of step using
+// banker's rounding, which keeps long runs of postings from drifting upward.
+func HalfEven(minor, step int64) int64 {
+	if step <= 1 {
+		return minor
+	}
+	q, r := minor/step, minor%step
+	switch {
+	case 2*r > step:
+		q++
+	case 2*r == step && q%2 != 0:
+		q++
+	}
+	return q * step
+}
-- 
2.43.0

Specifications

Seed
20260807
Extended Header
new file mode 100644
Files
1
Old Path
/dev/null
Creates
internal/ledger/rounding.go
Line Endings
LF
Encoding
UTF-8

Testing contract

Expected to pass
Scenario
Apply a patch that creates a file and check the resulting permission bits.
Expected result
internal/ledger/rounding.go is created with mode 100644 and the full contents of the + lines.

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 - new file mode Header” is a deterministic Novus Examples fixture for Visual diff / regression, Code parsing, Editor testing. A/B image twins with controlled pixel changes, anti-alias variants, and UI chrome crops for screenshot diff and visual regression tools.

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.

Treat A/B twins as a visual regression unit: run your pixel or perceptual diff, assert a non-zero delta on the changed twin, and keep thresholds calibrated against the documented change kind in specs.

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