Changes since v2 -- 8< -- diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt index 889a72a..79a1948 100644 --- a/Documentation/gitignore.txt +++ b/Documentation/gitignore.txt @@ -82,9 +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 possible to re-include a file if a parent - directory of that file is excluded, with restrictions. See section - NOTES for detail. + 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 @@ -138,8 +141,11 @@ not tracked by Git remain untracked. To stop tracking a file that is currently tracked, use 'git rm --cached'. -To re-include a file when its parent directory is excluded, the -following conditions must be met: +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) diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh index 9de49a6..da257c0 100755 --- a/t/t3001-ls-files-others-exclude.sh +++ b/t/t3001-ls-files-others-exclude.sh @@ -310,9 +310,14 @@ test_expect_success 'negative patterns' ' ( 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 && -- 8< -- Nguyễn Thái Ngọc Duy (2): dir.c: make last_exclude_matching_from_list() run til the end dir.c: don't exclude whole dir prematurely if neg pattern may match Documentation/gitignore.txt | 23 ++++++++-- dir.c | 89 +++++++++++++++++++++++++++++++++++--- t/t3001-ls-files-others-exclude.sh | 25 +++++++++++ 3 files changed, 127 insertions(+), 10 deletions(-) -- 2.3.0.rc1.137.g477eb31 -- 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