diff --git a/src/tui/mod.rs b/src/tui/mod.rs index 5640068..67ca8ea 100644 --- a/src/tui/mod.rs +++ b/src/tui/mod.rs @@ -757,7 +757,7 @@ fn test_output(app: &App, id: &str) -> Pager { fn diff_of(worktree: &str) -> Pager { let git = |a: &[&str]| crate::run::git(Path::new(worktree), a); let mut text = String::new(); - match git(&["status", "--short"]) { + match git(&["status", "--short", "--untracked-files=all"]) { Ok(s) if !s.trim().is_empty() => text.push_str(&format!("{s}\n")), Ok(_) => {} Err(e) => text.push_str(&format!("{e:#}\n")), @@ -767,6 +767,20 @@ fn diff_of(worktree: &str) -> Pager { Ok(s) => text.push_str(&s), Err(e) => text.push_str(&format!("{e:#}")), } + // `git diff HEAD` skips untracked files: show them as additions too. + // `--no-index` exits 1 when the files differ, so read stdout and ignore the status. + for f in git(&["ls-files", "--others", "--exclude-standard"]) + .unwrap_or_default() + .lines() + { + if let Ok(o) = std::process::Command::new("git") + .args(["diff", "--no-index", "--", "/dev/null", f]) + .current_dir(worktree) + .output() + { + text.push_str(&String::from_utf8_lossy(&o.stdout)); + } + } Pager { title: "diff".into(), lines: lines_of(&text), @@ -1435,6 +1449,14 @@ end = "escalated" assert!(tr.lines.last().unwrap().contains("ended: escalated")); // the agent's (here: the shell's) untracked file shows up in the diff view assert!(diff_of(&d.worktree).lines.iter().any(|l| l == "?? n")); + // files inside a new folder are listed one by one, not collapsed to "sub/" + std::fs::create_dir_all(Path::new(&d.worktree).join("sub")).unwrap(); + std::fs::write(Path::new(&d.worktree).join("sub/f"), "x").unwrap(); + let lines = diff_of(&d.worktree).lines; + assert!(lines.iter().any(|l| l == "?? sub/f")); + // and its content appears as an added file + assert!(lines.iter().any(|l| l == "+++ b/sub/f"), "{lines:?}"); + assert!(lines.iter().any(|l| l == "+x"), "{lines:?}"); let _ = std::fs::remove_dir_all(&dir); }