зеркало из https://github.com/microsoft/git.git
dir.c: make 'git-status --ignored' work within leading directories
'git-status --ignored path/' doesn't list ignored files and directories within 'path' if some component of 'path' is classified as untracked. Disable the DIR_SHOW_OTHER_DIRECTORIES flag while traversing leading directories. This prevents treat_leading_path() with DIR_SHOW_IGNORED flag from aborting at the top level untracked directory. As a side effect, this also eliminates a recursive directory scan per leading directory level, as treat_directory() can no longer call read_directory_recursive() when called from treat_leading_path(). Signed-off-by: Karsten Blees <blees@dcon.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
c94ab01026
Коммит
be8a84c526
3
dir.c
3
dir.c
|
@ -1447,12 +1447,14 @@ static int treat_leading_path(struct dir_struct *dir,
|
||||||
struct strbuf sb = STRBUF_INIT;
|
struct strbuf sb = STRBUF_INIT;
|
||||||
int baselen, rc = 0;
|
int baselen, rc = 0;
|
||||||
const char *cp;
|
const char *cp;
|
||||||
|
int old_flags = dir->flags;
|
||||||
|
|
||||||
while (len && path[len - 1] == '/')
|
while (len && path[len - 1] == '/')
|
||||||
len--;
|
len--;
|
||||||
if (!len)
|
if (!len)
|
||||||
return 1;
|
return 1;
|
||||||
baselen = 0;
|
baselen = 0;
|
||||||
|
dir->flags &= ~DIR_SHOW_OTHER_DIRECTORIES;
|
||||||
while (1) {
|
while (1) {
|
||||||
cp = path + baselen + !!baselen;
|
cp = path + baselen + !!baselen;
|
||||||
cp = memchr(cp, '/', path + len - cp);
|
cp = memchr(cp, '/', path + len - cp);
|
||||||
|
@ -1475,6 +1477,7 @@ static int treat_leading_path(struct dir_struct *dir,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strbuf_release(&sb);
|
strbuf_release(&sb);
|
||||||
|
dir->flags = old_flags;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,25 @@ test_expect_success 'status untracked directory with --ignored -u' '
|
||||||
git status --porcelain --ignored -u >actual &&
|
git status --porcelain --ignored -u >actual &&
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
'
|
'
|
||||||
|
cat >expected <<\EOF
|
||||||
|
?? untracked/uncommitted
|
||||||
|
!! untracked/ignored
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_expect_success 'status prefixed untracked directory with --ignored' '
|
||||||
|
git status --porcelain --ignored untracked/ >actual &&
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
|
cat >expected <<\EOF
|
||||||
|
?? untracked/uncommitted
|
||||||
|
!! untracked/ignored
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_expect_success 'status prefixed untracked sub-directory with --ignored -u' '
|
||||||
|
git status --porcelain --ignored -u untracked/ >actual &&
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
cat >expected <<\EOF
|
cat >expected <<\EOF
|
||||||
?? .gitignore
|
?? .gitignore
|
||||||
|
|
Загрузка…
Ссылка в новой задаче