1- use anyhow:: { anyhow, Context , Result } ;
1+ use anyhow:: { anyhow, Result } ;
22use git_features:: progress:: { self , Progress } ;
33use git_object:: { owned, HashKind } ;
44use git_odb:: { loose, pack, Write } ;
@@ -124,19 +124,29 @@ impl OutputWriter {
124124 }
125125}
126126
127+ pub struct Context {
128+ pub thread_limit : Option < usize > ,
129+ pub delete_pack : bool ,
130+ pub sink_compress : bool ,
131+ }
132+
127133pub fn pack_or_pack_index < P > (
128134 pack_path : impl AsRef < Path > ,
129135 object_path : Option < impl AsRef < Path > > ,
130136 check : SafetyCheck ,
131- thread_limit : Option < usize > ,
132137 progress : Option < P > ,
133- delete_pack : bool ,
134- sink_compress : bool ,
138+ Context {
139+ thread_limit,
140+ delete_pack,
141+ sink_compress,
142+ } : Context ,
135143) -> Result < ( ) >
136144where
137145 P : Progress ,
138146 <P as Progress >:: SubProgress : Send ,
139147{
148+ use anyhow:: Context ;
149+
140150 let path = pack_path. as_ref ( ) ;
141151 let bundle = pack:: Bundle :: at ( path) . with_context ( || {
142152 format ! (
@@ -154,17 +164,17 @@ where
154164
155165 let algorithm = object_path
156166 . as_ref ( )
157- . map ( |_| {
167+ . map ( |_| pack:: index:: traverse:: Algorithm :: Lookup )
168+ . unwrap_or_else ( || {
158169 if sink_compress {
159170 pack:: index:: traverse:: Algorithm :: Lookup
160171 } else {
161172 pack:: index:: traverse:: Algorithm :: DeltaTreeLookup
162173 }
163- } )
164- . unwrap_or ( pack:: index:: traverse:: Algorithm :: Lookup ) ;
174+ } ) ;
165175 let mut progress = bundle. index . traverse (
166176 & bundle. pack ,
167- pack:: index:: traverse:: Context {
177+ pack:: index:: traverse:: Options {
168178 algorithm,
169179 thread_limit,
170180 check : check. into ( ) ,
0 commit comments