summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2014-09-29 14:57:54 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2014-09-29 14:57:54 -0400
commit4c534892607a2127bff7f6266919470af37ef104 (patch)
tree97a5b794193262e0641b51053df81109411e3c05
parent89602a1a23a0c2db315cbde4faff3bab2d02a51c (diff)
parent7b7aa75f8047e99fa84d2351785e990ba6cc131c (diff)
downloadlibgit2-4c534892607a2127bff7f6266919470af37ef104.tar.gz
Merge pull request #2581 from jacquesg/stash-ignored-directories
Stash ignored directories
-rw-r--r--src/stash.c8
-rw-r--r--tests/stash/save.c17
2 files changed, 22 insertions, 3 deletions
diff --git a/src/stash.c b/src/stash.c
index 22f756e35..caffd0cea 100644
--- a/src/stash.c
+++ b/src/stash.c
@@ -232,7 +232,8 @@ static int build_untracked_tree(
}
if (flags & GIT_STASH_INCLUDE_IGNORED) {
- opts.flags |= GIT_DIFF_INCLUDE_IGNORED;
+ opts.flags |= GIT_DIFF_INCLUDE_IGNORED |
+ GIT_DIFF_RECURSE_IGNORED_DIRS;
data.include_ignored = true;
}
@@ -447,10 +448,11 @@ static int ensure_there_are_changes_to_stash(
if (include_untracked_files)
opts.flags |= GIT_STATUS_OPT_INCLUDE_UNTRACKED |
- GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS;
+ GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS;
if (include_ignored_files)
- opts.flags |= GIT_STATUS_OPT_INCLUDE_IGNORED;
+ opts.flags |= GIT_STATUS_OPT_INCLUDE_IGNORED |
+ GIT_STATUS_OPT_RECURSE_IGNORED_DIRS;
error = git_status_foreach_ext(repo, &opts, is_dirty_cb, NULL);
diff --git a/tests/stash/save.c b/tests/stash/save.c
index 3b301bfc0..7873d20ba 100644
--- a/tests/stash/save.c
+++ b/tests/stash/save.c
@@ -368,6 +368,23 @@ 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__ignored_directory(void)
+{
+ cl_git_pass(mkdir("stash/ignored_directory", 0777));
+ cl_git_pass(mkdir("stash/ignored_directory/sub", 0777));
+ cl_git_mkfile("stash/ignored_directory/sub/some_file", "stuff");
+
+ assert_status(repo, "ignored_directory/sub/some_file", GIT_STATUS_WT_NEW);
+ cl_git_pass(git_ignore_add_rule(repo, "ignored_directory/"));
+ assert_status(repo, "ignored_directory/sub/some_file", GIT_STATUS_IGNORED);
+
+ cl_git_pass(git_stash_save(&stash_tip_oid, repo, signature, NULL, GIT_STASH_INCLUDE_UNTRACKED | GIT_STASH_INCLUDE_IGNORED));
+
+ cl_assert(!git_path_exists("stash/ignored_directory/sub/some_file"));
+ cl_assert(!git_path_exists("stash/ignored_directory/sub"));
+ cl_assert(!git_path_exists("stash/ignored_directory"));
+}
+
void test_stash_save__skip_submodules(void)
{
git_repository *untracked_repo;