Unified patch format guide

The Copy patch and Download buttons write a standard unified diff. A program that understands GNU unified format can read the file. This desk does not apply the patch for you, and it is not a git host.

File headers

The first two lines name the files. The original is marked with --- a/ and the modified file with +++ b/. The names come from the filename fields on the checker, with a fallback of original.txt and modified.txt.

--- a/config.json
+++ b/config.json

Hunk headers and counts

Each changed region starts with a hunk header in the form @@ -oldStart,oldCount +newStart,newCount @@. The numbers are 1-based line positions and the number of lines from that side that appear in the hunk. An empty file uses a start of 0 and a count of 0.

@@ -2,7 +2,7 @@
   "service": "checkout-api",
-  "version": "1.4.0",
+  "version": "1.5.0",

Context lines

Unchanged lines in a hunk start with a space. Removed lines start with - and added lines start with +. This desk includes three unchanged context lines around each change, and it merges nearby changes into one hunk when their context would overlap.

What the download is not

A downloaded .patch or .diff is a text file written in this browser. It does not log in to a repository, it does not run git apply, and it does not prove that a third-party tool will accept every option such as Ignore whitespace. Read the file before you share it.

Back to the checker

Questions

Why does an empty file use 0,0 in the hunk header?

That is the usual unified-diff convention: there is no 1-based starting line on a side that contributes zero lines to the hunk.

Can I apply this patch with git apply?

Often yes, if the filenames and context match the tree you have. This desk does not run that command, and it cannot promise that every third-party tool will accept the file.