Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .config/jp/tools/src/git/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ fn git_diff_impl<R: ProcessRunner>(
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"],
};

Expand Down
31 changes: 31 additions & 0 deletions .config/jp/tools/tests/git_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion .jp/config/personas/committer.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading