@@ -216,10 +216,10 @@ extern "C" fn stash_apply_progress_cb(
216
216
mod tests {
217
217
use crate :: stash:: { StashApplyOptions , StashSaveOptions } ;
218
218
use crate :: test:: repo_init;
219
- use crate :: { Repository , StashFlags , Status } ;
219
+ use crate :: { IndexAddOption , Repository , StashFlags , Status } ;
220
220
use std:: fs;
221
221
use std:: io:: Write ;
222
- use std:: path:: Path ;
222
+ use std:: path:: { Path , PathBuf } ;
223
223
224
224
fn make_stash < C > ( next : C )
225
225
where
@@ -322,30 +322,39 @@ mod tests {
322
322
assert ! ( stash_name. starts_with( "WIP on main:" ) ) ;
323
323
}
324
324
325
+ fn create_file ( r : & Repository , name : & str , data : & str ) -> PathBuf {
326
+ let p = Path :: new ( r. workdir ( ) . unwrap ( ) ) . join ( name) ;
327
+ fs:: File :: create ( & p)
328
+ . unwrap ( )
329
+ . write ( data. as_bytes ( ) )
330
+ . unwrap ( ) ;
331
+ p
332
+ }
333
+
325
334
#[ test]
326
335
fn test_stash_save_ext ( ) {
327
336
let ( _td, mut repo) = repo_init ( ) ;
328
337
let signature = repo. signature ( ) . unwrap ( ) ;
329
338
330
- let path_a = Path :: new ( repo. workdir ( ) . unwrap ( ) ) . join ( "file_a" ) ;
331
- fs:: File :: create ( & path_a)
332
- . unwrap ( )
333
- . write ( "data" . as_bytes ( ) )
334
- . unwrap ( ) ;
339
+ create_file ( & repo, "file_a" , "foo" ) ;
340
+ create_file ( & repo, "file_b" , "foo" ) ;
335
341
336
- let path_b = Path :: new ( repo. workdir ( ) . unwrap ( ) ) . join ( "file_b" ) ;
337
- fs:: File :: create ( & path_b)
338
- . unwrap ( )
339
- . write ( "data" . as_bytes ( ) )
342
+ let mut index = repo. index ( ) . unwrap ( ) ;
343
+ index
344
+ . add_all ( [ "*" ] . iter ( ) , IndexAddOption :: DEFAULT , None )
340
345
. unwrap ( ) ;
346
+ index. write ( ) . unwrap ( ) ;
341
347
342
348
assert_eq ! ( repo. statuses( None ) . unwrap( ) . len( ) , 2 ) ;
343
349
344
350
let mut opt = StashSaveOptions :: new ( signature) ;
345
351
opt. pathspec ( "file_a" ) ;
346
- opt. flags ( Some ( StashFlags :: INCLUDE_UNTRACKED ) ) ;
347
352
repo. stash_save_ext ( Some ( & mut opt) ) . unwrap ( ) ;
348
353
354
+ assert_eq ! ( repo. statuses( None ) . unwrap( ) . len( ) , 0 ) ;
355
+
356
+ repo. stash_pop ( 0 , None ) . unwrap ( ) ;
357
+
349
358
assert_eq ! ( repo. statuses( None ) . unwrap( ) . len( ) , 1 ) ;
350
359
}
351
360
}
0 commit comments