Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diff correctness #1106

Merged
merged 20 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1838cbd
feat: support for querying only the header of an object with the `Fin…
Byron Nov 18, 2023
336d161
adapt to changes in `gix-object` (Find::try_header())
Byron Nov 18, 2023
ee47fba
fix: specify minimum required `url` version of v2.2.0 (#1119).
Byron Nov 17, 2023
86cdb42
feat: Add `Buffers` type.
Byron Nov 17, 2023
1ed74f7
use `Buffers` implementation from `gix-utils`
Byron Nov 17, 2023
c752f67
fix: Use `gix-objet::Find` error type.
Byron Nov 13, 2023
c74c7fe
feat!: simplify `Pipeline::new()` by reomving the metadata collection.
Byron Nov 15, 2023
7d754cc
more correct initialization order for new attribute search outcomes.
Byron Nov 15, 2023
1763862
adapt to changes in `gix-filter`
Byron Nov 15, 2023
0f03a08
feat: Allow obtaining mutable pipeline buffers.
Byron Nov 17, 2023
552bed2
feat!: Use `&dyn gix_object::Find` where possible.
Byron Nov 18, 2023
a0e4dec
adapt to changes in `gix-worktree`
Byron Nov 18, 2023
20e56b3
feat: add `Oid::is_null()` - previously it was only available on `Obj…
Byron Nov 27, 2023
ebe66db
feat: add `blob::Platform` and `blob::Pipeline` for diff-content conv…
Byron Nov 13, 2023
feca5d0
feat!: rewrite-tracker now uses blob diff-platform for correct and op…
Byron Nov 28, 2023
4aea9b0
feat: add the`diff::resource_cache()` low-level utility for rapid in-…
Byron Nov 28, 2023
6f4bbc3
feat: add key for `diff.external`.
Byron Dec 2, 2023
406acef
Allow empty paths to be passed to Stack in debug mode
Byron Dec 2, 2023
4743212
feat!: `object::blob::diff::Platform` now performs all necessary conv…
Byron Dec 2, 2023
1706e23
adapt to changes in `gix-diff`
Byron Nov 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ jobs:
name: crates without feature toggles
- run: set +x; for feature in progress fs-walkdir-parallel parallel io-pipe crc32 zlib zlib-rust-backend fast-sha1 rustsha1 cache-efficiency-debug; do (cd gix-features && cargo build --features $feature --target ${{ matrix.target }}); done
name: features of gix-features
- run: set +x; for name in gix-diff gix-pack; do (cd $name && cargo build --features wasm --target ${{ matrix.target }}); done
- run: set +x; for name in gix-pack; do (cd $name && cargo build --features wasm --target ${{ matrix.target }}); done
name: crates with 'wasm' feature
- run: cd gix-pack && cargo build --all-features --target ${{ matrix.target }}
name: gix-pack with all features (including wasm)
87 changes: 76 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 20 additions & 7 deletions crate-status.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,16 +293,29 @@ The top-level crate that acts as hub to all functionality provided by the `gix-*
Check out the [performance discussion][gix-diff-performance] as well.

* **tree**
* [x] changes needed to obtain _other tree_
* [x] changes needed to obtain _other tree_
* **patches**
* There are various ways to generate a patch from two blobs.
* [ ] any
* There are various ways to generate a patch from two blobs.
* [ ] text
* [ ] binary
* **lines**
* [x] Simple line-by-line diffs powered by the `imara-diff` crate.
* diffing, merging, working with hunks of data
* find differences between various states, i.e. index, working tree, commit-tree
* [x] Simple line-by-line diffs powered by the `imara-diff` crate.
* **generic rename tracker to find renames and copies**
* [x] find by exact match
* [x] find by similarity check
* [ ] heuristics to find best candidate
* [ ] find by basename to help detecting simple moves
* **blob**
* [x] a choice of to-worktree, to-git and to-worktree-if-needed conversions
* [x] `textconv` filters
* [x] special handling of files beyond the big-file threshold.
* [x] detection of binary files by looking at header (first 8k bytes)
* [x] caching of diff-able data
* [x] prepare invocation of external diff program
- [ ] pass meta-info
* [ ] working with hunks of data
* [x] API documentation
* [ ] Examples
* [ ] Examples

[gix-diff-performance]: https://github.com/Byron/gitoxide/discussions/74

Expand Down
83 changes: 30 additions & 53 deletions gitoxide-core/src/hours/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::{

use gix::bstr::BStr;
use itertools::Itertools;
use smallvec::SmallVec;

use crate::hours::{
util::{add_lines, remove_lines},
Expand Down Expand Up @@ -92,25 +91,16 @@ pub fn spawn_tree_delta_threads<'scope>(
move || -> Result<_, anyhow::Error> {
let mut out = Vec::new();
let (commits, changes, lines_count) = stats_counters;
let mut attributes = line_stats
let mut cache = line_stats
.then(|| -> anyhow::Result<_> {
repo.index_or_load_from_head().map_err(Into::into).and_then(|index| {
repo.attributes(
&index,
gix::worktree::stack::state::attributes::Source::IdMapping,
gix::worktree::stack::state::ignore::Source::IdMapping,
None,
)
.map_err(Into::into)
.map(|attrs| {
let matches = attrs.selected_attribute_matches(["binary", "text"]);
(attrs, matches)
})
})
Ok(repo.diff_resource_cache(gix::diff::blob::pipeline::Mode::ToGit, Default::default())?)
})
.transpose()?;
for chunk in rx {
for (commit_idx, parent_commit, commit) in chunk {
if let Some(cache) = cache.as_mut() {
cache.clear_resource_cache();
}
commits.fetch_add(1, Ordering::Relaxed);
if gix::interrupt::is_triggered() {
return Ok(out);
Expand Down Expand Up @@ -155,47 +145,34 @@ pub fn spawn_tree_delta_threads<'scope>(
previous_entry_mode,
id,
previous_id,
} => {
match (previous_entry_mode.is_blob(), entry_mode.is_blob()) {
(false, false) => {}
(false, true) => {
files.added += 1;
add_lines(line_stats, &lines_count, &mut lines, id);
}
(true, false) => {
files.removed += 1;
remove_lines(line_stats, &lines_count, &mut lines, previous_id);
}
(true, true) => {
files.modified += 1;
if let Some((attrs, matches)) = attributes.as_mut() {
let entry = attrs.at_entry(change.location, Some(false))?;
let is_text_file = if entry.matching_attributes(matches) {
let attrs: SmallVec<[_; 2]> =
matches.iter_selected().collect();
let binary = &attrs[0];
let text = &attrs[1];
!binary.assignment.state.is_set()
&& !text.assignment.state.is_unset()
} else {
// In the absence of binary or text markers, we assume it's text.
true
};

if let Some(Ok(diff)) =
is_text_file.then(|| change.event.diff()).flatten()
{
let mut nl = 0;
let counts = diff.line_counts();
nl += counts.insertions as usize + counts.removals as usize;
lines.added += counts.insertions as usize;
lines.removed += counts.removals as usize;
lines_count.fetch_add(nl, Ordering::Relaxed);
}
} => match (previous_entry_mode.is_blob(), entry_mode.is_blob()) {
(false, false) => {}
(false, true) => {
files.added += 1;
add_lines(line_stats, &lines_count, &mut lines, id);
}
(true, false) => {
files.removed += 1;
remove_lines(line_stats, &lines_count, &mut lines, previous_id);
}
(true, true) => {
files.modified += 1;
if let Some(cache) = cache.as_mut() {
let mut diff = change.diff(cache).map_err(|err| {
std::io::Error::new(std::io::ErrorKind::Other, err)
})?;
let mut nl = 0;
if let Some(counts) = diff.line_counts().map_err(|err| {
std::io::Error::new(std::io::ErrorKind::Other, err)
})? {
nl += counts.insertions as usize + counts.removals as usize;
lines.added += counts.insertions as usize;
lines.removed += counts.removals as usize;
lines_count.fetch_add(nl, Ordering::Relaxed);
}
}
}
}
},
}
Ok::<_, std::io::Error>(Default::default())
})?;
Expand Down
Loading
Loading