diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/stash/save.c | 36 | ||||
-rw-r--r-- | tests/stash/stash_helpers.c | 14 |
2 files changed, 40 insertions, 10 deletions
diff --git a/tests/stash/save.c b/tests/stash/save.c index f06c1fb71..87c6d7e0f 100644 --- a/tests/stash/save.c +++ b/tests/stash/save.c @@ -148,6 +148,25 @@ void test_stash_save__can_include_untracked_files(void) assert_blob_oid("refs/stash^3:just.ignore", NULL); } +void test_stash_save__untracked_skips_ignored(void) +{ + cl_git_append2file("stash/.gitignore", "bundle/vendor/\n"); + cl_must_pass(p_mkdir("stash/bundle", 0777)); + cl_must_pass(p_mkdir("stash/bundle/vendor", 0777)); + cl_git_mkfile("stash/bundle/vendor/blah", "contents\n"); + + cl_assert(git_path_exists("stash/when")); /* untracked */ + cl_assert(git_path_exists("stash/just.ignore")); /* ignored */ + cl_assert(git_path_exists("stash/bundle/vendor/blah")); /* ignored */ + + cl_git_pass(git_stash_save( + &stash_tip_oid, repo, signature, NULL, GIT_STASH_INCLUDE_UNTRACKED)); + + cl_assert(!git_path_exists("stash/when")); + cl_assert(git_path_exists("stash/bundle/vendor/blah")); + cl_assert(git_path_exists("stash/just.ignore")); +} + void test_stash_save__can_include_untracked_and_ignored_files(void) { cl_git_pass(git_stash_save(&stash_tip_oid, repo, signature, NULL, GIT_STASH_INCLUDE_UNTRACKED | GIT_STASH_INCLUDE_IGNORED)); @@ -342,7 +361,7 @@ void test_stash_save__can_stage_normal_then_stage_untracked(void) void test_stash_save__including_untracked_without_any_untracked_file_creates_an_empty_tree(void) { - cl_git_pass(p_unlink("stash/when")); + cl_must_pass(p_unlink("stash/when")); assert_status(repo, "what", GIT_STATUS_WT_MODIFIED | GIT_STATUS_INDEX_MODIFIED); assert_status(repo, "how", GIT_STATUS_INDEX_MODIFIED); @@ -354,3 +373,18 @@ void test_stash_save__including_untracked_without_any_untracked_file_creates_an_ assert_object_oid("stash^3^{tree}", EMPTY_TREE, GIT_OBJ_TREE); } + +void test_stash_save__skip_submodules(void) +{ + git_repository *untracked_repo; + cl_git_pass(git_repository_init(&untracked_repo, "stash/untracked_repo", false)); + cl_git_mkfile("stash/untracked_repo/content", "stuff"); + git_repository_free(untracked_repo); + + assert_status(repo, "untracked_repo/", GIT_STATUS_WT_NEW); + + cl_git_pass(git_stash_save( + &stash_tip_oid, repo, signature, NULL, GIT_STASH_INCLUDE_UNTRACKED)); + + assert_status(repo, "untracked_repo/", GIT_STATUS_WT_NEW); +} diff --git a/tests/stash/stash_helpers.c b/tests/stash/stash_helpers.c index 8b7d685f8..ff683eced 100644 --- a/tests/stash/stash_helpers.c +++ b/tests/stash/stash_helpers.c @@ -42,15 +42,11 @@ void assert_status( int status_flags) { unsigned int status; - int error; - error = git_status_file(&status, repo, path); - - if (status_flags < 0) { - cl_assert_equal_i(status_flags, error); - return; + if (status_flags < 0) + cl_assert_equal_i(status_flags, git_status_file(&status, repo, path)); + else { + cl_git_pass(git_status_file(&status, repo, path)); + cl_assert_equal_i((unsigned int)status_flags, status); } - - cl_assert_equal_i(0, error); - cl_assert_equal_i((unsigned int)status_flags, status); } |