From: Linus Torvalds <torvalds@linux-foundation.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: Fwd: Possibly nicer pathspec syntax?
Date: Tue, 7 Feb 2017 19:02:24 -0800 [thread overview]
Message-ID: <CA+55aFwPLtuPciN1o_03CwkKqFWgZd_br9Q14qyr7a7N7mxTeA@mail.gmail.com> (raw)
In-Reply-To: <xmqqefz9xv0x.fsf@gitster.mtv.corp.google.com>
On Tue, Feb 7, 2017 at 6:42 PM, Junio C Hamano <gitster@pobox.com> wrote:
>
> 1. I think some commands limit their operands to cwd and some work
> on the whole tree when given no pathspec. I think the "no
> positive? then let's give you everything except these you
> excluded" should base the definition of "everything" to that.
> IOW, "cd t && git grep -e foo" shows everything in t/ directory,
> so the default you would add would be "." for "grep"; "cd t &&
> git diff HEAD~100 HEAD" would show everything, so you would give
> ":(top)." for "diff".
No. The thing is, "git diff" is relative too - for path
specifications. And the negative entries are pathspecs - and they act
as relative ones.
IOW, that whole
cd drivers
git diff A..B -- net/
will actually show the diff for drivers/net - so the pathspec very
much acts as relative to the cwd.
So no, absolute (ie ":(top)" or ":/") doesn't actually make sense for
"diff" either, even though diff by default is absolute when not given
a pathname at all.
But if you do
cd drivers
git diff A..B -- :^/arch
then suddenly an absolute positive root _does_ make sense,. because
now the negative pathspec was absolute..
Odd? Yes it is. But the positive pathspec rules are what they are, and
they are actually what I suspect everybody really wants. The existing
negative ones match the rules for the positive ones.
So I suspect that the best thing is if the "implicit positive rule
when there are no explicit ones" ends up matching the same semantics
as the (explicit) negative entries have..
> 2. I am not sure what ctype.c change is about. Care to elaborate?
I didn't see the need for it either until I made the rest of the
patch, and it didn't work at all.
The pathspec.c code uses "if (is_pathspec_magic(..))" to test whether
a character is a short magiic pathspec character. But '^' wasn't in
that set, because it was already marked as being (only) in the regex
set.
Does that whole is_pathspec_magic() thing make any sense when we have
an array that specifies the special characters we react to? No it does
not.
But it is what the code does, and I just made that code work.
> 3. I think our recent trend is to wean ourselves away from "an
> empty element in pathspec means all paths match", and I think we
> even have accepted a patch to emit a warning. Doesn't the
> warning trigger for the new code below?
It didn't trigger for me in my testing, I suspect the warning is at an
earlier level when it walks through the argv[] array and fills in the
pathspec arrays. But I didn't actually look for it.
Linus
next prev parent reply other threads:[~2017-02-08 3:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CA+55aFyznf1k=iyiQx6KLj3okpid0-HexZWsVkxt7LqCdz+O5A@mail.gmail.com>
2017-02-07 23:12 ` Fwd: Possibly nicer pathspec syntax? Linus Torvalds
2017-02-08 0:54 ` Junio C Hamano
2017-02-08 1:48 ` Linus Torvalds
2017-02-08 2:40 ` Mike Hommey
2017-02-08 2:49 ` Linus Torvalds
2017-02-08 3:06 ` Mike Hommey
2017-02-08 2:42 ` Junio C Hamano
2017-02-08 3:02 ` Linus Torvalds [this message]
2017-02-08 3:12 ` Junio C Hamano
2017-02-08 3:28 ` Linus Torvalds
2017-02-08 4:42 ` Junio C Hamano
2017-02-08 5:12 ` Linus Torvalds
2017-02-08 6:39 ` Duy Nguyen
2017-02-08 17:39 ` Junio C Hamano
2017-02-08 21:11 ` Junio C Hamano
2017-02-09 13:48 ` Duy Nguyen
2017-02-09 13:27 ` Duy Nguyen
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CA+55aFwPLtuPciN1o_03CwkKqFWgZd_br9Q14qyr7a7N7mxTeA@mail.gmail.com \
--to=torvalds@linux-foundation.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).