git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Fwd: Possibly nicer pathspec syntax?

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 8, 2017, 00:54 UTC
Message-ID
<xmqqinoly01x.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CA+55aFzkTZAb1vy3G5M_Nb1BeOhTiCGksUfLa+ZQtiU2x6Q=Fw@mail.gmail.com>
Linus Torvalds <torvalds@linux-foundation.org> writes:
> [ Duh, I sent this just to Junio initially due to a brainfart. Here
> goes the list also ]
And my earlier response goes to the list ;-)
Linus Torvalds <torvalds@linux-foundation.org> writes:
> Most of the time when I use pathspecs, I just use the bog-standard
> normal ones, and everything works wonderfully.

It is, I think, a no-brainer to lift the "you must have at least one positive". If the user says "not this and that", it is reasonable to assume that "but include everything else" is implied.

As to "!" that triggers history substitution without quoting, it may be annoying and I think it is probably OK to pick a synonym letter, perhaps "^", now that the set of pathspec magics do not seem to be growing rapidly and there may not be any other existing magic that the natural meaning of "^" would match better than "negate". The primary reason why we used ! is, I think, to match patterns in the exclude files.

As to the leading ":", that is shared between the ":(long form)" and the short form, I am a bit hesitant to lose it. It allows the users to be trained only once, i.e. "if you want to match a path without magic in your working tree, you need to watch out for an unusual path that begins with a colon, which may be quite minority to begin with. You just prefix ./ in front to defeat it. Everything else you can type as-is, modulo wildcard metacharacters, but you know that already." and their brains need no upgrading. Once we start accepting short forms without the ":", every time we add a short form magic, the users need to be retrained.

In short, this
> Or even just allowing ^ in addition to ! for negation, and otherwise
> keeping the current syntax.

in addition to "no positives? let's pretend you also said '.' as a positive", would not be too bad, methinks. And that allows this

>     git diff -M --dirstat .. -- ':!drivers' ':!arch' .
to become
    git diff -M --dirstat .. -- :^{drivers,arch}
which is a bit shorter.  I personally am perfectly fine without ^, i.e.
    git diff -M --dirstat .. -- :\!{drivers,arch}
though.

By the way, I am wondering why this is private, not cc'ed to the mailing list. As messages addressed to gitster@ without git@vger bypass my Inbox and gets thrown into spam box, which I only occasionally scan to resurrect messages worth responding, and this is one of those cases ;-)

Previous: Linus TorvaldsNext: Linus Torvalds
Message 2 of 17 in “Fwd: Possibly nicer pathspec syntax?”
  1. Linus TorvaldsFeb 7, 2017
  2. Junio C HamanoFeb 8, 2017
  3. Linus TorvaldsFeb 8, 2017
  4. Junio C HamanoFeb 8, 2017
  5. Linus TorvaldsFeb 8, 2017
  6. Junio C HamanoFeb 8, 2017
  7. Linus TorvaldsFeb 8, 2017
  8. Junio C HamanoFeb 8, 2017
  9. Linus TorvaldsFeb 8, 2017
  10. Duy NguyenFeb 8, 2017
  11. Junio C HamanoFeb 8, 2017
  12. Junio C HamanoFeb 8, 2017
  13. Duy NguyenFeb 9, 2017
  14. Duy NguyenFeb 9, 2017
  15. Mike HommeyFeb 8, 2017
  16. Linus TorvaldsFeb 8, 2017
  17. Mike HommeyFeb 8, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.