Skip to content

Commit 8912059

Browse files
committed
docs: document git-style review commands
1 parent 5703768 commit 8912059

3 files changed

Lines changed: 59 additions & 12 deletions

File tree

README.md

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ bun install
1616
## Run
1717

1818
```bash
19-
bun run src/main.tsx -- git
19+
bun run src/main.tsx -- diff
2020
```
2121

2222
## Standalone binary
@@ -25,24 +25,33 @@ Build a local executable:
2525

2626
```bash
2727
bun run build:bin
28-
./dist/hunk git
28+
./dist/hunk diff
2929
```
3030

3131
Install it into `~/.local/bin`:
3232

3333
```bash
3434
bun run install:bin
35-
hunk git
35+
hunk
36+
hunk diff
3637
```
3738

3839
If you want a different install location, set `HUNK_INSTALL_DIR` before running the install script.
3940

4041
## Workflows
4142

42-
- `hunk git [range]`
43-
- `hunk diff <left> <right>`
44-
- `hunk patch [file|-]`
45-
- `hunk difftool <left> <right> [path]`
43+
- `hunk` — print standard CLI help with the most common commands
44+
- `hunk diff` — review local working tree changes in the full Hunk UI
45+
- `hunk diff --staged` / `hunk diff --cached` — review staged changes in the full Hunk UI
46+
- `hunk diff <ref>` — review changes versus a branch, tag, or commit-ish
47+
- `hunk diff <ref1>..<ref2>` / `hunk diff <ref1>...<ref2>` — review common Git ranges
48+
- `hunk diff -- <pathspec...>` — review only selected paths
49+
- `hunk show [ref]` — review the last commit or a given ref in the full Hunk UI
50+
- `hunk stash show [ref]` — review a stash entry in the full Hunk UI
51+
- `hunk diff <left> <right>` — compare two concrete files directly
52+
- `hunk patch [file|-]` — review a patch file or stdin, including pager mode
53+
- `hunk difftool <left> <right> [path]` — integrate with Git difftool
54+
- `hunk git [range]` — legacy alias for the original Git-style diff entrypoint
4655

4756
## Interaction
4857

@@ -67,7 +76,7 @@ Hunk reads layered TOML config with this precedence:
6776
1. built-in defaults
6877
2. global config: `$XDG_CONFIG_HOME/hunk/config.toml` or `~/.config/hunk/config.toml`
6978
3. repo-local config: `.hunk/config.toml`
70-
4. command-specific sections like `[git]`, `[diff]`, `[patch]`, `[difftool]`
79+
4. command-specific sections like `[git]`, `[diff]`, `[show]`, `[stash-show]`, `[patch]`, `[difftool]`
7180
5. `[pager]` when Hunk is running in pager mode
7281
6. explicit CLI flags
7382

@@ -94,6 +103,8 @@ mode = "split"
94103
CLI overrides are available when you want one-off or pager-specific behavior:
95104

96105
```bash
106+
hunk diff --mode split --line-numbers
107+
hunk show HEAD~1 --theme paper
97108
hunk patch - --mode stack --no-line-numbers
98109
hunk diff before.ts after.ts --theme paper --wrap
99110
```
@@ -155,14 +166,14 @@ Files omitted from the sidecar keep their original diff order and appear after t
155166
For Codex-driven changes, keep a transient sidecar at `.hunk/latest.json` and load it during review:
156167

157168
```bash
158-
hunk git --agent-context .hunk/latest.json
169+
hunk diff --agent-context .hunk/latest.json
159170
```
160171

161172
Suggested pattern:
162173

163174
- Codex makes code changes.
164175
- Codex refreshes `.hunk/latest.json` with a concise changeset summary, file summaries, and hunk-level rationale.
165-
- You open `hunk` against the working tree, staged diff, or a commit range with that sidecar.
176+
- You open `hunk diff`, `hunk diff --staged`, or `hunk show <ref>` with that sidecar.
166177

167178
Keep the sidecar concise. It should explain why a hunk exists, what risk to review, and how the files fit together. It should not narrate obvious syntax edits line by line.
168179

@@ -212,7 +223,18 @@ Interpretation:
212223

213224
## Git integration
214225

215-
Use Hunk as the default Git pager:
226+
For full-screen review, you can invoke Hunk directly with Git-shaped commands:
227+
228+
```bash
229+
hunk diff
230+
hunk diff --staged
231+
hunk diff main...feature
232+
hunk show
233+
hunk show HEAD~1
234+
hunk stash show
235+
```
236+
237+
Use Hunk as the default Git pager when you want it to behave like a normal pager under `git diff` / `git show`:
216238

217239
```bash
218240
git config --global core.pager 'hunk patch -'

src/core/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from "node:fs";
22
import { dirname, join, resolve } from "node:path";
33
import type { CliInput, CommonOptions, LayoutMode, PersistedViewPreferences } from "./types";
44

5-
const CONFIG_SECTION_NAMES = ["pager", "git", "diff", "patch", "difftool"] as const;
5+
const CONFIG_SECTION_NAMES = ["pager", "git", "diff", "show", "stash-show", "patch", "difftool"] as const;
66
const DEFAULT_VIEW_PREFERENCES: PersistedViewPreferences = {
77
mode: "auto",
88
showLineNumbers: true,

test/config.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,31 @@ describe("config resolution", () => {
181181
]);
182182
});
183183

184+
test("command-specific config sections also apply to show mode", () => {
185+
const home = createTempDir("hunk-config-home-");
186+
mkdirSync(join(home, ".config", "hunk"), { recursive: true });
187+
writeFileSync(
188+
join(home, ".config", "hunk", "config.toml"),
189+
[
190+
'[show]',
191+
'mode = "stack"',
192+
'line_numbers = false',
193+
].join('\n'),
194+
);
195+
196+
const resolved = resolveConfiguredCliInput(
197+
{
198+
kind: "show",
199+
ref: "HEAD~1",
200+
options: {},
201+
},
202+
{ cwd: createTempDir("hunk-config-cwd-"), env: { HOME: home } },
203+
);
204+
205+
expect(resolved.input.options.mode).toBe("stack");
206+
expect(resolved.input.options.lineNumbers).toBe(false);
207+
});
208+
184209
test("loadAppBootstrap exposes resolved initial preferences to the UI", async () => {
185210
const home = createTempDir("hunk-config-home-");
186211
const repo = createTempDir("hunk-config-repo-");

0 commit comments

Comments
 (0)