dir.c: git-status --ignored: don't list empty directories as ignored

'git-status --ignored' lists empty untracked directories as ignored, even
though they don't have any ignored files.

When checking if a directory is already listed as untracked (i.e. shouldn't
be listed as ignored as well), don't assume that the directory has only
ignored files if it doesn't have untracked files, as the directory may be
empty.

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Karsten Blees 2013-04-15 21:08:42 +02:00 коммит произвёл Junio C Hamano
Родитель 184d2a8e96
Коммит c94ab01026
2 изменённых файлов: 28 добавлений и 5 удалений

5
dir.c
Просмотреть файл

@ -1115,7 +1115,7 @@ static enum directory_treatment treat_directory(struct dir_struct *dir,
/*
* We are looking for ignored files and our directory is not ignored,
* check if it contains only ignored files
* check if it contains untracked files (i.e. is listed as untracked)
*/
if ((dir->flags & DIR_SHOW_IGNORED) && !exclude) {
int ignored;
@ -1123,7 +1123,8 @@ static enum directory_treatment treat_directory(struct dir_struct *dir,
ignored = read_directory_recursive(dir, dirname, len, 1, simplify);
dir->flags |= DIR_SHOW_IGNORED;
return ignored ? ignore_directory : show_directory;
if (ignored)
return ignore_directory;
}
if (!(dir->flags & DIR_HIDE_EMPTY_DIRECTORIES))

Просмотреть файл

@ -60,6 +60,31 @@ test_expect_success 'status ignored directory with --ignore -u' '
test_cmp expected actual
'
cat >expected <<\EOF
?? .gitignore
?? actual
?? expected
EOF
test_expect_success 'status empty untracked directory with --ignore' '
rm -rf ignored &&
mkdir untracked-ignored &&
mkdir untracked-ignored/test &&
git status --porcelain --ignored >actual &&
test_cmp expected actual
'
cat >expected <<\EOF
?? .gitignore
?? actual
?? expected
EOF
test_expect_success 'status empty untracked directory with --ignore -u' '
git status --porcelain --ignored -u >actual &&
test_cmp expected actual
'
cat >expected <<\EOF
?? .gitignore
?? actual
@ -68,9 +93,6 @@ cat >expected <<\EOF
EOF
test_expect_success 'status untracked directory with ignored files with --ignore' '
rm -rf ignored &&
mkdir untracked-ignored &&
mkdir untracked-ignored/test &&
: >untracked-ignored/ignored &&
: >untracked-ignored/test/ignored &&
git status --porcelain --ignored >actual &&