Revert "dir.c: don't exclude whole dir prematurely if neg pattern may match"
PATCH 1/1 Revert "dir.c: don't exclude whole dir prematurely if neg pattern may match"
This reverts commit 57534ee77d22e725d971ee89c77dc6aad61c573f. The feature added in that commit requires that patterns behave the same way from anywhere. But some patterns can behave differently depending on current "working" directory. The conditions to catch and avoid these patterns are too loose. The untracked listing and sparse-checkout selection can become incorrect as a result.
--- Documentation/gitignore.txt | 23 ++---------- dir.c | 76 +------------------------------------- t/t3001-ls-files-others-exclude.sh | 25 ------------- 3 files changed, 6 insertions(+), 118 deletions(-)
Documentation/gitignore.txt +4 -19
@@ -82,12 +82,12 @@ PATTERN FORMAT - An optional prefix "`!`" which negates the pattern; any matching file excluded by a previous pattern will become - included again. + included again. It is not possible to re-include a file if a parent + directory of that file is excluded. Git doesn't list excluded + directories for performance reasons, so any patterns on contained + files have no effect, no matter where they are defined. Put a backslash ("`\`") in front of the first "`!`" for patterns that begin with a literal "`!`", for example, "`\!important!.txt`". - It is possible to re-include a file if a parent directory of that - file is excluded if certain conditions are met. See section NOTES - for detail. - If the pattern ends with a slash, it is removed for the purpose of the following description, but it would only find
@@ -141,21 +141,6 @@ not tracked by Git remain untracked. To stop tracking a file that is currently tracked, use 'git rm --cached'. -To re-include files or directories when their parent directory is -excluded, the following conditions must be met: - - - The rules to exclude a directory and re-include a subset back must - be in the same .gitignore file. - - - The directory part in the re-include rules must be literal (i.e. no - wildcards) - - - The rules to exclude the parent directory must not end with a - trailing slash. - - - The rules to exclude the parent directory must have at least one - slash. - EXAMPLES --------
dir.c +2 -74
100 lines not on this page · raw message
t/t3001-ls-files-others-exclude.sh +0 -25
@@ -305,29 +305,4 @@ test_expect_success 'ls-files with "**" patterns and no slashes' ' test_cmp expect actual ' -test_expect_success 'negative patterns' ' - git init reinclude && - ( - cd reinclude && - cat >.gitignore <<-\EOF && - /fooo - /foo - !foo/bar/bar - EOF - mkdir fooo && - cat >fooo/.gitignore <<-\EOF && - !/* - EOF - mkdir -p foo/bar && - touch abc foo/def foo/bar/ghi foo/bar/bar && - git ls-files -o --exclude-standard >../actual && - cat >../expected <<-\EOF && - .gitignore - abc - foo/bar/bar - EOF - test_cmp ../expected ../actual - ) -' - test_done
Signature · 1 line
2.7.0.56.g46bc327
Quoted 2 lines · Nguyễn Thái Ngọc Duy
patterns are too loose. The untracked listing and sparse-checkout selection can become incorrect as a result.
These two lines should be this instead if you want to keep track of problem references. I amended the commit then forgot to format-patch again.
patterns are too loose. The untracked listing [1] and sparse-checkout selection [2] can become incorrect as a result.
[1] http://article.gmane.org/gmane.comp.version-control.git/283520
[2] http://article.gmane.org/gmane.comp.version-control.git/283532
Signature · 1 line
Duy
Quoted 8 lines · Duy Nguyen
Quoted 2 lines · Nguyễn Thái Ngọc Duy
patterns are too loose. The untracked listing and sparse-checkout selection can become incorrect as a result.
These two lines should be this instead if you want to keep track of problem references. I amended the commit then forgot to format-patch again.
Quoted 5 lines
patterns are too loose. The untracked listing [1] and sparse-checkout selection [2] can become incorrect as a result.
[1] http://article.gmane.org/gmane.comp.version-control.git/283520
[2] http://article.gmane.org/gmane.comp.version-control.git/283532
Thanks. I guess we need a 2.7.1 relatively soon now.