Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx> --- dir.c | 8 +++++--- t/t7002-grep.sh | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/dir.c b/dir.c index cb83332..0bd5d9f 100644 --- a/dir.c +++ b/dir.c @@ -1040,9 +1040,11 @@ void setup_standard_excludes(struct dir_struct *dir) const char *path; dir->exclude_per_dir = ".gitignore"; - path = git_path("info/exclude"); - if (!access(path, R_OK)) - add_excludes_from_file(dir, path); + if (!startup_info || startup_info->have_repository) { + path = git_path("info/exclude"); + if (!access(path, R_OK)) + add_excludes_from_file(dir, path); + } if (excludes_file && !access(excludes_file, R_OK)) add_excludes_from_file(dir, excludes_file); } diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh index e249c3e..06ec4cb 100755 --- a/t/t7002-grep.sh +++ b/t/t7002-grep.sh @@ -527,4 +527,28 @@ test_expect_success 'grep -e -- -- path' ' test_cmp expected actual ' +test_expect_success 'Setup fake .git' ' + cd t && + GIT_CEILING_DIRECTORIES="`pwd`" && + export GIT_CEILING_DIRECTORIES && + cd a && + mkdir -p .git/info && + cd ../.. + +' + +test_expect_success 'Ignore fake .git/info/exclude' ' + ( + cd t/a && + echo v > .git/info/exclude && + git grep --no-index vvv . && + rm .git/info/exclude + ) +' + +test_expect_success 'Unsetup fake .git' ' + rm -rf t/a && + unset GIT_CEILING_DIRECTORIES +' + test_done -- 1.7.0.rc1.541.g2da82.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html