MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / read_git_diff

Function read_git_diff

claw-code/rust/crates/runtime/src/prompt.rs:245–263  ·  view source on GitHub ↗
(cwd: &Path)

Source from the content-addressed store, hash-verified

243}
244
245fn read_git_diff(cwd: &Path) -> Option<String> {
246 let mut sections = Vec::new();
247
248 let staged = read_git_output(cwd, &["diff", "--cached"])?;
249 if !staged.trim().is_empty() {
250 sections.push(format!("Staged changes:\n{}", staged.trim_end()));
251 }
252
253 let unstaged = read_git_output(cwd, &["diff"])?;
254 if !unstaged.trim().is_empty() {
255 sections.push(format!("Unstaged changes:\n{}", unstaged.trim_end()));
256 }
257
258 if sections.is_empty() {
259 None
260 } else {
261 Some(sections.join("\n\n"))
262 }
263}
264
265fn read_git_output(cwd: &Path, args: &[&str]) -> Option<String> {
266 let output = Command::new("git")

Callers 1

discover_with_gitMethod · 0.85

Calls 2

read_git_outputFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected