Skip to content

Commit 14717f6

Browse files
committed
[pack #67] refactor
1 parent 1271c01 commit 14717f6

File tree

5 files changed

+22
-20
lines changed

5 files changed

+22
-20
lines changed

git-odb/src/store/compound/init.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ impl compound::Store {
3838
p.extension().unwrap_or_default() == "idx"
3939
&& p.file_name().unwrap_or_default().to_string_lossy().starts_with("pack-")
4040
})
41+
// TODO: make this configurable, git for instance sorts by modification date
42+
// https://github.com/libgit2/libgit2/blob/main/src/odb_pack.c#L41-L158
4143
.map(|(p, md)| pack::Bundle::at(p).map(|b| (b, md.len())))
4244
.collect::<Result<Vec<_>, _>>()?;
4345
packs_and_sizes.sort_by_key(|e| e.1);

git-pack/src/data/output/count/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ impl Count {
2626
}
2727

2828
///
29-
pub mod iter_from_objects;
30-
pub use iter_from_objects::{objects, objects_unthreaded};
29+
pub mod objects;
30+
pub use objects::{objects, objects_unthreaded};

git-pack/src/data/output/count/iter_from_objects.rs renamed to git-pack/src/data/output/count/objects.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ where
318318

319319
mod tree {
320320
pub mod changes {
321-
use crate::data::output::count::iter_from_objects::util::InsertImmutable;
321+
use crate::data::output::count::objects::util::InsertImmutable;
322322
use git_diff::tree::{
323323
visit::{Action, Change},
324324
Visit,
@@ -374,7 +374,7 @@ mod tree {
374374
}
375375

376376
pub mod traverse {
377-
use crate::data::output::count::iter_from_objects::util::InsertImmutable;
377+
use crate::data::output::count::objects::util::InsertImmutable;
378378
use git_hash::ObjectId;
379379
use git_object::{bstr::BStr, immutable::tree::Entry};
380380
use git_traverse::tree::visit::{Action, Visit};

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fn traversals() -> crate::Result {
9090
allow_thin_pack,
9191
) in [
9292
(
93-
count::iter_from_objects::ObjectExpansion::AsIs,
93+
count::objects::ObjectExpansion::AsIs,
9494
Count {
9595
trees: 0,
9696
commits: 15,
@@ -105,7 +105,7 @@ fn traversals() -> crate::Result {
105105
blobs: 0,
106106
tags: 1,
107107
},
108-
output::count::iter_from_objects::Outcome {
108+
output::count::objects::Outcome {
109109
input_objects: 16,
110110
expanded_objects: 0,
111111
decoded_objects: 16,
@@ -122,7 +122,7 @@ fn traversals() -> crate::Result {
122122
false,
123123
),
124124
(
125-
count::iter_from_objects::ObjectExpansion::TreeAdditionsComparedToAncestor,
125+
count::objects::ObjectExpansion::TreeAdditionsComparedToAncestor,
126126
Count {
127127
trees: 3,
128128
commits: 2, // todo: why more?
@@ -137,7 +137,7 @@ fn traversals() -> crate::Result {
137137
blobs: 96,
138138
tags: 0,
139139
},
140-
output::count::iter_from_objects::Outcome {
140+
output::count::objects::Outcome {
141141
input_objects: 1,
142142
expanded_objects: 102,
143143
decoded_objects: 18,
@@ -154,7 +154,7 @@ fn traversals() -> crate::Result {
154154
true,
155155
),
156156
(
157-
count::iter_from_objects::ObjectExpansion::TreeAdditionsComparedToAncestor,
157+
count::objects::ObjectExpansion::TreeAdditionsComparedToAncestor,
158158
Count {
159159
trees: 5,
160160
commits: 2, // todo: why more?
@@ -169,7 +169,7 @@ fn traversals() -> crate::Result {
169169
blobs: 96,
170170
tags: 0,
171171
},
172-
output::count::iter_from_objects::Outcome {
172+
output::count::objects::Outcome {
173173
input_objects: 1,
174174
expanded_objects: 102,
175175
decoded_objects: 18,
@@ -186,10 +186,10 @@ fn traversals() -> crate::Result {
186186
false,
187187
),
188188
(
189-
count::iter_from_objects::ObjectExpansion::TreeContents,
189+
count::objects::ObjectExpansion::TreeContents,
190190
whole_pack,
191191
whole_pack_obj_count,
192-
output::count::iter_from_objects::Outcome {
192+
output::count::objects::Outcome {
193193
input_objects: 16,
194194
expanded_objects: 852,
195195
decoded_objects: 57,
@@ -206,10 +206,10 @@ fn traversals() -> crate::Result {
206206
false,
207207
),
208208
(
209-
count::iter_from_objects::ObjectExpansion::TreeAdditionsComparedToAncestor,
209+
count::objects::ObjectExpansion::TreeAdditionsComparedToAncestor,
210210
whole_pack,
211211
whole_pack_obj_count,
212-
output::count::iter_from_objects::Outcome {
212+
output::count::objects::Outcome {
213213
input_objects: 16,
214214
expanded_objects: 866,
215215
decoded_objects: 208,
@@ -255,7 +255,7 @@ fn traversals() -> crate::Result {
255255
.map(Ok::<_, Infallible>),
256256
progress::Discard,
257257
&AtomicBool::new(false),
258-
count::iter_from_objects::Options {
258+
count::objects::Options {
259259
input_object_expansion: expansion_mode,
260260
thread_limit: deterministic_count_needs_single_thread,
261261
..Default::default()

gitoxide-core/src/pack/create.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ impl FromStr for ObjectExpansion {
4949
}
5050
}
5151

52-
impl From<ObjectExpansion> for pack::data::output::count::iter_from_objects::ObjectExpansion {
52+
impl From<ObjectExpansion> for pack::data::output::count::objects::ObjectExpansion {
5353
fn from(v: ObjectExpansion) -> Self {
54-
use pack::data::output::count::iter_from_objects::ObjectExpansion::*;
54+
use pack::data::output::count::objects::ObjectExpansion::*;
5555
match v {
5656
ObjectExpansion::None => AsIs,
5757
ObjectExpansion::TreeTraversal => TreeContents,
@@ -190,7 +190,7 @@ where
190190
input,
191191
progress,
192192
&interrupt::IS_INTERRUPTED,
193-
pack::data::output::count::iter_from_objects::Options {
193+
pack::data::output::count::objects::Options {
194194
thread_limit,
195195
chunk_size,
196196
input_object_expansion,
@@ -300,7 +300,7 @@ fn print(stats: Statistics, format: OutputFormat, out: impl std::io::Write) -> a
300300
fn human_output(
301301
Statistics {
302302
counts:
303-
pack::data::output::count::iter_from_objects::Outcome {
303+
pack::data::output::count::objects::Outcome {
304304
input_objects,
305305
expanded_objects,
306306
decoded_objects,
@@ -343,7 +343,7 @@ fn human_output(
343343
#[derive(Default)]
344344
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
345345
struct Statistics {
346-
counts: pack::data::output::count::iter_from_objects::Outcome,
346+
counts: pack::data::output::count::objects::Outcome,
347347
entries: pack::data::output::entry::iter_from_counts::Outcome,
348348
}
349349

0 commit comments

Comments
 (0)