summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-02-18 11:26:03 -0500
committerEdward Thomson <ethomson@microsoft.com>2015-02-18 11:26:03 -0500
commit09866d6f84a644c4dff258055c570d619fe7bad7 (patch)
treefeef0c7802d8a4b6e64276ea53a92d4bd37bb47e
parent57f45e7f4dd7202607f51292a816a262622e964c (diff)
downloadlibgit2-09866d6f84a644c4dff258055c570d619fe7bad7.tar.gz
stash: correctly stash wd modified/index deleted
-rw-r--r--src/stash.c3
-rw-r--r--tests/stash/save.c19
2 files changed, 20 insertions, 2 deletions
diff --git a/src/stash.c b/src/stash.c
index cad87d120..694853672 100644
--- a/src/stash.c
+++ b/src/stash.c
@@ -313,8 +313,7 @@ static int build_workdir_tree(
if ((error = git_commit_tree(&b_tree, b_commit)) < 0)
goto cleanup;
- if ((error = git_diff_tree_to_workdir_with_index(
- &diff, repo, b_tree, &opts)) < 0)
+ if ((error = git_diff_tree_to_workdir(&diff, repo, b_tree, &opts)) < 0)
goto cleanup;
data.include_changed = true;
diff --git a/tests/stash/save.c b/tests/stash/save.c
index a5bdd0cbe..1433730c6 100644
--- a/tests/stash/save.c
+++ b/tests/stash/save.c
@@ -399,3 +399,22 @@ void test_stash_save__skip_submodules(void)
assert_status(repo, "untracked_repo/", GIT_STATUS_WT_NEW);
}
+
+void test_stash_save__deleted_in_index_modified_in_workdir(void)
+{
+ git_index *index;
+
+ git_repository_index(&index, repo);
+
+ cl_git_pass(git_index_remove_bypath(index, "who"));
+ cl_git_pass(git_index_write(index));
+
+ assert_status(repo, "who", GIT_STATUS_WT_NEW | GIT_STATUS_INDEX_DELETED);
+
+ cl_git_pass(git_stash_save(&stash_tip_oid, repo, signature, NULL, GIT_STASH_DEFAULT));
+
+ assert_blob_oid("stash@{0}^0:who", "a0400d4954659306a976567af43125a0b1aa8595");
+ assert_blob_oid("stash@{0}^2:who", NULL);
+
+ git_index_free(index);
+}