pub enum DiffSpec {
WorkingTree,
Rev(String),
}Expand description
What a diff call compares — the working tree/copy, or a specific revision/revset (or range).
Shared by the vcs-git and vcs-jj wrappers (re-exported as
vcs_git::DiffSpec / vcs_jj::DiffSpec); each backend interprets it against
its own CLI (git diff … / jj diff -r …).
Deliberately not #[non_exhaustive]: each backend’s diff interpreter
must handle every variant, so adding one is a (pre-1.0) breaking change that
fails the wrappers’ exhaustive matches at compile time rather than slipping
through a runtime catch-all.
Variants§
WorkingTree
All tracked changes in the working tree/copy vs the last commit — staged
or not, excluding untracked files (git diff HEAD; jj diff -r @).
Rev(String)
A specific revision/revset or range, e.g. HEAD~1 / main..HEAD
(git diff <rev>) or @- / main..@ (jj diff -r <revset>).
This crate is intentionally plain data — no I/O, no validation — so
this string is passed through unchecked; guarding it against a
flag-like value (a leading -) is each backend wrapper’s job, and the
two differ: vcs-git runs an inline reject_flag_like check (plus a
trailing --) before using it, while vcs-jj relies on it landing in
jj’s -r <revset> flag-value slot, which the CLI itself rejects if
dash-prefixed. Don’t assume either guarantee from this type alone.