<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/ref-filter.h, branch v2.48.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.48.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.48.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2024-09-09T23:26:11Z</updated>
<entry>
<title>ref-filter: add ref_format_clear() function</title>
<updated>2024-09-09T23:26:11Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2024-09-09T23:21:18Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=db629c61f0be3665a36750fe2353b9ee958b0376'/>
<id>urn:sha1:db629c61f0be3665a36750fe2353b9ee958b0376</id>
<content type='text'>
After using the ref-filter API, callers should use ref_filter_clear() to
free any used memory. However, there's not a matching function to clear
the ref_format struct.

Traditionally this did not need to be cleaned up, as it was just a way
for the caller to store and pass format options as a single unit. Even
though the parsing step of some placeholders may allocate data, that's
usually inside their "used_atom" structs, which are part of the
ref_filter itself.

But a few placeholders keep data outside of there. The %(ahead-behind)
and %(is-base) parsers both keep a master list of bases, because they
perform a single filtering pass outside of the use of any particular
atom. And since the format parser does not have access to the ref_filter
struct, they store their cross-atom data in the ref_format struct
itself.

And thus when they are finished, the ref_format also needs to be cleaned
up. So let's add a function to do so, and call it from all of the users
of the ref-filter API.

The %(is-base) case is found by running LSan on t6300. After this patch,
the script can now be marked leak-free.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>for-each-ref: add 'is-base' token</title>
<updated>2024-08-14T17:10:06Z</updated>
<author>
<name>Derrick Stolee</name>
<email>stolee@gmail.com</email>
</author>
<published>2024-08-14T10:31:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9c1732ca113d565e431b303911fcf66bfa1f8f56'/>
<id>urn:sha1:9c1732ca113d565e431b303911fcf66bfa1f8f56</id>
<content type='text'>
The previous change introduced the get_branch_base_for_tip() method in
commit-reach.c. The motivation of that change was about using a heuristic to
deteremine the base branch for a source commit from a list of candidate
commit tips. This change makes that algorithm visible to users via a new
atom in the 'git for-each-ref' format. This change is very similar to the
chang in 49abcd21da6 (for-each-ref: add ahead-behind format atom,
2023-03-20).

Introduce the 'is-base:&lt;source&gt;' atom, which will indicate that the
algorithm should be computed and the result of the algorithm is reported
using an indicator of the form '(&lt;source&gt;)'. For example, using
'%(is-base:HEAD)' would result in one line having the token '(HEAD)'.

Use the sorted order of refs included in the ref filter to break ties in the
algorithm's heuristic. In the previous change, the motivating examples
include using an L0 trunk, long-lived L1 branches, and temporary release
branches. A caller could communicate the ordered preference among these
categories using the input refpecs and avoiding a different sort mechanism.
This sorting behavior is tested in the test scripts.

It is important to include this atom as a special case to
can_do_iterative_format() to match the expectations created in bd98f9774e1
(ref-filter.c: filter &amp; format refs in the same callback, 2023-11-14). The
ahead-behind atom was one of the special cases, and this similarly requires
using an algorithm across all input refs before starting the format of any
single ref.

In the test script, the format tokens use colons or lack whitespace to avoid
Git complaining about trailing whitespace errors.

Signed-off-by: Derrick Stolee &lt;stolee@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>ref-filter: properly distinuish pseudo and root refs</title>
<updated>2024-05-15T14:30:52Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-05-15T06:51:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f1701f279a3678e95daa5c093b8d30e815c1701b'/>
<id>urn:sha1:f1701f279a3678e95daa5c093b8d30e815c1701b</id>
<content type='text'>
The ref-filter interfaces currently define root refs as either a
detached HEAD or a pseudo ref. Pseudo refs aren't root refs though, so
let's properly distinguish those ref types.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>for-each-ref: add new option to include root refs</title>
<updated>2024-02-23T18:36:28Z</updated>
<author>
<name>Karthik Nayak</name>
<email>karthik.188@gmail.com</email>
</author>
<published>2024-02-23T10:01:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=33d15b54358d8ec7fc0bd70062ddd1116402c8fe'/>
<id>urn:sha1:33d15b54358d8ec7fc0bd70062ddd1116402c8fe</id>
<content type='text'>
The git-for-each-ref(1) command doesn't provide a way to print root refs
i.e pseudorefs and HEAD with the regular "refs/" prefixed refs.

This commit adds a new option "--include-root-refs" to
git-for-each-ref(1). When used this would also print pseudorefs and HEAD
for the current worktree.

Signed-off-by: Karthik Nayak &lt;karthik.188@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>ref-filter: rename 'FILTER_REFS_ALL' to 'FILTER_REFS_REGULAR'</title>
<updated>2024-02-23T18:36:27Z</updated>
<author>
<name>Karthik Nayak</name>
<email>karthik.188@gmail.com</email>
</author>
<published>2024-02-23T10:01:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=810f7a1aace85ed9ffc454db6726c818c86685f0'/>
<id>urn:sha1:810f7a1aace85ed9ffc454db6726c818c86685f0</id>
<content type='text'>
The flag 'FILTER_REFS_ALL' is a bit ambiguous, where ALL doesn't specify
if it means to contain refs from all worktrees or whether all types of
refs (regular, HEAD &amp; pseudorefs) or all of the above.

