Skip to content

feat(diff): add --json, and point a clean working copy at -c - #218

Merged
graywolf336 merged 1 commit into
devfrom
feat/diff-json-and-pending-hint
Sep 25, 2026
Merged

graywolf336 merged 1 commit into
devfrom
feat/diff-json-and-pending-hint

Conversation

@graywolf336

Copy link
Copy Markdown
Contributor

Problem

atomic diff conflates two questions — working copy vs. recorded state (no -c), and before vs. after a change (-c) — and had no machine-readable mode, making it the only core VCS command without one.

Changes

  • --json — versioned document: per-file status/paths, hunks with typed lines, insertion/deletion rollups. Takes precedence over --stat/--name-only/--name-status. A -c diff carries the change header under change; a working-copy diff carries view. Empty diffs still emit valid JSON.
  • Clean-working-copy hint — when there is nothing pending, name real copy-pasteable -c commands for the most recent changes on the current view. Uses include_inherited so a freshly forked draft doesn't claim it has no recorded changes.

Verification

  • cargo test -p atomic-cli — 1926 passed, 0 failed (5 new JSON unit tests)
  • clippy clean, fmt --check clean
  • Harness 05, 09, 11, 12, 13 — all pass (covers both the bare-diff and -c paths, including rename edge cases)
  • Round-tripped the JSON back to a byte-identical unified diff

Note

--cached remains accepted-but-inert (hide = true); untouched here.

`atomic diff` conflates two questions: working copy vs. recorded
state (no -c), and the state before vs. after a change (-c). It also
had no machine-readable mode, making it the only core VCS command
without one.

- Add `--json`, emitting a versioned document (per-file status and
  paths, hunks with typed lines, insertion/deletion rollups). It takes
  precedence over --stat/--name-only/--name-status so consumers get one
  parseable document instead of formatted output to re-parse. A `-c`
  diff carries the change header under `change`; a working-copy diff
  carries `view`. An empty diff still emits valid JSON.
- When the working copy is clean, name real copy-pasteable `-c`
  commands for the most recent changes on the current view. A clean
  working copy was a dead end for anyone expecting to see a change.
  Uses include_inherited so a freshly forked draft does not claim it
  has no recorded changes.
@graywolf336
graywolf336 merged commit 22de671 into dev Sep 25, 2026
15 of 16 checks passed
@graywolf336
graywolf336 deleted the feat/diff-json-and-pending-hint branch September 25, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants