summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-06-27 21:15:00 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2015-06-27 21:15:00 +0200
commit92ec9ed328c4864e9c3fc27d0894b40060eb74e5 (patch)
tree9e892f4f79b839682abe79b1bc233a484c09b8b9
parentb4d2c7cb3afbed611091784ef1abe9a546f8ed82 (diff)
parentee6eed5188606a17fb191b8f55f425d32bd4cef6 (diff)
downloadlibgit2-92ec9ed328c4864e9c3fc27d0894b40060eb74e5.tar.gz
Merge pull request #3260 from ethomson/apply_with_reflog_indices
stash: test we apply using reflog-like indices
-rw-r--r--tests/stash/apply.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/stash/apply.c b/tests/stash/apply.c
index 901667df3..1056ce7eb 100644
--- a/tests/stash/apply.c
+++ b/tests/stash/apply.c
@@ -413,3 +413,37 @@ void test_stash_apply__progress_cb_can_abort(void)
cl_git_fail_with(-44, git_stash_apply(repo, 0, &opts));
}
+
+void test_stash_apply__uses_reflog_like_indices_1(void)
+{
+ git_oid oid;
+
+ cl_git_mkfile("stash/untracked", "untracked\n");
+ cl_git_pass(git_stash_save(&oid, repo, signature, NULL, GIT_STASH_INCLUDE_UNTRACKED));
+ assert_status(repo, "untracked", GIT_ENOTFOUND);
+
+ // stash@{1} is the oldest (first) stash we made
+ cl_git_pass(git_stash_apply(repo, 1, NULL));
+ cl_assert_equal_i(git_index_has_conflicts(repo_index), 0);
+ assert_status(repo, "what", GIT_STATUS_WT_MODIFIED);
+ assert_status(repo, "how", GIT_STATUS_CURRENT);
+ assert_status(repo, "who", GIT_STATUS_WT_MODIFIED);
+ assert_status(repo, "when", GIT_STATUS_WT_NEW);
+ assert_status(repo, "why", GIT_STATUS_INDEX_NEW);
+ assert_status(repo, "where", GIT_STATUS_INDEX_NEW);
+}
+
+void test_stash_apply__uses_reflog_like_indices_2(void)
+{
+ git_oid oid;
+
+ cl_git_mkfile("stash/untracked", "untracked\n");
+ cl_git_pass(git_stash_save(&oid, repo, signature, NULL, GIT_STASH_INCLUDE_UNTRACKED));
+ assert_status(repo, "untracked", GIT_ENOTFOUND);
+
+ // stash@{0} is the newest stash we made immediately above
+ cl_git_pass(git_stash_apply(repo, 0, NULL));
+
+ cl_assert_equal_i(git_index_has_conflicts(repo_index), 0);
+ assert_status(repo, "untracked", GIT_STATUS_WT_NEW);
+}