#[non_exhaustive]pub struct Clean {
pub force: bool,
pub dry_run: bool,
pub directories: bool,
pub ignored: CleanIgnored,
}Expand description
Options for GitApi::clean (git clean) — deletes untracked files from
the working tree.
Force is a deliberate, explicit call, never a default. There is no
Clean::new() state, nor any other setter, that arms deletion by
itself — only the explicit force call does, the same
“no bare bool, no implied default” pattern BranchDelete::force and
WorktreeRemove::force use for their own destructive flag. Independently,
GitApi::clean itself refuses to run at all — before spawning git —
unless the spec picked either dry_run or
force: this crate’s own guard, so the outcome never
depends on whether the caller’s clean.requireForce git config happens to
be (mis)set to false. When dry_run is set, force is
ignored — dry-run always wins, so it is never possible to accidentally
delete while asking for a preview.
#[non_exhaustive], so build it through Clean::new and the chained
setters rather than a struct literal.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.force: boolActually delete rather than merely report (--force/-f). Ignored
when dry_run is also set.
dry_run: boolReport what would be deleted, without deleting anything (--dry-run/
-n). Takes priority over force.
directories: boolRemove whole untracked directories, not just untracked files (-d).
ignored: CleanIgnoredHow ignored files/directories are treated; see CleanIgnored.
Implementations§
Source§impl Clean
impl Clean
Sourcepub fn new() -> Self
pub fn new() -> Self
A clean spec with neither dry_run nor
force picked yet — passing this as-is to
GitApi::clean is refused before spawning (see the type docs); chain
one of the two setters before use.
Sourcepub fn force(self) -> Self
pub fn force(self) -> Self
Actually delete (--force/-f) — the one, explicit way to arm
deletion; see the type docs.
Sourcepub fn dry_run(self) -> Self
pub fn dry_run(self) -> Self
Report what would be deleted without deleting anything (--dry-run/-n).
Sourcepub fn directories(self) -> Self
pub fn directories(self) -> Self
Remove whole untracked directories too (-d).
Sourcepub fn include_ignored(self) -> Self
pub fn include_ignored(self) -> Self
Also remove ignored files/directories (-x), in addition to ordinary
untracked ones.
Sourcepub fn only_ignored(self) -> Self
pub fn only_ignored(self) -> Self
Remove only ignored files/directories (-X).