summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2023-02-16 10:23:28 +0000
committerGitHub <noreply@github.com>2023-02-16 10:23:28 +0000
commit05ba3fe4e15ce91e6470ae57d1f4a71fc6147eba (patch)
treec12ebe6dc8cc8f17c8df1194aa7d61cc1d1a936d /tests
parent7108b4318f365968ad542d3a11b6b1a67c41306d (diff)
parent35580d88a834438275adea77785a5f356352ea21 (diff)
downloadlibgit2-05ba3fe4e15ce91e6470ae57d1f4a71fc6147eba.tar.gz
Merge pull request #6330 from gitkraken-jacobw/partial-stashing
stash: partial stash specific files
Diffstat (limited to 'tests')
-rw-r--r--tests/libgit2/core/structinit.c5
-rw-r--r--tests/libgit2/stash/save.c37
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/libgit2/core/structinit.c b/tests/libgit2/core/structinit.c
index 160e2f612..8a6e48d2a 100644
--- a/tests/libgit2/core/structinit.c
+++ b/tests/libgit2/core/structinit.c
@@ -160,6 +160,11 @@ void test_core_structinit__compare(void)
git_stash_apply_options, GIT_STASH_APPLY_OPTIONS_VERSION, \
GIT_STASH_APPLY_OPTIONS_INIT, git_stash_apply_options_init);
+ /* stash save */
+ CHECK_MACRO_FUNC_INIT_EQUAL( \
+ git_stash_save_options, GIT_STASH_SAVE_OPTIONS_VERSION, \
+ GIT_STASH_SAVE_OPTIONS_INIT, git_stash_save_options_init);
+
/* status */
CHECK_MACRO_FUNC_INIT_EQUAL( \
git_status_options, GIT_STATUS_OPTIONS_VERSION, \
diff --git a/tests/libgit2/stash/save.c b/tests/libgit2/stash/save.c
index f574211d7..23f3c1cbb 100644
--- a/tests/libgit2/stash/save.c
+++ b/tests/libgit2/stash/save.c
@@ -130,6 +130,19 @@ void test_stash_save__can_keep_index(void)
assert_status(repo, "just.ignore", GIT_STATUS_IGNORED);
}
+void test_stash_save__can_keep_all(void)
+{
+ cl_git_pass(git_stash_save(&stash_tip_oid, repo, signature, NULL, GIT_STASH_KEEP_ALL));
+
+ assert_status(repo, "what", GIT_STATUS_WT_MODIFIED | GIT_STATUS_INDEX_MODIFIED);
+ assert_status(repo, "how", GIT_STATUS_INDEX_MODIFIED);
+ 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_WT_MODIFIED | GIT_STATUS_INDEX_NEW);
+ assert_status(repo, "just.ignore", GIT_STATUS_IGNORED);
+}
+
static void assert_commit_message_contains(const char *revision, const char *fragment)
{
git_commit *commit;
@@ -488,3 +501,27 @@ void test_stash_save__deleted_in_index_modified_in_workdir(void)
git_index_free(index);
}
+
+void test_stash_save__option_paths(void)
+{
+ git_stash_save_options options = GIT_STASH_SAVE_OPTIONS_INIT;
+ char *paths[2] = { "who", "where" };
+
+ options.paths = (git_strarray){
+ paths,
+ 2
+ };
+ options.stasher = signature;
+
+ cl_git_pass(git_stash_save_with_opts(&stash_tip_oid, repo, &options));
+
+ assert_blob_oid("refs/stash:who", "a0400d4954659306a976567af43125a0b1aa8595");
+ assert_blob_oid("refs/stash:where", "e3d6434ec12eb76af8dfa843a64ba6ab91014a0b");
+
+ assert_blob_oid("refs/stash:what", "ce013625030ba8dba906f756967f9e9ca394464a");
+ assert_blob_oid("refs/stash:how", "ac790413e2d7a26c3767e78c57bb28716686eebc");
+ assert_blob_oid("refs/stash:when", NULL);
+ assert_blob_oid("refs/stash:why", NULL);
+ assert_blob_oid("refs/stash:.gitignore", "ac4d88de61733173d9959e4b77c69b9f17a00980");
+ assert_blob_oid("refs/stash:just.ignore", NULL);
+}