summaryrefslogtreecommitdiff
path: root/tests/stash
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-04-02 12:07:27 -0700
committerRussell Belfer <rb@github.com>2014-04-22 15:23:43 -0700
commit24d17de255caa57b01c0c758e6fc81aad493806e (patch)
tree5d4831849777583e4cd2d6b46ac6a7a532fa468b /tests/stash
parenta32d684f866e7710fd139d69ad5d1a8d0ae527c4 (diff)
downloadlibgit2-24d17de255caa57b01c0c758e6fc81aad493806e.tar.gz
Make stash and checkout ignore contained repos
To emulate git, stash should not remove untracked git repositories inside the parent repo, and checkout's REMOVE_UNTRACKED should also skip over these items. `git stash` actually prints a warning message for these items. That should be possible with a checkout notify callback if you wanted to, although it would require a bit of extra logic as things are at the moment.
Diffstat (limited to 'tests/stash')
-rw-r--r--tests/stash/save.c17
-rw-r--r--tests/stash/stash_helpers.c13
2 files changed, 21 insertions, 9 deletions
diff --git a/tests/stash/save.c b/tests/stash/save.c
index f06c1fb71..5165eeadf 100644
--- a/tests/stash/save.c
+++ b/tests/stash/save.c
@@ -342,7 +342,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 +354,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..29cb25c5f 100644
--- a/tests/stash/stash_helpers.c
+++ b/tests/stash/stash_helpers.c
@@ -44,13 +44,10 @@ void assert_status(
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);
}