Files and patches
Use file comparison when you already have before and after content, and patch mode when another tool emits unified diff text.
Compare files
Section titled “Compare files”hunk diff before.ts after.tsWhen both operands are existing concrete files, Hunk treats them as a direct comparison instead of VCS targets. Add --watch to reload when either file changes:
hunk diff before.ts after.ts --watchOpen a patch file
Section titled “Open a patch file”hunk patch changes.patchA file-backed patch can use watch mode. It remains tied to that file path.
Read a patch from stdin
Section titled “Read a patch from stdin”git diff --no-color | hunk patch -Use - to make stdin explicit. Stdin is a snapshot, so it cannot use --watch; write the patch to a file when you need continuous reloads.
Patch-like input is parsed into the same file and hunk model as repository input. Non-diff text belongs in pager mode, where Hunk can fall back to plain text.