aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/gitignore.txt
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2015-09-21 16:56:15 +0700
committerJunio C Hamano <gitster@pobox.com>2015-09-21 11:06:47 -0700
commit57534ee77d22e725d971ee89c77dc6aad61c573f (patch)
treeb39f066cd62141319d0d5d5d4279013a70d374da /Documentation/gitignore.txt
parente6efecc46a34a984535e6a90e45a9db45af4eff2 (diff)
downloadgit-57534ee77d22e725d971ee89c77dc6aad61c573f.tar.gz
dir.c: don't exclude whole dir prematurely if neg pattern may match
If there is a pattern "!foo/bar", this patch makes it not exclude "foo" right away. This gives us a chance to examine "foo" and re-include "foo/bar". In order for it to detect that the directory under examination should not be excluded right away, in other words it is a parent directory of a negative pattern, the "directory path" of the negative pattern must be literal. Patterns like "!f?o/bar" can't stop "foo" from being excluded. Basename matching (i.e. "no slashes in the pattern") or must-be-dir matching (i.e. "trailing slash in the pattern") does not work well with this. For example, if we descend in "foo" and are examining "foo/abc", current code for "foo/" pattern will check if path "foo/abc", not "foo", is a directory. The same problem with basename matching. These may need big code reorg to make it work. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/gitignore.txt')
-rw-r--r--Documentation/gitignore.txt23
1 files changed, 19 insertions, 4 deletions
diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt
index 4fd04423e9..9cce703c5a 100644
--- a/Documentation/gitignore.txt
+++ b/Documentation/gitignore.txt
@@ -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. 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.
+ included again.
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,6 +141,21 @@ 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
--------