@@ -413,3 +413,37 @@ void test_stash_apply__progress_cb_can_abort(void)
413
413
414
414
cl_git_fail_with (-44 , git_stash_apply (repo , 0 , & opts ));
415
415
}
416
+
417
+ void test_stash_apply__uses_reflog_like_indices_1 (void )
418
+ {
419
+ git_oid oid ;
420
+
421
+ cl_git_mkfile ("stash/untracked" , "untracked\n" );
422
+ cl_git_pass (git_stash_save (& oid , repo , signature , NULL , GIT_STASH_INCLUDE_UNTRACKED ));
423
+ assert_status (repo , "untracked" , GIT_ENOTFOUND );
424
+
425
+ // stash@{1} is the oldest (first) stash we made
426
+ cl_git_pass (git_stash_apply (repo , 1 , NULL ));
427
+ cl_assert_equal_i (git_index_has_conflicts (repo_index ), 0 );
428
+ assert_status (repo , "what" , GIT_STATUS_WT_MODIFIED );
429
+ assert_status (repo , "how" , GIT_STATUS_CURRENT );
430
+ assert_status (repo , "who" , GIT_STATUS_WT_MODIFIED );
431
+ assert_status (repo , "when" , GIT_STATUS_WT_NEW );
432
+ assert_status (repo , "why" , GIT_STATUS_INDEX_NEW );
433
+ assert_status (repo , "where" , GIT_STATUS_INDEX_NEW );
434
+ }
435
+
436
+ void test_stash_apply__uses_reflog_like_indices_2 (void )
437
+ {
438
+ git_oid oid ;
439
+
440
+ cl_git_mkfile ("stash/untracked" , "untracked\n" );
441
+ cl_git_pass (git_stash_save (& oid , repo , signature , NULL , GIT_STASH_INCLUDE_UNTRACKED ));
442
+ assert_status (repo , "untracked" , GIT_ENOTFOUND );
443
+
444
+ // stash@{0} is the newest stash we made immediately above
445
+ cl_git_pass (git_stash_apply (repo , 0 , NULL ));
446
+
447
+ cl_assert_equal_i (git_index_has_conflicts (repo_index ), 0 );
448
+ assert_status (repo , "untracked" , GIT_STATUS_WT_NEW );
449
+ }
0 commit comments