Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b107f28

Browse files
committed
stash: test we apply using reflog-like indices
1 parent 3b66c6a commit b107f28

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/stash/apply.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,3 +337,37 @@ void test_stash_apply__progress_cb_can_abort(void)
337337

338338
cl_git_fail_with(-44, git_stash_apply(repo, 0, &opts));
339339
}
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

Comments
 (0)