I think I have found a bug in "git status --untracked-files=all
--ignored", in both 1.8.0 and in master:
$ git init status-test
Initialized empty Git repository in
/home/mhagger/self/proj/git/status-test/.git/
$ cd status-test
$ touch x
$ touch x.ignore-me
$ mkdir y
$ touch y/foo
$ touch y/foo.ignore-me
$ git status --porcelain --untracked-files=all --ignored
?? x
?? x.ignore-me
?? y/foo
?? y/foo.ignore-me
The above output is what I expect. But if I add a .gitignore file, the
output of y/foo.ignore-me is incorrectly suppressed:
$ echo '*.ignore-me' >.gitignore
$ git status --porcelain --untracked-files=all --ignored
?? .gitignore
?? x
?? y/foo
!! x.ignore-me
I came across this problem when trying to use the results of the above
command to build a more flexible "git clean" type of script.
I don't have time to look into this at the moment, if somebody wants to
jump in.
Michael
--
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
When looking for ignored files, we do not recurse into untracked
directory, and simply consider the directory ignored status.
As a consequence, we don't see ignored files in those directories.
Change that behavior by recursing into untracked directories searching
for ignored files.
Signed-off-by: Antoine Pelisse <redacted>
---
I jumped in.
This seems to be broken since the creation of the --ignored option to
wt-status.
This fixes the issue and breaks none of the existing tests.
The behavior seems sane to me, giving something like that:
?? .gitignore
?? x
?? y/foo
!! x.ignore-me
!! y/foo.ignore-me
Cheers,
Antoine
wt-status.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/wt-status.c b/wt-status.c
index 2a9658b..7c41488 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -516,7 +516,7 @@ static void wt_status_collect_untracked(struct wt_status *s)
if (s->show_ignored_files) {
dir.nr = 0;
- dir.flags = DIR_SHOW_IGNORED | DIR_SHOW_OTHER_DIRECTORIES;
+ dir.flags = DIR_SHOW_IGNORED;
fill_directory(&dir, s->pathspec);
for (i = 0; i < dir.nr; i++) {
struct dir_entry *ent = dir.entries[i];
--1.8.1.rc3.11.g86c3e6e.dirty
When looking for ignored files, we do not recurse into untracked
directory, and simply consider the directory ignored status.
As a consequence, we don't see ignored files in those directories.
Change that behavior by recursing into untracked directories, if not
ignored themselves, searching for ignored files.
Signed-off-by: Antoine Pelisse <redacted>
---
Actually, the previous patch breaks the case where the directory is ignored.
This one should fix both issues.
Let me know if you see any other use case that could be an issue.
dir.c | 7 +++++++
wt-status.c | 2 +-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/dir.c b/dir.c
index 5a83aa7..2863799 100644
--- a/dir.c
+++ b/dir.c
@@ -1042,6 +1042,13 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
return path_ignored;
}
+ /*
+ * Don't recurse into ignored directories when looking for
+ * ignored files, but still show the directory as ignored.
+ */
+ if (exclude && (dir->flags & DIR_SHOW_IGNORED) && dtype == DT_DIR)
+ return path_handled;
+
switch (dtype) {
default:
return path_ignored;diff --git a/wt-status.c b/wt-status.c
index 2a9658b..7c41488 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -516,7 +516,7 @@ static void wt_status_collect_untracked(struct wt_status *s)
if (s->show_ignored_files) {
dir.nr = 0;
- dir.flags = DIR_SHOW_IGNORED | DIR_SHOW_OTHER_DIRECTORIES;
+ dir.flags = DIR_SHOW_IGNORED;
fill_directory(&dir, s->pathspec);
for (i = 0; i < dir.nr; i++) {
struct dir_entry *ent = dir.entries[i];
--1.8.1.rc3.12.g8864e38