From: Jeff Hostetler Date: Fri, 07 Jun 2019 19:15:53 GMT Subject: Re: [RFC PATCH 11/13] walken: add filtered object walk Message-ID: <712ced21-cc7a-0a4a-9cf2-64b1e7c5127a@jeffhostetler.com> In-Reply-To: <20190607010811.52944-12-emilyshaffer@google.com> On 6/6/2019 9:08 PM, Emily Shaffer wrote: > Demonstrate how filter specs can be used when performing a revision walk > of all object types. In this case, tree depth is used. Contributors who > are following the revision walking tutorial will be encouraged to run > the revision walk with and without the filter in order to compare the > number of objects seen in each case. > > Signed-off-by: Emily Shaffer > --- > builtin/walken.c | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/builtin/walken.c b/builtin/walken.c > index 408af6c841..f2c98bcd6b 100644 > --- a/builtin/walken.c > +++ b/builtin/walken.c > @@ -13,6 +13,7 @@ > #include "pretty.h" > #include "line-log.h" > #include "list-objects.h" > +#include "list-objects-filter-options.h" > #include "grep.h" > > static const char * const walken_usage[] = { > @@ -154,7 +155,22 @@ static int walken_object_walk(struct rev_info *rev) > blob_count = 0; > tree_count = 0; > > - traverse_commit_list(rev, walken_show_commit, walken_show_object, NULL); > + if (1) { > + /* Unfiltered: */ > + printf(_("Unfiltered object walk.\n")); > + traverse_commit_list(rev, walken_show_commit, > + walken_show_object, NULL); > + } else { > + printf(_("Filtered object walk with filterspec 'tree:1'.\n")); > + /* > + * We can parse a tree depth of 1 to demonstrate the kind of > + * filtering that could occur eg during shallow cloning. > + */ I think I'd avoid the term "shallow clone" here. Shallow clone refers to getting a limited commit history. That's orthogonal from partial clone and the filtered tree walk that operates *within* a commit or a series of commits. Granted, a user might want to do both a shallow and partial clone (and then later partial fetches), but I wouldn't mix the concepts here. > + parse_list_objects_filter(&filter_options, "tree:1"); > + > + traverse_commit_list_filtered(&filter_options, rev, > + walken_show_commit, walken_show_object, NULL, &omitted); > + } > > printf(_("Object walk completed. Found %d commits, %d blobs, %d tags, " > "and %d trees.\n"), commit_count, blob_count, tag_count, >