{"thread":{"id":"26998","subject":"[PATCHv2] Documentation: enhance gitignore whitelist example","startedAt":"2011-04-05T21:06:23Z","lastAt":"2011-04-05T21:06:23Z","messageCount":1,"participants":["Eric Blake"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"165212","messageId":"1302037583-19289-1-git-send-email-eblake@redhat.com","threadId":"26998","inReplyTo":null,"subject":"[PATCHv2] Documentation: enhance gitignore whitelist example","fromName":"Eric Blake","fromEmail":"eblake@redhat.com","sentAt":"2011-04-05T21:06:23Z","receivedAt":"2011-04-05T21:06:23Z","isPatch":false,"sender":{"key":"eblake@redhat.com","avatar":"https://avatars.githubusercontent.com/u/32933908?v=4"},"body":"I was trying to whitelist a single file pattern in a directory\nthat I was otherwise content to ignore, but when I tried:\n\n  /m4/\n  !/m4/virt-*.m4\n\nthen 'git add' kept warning me that I had to use -f.  I finally\nfigured out that ignoring a directory is much different than ignoring\nall files in a directory, when it comes to later negation patterns:\n\n  /m4/*\n  !/m4/virt-*.m4\n\nImproving the documentation will help others learn from my mistake.\n\nSigned-off-by: Eric Blake <eblake@redhat.com>\nAcked-by: Jonathan Nieder <jrnieder@gmail.com>\nCC: Johannes Sixt <j6t@kdbg.org>\n---\n\nv2: incorporate helpful comments from Junio\n\n Documentation/gitignore.txt |   25 +++++++++++++++++++++----\n 1 files changed, 21 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt\nindex 2e7328b..0955931 100644\n--- a/Documentation/gitignore.txt\n+++ b/Documentation/gitignore.txt\n@@ -70,7 +70,11 @@ PATTERN FORMAT\n  - An optional prefix '!' which negates the pattern; any\n    matching file excluded by a previous pattern will become\n    included again.  If a negated pattern matches, this will\n-   override lower precedence patterns sources.\n+   override lower precedence patterns sources.  However, since\n+   directory patterns prevent searching for any files below\n+   that directory, if it is desirable to whitelist a single\n+   file in a directory, you should first exclude all files in\n+   the directory rather than the directory itself.\n\n  - If the pattern ends with a slash, it is removed for the\n    purpose of the following description, but it would only find\n@@ -87,7 +91,8 @@ PATTERN FORMAT\n\n  - Otherwise, git treats the pattern as a shell glob suitable\n    for consumption by fnmatch(3) with the FNM_PATHNAME flag:\n-   wildcards in the pattern will not match a / in the pathname.\n+   wildcards in the pattern will not match a / in the pathname,\n+   and do not ignore files with a leading . in the pathname.\n    For example, \"Documentation/{asterisk}.html\" matches\n    \"Documentation/git.html\" but not \"Documentation/ppc/ppc.html\"\n    or \"tools/perf/Documentation/perf.html\".\n@@ -116,8 +121,11 @@ EXAMPLES\n     [...]\n     # Untracked files:\n     [...]\n+    #       Documentation/build\n     #       Documentation/foo.html\n     #       Documentation/gitignore.html\n+    #       build/log\n+    #       build/.file\n     #       file.o\n     #       lib.a\n     #       src/internal.o\n@@ -125,19 +133,28 @@ EXAMPLES\n     $ cat .git/info/exclude\n     # ignore objects and archives, anywhere in the tree.\n     *.[oa]\n+    # ignore files in the immediate child directory build,...\n+    /build/*\n+    # ... except for the log.\n+    !/build/log\n     $ cat Documentation/.gitignore\n-    # ignore generated html files,\n+    # ignore generated html files,...\n     *.html\n-    # except foo.html which is maintained by hand\n+    # ... except foo.html which is maintained by hand\n     !foo.html\n     $ git status\n     [...]\n     # Untracked files:\n     [...]\n+    #       Documentation/build\n     #       Documentation/foo.html\n+    #       build/log\n     [...]\n --------------------------------------------------------------\n\n+Note that using `!/build/log' works with an earlier `/build/*' but\n+would have no effect if there were an earlier `/build/'.\n+\n Another example:\n\n --------------------------------------------------------------\n-- \n1.7.4\n"}]}