<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/list-objects-filter-options.h, branch jch</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=jch</id>
<link rel='self' href='https://git.shady.money/git/atom?h=jch'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2026-02-17T19:46:40Z</updated>
<entry>
<title>list-objects-filter-options: support 'auto' mode for --filter</title>
<updated>2026-02-17T19:46:40Z</updated>
<author>
<name>Christian Couder</name>
<email>christian.couder@gmail.com</email>
</author>
<published>2026-02-16T13:23:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=cd1a89838ad6753830afeed4ad8319e567b6e43d'/>
<id>urn:sha1:cd1a89838ad6753830afeed4ad8319e567b6e43d</id>
<content type='text'>
In a following commit, we are going to allow passing "auto" as a
&lt;filterspec&gt; to the `--filter=&lt;filterspec&gt;` option, but only for some
commands. Other commands that support the `--filter=&lt;filterspec&gt;`
option should still die() when 'auto' is passed.

Let's set up the "list-objects-filter-options.{c,h}" infrastructure to
support that:

- Add a new `unsigned int allow_auto_filter : 1;` flag to
  `struct list_objects_filter_options` which specifies if "auto" is
  accepted or not by the current command.
- Change gently_parse_list_objects_filter() to parse "auto" if it's
  accepted.
- Make sure we die() if "auto" is combined with another filter.
- Update list_objects_filter_release() to preserve the
  allow_auto_filter flag, as this function is often called (via
  opt_parse_list_objects_filter) to reset the struct before parsing a
  new value.

Let's also update `list-objects-filter.c` to recognize the new
`LOFC_AUTO` choice. Since "auto" must be resolved to a concrete filter
before filtering actually begins, initializing a filter with
`LOFC_AUTO` is invalid and will trigger a BUG().

Note that ideally combining "auto" with "auto" could be allowed, but in
practice, it's probably not worth the added code complexity. And if we
really want it, nothing prevents us to allow it in future work.

If we ever want to give a meaning to combining "auto" with a different
filter too, nothing prevents us to do that in future work either.

Also note that the new `allow_auto_filter` flag depends on the command,
not user choices, so it should be reset to the command default when
`struct list_objects_filter_options` instances are reset.

While at it, let's add a new "u-list-objects-filter-options.c" file for
`struct list_objects_filter_options` related unit tests. For now it
only tests gently_parse_list_objects_filter() though.

Signed-off-by: Christian Couder &lt;chriscool@tuxfamily.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>list-objects-filter-options.h: *.txt -&gt; *.adoc fixes</title>
<updated>2025-03-03T21:49:23Z</updated>
<author>
<name>Todd Zullinger</name>
<email>tmz@pobox.com</email>
</author>
<published>2025-03-03T20:44:18Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=02ed88f6a23d142f6e5c7e0b351704654796a6fe'/>
<id>urn:sha1:02ed88f6a23d142f6e5c7e0b351704654796a6fe</id>
<content type='text'>
Signed-off-by: Todd Zullinger &lt;tmz@pobox.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>list-objects-filter-options.h: remove unneccessary include</title>
<updated>2023-06-21T20:39:53Z</updated>
<author>
<name>Elijah Newren</name>
<email>newren@gmail.com</email>
</author>
<published>2023-05-16T06:34:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=768122900f7af84c2536fd9cb9d205f8ad774322'/>
<id>urn:sha1:768122900f7af84c2536fd9cb9d205f8ad774322</id>
<content type='text'>
Signed-off-by: Elijah Newren &lt;newren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'en/header-split-cleanup'</title>
<updated>2023-04-06T20:38:31Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2023-04-06T20:38:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6047b28eb7e1a0b0061c5310034f7b5683ea401a'/>
<id>urn:sha1:6047b28eb7e1a0b0061c5310034f7b5683ea401a</id>
<content type='text'>
Split key function and data structure definitions out of cache.h to
new header files and adjust the users.

* en/header-split-cleanup:
  csum-file.h: remove unnecessary inclusion of cache.h
  write-or-die.h: move declarations for write-or-die.c functions from cache.h
  treewide: remove cache.h inclusion due to setup.h changes
  setup.h: move declarations for setup.c functions from cache.h
  treewide: remove cache.h inclusion due to environment.h changes
  environment.h: move declarations for environment.c functions from cache.h
  treewide: remove unnecessary includes of cache.h
  wrapper.h: move declarations for wrapper.c functions from cache.h
  path.h: move function declarations for path.c functions from cache.h
  cache.h: remove expand_user_path()
  abspath.h: move absolute path functions from cache.h
  environment: move comment_line_char from cache.h
  treewide: remove unnecessary cache.h inclusion from several sources
  treewide: remove unnecessary inclusion of gettext.h
  treewide: be explicit about dependence on gettext.h
  treewide: remove unnecessary cache.h inclusion from a few headers
</content>
</entry>
<entry>
<title>Merge branch 'sg/parse-options-h-users'</title>
<updated>2023-03-30T20:47:11Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2023-03-30T20:47:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=dbb4102f7b1fea1f7e55450951d5692a4bc937d3'/>
<id>urn:sha1:dbb4102f7b1fea1f7e55450951d5692a4bc937d3</id>
<content type='text'>
Code clean-up to include and/or uninclude parse-options.h file as
needed.

* sg/parse-options-h-users:
  treewide: remove unnecessary inclusions of parse-options.h from headers
  treewide: include parse-options.h in source files
