Re: [RFC PATCH 06/15] Automatically reuse sparse limiting arguments in revision walking
- From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
- Date
- Sep 5, 2010, 07:12 UTC
- Message-ID
- <AANLkTimw89nkui5UdJPu-s5yQ=mP4wtw0tKTZxsq2L4W@mail.gmail.com>
- In-Reply-To
- <AANLkTi=ywOZfkxfr1Gt3AMMbWDphKjTBudG=E4+xer-P@mail.gmail.com>
On Sun, Sep 5, 2010 at 2:50 PM, Elijah Newren <newren@gmail.com> wrote:
Show 19 quoted lines
> On Sat, Sep 4, 2010 at 7:58 PM, Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote: >> On Sun, Sep 5, 2010 at 10:13 AM, Elijah Newren <newren@gmail.com> wrote: >>> In a sparse repository, by automatically making use of sparse limits >>> specified at clone time, we can avoid walking uninteresting commits and > >> >> I have a nicer approach here. Instead of modifying setup_revisions() >> and similar functions, I update get_pathspec() to rewrite the >> pathspecs from command line in narrow/shallow repos. get_pathspec() >> currently does some form of rewriting already (prepending prefix). >> >> So if you do "git log", get_pathspec() would return "git log -- PATH1 >> PATH2...". Will repost my series soon, or I can send that particular >> patch to you. > > Ooh, that's clever. I like it. Do you also do verification that any > paths specified by the user are a subset of the paths the sparse clone > is limited to? That'd be really nice. Much better than my simple > dumb "just append" logic.
I do.
Show 7 quoted lines
> How do you reconcile conflicting needs, though? For most cases, > whenever the user specifies paths, get_pathspec should make sure those > paths are a subset of the sparse paths (throwing an error if they're > not) and then just use the user-specified ones. However, I think > doing this in all cases would break ls-files/cat-file -p, as the > pathspecs passed to those are not necessarily rooted at the toplevel > of the repository (and the prefix doesn't correct for that either).
Yes, some commands will just skip the pathspec rewrite. It's up to those commands to rewrite pathspec themselves.
So get_pathspec() will have pathspec rewrite by default. Other commands will use another variant of it (i.e. get_pathspec_narrow()), which allows to skip the rewrite completely.
-- Duy