git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 07/13] object-filter: common declarations for object filtering

From
JTJonathan Tan <jonathantanmy@google.com>
Date
Sep 28, 2017, 00:05 UTC
Message-ID
<20170927170533.65498396e008fa148a3fda90@google.com>
In-Reply-To
<7774ff8d-3a53-860d-9343-292938d59d12@jeffhostetler.com>

On Wed, 27 Sep 2017 13:09:42 -0400 Jeff Hostetler <git@jeffhostetler.com> wrote:

Show 22 quoted lines
> On 9/26/2017 6:39 PM, Jonathan Tan wrote:
> > On Fri, 22 Sep 2017 20:30:11 +0000
> > Jeff Hostetler <git@jeffhostetler.com> wrote:
> > 
> >>   Makefile        |   1 +
> >>   object-filter.c | 269 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >>   object-filter.h | 173 ++++++++++++++++++++++++++++++++++++
> >>   3 files changed, 443 insertions(+)
> >>   create mode 100644 object-filter.c
> >>   create mode 100644 object-filter.h
> > 
> > I think these and list-objects-filter-* are multiple levels of
> > indirection too many. Would a single file with a few implementations of
> > filter_object_fn be sufficient?
> 
> I did that in my first draft and I found it confusing.
> 
> Each filter has 3 parts (some filter-specific data structures,
> a filter callback routine, a driver to call the traverse code).
> I found it easier to reason about each filter in isolation.
> And it makes it easier to work on each independently and keep
> their inclusion in separate commits.
I looked at object-filter.{c,h} a bit more. It seems that these files:
 1) define a struct that contains all the options that we would want
 2) supplies a way to populate this struct from code that uses parse-options
 3) supplies a way to populate this struct from code that calculates
    options by hand
 4) supplies a way to populate this struct from "protocol" ("<key>" or
    "<key> <value>" strings)

And the next commit takes the struct that object-filter.{c,h} produces and actually performs the traversal.

I think this can be significantly simplified, though. Would this work:
 a) Define the object_filter_options struct, but make all fields
    correspond to a single parameter each. Define
    OBJECT_FILTER_OPTIONS_INIT to initialize everything to 0 except for
    large_byte_limit to ULONG_MAX (so that we can detect if something
    else is set to it).
 b) Define one single OPT_PARSE_FILTER macro containing all the
    parameters. We can use the non-callback macros here. That solves 2)
    above.
 c) Define a function that takes in (int *argc, char ***argv) that can
    "massage" it to remove all filter-related arguments, storing them in
    a object_filter_options struct. That solves 3) above. As discussed
    in the API documentation, this means that argument lists of the form
    "--unknown --known" (where "--unknown" takes an argument) are
    processed differently, but then again, rev-list never supported them
    anyway (it required "--unknown=<arg>").
 d) Define a function that converts "<key>" into "--<key>" and "<key>
    <value>" into "--<key>=<value>", and use the existing mechanism.
    That solves 4) above.

This removes the need to maintain the lists of one-per-argument functions, including the parse_filter_* and opt_parse_filter_* functions declared in the header file. If we were to add a feature, we wouldn't need to change anything in the caller, and wouldn't need to hand-edit object_filter_hand_parse_arg() and object_filter_hand_parse_protocol().

Previous: Jeff HostetlerNext: Jeff Hostetler
Message 6 of 16 in “list-objects-filter-large: add large blob filter to list-objects”
  1. 05/13 list-objects-filter-large: add large blob filter to list-objectsJeff Hostetler, Sep 22, 2017
  2. 06/13 list-objects-filter-sparse: add sparse-checkout based filterJeff Hostetler, Sep 22, 2017
  3. 07/13 object-filter: common declarations for object filteringJeff Hostetler, Sep 22, 2017
  4. Jonathan TanSep 26, 2017
  5. Jeff HostetlerSep 27, 2017
  6. Jonathan TanSep 28, 2017
  7. Jeff HostetlerSep 28, 2017
  8. Jonathan TanSep 29, 2017
  9. 08/13 list-objects: add traverse_commit_list_filtered methodJeff Hostetler, Sep 22, 2017
  10. 09/13 rev-list: add object filtering supportJeff Hostetler, Sep 22, 2017
  11. Jonathan TanSep 26, 2017
  12. Jeff HostetlerSep 27, 2017
  13. 10/13 rev-list: add filtering help textJeff Hostetler, Sep 22, 2017
  14. 11/13 t6112: rev-list object filtering testJeff Hostetler, Sep 22, 2017
  15. 13/13 pack-objects: add filtering help textJeff Hostetler, Sep 22, 2017
  16. 12/13 pack-objects: add object filtering supportJeff Hostetler, Sep 22, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.