From: Michael J Gruber <git@drmicha.warpmail.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Nguyen Thai Ngoc Duy <pclouds@gmail.com>,
Sverre Rabbelier <srabbelier@gmail.com>,
git@vger.kernel.org
Subject: Re: [PATCH/alternative/raw and rough] setup.c: denote repo wide pathspecs by ':'
Date: Wed, 02 Mar 2011 18:31:28 +0100 [thread overview]
Message-ID: <4D6E7EF0.5040106@drmicha.warpmail.net> (raw)
In-Reply-To: <7vhbblcvl7.fsf@alter.siamese.dyndns.org>
Junio C Hamano venit, vidit, dixit 02.03.2011 17:53:
> Michael J Gruber <git@drmicha.warpmail.net> writes:
>
>> [*] I keep forgetting that some people may have files whose names begin
>> with ":". They are ambiguous now already with "treeish pathspec"
>> commands, but not with "pathspec" commands. The latter would change.
>
> Just to make sure I understand that they have easy workarounds:
>
> - If you have a path foo/:bar, you can say
>
> git log master -- foo/:bar
>
> because ':' signals the magic and gets stripped only when it is at the
> beginning (i.e. not affecting foo/:bar); and
Yes.
>
> - For :boz at the root level, you can say
>
> git log master -- '\:boz'
>
> because the backslash in '\:boz' makes the colon not at the beginning and
> the glob match sees '\:boz' and then matches '\:' with literal ':' at the
> beginning of the pathname ":boz".
Yes. Due to the shell escaping, a shorter way is
git log master -- ::boz
:)
>
> In very old times, git used to work only from the top-level of the working
> tree.
>
> The way we give an illusion that a command is restricted within the
> current working directory was by learning the "prefix" returned by
> setup_git_directory() while it chdir(2)'s up to the root level of the
> working tree, and then by limiting the operation to the pathspec given
> from the command line (each of whose elements prefixed by "prefix" by
> calling get_pathspec()).
>
> Your ':'-prefix trick will naturally work very well with this arrangement.
> Instead of prefixing the "prefix", you would just strip ':' from the front
> for such a magic pathspec element, and that should be all that is necessary.
and pretend prefix == NULL, exactly.
>
> There is a small worry, though. Some codepaths have tricks that take
> advantage of the knowledge of the current behaviour that the resulting
> pathspec elements all refer to subtree under the "prefix", and try to
> optimize their tree traversal. I think dir.c:fill_directory()'s use of
> common_prefix() is safe (it recomputes what is common based on the result
> of get_pathspec(), not blindly using the original "prefix"), but we need
> to make sure there isn't a codepath that blindly believes that the
> original "prefix" defines the extent of the operation. Anything that
> understands "../" to step outside the cwd should be already safe, so I
> hopefully am being worried too much.
Except for rerere, I've tried all callers, and all work. ls-tree is a
bit strange, but that was true already for rev:path. I think it's OK if
ls-tree does not grok this, but I'll have another look.
>
> Earlier, the list consensus was that if we were to aim for uniformity, we
> should make everything relative to the root of the working tree when there
> is no pathspec by default, because you can always give a single '.' to
> restrict the extent of the operation to the cwd, but you cannot extend the
> extent of the operation without tediously counting "../".
Hadn't we decided there were exceptions (e.g. grep), and there weren't
that many suggested changes (to repo-wide) left?
> Would this ':'
> trick affect that argument? If a command is relative to the cwd with no
> pathspec, you can now give a single ':' to affect the whole tree.
In my view yes. I would even say: If we don't change every single
command to repo-wide default there is no need to change (and break
things) if we have an easy one-character way of saying "repo-wide".
>
> As I wrote in my response to Jeff in
>
> http://thread.gmane.org/gmane.comp.version-control.git/133570/focus=133874
>
> I always thought that it would be the best solution that makes the choice
> of the default irrelevant, and this ":" trick certainly feels like this is
> that solution (I also think having a good default matters).
>
> And we can start thinking about deprecating --full-tree option, no? I
> like that, too ;-).
>
:)
Michael
next prev parent reply other threads:[~2011-03-02 17:35 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-28 0:17 git-grep to operate across who repository and not just CWD? David Chanters
2011-02-28 9:27 ` Michael J Gruber
2011-02-28 15:27 ` Jay Soffian
2011-02-28 18:32 ` Junio C Hamano
2011-02-28 18:38 ` Junio C Hamano
2011-02-28 22:25 ` Phil Hord
2011-03-01 8:05 ` Michael J Gruber
2011-03-01 8:16 ` Nguyen Thai Ngoc Duy
2011-03-01 8:54 ` Michael J Gruber
2011-03-01 9:32 ` Nguyen Thai Ngoc Duy
2011-03-01 9:44 ` Nguyen Thai Ngoc Duy
2011-03-01 9:53 ` [PATCH/POC 0/2] grep --full-tree Michael J Gruber
2011-03-01 9:53 ` [PATCH/RFC 1/2] grep: --full-tree Michael J Gruber
2011-03-01 9:53 ` [PATCH/RFC 2/2] grep: make --full-tree work with pathspecs Michael J Gruber
2011-03-01 19:20 ` Junio C Hamano
2011-03-01 10:21 ` [PATCH/alternative/raw and rough] setup.c: denote repo wide pathspecs by ':' Michael J Gruber
2011-03-01 11:13 ` Nguyen Thai Ngoc Duy
2011-03-01 11:16 ` Michael J Gruber
2011-03-01 11:50 ` Nguyen Thai Ngoc Duy
2011-03-01 11:57 ` Michael J Gruber
2011-03-01 12:08 ` Nguyen Thai Ngoc Duy
2011-03-01 14:50 ` Junio C Hamano
2011-03-01 15:01 ` Michael J Gruber
2011-03-01 20:00 ` Junio C Hamano
2011-03-02 12:34 ` Sverre Rabbelier
2011-03-02 12:57 ` Nguyen Thai Ngoc Duy
2011-03-02 13:12 ` Michael J Gruber
2011-03-02 16:53 ` Junio C Hamano
2011-03-02 17:31 ` Michael J Gruber [this message]
2011-03-03 2:42 ` Miles Bader
2011-03-03 3:52 ` Junio C Hamano
2011-03-03 3:44 ` Phil Hord
2011-03-03 8:20 ` Michael J Gruber
2011-03-01 16:25 ` Phil Hord
2011-03-01 18:31 ` James Pickens
2011-03-02 0:12 ` Nguyen Thai Ngoc Duy
2011-03-03 3:51 ` Phil Hord
2011-03-03 8:21 ` Michael J Gruber
2011-03-01 11:49 ` Michael J Gruber
2011-03-01 13:05 ` Phil Hord
2011-03-23 15:32 ` [PATCH] pathspec: reserve some letters after a colon pathspec Nguyễn Thái Ngọc Duy
2011-03-23 18:04 ` Junio C Hamano
2011-03-24 7:15 ` Michael J Gruber
2011-03-24 7:49 ` Nguyen Thai Ngoc Duy
2011-03-24 8:12 ` Junio C Hamano
2011-03-24 14:46 ` Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D6E7EF0.5040106@drmicha.warpmail.net \
--to=git@drmicha.warpmail.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pclouds@gmail.com \
--cc=srabbelier@gmail.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.
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 NNTP newsgroup(s).