Re: [RFC PATCH 06/15] Automatically reuse sparse limiting arguments in revision walking
From: Nguyen Thai Ngoc Duy <hidden>
Date: 2016-06-15 22:49:29
On Sun, Sep 5, 2010 at 2:50 PM, Elijah Newren [off-list ref] wrote:
On Sat, Sep 4, 2010 at 7:58 PM, Nguyen Thai Ngoc Duy [off-list ref] wrote:quoted
On Sun, Sep 5, 2010 at 10:13 AM, Elijah Newren [off-list ref] wrote:quoted
In a sparse repository, by automatically making use of sparse limits specified at clone time, we can avoid walking uninteresting commits andquoted
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.
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