fn diff_ref_spec(target: &str) -> StringExpand description
Translate a caller-supplied diff target into the git ref-spec
the underlying subprocess receives.
HEAD->HEAD(two-dot semantics: working tree vs HEAD, which is what the user means by “uncommitted edits”).- Anything else (branch name, SHA) ->
<target>...HEAD(three-dot semantics: diff from the merge-base oftargetandHEADtoHEAD, i.e. “what did THIS branch contribute”).
Why the asymmetry: after a squash-merge of the branch into the
target, two-dot git diff main HEAD is empty (content already in
main with a different SHA) while three-dot git diff main...HEAD
still surfaces the branch’s contributions vs the merge-base. The
Inspector GIT panel uses three-dot via
forge_agent::env::git_diff::scan’s format!("{default}...HEAD")
at the branch-ahead layer; this helper keeps the overlay scanner
in sync so the panel + overlay never disagree on what’s diffable.