Skip to content
Novus Examples
patch3.5 KB

Git Patch - Every Extended Header in One Commit

The torture test: one commit that creates a file, deletes an executable, renames at 100%, copies with detection on, changes a mode while editing, and adds a binary blob. The diffstat carries the matching create/delete/rename/mode-change summary lines that follow the file table.

Preview — first 50 linespatch
From 4209c156df58d9f5fc2eca304b7170ed06497b92 Mon Sep 17 00:00:00 2001
From: Ada Fernsby <ada.fernsby@example.invalid>
Date: Mon, 9 Mar 2026 16:30:00 +0000
Subject: [PATCH] chore: the quarterly tidy-up

One commit that adds, deletes, renames, copies, chmods and adds a binary,
so every extended header git can emit appears in a single patch.

Signed-off-by: Ada Fernsby <ada.fernsby@example.invalid>
Reviewed-by: Priya Raman <priya.raman@example.invalid>
---
 internal/ledger/rounding.go                   | 17 +++++++++++++++++
 scripts/legacy-import.sh                      |  6 ------
 docs/{README.md => guide.md}                  |  0
 internal/ledger/{apply.go => apply_strict.go} |  4 ++--
 scripts/release.sh                            |  1 +
 assets/badge.png                              | Bin 0 -> 89 bytes
 6 files changed, 20 insertions(+), 8 deletions(-)
 create mode 100644 internal/ledger/rounding.go
 delete mode 100755 scripts/legacy-import.sh
 rename docs/{README.md => guide.md} (100%)
 copy internal/ledger/{apply.go => apply_strict.go} (85%)
 mode change 100644 => 100755 scripts/release.sh
 create mode 100644 assets/badge.png

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
+}
diff --git a/scripts/legacy-import.sh b/scripts/legacy-import.sh
deleted file mode 100755
109 lines total — download for the full file.

Specifications

Seed
20260807
Files
6
Headers
new file mode, deleted file mode, similarity index, rename from/to, copy from/to, old/new mode, GIT binary patch
Summary Lines
5
Line Endings
LF
Encoding
UTF-8

Testing contract

Expected to pass
Scenario
Parse a six-file patch in which every git extended header appears at least once.
Expected result
Six file sections are reported with the correct kind for each; the diffstat table and its five summary lines agree with the sections below them.

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 - Every Extended Header in One Commit” 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.