Since here it is actually referring to all refs with the "refs/" prefix,
let's rename it to 'FILTER_REFS_REGULAR' to indicate that this is
specifically for regular refs.

Signed-off-by: Karthik Nayak &lt;karthik.188@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'en/header-cleanup'</title>
<updated>2024-01-08T22:05:15Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-01-08T22:05:15Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=492ee03f60297e7e83d101f4519ab8abc98782bc'/>
<id>urn:sha1:492ee03f60297e7e83d101f4519ab8abc98782bc</id>
<content type='text'>
Remove unused header "#include".

* en/header-cleanup:
  treewide: remove unnecessary includes in source files
  treewide: add direct includes currently only pulled in transitively
  trace2/tr2_tls.h: remove unnecessary include
  submodule-config.h: remove unnecessary include
  pkt-line.h: remove unnecessary include
  line-log.h: remove unnecessary include
  http.h: remove unnecessary include
  fsmonitor--daemon.h: remove unnecessary includes
  blame.h: remove unnecessary includes
  archive.h: remove unnecessary include
  treewide: remove unnecessary includes in source files
  treewide: remove unnecessary includes from header files
</content>
</entry>
<entry>
<title>treewide: remove unnecessary includes from header files</title>
<updated>2023-12-26T20:04:31Z</updated>
<author>
<name>Elijah Newren</name>
<email>newren@gmail.com</email>
</author>
<published>2023-12-23T17:14:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=147438e8a0eb31a06cb9aefbf0de8c45e544a4c7'/>
<id>urn:sha1:147438e8a0eb31a06cb9aefbf0de8c45e544a4c7</id>
<content type='text'>
There are three kinds of unnecessary includes:
  * includes which aren't directly needed, but which include some other
    forgotten include
  * includes which could be replaced by a simple forward declaration of
    some structs
  * includes which aren't needed at all

Remove the third kind of include.  Subsequent commits (and a subsequent
series) will work on removing some of the other kinds of includes.

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>ref-filter.h: add functions for filter/format &amp; format-only</title>
<updated>2023-11-16T05:02:59Z</updated>
<author>
<name>Victoria Dye</name>
<email>vdye@github.com</email>
</author>
<published>2023-11-14T19:53:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e7574b0c6b1e0cf2de9e000766a13d23fd9516e6'/>
<id>urn:sha1:e7574b0c6b1e0cf2de9e000766a13d23fd9516e6</id>
<content type='text'>
Add two new public methods to 'ref-filter.h':

* 'print_formatted_ref_array()' which, given a format specification &amp; array
  of ref items, formats and prints the items to stdout.
* 'filter_and_format_refs()' which combines 'filter_refs()',
  'ref_array_sort()', and 'print_formatted_ref_array()' into a single
  function.

This consolidates much of the code used to filter and format refs in
'builtin/for-each-ref.c', 'builtin/tag.c', and 'builtin/branch.c', reducing
duplication and simplifying the future changes needed to optimize the filter
&amp; format process.

Signed-off-by: Victoria Dye &lt;vdye@github.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>ref-filter.h: move contains caches into filter</title>
<updated>2023-11-16T05:02:59Z</updated>
<author>
<name>Victoria Dye</name>
<email>vdye@github.com</email>
</author>
<published>2023-11-14T19:53:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6d6e5c53b0c3d5566680ee8786d40405db917917'/>
<id>urn:sha1:6d6e5c53b0c3d5566680ee8786d40405db917917</id>
<content type='text'>
Move the 'contains_cache' and 'no_contains_cache' used in filter_refs into
an 'internal' struct of the 'struct ref_filter'. In later patches, the
'struct ref_filter *' will be a common data structure across multiple
filtering functions. These caches are part of the common functionality the
filter struct will support, so they are updated to be internally accessible
wherever the filter is used.

The design used here mirrors what was introduced in 576de3d956
(unpack_trees: start splitting internal fields from public API, 2023-02-27)
for 'unpack_trees_options'.

Signed-off-by: Victoria Dye &lt;vdye@github.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>ref-filter.h: add max_count and omit_empty to ref_format</title>
<updated>2023-11-16T05:02:59Z</updated>
<author>
<name>Victoria Dye</name>
<email>vdye@github.com</email>
</author>
<published>2023-11-14T19:53:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9d4fcfe1ff5b901f47f8226d078d22370bb955be'/>
<id>urn:sha1:9d4fcfe1ff5b901f47f8226d078d22370bb955be</id>
<content type='text'>
Add an internal 'array_opts' struct to 'struct ref_format' containing
formatting options that pertain to the formatting of an entire ref array:
'max_count' and 'omit_empty'. These values are specified by the '--count'
and '--omit-empty' options, respectively, to 'for-each-ref'/'tag'/'branch'.
Storing these values in the 'ref_format' will simplify the consolidation of
ref array formatting logic across builtins in later patches.

Signed-off-by: Victoria Dye &lt;vdye@github.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