</content>
</entry>
<entry>
<title>treewide: be explicit about dependence on gettext.h</title>
<updated>2023-03-21T17:56:51Z</updated>
<author>
<name>Elijah Newren</name>
<email>newren@gmail.com</email>
</author>
<published>2023-03-21T06:25:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f394e093df10f1867d9bb2180b3789ee61124aed'/>
<id>urn:sha1:f394e093df10f1867d9bb2180b3789ee61124aed</id>
<content type='text'>
Dozens of files made use of gettext functions, without explicitly
including gettext.h.  This made it more difficult to find which files
could remove a dependence on cache.h.  Make C files explicitly include
gettext.h if they are using it.

However, while compat/fsmonitor/fsm-ipc-darwin.c should also gain an
include of gettext.h, it was left out to avoid conflicting with an
in-flight topic.

Signed-off-by: Elijah Newren &lt;newren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>treewide: remove unnecessary inclusions of parse-options.h from headers</title>
<updated>2023-03-20T18:55:18Z</updated>
<author>
<name>SZEDER Gábor</name>
<email>szeder.dev@gmail.com</email>
</author>
<published>2023-03-19T16:27:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c4d9c79378e9108358c3f20e27bc437754cd805d'/>
<id>urn:sha1:c4d9c79378e9108358c3f20e27bc437754cd805d</id>
<content type='text'>
The headers 'diagnose.h', 'list-objects-filter-options.h',
'ref-filter.h' and 'remote.h' declare option parsing callback
functions with a 'struct option*' parameter, and 'revision.h' declares
an option parsing helper function taking 'struct parse_opt_ctx_t*' and
'struct option*' parameters.  These headers all include
'parse-options.h', although they don't need any of the type
definitions from that header file.  Furthermore,
'list-objects-filter-options.h' and 'ref-filter.h' also define some
OPT_* macros to initialize a 'struct option', but these don't
necessitate the inclusion of parse-options.h in these headers either,
because these macros are only expanded in source files.

Remove these unnecessary inclusions of parse-options.h and use forward
declarations to declare the necessary types.

After this patch none of the header files include parse-options.h
anymore.

With these changes, the build time after modifying only
parse-options.h is reduced by about 30%, and the number of targets
built is almost 20% less:

  Before:

    $ touch parse-options.h &amp;&amp; time make -j4 |wc -l
    353

    real    1m1.527s
    user    3m32.205s
    sys	    0m15.903s

  After:

    289

    real    0m39.285s
    user    2m12.540s
    sys     0m11.164s

Signed-off-by: SZEDER Gábor &lt;szeder.dev@gmail.com&gt;
Reviewed-by: Elijah Newren &lt;newren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>object.h: stop depending on cache.h; make cache.h depend on object.h</title>
<updated>2023-02-24T01:25:29Z</updated>
<author>
<name>Elijah Newren</name>
<email>newren@gmail.com</email>
</author>
<published>2023-02-24T00:09:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a64215b6cd5e67939187475c5b248dc5d13e3d60'/>
<id>urn:sha1:a64215b6cd5e67939187475c5b248dc5d13e3d60</id>
<content type='text'>
Things should be able to depend on object.h without pulling in all of
cache.h.  Move an enum to allow this.

Note that a couple files previously depended on things brought in
through cache.h indirectly (revision.h -&gt; commit.h -&gt; object.h -&gt;
cache.h).  As such, this change requires making existing dependencies
more explicit in half a dozen files.  The inclusion of strbuf.h in
some headers if of particular note: these headers directly embedded a
strbuf in some new structs, meaning they should have been including
strbuf.h all along but were indirectly getting the necessary
definitions.

Signed-off-by: Elijah Newren &lt;newren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>list-objects-filter: remove OPT_PARSE_LIST_OBJECTS_FILTER_INIT()</title>
<updated>2022-11-30T01:00:35Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2022-11-29T12:26:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d4f7036887f54184d666a1096ee96dfb2e9ad881'/>
<id>urn:sha1:d4f7036887f54184d666a1096ee96dfb2e9ad881</id>
<content type='text'>
OPT_PARSE_LIST_OBJECTS_FILTER_INIT() with a non-NULL second argument
passes a function pointer via an object pointer, which is undefined.  It
may work fine on platforms that implement C99 extension J.5.7 (Function
pointer casts).  Remove the unused macro and avoid the dependency on
that extension.

Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>list-objects-filter: convert filter_spec to a strbuf</title>
<updated>2022-09-12T15:38:59Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2022-09-11T05:03:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c54980ab83661e8e290003fbd5ab44b12e4e77b1'/>
<id>urn:sha1:c54980ab83661e8e290003fbd5ab44b12e4e77b1</id>
<content type='text'>
Originally, the filter_spec field was just a string pointer. In
cf9ceb5a12 (list-objects-filter-options: make filter_spec a string_list,
2019-06-27) it became a string_list, but that commit notes:

    A strbuf would seem to be a more natural choice for this object, but
    it unfortunately requires initialization besides just zero'ing out
    the memory.  This results in all container structs, and all
    containers of those structs, etc., to also require initialization.
    Initializing them all would be more cumbersome that simply using a
    string_list, which behaves properly when its contents are zero'd.

Now that we've changed the struct to require non-zero initialization
anyway (ironically, because string_list also needed non-zero
initialization to avoid leaks), we can now convert to that more natural
type.

This makes the list_objects_filter_spec() function much less awkward, as
it had to collapse the string_list to a single-entry list on the fly.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
