@@ -116,10 +116,10 @@ impl git_odb::Write for OutputWriter {
116116}
117117
118118impl OutputWriter {
119- fn new ( path : Option < impl AsRef < Path > > ) -> Self {
119+ fn new ( path : Option < impl AsRef < Path > > , compress : bool ) -> Self {
120120 match path {
121121 Some ( path) => OutputWriter :: Loose ( loose:: Db :: at ( path. as_ref ( ) ) ) ,
122- None => OutputWriter :: Sink ( git_odb:: sink ( ) . compress ( true ) ) ,
122+ None => OutputWriter :: Sink ( git_odb:: sink ( ) . compress ( compress ) ) ,
123123 }
124124 }
125125}
@@ -131,6 +131,7 @@ pub fn pack_or_pack_index<P>(
131131 thread_limit : Option < usize > ,
132132 progress : Option < P > ,
133133 delete_pack : bool ,
134+ sink_compress : bool ,
134135) -> Result < ( ) >
135136where
136137 P : Progress ,
@@ -151,18 +152,28 @@ where
151152 ) ) ;
152153 }
153154
155+ let algorithm = object_path
156+ . as_ref ( )
157+ . map ( |_| {
158+ if sink_compress {
159+ pack:: index:: traverse:: Algorithm :: Lookup
160+ } else {
161+ pack:: index:: traverse:: Algorithm :: DeltaTreeLookup
162+ }
163+ } )
164+ . unwrap_or ( pack:: index:: traverse:: Algorithm :: Lookup ) ;
154165 let mut progress = bundle. index . traverse (
155166 & bundle. pack ,
156167 pack:: index:: traverse:: Context {
157- algorithm : pack :: index :: traverse :: Algorithm :: Lookup ,
168+ algorithm,
158169 thread_limit,
159170 check : check. into ( ) ,
160171 } ,
161172 progress,
162173 {
163174 let object_path = object_path. map ( |p| p. as_ref ( ) . to_owned ( ) ) ;
164175 move || {
165- let out = OutputWriter :: new ( object_path. clone ( ) ) ;
176+ let out = OutputWriter :: new ( object_path. clone ( ) , sink_compress ) ;
166177 move |object_kind, buf, index_entry, _entry_stats, progress| {
167178 let written_id = out
168179 . write_buf ( object_kind, buf, HashKind :: Sha1 )
0 commit comments