1
1
use std:: ffi:: CStr ;
2
- use std:: mem:: MaybeUninit ;
3
2
use std:: path:: Path ;
4
3
use std:: { io, marker, mem, ptr} ;
5
4
@@ -108,7 +107,7 @@ pub type TransportProgress<'a> = IndexerProgress<'a>;
108
107
/// database if, and only if, the pack file is self-contained (i.e. not "thin").
109
108
pub struct Indexer < ' odb > {
110
109
raw : * mut raw:: git_indexer ,
111
- progress : MaybeUninit < raw:: git_indexer_progress > ,
110
+ progress : raw:: git_indexer_progress ,
112
111
progress_payload_ptr : * mut OdbPackwriterCb < ' odb > ,
113
112
}
114
113
@@ -128,7 +127,6 @@ impl<'a> Indexer<'a> {
128
127
let odb = odb. map ( Binding :: raw) . unwrap_or_else ( ptr:: null_mut) ;
129
128
130
129
let mut out = ptr:: null_mut ( ) ;
131
- let progress = MaybeUninit :: uninit ( ) ;
132
130
let progress_cb: raw:: git_indexer_progress_cb = Some ( write_pack_progress_cb) ;
133
131
let progress_payload = Box :: new ( OdbPackwriterCb { cb : None } ) ;
134
132
let progress_payload_ptr = Box :: into_raw ( progress_payload) ;
@@ -148,7 +146,7 @@ impl<'a> Indexer<'a> {
148
146
149
147
Ok ( Self {
150
148
raw : out,
151
- progress,
149
+ progress : Default :: default ( ) ,
152
150
progress_payload_ptr,
153
151
} )
154
152
}
@@ -161,10 +159,7 @@ impl<'a> Indexer<'a> {
161
159
/// `pack-<checksum>.idx` respectively).
162
160
pub fn commit ( mut self ) -> Result < String , Error > {
163
161
unsafe {
164
- try_call ! ( raw:: git_indexer_commit(
165
- self . raw,
166
- self . progress. as_mut_ptr( )
167
- ) ) ;
162
+ try_call ! ( raw:: git_indexer_commit( self . raw, & mut self . progress) ) ;
168
163
169
164
let name = CStr :: from_ptr ( raw:: git_indexer_name ( self . raw ) ) ;
170
165
Ok ( name. to_str ( ) . expect ( "pack name not utf8" ) . to_owned ( ) )
@@ -191,7 +186,7 @@ impl io::Write for Indexer<'_> {
191
186
let ptr = buf. as_ptr ( ) as * mut c_void ;
192
187
let len = buf. len ( ) ;
193
188
194
- let res = raw:: git_indexer_append ( self . raw , ptr, len, self . progress . as_mut_ptr ( ) ) ;
189
+ let res = raw:: git_indexer_append ( self . raw , ptr, len, & mut self . progress ) ;
195
190
if res < 0 {
196
191
Err ( io:: Error :: new (
197
192
io:: ErrorKind :: Other ,
0 commit comments