diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2015-06-20 23:44:22 +0300 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2015-06-26 01:34:36 +0300 |
commit | 82b1c93d088319c4e385c11ce738b68103eab96c (patch) | |
tree | ab3c961fea42fde1a8d739be70d8744e5e8ae324 /tests/stash | |
parent | 1db6a0ab52e54397e450c2796dce65eced8c4c25 (diff) |
stash: don't allow apply with staged changes
Diffstat (limited to 'tests/stash')
-rw-r--r-- | tests/stash/apply.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/stash/apply.c b/tests/stash/apply.c index bd6bb565d..db145d58d 100644 --- a/tests/stash/apply.c +++ b/tests/stash/apply.c @@ -118,13 +118,14 @@ void test_stash_apply__conflict_index_with_reinstate_index(void) cl_git_rewritefile("stash/who", "nothing\n"); cl_git_pass(git_index_add_bypath(repo_index, "who")); cl_git_pass(git_index_write(repo_index)); + cl_repo_commit_from_index(NULL, repo, signature, 0, "Other commit"); cl_git_fail_with(git_stash_apply(repo, 0, &opts), GIT_ECONFLICT); cl_assert_equal_i(git_index_has_conflicts(repo_index), 0); assert_status(repo, "what", GIT_STATUS_CURRENT); assert_status(repo, "how", GIT_STATUS_CURRENT); - assert_status(repo, "who", GIT_STATUS_INDEX_MODIFIED); + assert_status(repo, "who", GIT_STATUS_CURRENT); assert_status(repo, "when", GIT_ENOTFOUND); assert_status(repo, "why", GIT_ENOTFOUND); } @@ -238,6 +239,22 @@ void test_stash_apply__conflict_commit_with_reinstate_index(void) assert_status(repo, "why", GIT_STATUS_INDEX_NEW); } +void test_stash_apply__fails_with_uncommitted_changes_in_index(void) +{ + cl_git_rewritefile("stash/who", "nothing\n"); + cl_git_pass(git_index_add_bypath(repo_index, "who")); + cl_git_pass(git_index_write(repo_index)); + + cl_git_fail_with(git_stash_apply(repo, 0, NULL), GIT_EUNCOMMITTED); + + cl_assert_equal_i(git_index_has_conflicts(repo_index), 0); + assert_status(repo, "what", GIT_STATUS_CURRENT); + assert_status(repo, "how", GIT_STATUS_CURRENT); + assert_status(repo, "who", GIT_STATUS_INDEX_MODIFIED); + assert_status(repo, "when", GIT_ENOTFOUND); + assert_status(repo, "why", GIT_ENOTFOUND); +} + void test_stash_apply__pop(void) { cl_git_pass(git_stash_pop(repo, 0, NULL)); |