Skip to content
gohacks.dev
Tooling

Unified Diff Viewer

Paste a git diff or .patch file and read it as a coloured, per-file view with old and new line numbers and added and removed line counts.

Free · No sign-up · Your inputs stay in your browser

Input

Render a unified diff

2 files, +7 −3

app/Http/Controllers/LoginController.php+6 −2
@@ -12,9 +12,13 @@ class LoginController extends Controller
1212 public function store(Request $request)
1313 {
14− $credentials = $request->only('email', 'password');
14+ $credentials = $request->validate([
15+ 'email' => ['required', 'email'],
16+ 'password' => ['required'],
17+ ]);
1518
1619 if (Auth::attempt($credentials)) {
17− return redirect('/home');
20+ $request->session()->regenerate();
21+ return redirect()->intended('/home');
1822 }
routes/web.php+1 −1
@@ -3,3 +3,3 @@
3−Route::post('/login', [LoginController::class, 'store']);
3+Route::post('/login', [LoginController::class, 'store'])->middleware('throttle:login');

Parsed from the unified format: each @@ hunk header gives the starting line in the old and new file, and the line numbers count on from there. Apply a patch with git apply --check first, then git apply; for a patch made with git format-patch, git am keeps the author and message. Runs in this browser; nothing you paste is sent anywhere.

Reading a hunk header

@@ -12,9 +12,13 @@ means the hunk starts at line 12 and spans 9 lines in the old file, and starts at line 12 and spans 13 in the new one. Text after the second @@ is the enclosing function or class, which Git finds with its diff driver. The format is described in the git diff documentation.

Applying a patch

git apply --check file.patch reports whether it applies cleanly without changing anything; git apply then applies it. Patches made with git format-patch carry the author and message and are applied with git am.

Share

Frequently asked questions

How do I get a pull request as a diff?
Add .diff or .patch to a GitHub pull request URL, or run git diff main...branch locally.
Why does git apply say the patch does not apply?
The surrounding lines changed since the patch was made. git apply --3way tries a merge using the blobs recorded in the patch.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools