Skip to content

fix(diff): honor positional file filter with --change - #120

Merged
graywolf336 merged 1 commit into
devfrom
fix/diff-change-file-filter
Jul 21, 2026
Merged

graywolf336 merged 1 commit into
devfrom
fix/diff-change-file-filter

Conversation

@graywolf336

Copy link
Copy Markdown
Contributor

Problem

atomic diff --change <hash> <file> silently ignored the trailing file filter and always showed every file touched by the change.

Root cause

Diff::run short-circuits into show_change_diff when --change is set (command.rs), and none of the three change-diff code paths in helpers.rs ever consulted self.files:

  1. Git-import metadata path (build_git_import_file_diffs)
  2. Semantic FileOps path (show_change_diff_from_file_ops)
  3. Legacy computed fallback (show_change_diff_computed)

Fix

  • Added file_matches_filter() — exact repo-relative match, tolerating a leading ./
  • Added filter_file_diffs() — prunes computed FileDiffs and rebuilds aggregate stats from surviving entries
  • Wired filtering into all three paths; the legacy computed path filters the file list up front to avoid expensive before/after content retrieval for filtered-out files

Verification

Reproduced against a change touching two files:

# Before: both files shown despite filter
$ atomic diff --change NPA4BUIJFNAO .vault/intents/manual/auditor/5/intent.md --name-only
.vault/attestations/LINK-5/attested.md
.vault/intents/manual/auditor/5/intent.md

# After: only the filtered file
$ atomic diff --change NPA4BUIJFNAO .vault/intents/manual/auditor/5/intent.md --name-only
.vault/intents/manual/auditor/5/intent.md

Also verified: no filter still shows all files, non-matching filter prints "No changes detected", --stat totals reflect only filtered files.

Added 7 unit tests covering the filter helpers. Full atomic-cli diff test suite passes (135 tests), cargo fmt --check and clippy clean.

@graywolf336
graywolf336 requested a review from leefaus July 21, 2026 18:10
@graywolf336
graywolf336 marked this pull request as ready for review July 21, 2026 18:10
@graywolf336
graywolf336 changed the base branch from release to dev July 21, 2026 18:17
`atomic diff --change <hash> <file>` silently ignored the trailing
file filter and always showed every file touched by the change.

Root cause: Diff::run short-circuits into show_change_diff when
--change is set, and none of the three change-diff code paths
(git-import metadata, semantic FileOps, legacy computed fallback)
ever consulted self.files.

Fix: add a file_matches_filter helper (exact repo-relative match,
tolerating a leading ./) and a filter_file_diffs helper that prunes
computed FileDiffs and rebuilds the aggregate stats, then wire them
into all three paths. The legacy computed path filters the file list
up front to avoid the expensive before/after content retrieval for
filtered-out files.
@graywolf336
graywolf336 force-pushed the fix/diff-change-file-filter branch from 46c2c56 to 934260d Compare July 21, 2026 18:19
@graywolf336
graywolf336 marked this pull request as draft July 21, 2026 18:19
@graywolf336
graywolf336 marked this pull request as ready for review July 21, 2026 18:20
@graywolf336
graywolf336 merged commit 2ed6be6 into dev Jul 21, 2026
16 checks passed
@graywolf336
graywolf336 deleted the fix/diff-change-file-filter branch July 21, 2026 18:33
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