Skip to main content

Module command_clean

Module command_clean 

Source
Expand description

The Git 2.56.0 option table of git clean and its deletion facts. What: The complete git clean option table of Git 2.56.0 and the deletion facts read from it. Why: The linked-worktree policy guards a clean that can delete files. Git’s last --dry-run/--no-dry-run wins, in clusters (-ndX) and abbreviations (--dry).

In TS you’d write (pseudocode):

// cleanChangesWorktree(parseCleanRegion(['-ndX'])) === false

Structs§

CleanRegion
What: Final-state facts of one git clean region. bool is true or false. Why: The policy decides from the final dry-run state; interactive is reported for its diagnostics.

Constants§

CLEAN_TABLE
What: Rows of options[] in cmd_clean (builtin/clean.c:936-948), in source order. &[OptionSpec] is a borrowed table baked into the program; None in the long position means the option has only a letter. Why: -e/--exclude takes a value and is PARSE_OPT_NONEG; -d, -x and -X have no long spelling.
DRY_RUN
-n, --dry-run.
INTERACTIVE
-i, --interactive.

Functions§

clean_changes_worktree
What: Whether the clean can delete files. &CleanRegion borrows the facts. Why: Every unlink and rmdir in Git’s clean is skipped under dry run, also after the interactive menu chose what to delete (builtin/clean.c:191, 223, 267, 1050-1078). Gotcha: Divergence from the incumbent, which treated every interactive clean as deleting: git clean -i -n deletes nothing in Git 2.56.0.
parse_clean_region
What: Parse the region after clean. Result<A, B> is “either success A or failure B”. Why: A region Git itself would refuse yields the refusal; Git then deletes nothing.