diff options
author | Vicent Marti <vicent@github.com> | 2014-04-25 02:04:12 -0700 |
---|---|---|
committer | Vicent Marti <vicent@github.com> | 2014-04-25 02:04:12 -0700 |
commit | 2ad51b81d2d735c50549f16c308d61c0a5ed990c (patch) | |
tree | 206483ccc5c59eafe9f7036faaf8ecf26ea40de7 /tests | |
parent | af9eeac93929bdf10c30e60f34717959d83b6bd3 (diff) | |
parent | a409acefbbadeb607e4d6dde681bff5aed6ae9fc (diff) | |
download | libgit2-2ad51b81d2d735c50549f16c308d61c0a5ed990c.tar.gz |
Merge pull request #2241 from libgit2/rb/stash-skip-submodules
Improve stash and checkout for ignored + untracked items
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); } |