Re: [PATCH 1/4] magic pathspec: add tentative ":/path/from/top/level" pathspec support
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 8, 2011, 16:37 UTC
- Message-ID
- <7vpqow4s3f.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <7vtye84wc3.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 15 quoted lines
> Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes: > >> On Thu, Apr 7, 2011 at 11:18 PM, Junio C Hamano <gitster@pobox.com> wrote: >> >>> This is so that you can say ":/.gitignore" and do not have to say >>> ":/:.gitignore". >> >> But then, say people have a file named @foo at top dir. They can write >> ":/@foo" to address the file. Some time later we decide to use '@' as >> magic, how can we re-train user's fingers? > > You don't. The primary goal of short form is to be short to type from the > command line, and if you are in doubt, you can always disambiguate by > saying ":/:@foo", and you can use the terminating colon even if you are > sure "@" is not a magic in your version of git.
Actually, after thinking a bit more about it, I changed my mind.
It is not such a big deal to require the terminating colon for a pathname that begins with a nonalnum (except for '.' and we might find some others perhaps '_'), as they are rare.
I agree that we should reserve most of the nonalnum ASCII as potential magic, and require the terminating colon if the user wants to start the pattern part with a potential magic signature letter and error out if we see a magic that we do not support yet. The reason I said "most of" is that we should exclude some non-alnum letters that often begin a filename.
Off the top of my head, we should exclude "." (period -- dot-files are common), "_" (underscore), and possibly "+" (plus) and "=" (equal), as I saw these used to start filenames, but the latter two are rather rare and I don't mind requiring the terminating colon after the magic signature.