From: Duy Nguyen <pclouds@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: Fwd: Possibly nicer pathspec syntax?
Date: Thu, 9 Feb 2017 20:27:31 +0700 [thread overview]
Message-ID: <CACsJy8AbSrcqEiDByyTha9UdQvwFFXkjzKpAn6H96WD+aMdh1Q@mail.gmail.com> (raw)
In-Reply-To: <xmqqy3xgwpiq.fsf@gitster.mtv.corp.google.com>
On Thu, Feb 9, 2017 at 12:39 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Duy Nguyen <pclouds@gmail.com> writes:
>
>> On Wed, Feb 8, 2017 at 12:12 PM, Linus Torvalds
>> <torvalds@linux-foundation.org> wrote:
>>> Two-patch series to follow.
>>
>> glossary-content.txt update for both patches would be nice.
>
> I am no longer worried about it as I saw somebody actually sent
> follow-up patches on this, but I want to pick your brain on one
> thing that is related to this codepath.
>
> We have PATHSPEC_PREFER_CWD and PATHSPEC_PREFER_FULL bits in flags,
> added at fc12261fea ("parse_pathspec: add PATHSPEC_PREFER_{CWD,FULL}
> flags", 2013-07-14), and I think the intent is some commands when
> given no pathspec work on all paths in the current subdirectory
> while others work on the full tree, regardless of where you are.
> "grep" is in the former camp, "log" is in the latter. And there is
> a check to catch a bug in a caller that sets both.
>
> I am wondering about this hunk (this is from the original commit
> that added it):
>
> if (!entry) {
> static const char *raw[2];
>
> + if (flags & PATHSPEC_PREFER_FULL)
> + return;
> +
> + if (!(flags & PATHSPEC_PREFER_CWD))
> + die("BUG: PATHSPEC_PREFER_CWD requires arguments");
> +
> pathspec->items = item = xmalloc(sizeof(*item));
> memset(item, 0, sizeof(*item));
> item->match = prefix;
> ... returns a single entry pathspec to cover cwd ...
>
> The BUG message is given when
>
> - The command got no pathspec from the caller; and
> - PATHSPEC_PREFER_FULL is not set; and
> - PATHSPEC_PREFER_CWD is NOT set.
>
> but the message says that the caller must have args when it sets
> prefer-cwd. Is this a simple typo? If so what should it say?
>
> die("BUG: one of PATHSPEC_PREFER_FULL or _CWD must be set");
Without reading through your next mail, I'd say "BUG: this command
requires arguments".
> Does this third possibility (i.e. a caller is allowed to pass
> "flags" that does not prefer either) exist to support a command
> where the caller MUST have at least one pathspec? If that were the
> case, this wouldn't be a BUG but an end-user error, e.g.
>
> die("at least one pathspec element is required");
Or this. Yes. I might have just been defensive at then and kept the
third option open.
> If you know offhand which callers pass neither of the two
> PATHSPEC_PREFER_* bits and remember for what purpose you allowed
> them to do so, please remind me. I'll keep digging in the meantime.
I don't usually remember what I ate yesterday and this commit was from
2013 :D But I'll see if your findings spark anything in my brain.
--
Duy
prev parent reply other threads:[~2017-02-09 13:28 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
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 [this message]
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=CACsJy8AbSrcqEiDByyTha9UdQvwFFXkjzKpAn6H96WD+aMdh1Q@mail.gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=torvalds@linux-foundation.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.
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).