Skip to main content

diff_head

Function diff_head 

Source
pub fn diff_head(cwd: &Path) -> Result<String>
Expand description

git diff HEAD --no-ext-diff with a fallback for fresh repos.

In a fresh repo git diff HEAD exits with status 128 (fatal: bad revision) because there is no HEAD yet. We detect that case by probing git rev-parse --verify HEAD first; when HEAD does not resolve we return Ok(String::new()) so the overlay can render an empty diff doc instead of failing. Real errors (non-zero exit for any other reason) propagate to the caller unchanged.