@@ -337,3 +337,37 @@ void test_stash_apply__progress_cb_can_abort(void)
337
337
338
338
cl_git_fail_with (-44 , git_stash_apply (repo , 0 , & opts ));
339
339
}
340
+
341
+ void test_stash_apply__uses_reflog_like_indices_1 (void )
342
+ {
343
+ git_oid oid ;
344
+
345
+ cl_git_mkfile ("stash/untracked" , "untracked\n" );
346
+ cl_git_pass (git_stash_save (& oid , repo , signature , NULL , GIT_STASH_INCLUDE_UNTRACKED ));
347
+ assert_status (repo , "untracked" , GIT_ENOTFOUND );
348
+
349
+ // stash@{1} is the oldest (first) stash we made
350
+ cl_git_pass (git_stash_apply (repo , 1 , NULL ));
351
+ cl_assert_equal_i (git_index_has_conflicts (repo_index ), 0 );
352
+ assert_status (repo , "what" , GIT_STATUS_WT_MODIFIED );
353
+ assert_status (repo , "how" , GIT_STATUS_CURRENT );
354
+ assert_status (repo , "who" , GIT_STATUS_WT_MODIFIED );
355
+ assert_status (repo , "when" , GIT_STATUS_WT_NEW );
356
+ assert_status (repo , "why" , GIT_STATUS_INDEX_NEW );
357
+ assert_status (repo , "where" , GIT_STATUS_INDEX_NEW );
358
+ }
359
+
360
+ void test_stash_apply__uses_reflog_like_indices_2 (void )
361
+ {
362
+ git_oid oid ;
363
+
364
+ cl_git_mkfile ("stash/untracked" , "untracked\n" );
365
+ cl_git_pass (git_stash_save (& oid , repo , signature , NULL , GIT_STASH_INCLUDE_UNTRACKED ));
366
+ assert_status (repo , "untracked" , GIT_ENOTFOUND );
367
+
368
+ // stash@{0} is the newest stash we made immediately above
369
+ cl_git_pass (git_stash_apply (repo , 0 , NULL ));
370
+
371
+ cl_assert_equal_i (git_index_has_conflicts (repo_index ), 0 );
372
+ assert_status (repo , "untracked" , GIT_STATUS_WT_NEW );
373
+ }
0 commit comments