From: Junio C Hamano <gitster@pobox.com>
To: Duy Nguyen <pclouds@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: Fwd: Possibly nicer pathspec syntax?
Date: Wed, 08 Feb 2017 13:11:04 -0800 [thread overview]
Message-ID: <xmqqwpd0v15j.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <xmqqy3xgwpiq.fsf@gitster.mtv.corp.google.com> (Junio C. Hamano's message of "Wed, 08 Feb 2017 09:39:25 -0800")
Junio C Hamano <gitster@pobox.com> writes:
> 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.
Answering my own questions, here are my findings so far and a
tentative conclusion.
With or without the patch in this thread, parse_pathspec() behaves
the same way for either CWD or FULL if you feed a non-empty
pathspec with at least one positive element. IOW, if a caller feeds
a non-empty pathspec and there is no "negative" element involved, it
does not matter if we feed CWD or FULL.
There are only a handful of callers that pass neither preference
bits to parse_pathspec(). Here are my observations on them that
tells me that most of them are OK if we change them to prefer
either CWD or FULL:
- archive.c::path_exists() feeds a pathspec with a single element
to see if read_tree_recursive() finds any matching paths, to
allow its caller to iterate over the original pathspec and see
if there is a typo (i.e. an element that matches nothing). It
should prefer FULL to match what parse_pathspec_arg(), its
caller, uses.
The caller probably should refrain from passing ones with
negative magic. I.e. "git archive -- t :\!t/perf" errors out
because checking each element independently in the loop means
that ":\!t/perf" is checked alone, triggering "there is nothing
to exclude from".
- blame.c::find_origin() feeds a pathspec with a single element,
which is a path in the history and does so as a literal, hence
no room for "negative" to kick in.
- builtin/check-ignore.c::check_ignore(), when argc==0, does not
call parse_pathspec(). It does not take any magic other than
FROMTOP, so "negative" won't come into the picture.
- builtin/checkout.c::cmd_checkout(), when argc==0, does not call
parse_pathspec(). This codepath will get affected by Linus's
change ("cd t && git checkout :\!perf" would try to check out
everything except t/perf, but what is a reasonable definition of
"everything" in the context of this command). We need to
decide, and I am leaning towards preferring CWD for this case.
- revision.c::setup_revisions() calls parse_pathspec() only when
the caller gave a non-empty pathspec. This pathspec is used for
pruning log traversal (e.g. "only show commits that touch these
paths") and is affected by Linus's change. It should favor
FULL.
- tree-diff.c::try_to_follow_renames() feeds a pathspec with a
single element as a literal, hence no room for "negative" to
kick in.
So, I am tempted to suggest us doing the following:
* Leave a NEEDSWORK comment to archive.c::path_exists() that is
used for checking the validation of pathspec elements. To fix it
properly, we need to be able to skip a negative pathspec to be
passed to this function by the caller, and to do so, we need to
expose a helper from the pathspec API that gets a single string
and returns what magic it has, but that is of lower priority.
* Retire the PATHSPEC_PREFER_CWD bit and replace its use with the
lack of the PATHSPEC_PREFER_FULL bit.
* Keep most of the above callsites that currently do not pass
CWD/FULL as they are, except the ones that should take FULL (see
above).
Comments?
next prev parent reply other threads:[~2017-02-08 22:56 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 [this message]
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=xmqqwpd0v15j.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.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).