Re: [WIP PATCH 0/5] support --exclude for diff/log commands

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

> Nguyán ThÃi Ngác Duy  <pclouds@xxxxxxxxx> writes:
>
>> On the other hand, if we go with ':' as a mark of special pathspecs, then
>>
>>  - ":/" mark pathspecs relative to worktree root
>>  - ":!" may mark negative pathspecs
> ...
>
> As the choice of the syntax goes, in the recent "grep --full-tree"
> discussion, I thought people are more or less happy with the colon
> prefixed "magic pathspec" syntax, and something along the lines of the
> above two seems to be a good design.
>
> The two most important things to consider are to make sure that people
> with funny pathnames can work it around by quoting, and the prefixing
> scheme is extensible so that other types of magic can later be introduced
> with the same kind of escape hatch for people with funny pathnames that
> begin with or contain new magic characters used to trigger the new magic.
>
> I said "something along the lines" above because ":/ for root, :! for
> negative" does not yet specify how the scheme would satisfy the above
> two consideration very well.

Let's step back a bit.

We chose to use ":/<regexp>" as one new form of extended SHA-1 expression
to name an object for two reasons: (1) no normal <ref> can have a colon in
it, because of check-ref-format restriction; (2) ":" is an unlikely letter
to appear at the beginning of a pathname, and people with such a path can
work around by saying "./:frotz" or "\:xyzzy".

There is a disambiguation logic to check a list of arguments that lacks an
explicit "--" separator to make sure that each element early on the list
can only be interpreted as an object name but not as a pathname that
exists on the filesystem, and all the remaining elements are pathnames
that exist on the filesystem.

If we introduce an extended syntax for pathspec and make the prefix magic
character ":", and if we choose to use ":/" as one kind of magic, I was a
bit worried that this may affect the disambiguation.  The users must use
an explicit "--" when feeding a pathspec with the magic so that the parser
knows which kind of magic (either object name magic or pathspec magic)
they are talking about.

I however realized that it is not an issue at all, because the users
already need to disambiguate with "--" when using wildcards in their
pathspecs (e.g. "git log 'Makefil*'" will give you an ambiguity error).
Admittedly, wildcard pathspecs are lessor kind of magic, but they are
magic nevertheless.

So my tentative conclusion is that there is no problem using the same ":"
as the magic introducer for pathspecs, just like we do for object names.

	Side note: please point out flaws in the above train of thought
        that would make the end result non-workable.

Although I like the general approach Michael took with his "alternative
setup.c that understands tree-wide pathspec" patch (Cf. $gmane/168207), I
agree ":/" would be better than saying "':' is root, and we don't allow
any other magic under ':'" for the sake of extensibility.

I am not very happy with ":!" as negative from syntactical point of view,
because traditionally "!" is a tad cumbersome to quote in shells with
history support (e.g. "csh"), but unfortunately I don't think of any good
alternative that is easy to type.  Pathspecs are globs by nature, and "!"
is a good choice of nagation indicator for that reason (think "[!aeiou]"
not "[^aeiou]" the latter of which is a regexp and not glob), though.

--
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


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]