diff --git a/.config/jp/tools/src/git/diff.rs b/.config/jp/tools/src/git/diff.rs index c0a43533..e66bb028 100644 --- a/.config/jp/tools/src/git/diff.rs +++ b/.config/jp/tools/src/git/diff.rs @@ -41,8 +41,14 @@ fn git_diff_impl( env: &[(&str, &str)], ) -> ToolResult { let mut args = match status { - DiffStatus::All => vec!["diff-index", "-p", "HEAD"], - DiffStatus::Staged => vec!["diff-index", "--cached", "-p", "HEAD"], + DiffStatus::All => vec!["diff-index", "--ita-invisible-in-index", "-p", "HEAD"], + DiffStatus::Staged => vec![ + "diff-index", + "--cached", + "--ita-invisible-in-index", + "-p", + "HEAD", + ], DiffStatus::Unstaged => vec!["diff-files", "-p"], }; diff --git a/.config/jp/tools/tests/git_tests.rs b/.config/jp/tools/tests/git_tests.rs index f7bbda25..cb13f19a 100644 --- a/.config/jp/tools/tests/git_tests.rs +++ b/.config/jp/tools/tests/git_tests.rs @@ -1169,6 +1169,37 @@ async fn diff_commit_no_match_for_path() { assert!(content.contains("No diff found")); } +#[tokio::test] +async fn staged_diff_excludes_intent_to_add_files() { + if !has_git() { + return; + } + + let (_dir, root) = init_repo(); + + // Also stage a real change so we can verify the diff isn't just empty. + commit_then_modify(&root, "tracked.rs", "old\n", "new\n"); + git(&root, &["add", "tracked.rs"]); + + // Create an untracked file and mark it intent-to-add. + fs::write(root.join("ita.rs"), "intent to add content\n").unwrap(); + git(&root, &["add", "--intent-to-add", "ita.rs"]); + + let content = run_ok(ctx(&root), tool("git_diff", &json!({"status": "staged"}))).await; + + // The real staged change must be present. + assert!( + content.contains("tracked.rs"), + "staged diff should contain the genuinely staged file" + ); + + // The intent-to-add file must NOT appear in staged output. + assert!( + !content.contains("ita.rs"), + "staged diff must not contain intent-to-add file, got: {content}" + ); +} + #[tokio::test] async fn sequential_staging_across_tools() { if !has_git() { diff --git a/.jp/config/personas/committer.toml b/.jp/config/personas/committer.toml index 7722cb9d..e5ffbc37 100644 --- a/.jp/config/personas/committer.toml +++ b/.jp/config/personas/committer.toml @@ -23,7 +23,7 @@ title.generate.auto = false tools.'*' = { enable = false, run = "unattended" } attachments = [ "cmd:git branch --show-current?description=Current branch name", - "cmd:git diff-index --cached -p HEAD -- . :^crates/jp_llm/tests/fixtures :^Cargo.lock :^.jp/conversations?description=Diff of current cached/changed hunks (excluding test fixtures and Cargo.lock)", + "cmd:git diff-index --cached --ita-invisible-in-index -p HEAD -- . :^crates/jp_llm/tests/fixtures :^Cargo.lock :^.jp/conversations?description=Diff of current cached/changed hunks (excluding test fixtures and Cargo.lock)", ] [style]