Re: [RFC PATCH 3/3] list-objects-filter: teach tree:# how to handle >0
Matthew DeVore writes: > The long-term goal at the end of this is to allow a partial clone to > eagerly fetch an entire directory of files by fetching a tree and > specifying =1. This, for instance, would make a build operation > fast and convenient This would reduce round-trip, as you do not have to fetch the tree to see what its contents are before issuing another set of fetches for them. Those who are building virtual filesystem that let you mount a specific tree object, perhaps via fuse, may find it useful, too, even though I suspect that may not be your primary focus. > diff --git a/Documentation/rev-list-options.txt > b/Documentation/rev-list-options.txt > index c2c1c40e6..c78985c41 100644 > --- a/Documentation/rev-list-options.txt > +++ b/Documentation/rev-list-options.txt > @@ -734,8 +734,12 @@ specification contained in . > + > The form '--filter=tree:' omits all blobs and trees whose depth > from the root tree is >= (minimum depth if an object is located > -at multiple depths in the commits traversed). Currently, only =0 > -is supported, which omits all blobs and trees. > +at multiple depths in the commits traversed). =0 will not include > +any trees or blobs unless included explicitly in . =1 Here, refers to the objects directly requested on the command line (or --stdin)? Triggering this question from me is a sign that this description may want to say a bit more to avoid the same question from the real readers. Perhaps replace "included explicitly in " with "explicitly requested by listing them on the command line or feeding them with `--stdin`", or something like that? > diff --git a/list-objects-filter-options.c b/list-objects-filter-options.c > index e8da2e858..9dc61d6e6 100644 > --- a/list-objects-filter-options.c > +++ b/list-objects-filter-options.c > @@ -50,12 +50,12 @@ static int gently_parse_list_objects_filter( > } > > } else if (skip_prefix(arg, "tree:", &v0)) { > - unsigned long depth; > - if (!git_parse_ulong(v0, &depth) || depth != 0) { > + if (!git_parse_ulong(v0, > + &filter_options->tree_depth_limit_value)) { > if (errbuf) { > strbuf_addstr( > errbuf, > - _("only 'tree:0' is supported")); > + _("expected 'tree:'")); We do not accept "tree:-1", even though "-1" is an int. Is it too obvious to worry about? I do not think we want to say tree: even if we do want to make it clear we reject "tree:-1" I am wondering if "expected 'tree:'" would work better. > diff --git a/list-objects-filter-options.h b/list-objects-filter-options.h > index af64e5c66..c1ae70cd8 100644 > --- a/list-objects-filter-options.h > +++ b/list-objects-filter-options.h > @@ -44,6 +44,7 @@ struct list_objects_filter_options { > struct object_id *sparse_oid_value; > char *sparse_path_value; > unsigned long blob_limit_value; > + unsigned long tree_depth_limit_value; > }; This change gets it right by adding "depth" in the field name and it is not a comment on this patch, but someday not in too distant future we should rename the "blob_limit_value" to make it clear that it is filtering by number of bytes, as other filtering criteria on blobs that can be expressed in ulong are quite possible. > -static enum list_objects_filter_result filter_trees_none( > +static enum list_objects_filter_result filter_trees_depth( > enum list_objects_filter_situation filter_situation, > struct object *obj, > const char *pathname, > const char *filename, > void *filter_data_) > { > - struct filter_trees_none_data *filter_data = filter_data_; > + struct filter_trees_depth_data *filter_data = filter_data_; > + > + int too_deep = filter_data->current_depth >= filter_data->max_depth; Does max mean "maximum allowed", or "this and anything larger are rejected". The latter sound wrong, but I offhand do not know if your current_depth counts from 0 or 1, so there may not be off-by-one. - dir.c::within_depth() that is used by pathspec matching that in turn is used by "grep --max-depth=1" does "if (depth > max_depth)", which sounds more in line with the usual convention, I would think. - pack-objects has max_delta_cache_size, which also is used as "maximum allowed", not "this is already too big". So is its max_depth. There may be other examples. One existing violator I noticed was the "reject blobs that is this size or larger" in this file; it is called "max_bytes", but it is apparently not "maximum allowed", which we probably would want to fix. > + /* > + * Note that we do not use _MARK_SEEN in order to allow re-traversal in > + * case we encounter a tree or blob again at a shallower depth. > + */ Hmph. Earlier tree:0 support never even read the actual tree, so this was
Re: [RFC PATCH 3/3] list-objects-filter: teach tree:# how to handle >0
A quick update: I've read Junio's comments on this patchset and basically agree with them, but I haven't had a chance to apply them yet. I plan to pick this patchset up again (as well as the patch "md/list-lazy-objects-fix") once things settle down in my day job. On Sun, Oct 14, 2018 at 7:31 PM Junio C Hamano wrote: > > Matthew DeVore writes: > > > The long-term goal at the end of this is to allow a partial clone to > > eagerly fetch an entire directory of files by fetching a tree and > > specifying =1. This, for instance, would make a build operation > > fast and convenient > > This would reduce round-trip, as you do not have to fetch the tree > to see what its contents are before issuing another set of fetches > for them. Those who are building virtual filesystem that let you > mount a specific tree object, perhaps via fuse, may find it useful, > too, even though I suspect that may not be your primary focus. > > > diff --git a/Documentation/rev-list-options.txt > > b/Documentation/rev-list-options.txt > > index c2c1c40e6..c78985c41 100644 > > --- a/Documentation/rev-list-options.txt > > +++ b/Documentation/rev-list-options.txt > > @@ -734,8 +734,12 @@ specification contained in . > > + > > The form '--filter=tree:' omits all blobs and trees whose depth > > from the root tree is >= (minimum depth if an object is located > > -at multiple depths in the commits traversed). Currently, only =0 > > -is supported, which omits all blobs and trees. > > +at multiple depths in the commits traversed). =0 will not include > > +any trees or blobs unless included explicitly in . =1 > > Here, refers to the objects directly requested on the > command line (or --stdin)? Triggering this question from me is a > sign that this description may want to say a bit more to avoid the > same question from the real readers. Perhaps replace "included > explicitly in " with "explicitly requested by listing them > on the command line or feeding them with `--stdin`", or something > like that? > > > diff --git a/list-objects-filter-options.c b/list-objects-filter-options.c > > index e8da2e858..9dc61d6e6 100644 > > --- a/list-objects-filter-options.c > > +++ b/list-objects-filter-options.c > > @@ -50,12 +50,12 @@ static int gently_parse_list_objects_filter( > > } > > > > } else if (skip_prefix(arg, "tree:", &v0)) { > > - unsigned long depth; > > - if (!git_parse_ulong(v0, &depth) || depth != 0) { > > + if (!git_parse_ulong(v0, > > + > > &filter_options->tree_depth_limit_value)) { > > if (errbuf) { > > strbuf_addstr( > > errbuf, > > - _("only 'tree:0' is supported")); > > + _("expected 'tree:'")); > > We do not accept "tree:-1", even though "-1" is an int. Is it too > obvious to worry about? I do not think we want to say tree: > even if we do want to make it clear we reject "tree:-1" > > I am wondering if "expected 'tree:'" would work better. > > > diff --git a/list-objects-filter-options.h b/list-objects-filter-options.h > > index af64e5c66..c1ae70cd8 100644 > > --- a/list-objects-filter-options.h > > +++ b/list-objects-filter-options.h > > @@ -44,6 +44,7 @@ struct list_objects_filter_options { > > struct object_id *sparse_oid_value; > > char *sparse_path_value; > > unsigned long blob_limit_value; > > + unsigned long tree_depth_limit_value; > > }; > > This change gets it right by adding "depth" in the field name and it > is not a comment on this patch, but someday not in too distant > future we should rename the "blob_limit_value" to make it clear that > it is filtering by number of bytes, as other filtering criteria on > blobs that can be expressed in ulong are quite possible. > > > -static enum list_objects_filter_result filter_trees_none( > > +static enum list_objects_filter_result filter_trees_depth( > > enum list_objects_filter_situation filter_situation, > > struct object *obj, > > const char *pathname, > > const char *filename, > > void *filter_data_) > > { > > - struct filter_trees_none_data *filter_data = filter_data_; > > + struct filter_trees_depth_data *filter_data = filter_data_; > > + > > + int too_deep = filter_data->current_depth >= filter_data->max_depth; > > Does max mean "maximum allowed", or "this and anything larger are > rejected". The latter sound wrong, but I offhand do not know if > your current_depth counts from 0 or 1, so there may not be > off-by-one. > > - dir.c::within_depth() that is used by pathspec matching that in turn >is used by "grep --max-depth=1" does "if (depth > max_depth)", which >sounds more in line with the usual convention, I would think. > > - pack-objects has max_delta_cache_size, which also is used as >"maximum allowed", not "this is already too big".
Re: [RFC PATCH 3/3] list-objects-filter: teach tree:# how to handle >0
On Sun, Oct 14, 2018 at 7:31 PM Junio C Hamano wrote: > > Matthew DeVore writes: > > > The long-term goal at the end of this is to allow a partial clone to > > eagerly fetch an entire directory of files by fetching a tree and > > specifying =1. This, for instance, would make a build operation > > fast and convenient > > This would reduce round-trip, as you do not have to fetch the tree > to see what its contents are before issuing another set of fetches > for them. Those who are building virtual filesystem that let you > mount a specific tree object, perhaps via fuse, may find it useful, > too, even though I suspect that may not be your primary focus. I added a paragraph mentioning the "roundtrip" aspect to the commit message, since this *may* help someone find a use for it. > > > diff --git a/Documentation/rev-list-options.txt > > b/Documentation/rev-list-options.txt > > index c2c1c40e6..c78985c41 100644 > > --- a/Documentation/rev-list-options.txt > > +++ b/Documentation/rev-list-options.txt > > @@ -734,8 +734,12 @@ specification contained in . > > + > > The form '--filter=tree:' omits all blobs and trees whose depth > > from the root tree is >= (minimum depth if an object is located > > -at multiple depths in the commits traversed). Currently, only =0 > > -is supported, which omits all blobs and trees. > > +at multiple depths in the commits traversed). =0 will not include > > +any trees or blobs unless included explicitly in . =1 > > Here, refers to the objects directly requested on the > command line (or --stdin)? Triggering this question from me is a > sign that this description may want to say a bit more to avoid the > same question from the real readers. Perhaps replace "included > explicitly in " with "explicitly requested by listing them > on the command line or feeding them with `--stdin`", or something > like that? I have reworded this to be more explicit about "stdin," and also to avoid directly admitting that trees are allowed in the argument, since I've dropped the s/// patch. Here is the new paragraph: The form '--filter=tree:' omits all blobs and trees whose depth from the root tree is >= (minimum depth if an object is located at multiple depths in the commits traversed). =0 will not include any trees or blobs unless included explicitly in the command-line (or standard input when --stdin is used). =1 will include only the tree and blobs which are referenced directly by a commit reachable from or an explicitly-given object. =2 is like =1 while also including trees and blobs one more level removed from an explicitly-given commit or tree. > > + _("expected 'tree:'")); > > We do not accept "tree:-1", even though "-1" is an int. Is it too > obvious to worry about? I do not think we want to say tree: > even if we do want to make it clear we reject "tree:-1" > > I am wondering if "expected 'tree:'" would work better. Yes, I agree, is more helpful and not ambiguous in a significant way. Fixed. > > + unsigned long tree_depth_limit_value; > > }; > > This change gets it right by adding "depth" in the field name and it > is not a comment on this patch, but someday not in too distant > future we should rename the "blob_limit_value" to make it clear that > it is filtering by number of bytes, as other filtering criteria on > blobs that can be expressed in ulong are quite possible. Agreed. > > > -static enum list_objects_filter_result filter_trees_none( > > +static enum list_objects_filter_result filter_trees_depth( > > enum list_objects_filter_situation filter_situation, > > struct object *obj, > > const char *pathname, > > const char *filename, > > void *filter_data_) > > { > > - struct filter_trees_none_data *filter_data = filter_data_; > > + struct filter_trees_depth_data *filter_data = filter_data_; > > + > > + int too_deep = filter_data->current_depth >= filter_data->max_depth; > > Does max mean "maximum allowed", or "this and anything larger are > rejected". The latter sound wrong, but I offhand do not know if > your current_depth counts from 0 or 1, so there may not be > off-by-one. > It means "this and anything larger are rejected." The documentation words it similarly: " The form '--filter=tree:' omits all blobs and trees whose depth from the root tree is >= ... " There is no intuitive phrase to mean "distance from root tree minus one" (left operand) and I don't want to change the filter option field to something different from what the user entered (right operand), so I think we'd best use ">=" and I've renamed the field to "exclusion_trigger_depth". > There may be other examples. One existing violator I noticed was > the "reject blobs that is this size or larger" in this file; it is > called "max_bytes", but it is apparently not "maximum allowed", > which we probably would want to fix. > That's not ideal. The documentation suggests it means "maximum allowed," and JGit apparently