Skip to content
Testaroo
patch1.3 KB

Git Patch - Rename Plus Edits at similarity index 68%

A rename that also edits the file, so the similarity index drops to 68% and the rename headers are followed by an index line and real hunks whose `---`/`+++` paths differ from each other. A patcher that applies hunks to the path on the `---` line writes to the file that no longer exists.

Preview, first 46 linespatch
From ea95802ea6e8a65709717da7c36890ee2f600461 Mon Sep 17 00:00:00 2001
From: Ada Fernsby <ada.fernsby@example.invalid>
Date: Fri, 6 Mar 2026 10:12:40 +0000
Subject: [PATCH] refactor(ledger): rename apply.go to posting.go

Matches the package vocabulary used everywhere else.
---
 internal/ledger/{apply.go => posting.go} | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
 rename internal/ledger/{apply.go => posting.go} (68%)

diff --git a/internal/ledger/apply.go b/internal/ledger/posting.go
similarity index 68%
rename from internal/ledger/apply.go
rename to internal/ledger/posting.go
index 95f499d..ce501c6 100644
--- a/internal/ledger/apply.go
+++ b/internal/ledger/posting.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
Extended Header
similarity index / rename from / rename to + index
Files
1
Similarity Index
68
Old Path
internal/ledger/apply.go
New Path
internal/ledger/posting.go
Line Endings
LF
Encoding
UTF-8

Testing contract

Expected to pass
Scenario
Apply a patch that renames a file and edits it in the same section.
Expected result
internal/ledger/apply.go is gone, internal/ledger/posting.go exists, and the hunks are applied to the new path.

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 - Rename Plus Edits at similarity index 68%” is a deterministic Testaroo 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.