Skip to content

Commit dfb3f18

Browse files
committed
Merge branch 'gix-status'
2 parents 5ce9784 + 1706e23 commit dfb3f18

File tree

82 files changed

+4728
-537
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+4728
-537
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ jobs:
205205
name: crates without feature toggles
206206
- 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
207207
name: features of gix-features
208-
- run: set +x; for name in gix-diff gix-pack; do (cd $name && cargo build --features wasm --target ${{ matrix.target }}); done
208+
- run: set +x; for name in gix-pack; do (cd $name && cargo build --features wasm --target ${{ matrix.target }}); done
209209
name: crates with 'wasm' feature
210210
- run: cd gix-pack && cargo build --all-features --target ${{ matrix.target }}
211211
name: gix-pack with all features (including wasm)

Cargo.lock

Lines changed: 76 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crate-status.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,16 +293,29 @@ The top-level crate that acts as hub to all functionality provided by the `gix-*
293293
Check out the [performance discussion][gix-diff-performance] as well.
294294

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

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

gitoxide-core/src/hours/core.rs

Lines changed: 30 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use std::{
88

99
use gix::bstr::BStr;
1010
use itertools::Itertools;
11-
use smallvec::SmallVec;
1211

1312
use crate::hours::{
1413
util::{add_lines, remove_lines},
@@ -92,25 +91,16 @@ pub fn spawn_tree_delta_threads<'scope>(
9291
move || -> Result<_, anyhow::Error> {
9392
let mut out = Vec::new();
9493
let (commits, changes, lines_count) = stats_counters;
95-
let mut attributes = line_stats
94+
let mut cache = line_stats
9695
.then(|| -> anyhow::Result<_> {
97-
repo.index_or_load_from_head().map_err(Into::into).and_then(|index| {
98-
repo.attributes(
99-
&index,
100-
gix::worktree::stack::state::attributes::Source::IdMapping,
101-
gix::worktree::stack::state::ignore::Source::IdMapping,
102-
None,
103-
)
104-
.map_err(Into::into)
105-
.map(|attrs| {
106-
let matches = attrs.selected_attribute_matches(["binary", "text"]);
107-
(attrs, matches)
108-
})
109-
})
96+
Ok(repo.diff_resource_cache(gix::diff::blob::pipeline::Mode::ToGit, Default::default())?)
11097
})
11198
.transpose()?;
11299
for chunk in rx {
113100
for (commit_idx, parent_commit, commit) in chunk {
101+
if let Some(cache) = cache.as_mut() {
102+
cache.clear_resource_cache();
103+
}
114104
commits.fetch_add(1, Ordering::Relaxed);
115105
if gix::interrupt::is_triggered() {
116106
return Ok(out);
@@ -155,47 +145,34 @@ pub fn spawn_tree_delta_threads<'scope>(
155145
previous_entry_mode,
156146
id,
157147
previous_id,
158-
} => {
159-
match (previous_entry_mode.is_blob(), entry_mode.is_blob()) {
160-
(false, false) => {}
161-
(false, true) => {
162-
files.added += 1;
163-
add_lines(line_stats, &lines_count, &mut lines, id);
164-
}
165-
(true, false) => {
166-
files.removed += 1;
167-
remove_lines(line_stats, &lines_count, &mut lines, previous_id);
168-
}
169-
(true, true) => {
170-
files.modified += 1;
171-
if let Some((attrs, matches)) = attributes.as_mut() {
172-
let entry = attrs.at_entry(change.location, Some(false))?;
173-
let is_text_file = if entry.matching_attributes(matches) {
174-
let attrs: SmallVec<[_; 2]> =
175-
matches.iter_selected().collect();
176-
let binary = &attrs[0];
177-
let text = &attrs[1];
178-
!binary.assignment.state.is_set()
179-
&& !text.assignment.state.is_unset()
180-
} else {
181-
// In the absence of binary or text markers, we assume it's text.
182-
true
183-
};
184-
185-
if let Some(Ok(diff)) =
186-
is_text_file.then(|| change.event.diff()).flatten()
187-
{
188-
let mut nl = 0;
189-
let counts = diff.line_counts();
190-
nl += counts.insertions as usize + counts.removals as usize;
191-
lines.added += counts.insertions as usize;
192-
lines.removed += counts.removals as usize;
193-
lines_count.fetch_add(nl, Ordering::Relaxed);
194-
}
148+
} => match (previous_entry_mode.is_blob(), entry_mode.is_blob()) {
149+
(false, false) => {}
150+
(false, true) => {
151+
files.added += 1;
152+
add_lines(line_stats, &lines_count, &mut lines, id);
153+
}
154+
(true, false) => {
155+
files.removed += 1;
156+
remove_lines(line_stats, &lines_count, &mut lines, previous_id);
157+
}
158+
(true, true) => {
159+
files.modified += 1;
160+
if let Some(cache) = cache.as_mut() {
161+
let mut diff = change.diff(cache).map_err(|err| {
162+
std::io::Error::new(std::io::ErrorKind::Other, err)
163+
})?;
164+
let mut nl = 0;
165+
if let Some(counts) = diff.line_counts().map_err(|err| {
166+
std::io::Error::new(std::io::ErrorKind::Other, err)
167+
})? {
168+
nl += counts.insertions as usize + counts.removals as usize;
169+
lines.added += counts.insertions as usize;
170+
lines.removed += counts.removals as usize;
171+
lines_count.fetch_add(nl, Ordering::Relaxed);
195172
}
196173
}
197174
}
198-
}
175+
},
199176
}
200177
Ok::<_, std::io::Error>(Default::default())
201178
})?;

0 commit comments

Comments
 (0)