summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/clean.c2
-rw-r--r--dir.c4
2 files changed, 5 insertions, 1 deletions
diff --git a/builtin/clean.c b/builtin/clean.c
index 4ca12bc0c0..3ca940f83a 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -954,7 +954,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
remove_directories = 1;
}
- if (remove_directories)
+ if (remove_directories && !ignored_only)
dir.flags |= DIR_SHOW_IGNORED_TOO | DIR_KEEP_UNTRACKED_CONTENTS;
if (read_cache() < 0)
diff --git a/dir.c b/dir.c
index 6fb2f8ecdd..a3ad9702d6 100644
--- a/dir.c
+++ b/dir.c
@@ -193,6 +193,10 @@ int fill_directory(struct dir_struct *dir,
const char *prefix;
size_t prefix_len;
+ unsigned exclusive_flags = DIR_SHOW_IGNORED | DIR_SHOW_IGNORED_TOO;
+ if ((dir->flags & exclusive_flags) == exclusive_flags)
+ BUG("DIR_SHOW_IGNORED and DIR_SHOW_IGNORED_TOO are exclusive");
+
/*
* Calculate common prefix for the pathspec, and
* use that to optimize the directory walk