dir.c: Omit non-excluded directories with dir->show_ignored
This makes "git-ls-files --others --directory --ignored" behave as documented and consequently also fixes "git-clean -d -X". Previously, git-clean would remove non-excluded directories even when using the -X option. Signed-off-by: Michael Spang <mspang@uwaterloo.ca> Signed-off-by: Junio C Hamano <junkio@cox.net>
Michael Spang committed
May 6, 2007 at 22:35 UTC
b991625611da1cba39c6ac50d0329e5d5ce5d0ab
1 file changed
+6
-1
dir.c
+6
-1
@@ -448,6 +448,7 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co
448
449
while ((de = readdir(fdir)) != NULL) {
450
int len;
451
+ int exclude;
452
453
if ((de->d_name[0] == '.') &&
454
(de->d_name[1] == 0 ||
@@ -461,7 +462,9 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co
462
memcpy(fullname + baselen, de->d_name, len+1);
463
if (simplify_away(fullname, baselen + len, simplify))
464
continue;
464
- if (excluded(dir, fullname) != dir->show_ignored) {
465
+
466
+ exclude = excluded(dir, fullname);
467
+ if (exclude != dir->show_ignored) {
468
if (!dir->show_ignored || DTYPE(de) != DT_DIR) {
469
continue;
470
}
@@ -484,6 +487,8 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co
487
len++;
488
switch (treat_directory(dir, fullname, baselen + len, simplify)) {
489
case show_directory:
490
+ if (exclude != dir->show_ignored)
491
+ continue;
492
break;
493
case recurse_into_directory:
494
contents += read_directory_recursive(dir,