git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, "Bruce Korb" <bruce.korb@gmail.com>,
	"Andreas Schwab" <schwab@linux-m68k.org>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: Re: [PATCH] Document escaping of special characters in gitignore files
Date: Wed, 5 Jan 2011 20:27:18 +0100	[thread overview]
Message-ID: <201101052027.24640.jnareb@gmail.com> (raw)
In-Reply-To: <7vwrmjchuu.fsf@alter.siamese.dyndns.org>

On Wed, 5 Jan 2011, Junio C Hamano wrote:
> Jakub Narebski <jnareb@gmail.com> writes:
> 
> > This patch was originally send 10 Sep 2010, but I guess it was lost
> > because it appeared only deep in thread inside response, and not as
> > well separated patch.  I have found about it when I got conflict
> > merging current code.
> >
> > It applies on top of current 'master'.
> 
> Thanks.  A few questions before applying.
> 
> > diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt
> > index 7dc2e8b..20abc20 100644
> > --- a/Documentation/gitignore.txt
> > +++ b/Documentation/gitignore.txt
> > @@ -68,6 +68,7 @@ Patterns have the following format:
> >     for readability.
> >  
> >   - A line starting with # serves as a comment.
> > +   Use `\#` for a literal # character starting filename.
> 
> Is a literal bs safe here?  You later use "{backslash}#" in this same
> file, and it might make sense to do so here for the sake of source
> readability, even if a literal bs is safe here---provided that
> "{backslash}#" does not break here, of course.

First, I have checked how it is done in current codebase, and as one
can check, inside backtics escape sequences are written literally, e.g.
`\"`, `\\` in Documentation/config.txt -- notice that those are about
escaping of special characters too.

Second, http://www.methods.co.nz/asciidoc/userguide.html#_text_formatting
("7. Text Formatting", "7.1. Quoted Text") says (emphasizis mine):

  Word phrases `enclosed in backtick characters` (grave accents) are also
  rendered in a monospaced font but in this case the enclosed text is
  __rendered literally__ and is not subject to further expansion (see
  inline literal).

So yes, it is safe, and no, `{backslash}#` would not work.


I later use "{backslash}#" because it is inside double quotes, and not
backticks.  It is similar to how {caret} is treated inside double or
single quotes.

> > @@ -98,6 +99,12 @@ Patterns have the following format:
> > ...
> > + - You can escape special characters using backslash.
> > +   For example, "{backslash}#*" matches files beginning in `#`
> > ...
> 
> > diff --git a/templates/info--exclude b/templates/info--exclude
> > index a5196d1..2ebaf0d 100644
> > --- a/templates/info--exclude
> > +++ b/templates/info--exclude
> > @@ -4,3 +4,4 @@
> >  # exclude patterns (uncomment them if you want to use them):
> >  # *.[oa]
> >  # *~
> > +# \#*#
> 
> Do we need this?  Without explanation it is somewhat hard to realize that
> this last line is also an example of a pattern that excludes any filename
> that begins and ends with a pound.

Well, perhaps not.  Note though that this exclude pattern is actually
useful for me, as GNU Emacs uses this convention ("#<filename>#") for
auto-save files.   From "(emacs.gz)Auto Save Files":

     Auto-saving does not normally save in the files that you visited,
  because it can be very undesirable to save a program that is in an
  inconsistent state when you have made half of a planned change.
  Instead, auto-saving is done in a different file called the "auto-save
  file", and the visited file is changed only when you request saving
  explicitly (such as with `C-x C-s').

     Normally, the auto-save file name is made by appending `#' to the
  front and rear of the visited file name.  Thus, a buffer visiting file
  `foo.c' is auto-saved in a file `#foo.c#'.

-- 
Jakub Narebski
Poland

  reply	other threads:[~2011-01-05 19:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-05 13:38 [PATCH] Document escaping of special characters in gitignore files Jakub Narebski
2011-01-05 15:53 ` Andreas Schwab
2011-01-05 18:42 ` Junio C Hamano
2011-01-05 19:27   ` Jakub Narebski [this message]
2011-01-05 19:38     ` Thomas Rast
2011-01-05 20:12     ` Bruce Korb
2011-01-05 20:37       ` Junio C Hamano
2011-01-05 21:02         ` Jakub Narebski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201101052027.24640.jnareb@gmail.com \
    --to=jnareb@gmail.com \
    --cc=avarab@gmail.com \
    --cc=bruce.korb@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).