From 4a6b0adb9b69d0761e4af404a01c2ce1115a4be0 Mon Sep 17 00:00:00 2001 From: Brent Wheeldon Date: Fri, 2 Oct 2026 16:31:55 -0400 Subject: [PATCH] fix: force color.ui=false in git calls so --since works under forced-color configs `color.ui`/`color.diff = always` makes git emit ANSI-wrapped hunk headers even when piped, which hunk_ranges failed to parse, silently dropping every file from --since scoping. Add a regression test with `color.ui=always` set. --- src/main.rs | 1 + tests/cli.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/main.rs b/src/main.rs index bf54e00..7b284e2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,6 +55,7 @@ fn git(root: Option<&Path>, args: &[&str]) -> Result { if let Some(r) = root { cmd.arg("-C").arg(r); } + cmd.args(["-c", "color.ui=false"]); let out = cmd .args(args) .output() diff --git a/tests/cli.rs b/tests/cli.rs index f281c63..098bf3b 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -1025,6 +1025,19 @@ fn since_lists_only_lines_the_branch_introduced() { assert!(!json.contains("// pre-existing narration"), "{json}"); } +#[test] +fn since_ignores_a_forced_color_git_config() { + let Some((d, base)) = repo_with_base("a.rs", BASE_RS) else { return }; + git_in(&d, &["config", "color.ui", "always"]); + write_in(&d, "a.rs", &format!("{BASE_RS}// brand new narration\nfn b() {{}}\n")); + + let out = run(&[d.to_str().unwrap(), "--list", "--since", &base]); + assert!(out.status.success(), "stderr: {:?}", out.stderr); + let json = String::from_utf8(out.stdout).unwrap(); + assert!(json.contains("// brand new narration"), "{json}"); + assert!(!json.contains("// pre-existing narration"), "{json}"); +} + #[test] fn since_strips_only_lines_the_branch_introduced() { let Some((d, base)) = repo_with_base("a.rs", BASE_RS) else { return };