Skip to content

Commit e441fa9

Browse files
authored
Merge pull request GitoxideLabs#2438 from mystor/push-wvvuuwmrwlul
diff: skip subtrees with identical oids
2 parents 93f39fb + e63d487 commit e441fa9

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

gix-diff/src/tree/function.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -300,24 +300,30 @@ fn handle_lhs_and_rhs_with_equal_filenames(
300300
) -> Result<(), Error> {
301301
match (lhs.mode.is_tree(), rhs.mode.is_tree()) {
302302
(true, true) => {
303-
delegate.push_back_tracked_path_component(lhs.filename);
304-
if lhs.oid != rhs.oid
305-
&& delegate
303+
if lhs.oid == rhs.oid {
304+
// If the tree oids are identical, we won't bother recursing
305+
// into this subtree as the entire tree is identical.
306+
// For path management purposes, treat it like a skipped blob.
307+
delegate.push_path_component(lhs.filename);
308+
} else {
309+
delegate.push_back_tracked_path_component(lhs.filename);
310+
if delegate
306311
.visit(Change::Modification {
307312
previous_entry_mode: lhs.mode,
308313
previous_oid: lhs.oid.to_owned(),
309314
entry_mode: rhs.mode,
310315
oid: rhs.oid.to_owned(),
311316
})
312317
.is_break()
313-
{
314-
return Err(Error::Cancelled);
318+
{
319+
return Err(Error::Cancelled);
320+
}
321+
queue.push_back((
322+
Some(lhs.oid.to_owned()),
323+
Some(rhs.oid.to_owned()),
324+
relation_to_propagate,
325+
));
315326
}
316-
queue.push_back((
317-
Some(lhs.oid.to_owned()),
318-
Some(rhs.oid.to_owned()),
319-
relation_to_propagate,
320-
));
321327
}
322328
(_, true) => {
323329
delegate.push_back_tracked_path_component(lhs.filename);

gix-pack/tests/pack/data/output/count_and_entries.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ fn traversals() -> crate::Result {
146146
output::count::objects::Outcome {
147147
input_objects: 1,
148148
expanded_objects: 102,
149-
decoded_objects: 18,
149+
decoded_objects: 10,
150150
total_objects: 103,
151151
},
152152
output::entry::iter_from_counts::Outcome {
@@ -179,7 +179,7 @@ fn traversals() -> crate::Result {
179179
output::count::objects::Outcome {
180180
input_objects: 1,
181181
expanded_objects: 102,
182-
decoded_objects: 18,
182+
decoded_objects: 10,
183183
total_objects: 103,
184184
},
185185
output::entry::iter_from_counts::Outcome {
@@ -221,7 +221,7 @@ fn traversals() -> crate::Result {
221221
output::count::objects::Outcome {
222222
input_objects: 16,
223223
expanded_objects: 866,
224-
decoded_objects: 208,
224+
decoded_objects: 74,
225225
total_objects: 868,
226226
},
227227
output::entry::iter_from_counts::Outcome {

0 commit comments

Comments
 (0)