Skip to content

Commit

Permalink
improve docs around worktree-filters and renormalization
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Sep 27, 2024
1 parent 21bca6c commit ad9587a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions gix-filter/src/eol/convert_to_git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ pub(crate) mod function {
/// Return `true` if `buf` was written or `false` if nothing had to be done.
/// Depending on the state in `buf`, `index_object` is called to write the version of `src` as stored in the index
/// into the buffer and if it is a blob, or return `Ok(None)` if no such object exists.
/// If renormalization is desired, let it return `Ok(None)` at all times to not let it have any influence over the
/// outcome of this function.
///
/// *If renormalization is desired*, let it return `Ok(None)` at all times to not let it have any influence over the
/// outcome of this function. Otherwise, it will check if the in-index buffer already has newlines that it would now
/// want to change, and avoid doing so as what's in Git should be what's desired (except for when *renormalizing*).
/// If `round_trip_check` is not `None`, round-tripping will be validated and handled accordingly.
pub fn convert_to_git(
src: &[u8],
Expand Down
10 changes: 5 additions & 5 deletions gix-filter/src/pipeline/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl Pipeline {
self.options.eol_config,
)?;

let mut in_buffer = false;
let mut in_src_buffer = false;
// this is just an approximation, but it's as good as it gets without reading the actual input.
let would_convert_eol = eol::convert_to_git(
b"\r\n",
Expand Down Expand Up @@ -119,13 +119,13 @@ impl Pipeline {
}
self.bufs.clear();
read.read_to_end(&mut self.bufs.src)?;
in_buffer = true;
in_src_buffer = true;
}
}
if !in_buffer && (apply_ident_filter || encoding.is_some() || would_convert_eol) {
if !in_src_buffer && (apply_ident_filter || encoding.is_some() || would_convert_eol) {
self.bufs.clear();
src.read_to_end(&mut self.bufs.src)?;
in_buffer = true;
in_src_buffer = true;
}

if let Some(encoding) = encoding {
Expand Down Expand Up @@ -158,7 +158,7 @@ impl Pipeline {
if apply_ident_filter && ident::undo(&self.bufs.src, &mut self.bufs.dest)? {
self.bufs.swap();
}
Ok(if in_buffer {
Ok(if in_src_buffer {
ToGitOutcome::Buffer(&self.bufs.src)
} else {
ToGitOutcome::Unchanged(src)
Expand Down

0 comments on commit ad9587a

Please sign in to comment.