Skip to main content

clean

Function clean 

Source
pub fn clean<R: Read, W: Write>(
    store: &Store,
    input: &mut R,
    output: &mut W,
    path: &str,
    extensions: &[CleanExtension],
) -> Result<CleanOutcome, CleanError>
Expand description

Apply the clean filter to input, writing the resulting pointer (or the pass-through bytes) to output.

Algorithm:

  1. Read up to MAX_POINTER_SIZE bytes.
  2. If those bytes parse as a valid pointer, emit them verbatim (CleanOutcome::Passthrough).
  3. Otherwise stream the buffered head + the rest of input through each configured extension in priority order, hashing the input to each phase to record ext-N-<name> sha256:<hash> lines, and Store::insert the final phase’s output.

path is the working-tree path (as passed by git on the command line / filter-process header). It substitutes for %f in each extension’s clean command. May be empty when no path is known (e.g. piped invocation git lfs clean with no -- arg).