Skip to content

Add --in-git-diff convenience option - #628

Open
ychampion wants to merge 2 commits into
sourcefrog:mainfrom
ychampion:fix/in-git-diff-245
Open

ychampion wants to merge 2 commits into
sourcefrog:mainfrom
ychampion:fix/in-git-diff-245

Conversation

@ychampion

@ychampion ychampion commented Jul 16, 2026 •

Copy link
Copy Markdown

Summary

Add --in-git-diff REVISION to test mutations in code changed since a Git revision, using the existing diff filter. This avoids creating a temporary patch file and works from nested workspaces.

Revisions beginning with - are rejected before invoking Git, so values such as --quiet cannot silently produce a successful run with no mutants. The test fixture disables commit signing for its own Git invocation.

Closes #245.

Validation

  • Both review findings reproduced before the follow-up; all four in_git_diff tests pass, including option-like revisions and an inherited signing configuration.
  • The full workspace/all-feature run and environment-corrected reruns passed 291 unit tests, 141 active integration tests, and two attribute doctests; two existing integration ignores remain. Permission fixtures required removing root DAC bypass, and color tests required unsetting NO_COLOR with a non-dumb terminal.
  • Strict all-target/all-feature Clippy, formatting, and diff checks pass.

Written by an agent (Codex, gpt-6-astra).

Add the maintainer-requested Git revision adapter while reusing the existing unified-diff filter. Keep explicit patch-file input unchanged and cover nested workspaces plus invalid revisions.

Constraint: Use the Git CLI requested in sourcefrog#245 without adding a dependency.
Rejected: git2-rs | Unnecessary build weight for a single diff invocation.
Confidence: high
Scope-risk: narrow
Directive: Keep --in-diff and --in-git-diff mutually exclusive.
Tested: Focused diff tests; strict all-target/all-feature Clippy; 429/431 all-feature nextest cases; release build and nested-workspace smoke; rustfmt; cargo-machete; diff checks.
Not-tested: mdBook linkcheck and typos binaries are unavailable locally; two permission-denied tests fail as root identically on upstream.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new CLI filter option, --in-git-diff REVISION, to let cargo-mutants compute a diff by invoking git diff directly and then reuse the existing diff-based mutant filtering logic (including behavior for nested workspaces and invalid revisions).

Changes:

  • Add --in-git-diff REVISION CLI option and wire it into mutant filtering flow.
  • Implement diff_filter_git() to run git diff and feed its output into the existing diff filter.
  • Add tests plus user-facing documentation updates (book + NEWS).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/main.rs Adds integration tests for filtering via git diff, including nested workspace and invalid revision handling.
src/main.rs Introduces the --in-git-diff argument and applies it in the main filtering pipeline.
src/in_diff.rs Adds diff_filter_git() and a new DiffFilterError::Git error variant for git invocation failures.
NEWS.md Documents the new --in-git-diff option in Unreleased notes.
book/src/in-diff.md Updates the user guide to describe --in-git-diff and its interaction with --in-diff.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/in_diff.rs Resolved
Comment thread tests/main.rs Resolved
@sourcefrog sourcefrog self-assigned this Aug 23, 2026

This branch has not been deployed

No deployments
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.

--in-git-diff convenience option

3 participants