{"thread":{"id":"26201","subject":"[PATCH] Document escaping of special characters in gitignore files","startedAt":"2011-01-05T13:38:52Z","lastAt":"2011-01-05T21:02:32Z","messageCount":8,"participants":["Jakub Narebski","Andreas Schwab","Junio C Hamano","Thomas Rast","Bruce Korb"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"158958","messageId":"1294234732-20094-1-git-send-email-jnareb@gmail.com","threadId":"26201","inReplyTo":null,"subject":"[PATCH] Document escaping of special characters in gitignore files","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-01-05T13:38:52Z","receivedAt":"2011-01-05T13:38:52Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"You can use backslash to escape special characters, like '#' or '*',\nin gitignore files.\n\nRequested-by: Bruce Korb <bruce.korb@gmail.com>\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nThis patch was originally send 10 Sep 2010, but I guess it was lost\nbecause it appeared only deep in thread inside response, and not as\nwell separated patch.  I have found about it when I got conflict\nmerging current code.\n\nIt applies on top of current 'master'.\n\n Documentation/gitignore.txt |    7 +++++++\n templates/info--exclude     |    1 +\n 2 files changed, 8 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt\nindex 7dc2e8b..20abc20 100644\n--- a/Documentation/gitignore.txt\n+++ b/Documentation/gitignore.txt\n@@ -68,6 +68,7 @@ Patterns have the following format:\n    for readability.\n \n  - A line starting with # serves as a comment.\n+   Use `\\#` for a literal # character starting filename.\n \n  - An optional prefix '!' which negates the pattern; any\n    matching file excluded by a previous pattern will become\n@@ -98,6 +99,12 @@ Patterns have the following format:\n    For example, \"/{asterisk}.c\" matches \"cat-file.c\" but not\n    \"mozilla-sha1/sha1.c\".\n \n+ - You can escape special characters using backslash.\n+   For example, \"{backslash}#*\" matches files beginning in `#`\n+   (otherwise it would be considered comment),\n+   and \"{backslash}!*{backslash}?\" matches files starting with `!`\n+   (negate pattern prefix) and ending with `?` (glob wildcard).\n+\n NOTES\n -----\n \ndiff --git a/templates/info--exclude b/templates/info--exclude\nindex a5196d1..2ebaf0d 100644\n--- a/templates/info--exclude\n+++ b/templates/info--exclude\n@@ -4,3 +4,4 @@\n # exclude patterns (uncomment them if you want to use them):\n # *.[oa]\n # *~\n+# \\#*#\n-- \n1.7.3\n"},{"id":"158964","messageId":"m27hejtkil.fsf@igel.home","threadId":"26201","inReplyTo":"1294234732-20094-1-git-send-email-jnareb@gmail.com","subject":"Re: [PATCH] Document escaping of special characters in gitignore files","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2011-01-05T15:53:06Z","receivedAt":"2011-01-05T15:53:06Z","isPatch":true,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt\n> index 7dc2e8b..20abc20 100644\n> --- a/Documentation/gitignore.txt\n> +++ b/Documentation/gitignore.txt\n> @@ -68,6 +68,7 @@ Patterns have the following format:\n>     for readability.\n>  \n>   - A line starting with # serves as a comment.\n> +   Use `\\#` for a literal # character starting filename.\n\nShould this be written as `{backslash}#`?\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"158977","messageId":"7vwrmjchuu.fsf@alter.siamese.dyndns.org","threadId":"26201","inReplyTo":"1294234732-20094-1-git-send-email-jnareb@gmail.com","subject":"Re: [PATCH] Document escaping of special characters in gitignore files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-01-05T18:42:33Z","receivedAt":"2011-01-05T18:42:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> This patch was originally send 10 Sep 2010, but I guess it was lost\n> because it appeared only deep in thread inside response, and not as\n> well separated patch.  I have found about it when I got conflict\n> merging current code.\n>\n> It applies on top of current 'master'.\n\nThanks.  A few questions before applying.\n\n> diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt\n> index 7dc2e8b..20abc20 100644\n> --- a/Documentation/gitignore.txt\n> +++ b/Documentation/gitignore.txt\n> @@ -68,6 +68,7 @@ Patterns have the following format:\n>     for readability.\n>  \n>   - A line starting with # serves as a comment.\n> +   Use `\\#` for a literal # character starting filename.\n\nIs a literal bs safe here?  You later use \"{backslash}#\" in this same\nfile, and it might make sense to do so here for the sake of source\nreadability, even if a literal bs is safe here---provided that\n\"{backslash}#\" does not break here, of course.\n\n> @@ -98,6 +99,12 @@ Patterns have the following format:\n> ...\n> + - You can escape special characters using backslash.\n> +   For example, \"{backslash}#*\" matches files beginning in `#`\n> ...\n\n> diff --git a/templates/info--exclude b/templates/info--exclude\n> index a5196d1..2ebaf0d 100644\n> --- a/templates/info--exclude\n> +++ b/templates/info--exclude\n> @@ -4,3 +4,4 @@\n>  # exclude patterns (uncomment them if you want to use them):\n>  # *.[oa]\n>  # *~\n> +# \\#*#\n\nDo we need this?  Without explanation it is somewhat hard to realize that\nthis last line is also an example of a pattern that excludes any filename\nthat begins and ends with a pound.\n"},{"id":"158981","messageId":"201101052027.24640.jnareb@gmail.com","threadId":"26201","inReplyTo":"7vwrmjchuu.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Document escaping of special characters in gitignore files","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-01-05T19:27:18Z","receivedAt":"2011-01-05T19:27:18Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Wed, 5 Jan 2011, Junio C Hamano wrote:\n> Jakub Narebski <jnareb@gmail.com> writes:\n> \n> > This patch was originally send 10 Sep 2010, but I guess it was lost\n> > because it appeared only deep in thread inside response, and not as\n> > well separated patch.  I have found about it when I got conflict\n> > merging current code.\n> >\n> > It applies on top of current 'master'.\n> \n> Thanks.  A few questions before applying.\n> \n> > diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt\n> > index 7dc2e8b..20abc20 100644\n> > --- a/Documentation/gitignore.txt\n> > +++ b/Documentation/gitignore.txt\n> > @@ -68,6 +68,7 @@ Patterns have the following format:\n> >     for readability.\n> >  \n> >   - A line starting with # serves as a comment.\n> > +   Use `\\#` for a literal # character starting filename.\n> \n> Is a literal bs safe here?  You later use \"{backslash}#\" in this same\n> file, and it might make sense to do so here for the sake of source\n> readability, even if a literal bs is safe here---provided that\n> \"{backslash}#\" does not break here, of course.\n\nFirst, I have checked how it is done in current codebase, and as one\ncan check, inside backtics escape sequences are written literally, e.g.\n`\\\"`, `\\\\` in Documentation/config.txt -- notice that those are about\nescaping of special characters too.\n\nSecond, http://www.methods.co.nz/asciidoc/userguide.html#_text_formatting\n(\"7. Text Formatting\", \"7.1. Quoted Text\") says (emphasizis mine):\n\n  Word phrases `enclosed in backtick characters` (grave accents) are also\n  rendered in a monospaced font but in this case the enclosed text is\n  __rendered literally__ and is not subject to further expansion (see\n  inline literal).\n\nSo yes, it is safe, and no, `{backslash}#` would not work.\n\n\nI later use \"{backslash}#\" because it is inside double quotes, and not\nbackticks.  It is similar to how {caret} is treated inside double or\nsingle quotes.\n\n> > @@ -98,6 +99,12 @@ Patterns have the following format:\n> > ...\n> > + - You can escape special characters using backslash.\n> > +   For example, \"{backslash}#*\" matches files beginning in `#`\n> > ...\n> \n> > diff --git a/templates/info--exclude b/templates/info--exclude\n> > index a5196d1..2ebaf0d 100644\n> > --- a/templates/info--exclude\n> > +++ b/templates/info--exclude\n> > @@ -4,3 +4,4 @@\n> >  # exclude patterns (uncomment them if you want to use them):\n> >  # *.[oa]\n> >  # *~\n> > +# \\#*#\n> \n> Do we need this?  Without explanation it is somewhat hard to realize that\n> this last line is also an example of a pattern that excludes any filename\n> that begins and ends with a pound.\n\nWell, perhaps not.  Note though that this exclude pattern is actually\nuseful for me, as GNU Emacs uses this convention (\"#<filename>#\") for\nauto-save files.   From \"(emacs.gz)Auto Save Files\":\n\n     Auto-saving does not normally save in the files that you visited,\n  because it can be very undesirable to save a program that is in an\n  inconsistent state when you have made half of a planned change.\n  Instead, auto-saving is done in a different file called the \"auto-save\n  file\", and the visited file is changed only when you request saving\n  explicitly (such as with `C-x C-s').\n\n     Normally, the auto-save file name is made by appending `#' to the\n  front and rear of the visited file name.  Thus, a buffer visiting file\n  `foo.c' is auto-saved in a file `#foo.c#'.\n\n-- \nJakub Narebski\nPoland\n"},{"id":"158982","messageId":"201101052038.28515.trast@student.ethz.ch","threadId":"26201","inReplyTo":"201101052027.24640.jnareb@gmail.com","subject":"Re: [PATCH] Document escaping of special characters in gitignore files","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2011-01-05T19:38:28Z","receivedAt":"2011-01-05T19:38:28Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Jakub Narebski wrote:\n> Second, http://www.methods.co.nz/asciidoc/userguide.html#_text_formatting\n> (\"7. Text Formatting\", \"7.1. Quoted Text\") says (emphasizis mine):\n> \n>   Word phrases `enclosed in backtick characters` (grave accents) are also\n>   rendered in a monospaced font but in this case the enclosed text is\n>   __rendered literally__ and is not subject to further expansion (see\n>   inline literal).\n> \n> So yes, it is safe, and no, `{backslash}#` would not work.\n\nThis is correct, but the behaviour you quote was introduced in a minor\nrelease of asciidoc (!!!).  From 71c020c5:\n\n    Disable asciidoc 8.4.1+ semantics for `{plus}` and friends\n    \n    asciidoc 8.4.1 changed the semantics of inline backtick quoting so\n    that they disable parsing of inline constructs, i.e.,\n    \n      Input:    `{plus}`\n      Pre 8.4.1:        +\n      Post 8.4.1:       {plus}\n    \n    Fix this by defining the asciidoc attribute 'no-inline-literal'\n    (which, per the 8.4.1 changelog, is the toggle to return to the old\n    behaviour) when under ASCIIDOC8.\n\nSo in fact with current settings in Documentation/Makefile, the brace\nescapes *are* expanded even within backticks.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"158985","messageId":"4D24D0CB.3030004@gmail.com","threadId":"26201","inReplyTo":"201101052027.24640.jnareb@gmail.com","subject":"Re: [PATCH] Document escaping of special characters in gitignore files","fromName":"Bruce Korb","fromEmail":"bruce.korb@gmail.com","sentAt":"2011-01-05T20:12:59Z","receivedAt":"2011-01-05T20:12:59Z","isPatch":true,"sender":{"key":"bruce.korb@gmail.com","avatar":"https://gravatar.com/avatar/86d91467dc7cc8466a9d133a7b93a5d21233052017c144c9a6f6f7e5110344d0?d=mp&s=160"},"body":"On 01/05/11 11:27, Jakub Narebski wrote:\n>>> +++ b/templates/info--exclude\n>>> @@ -4,3 +4,4 @@\n>>>  # exclude patterns (uncomment them if you want to use them):\n>>>  # *.[oa]\n>>>  # *~\n>>> +# \\#*#\n>>\n>> Do we need this?  Without explanation it is somewhat hard to realize that\n>> this last line is also an example of a pattern that excludes any filename\n>> that begins and ends with a pound.\n> \n> Well, perhaps not.  Note though that this exclude pattern is actually\n> useful for me, as GNU Emacs uses this convention (\"#<filename>#\") for\n> auto-save files.\n\nAs the source of this thread, I, too, use emacs and it is exactly\nthe problem of trying to figure out how to get git to ignore these\nauto save files that got me down this path.  It was too hard to figure out.\nSo I suggested some doc changes and the addition of the \"exclude\nemacs auto save files\" pattern to the sample text.  People who do not\nuse emacs would not understand the \\#*# line and folks who do would.\nThey see files like that all the time.  For the sake of vi users, you\nmight want to explain them, but I don't think it is crucial.\nIt *is* important to have an example of a needs-to-be-escaped file name.\n"},{"id":"158987","messageId":"7vk4ijccji.fsf@alter.siamese.dyndns.org","threadId":"26201","inReplyTo":"4D24D0CB.3030004@gmail.com","subject":"Re: [PATCH] Document escaping of special characters in gitignore files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-01-05T20:37:21Z","receivedAt":"2011-01-05T20:37:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bruce Korb <bruce.korb@gmail.com> writes:\n\n> On 01/05/11 11:27, Jakub Narebski wrote:\n>>>> +++ b/templates/info--exclude\n>>>> @@ -4,3 +4,4 @@\n>>>>  # exclude patterns (uncomment them if you want to use them):\n>>>>  # *.[oa]\n>>>>  # *~\n>>>> +# \\#*#\n>>>\n>>> Do we need this?  Without explanation it is somewhat hard to realize that\n>>> this last line is also an example of a pattern that excludes any filename\n>>> that begins and ends with a pound.\n>> \n>> Well, perhaps not.  Note though that this exclude pattern is actually\n>> useful for me, as GNU Emacs uses this convention (\"#<filename>#\") for\n>> auto-save files.\n>\n> As the source of this thread, I, too, use emacs and it is exactly\n> the problem of trying to figure out how to get git to ignore these\n> auto save files that got me down this path.  It was too hard to figure out.\n> So I suggested some doc changes and the addition of the \"exclude\n> emacs auto save files\" pattern to the sample text.  People who do not\n> use emacs would not understand the \\#*# line and folks who do would.\n> They see files like that all the time.  For the sake of vi users, you\n> might want to explain them, but I don't think it is crucial.\n> It *is* important to have an example of a needs-to-be-escaped file name.\n\nPerhaps a single liner comment to describe the three examples immediately\nbelow \"exclude patterns (uncomment them...\" is in order in that case,\nsomething like:\n\n# exclude patterns (object and library, emacs backup, emacs autosave\n# files) -- uncomment if you want to use them\n# *.[oa]\n# *~\n# \\#*#\n"},{"id":"158992","messageId":"201101052202.34043.jnareb@gmail.com","threadId":"26201","inReplyTo":"7vk4ijccji.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Document escaping of special characters in gitignore files","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-01-05T21:02:32Z","receivedAt":"2011-01-05T21:02:32Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Wed, 5 Jan 2011, Junio C Hamano wrote:\n\n> Perhaps a single liner comment to describe the three examples immediately\n> below \"exclude patterns (uncomment them...\" is in order in that case,\n> something like:\n> \n> # exclude patterns (object and library, emacs backup, emacs autosave\n> # files) -- uncomment if you want to use them\n> # *.[oa]\n> # *~\n\nErrr... I think that '*~' pattern is generic UNIX backup, like '*.bak'\nis for MS-DOS / MS Windows.\n\nhttp://en.wikipedia.org/wiki/Tilde#Backup_filenames\n\n  Backup filenames\n\n  The dominant Unix convention for naming backup copies of files is\n  appending a tilde to the original file name. It originated with the\n  Emacs text editor[citation needed] and was adopted by many other\n  editors and some command-line tools.\n\n> # \\#*#\n\nAnyway, should I reroll this patch with above addition?  Should I add\nan explanation why we can use `\\#` but need to use \"{tilde}#\"? \n-- \nJakub Narebski\nPoland\n"}]}