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

Re: [PATCH v2] ref-filter: format iteratively with lexicographic refname sorting

From
Toon Claes <toon@iotcl.com>
Date
Oct 21, 2024, 11:10 UTC
Message-ID
<87ttd5btjf.fsf@iotcl.com>
In-Reply-To
<e0daa6a2eac97c2b18a53399b7c124fc8d3d238d.1729141657.git.ps@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 46 quoted lines
> [snip]
>
>  ref-filter.c | 28 +++++++++++++++++++++-------
>  1 file changed, 21 insertions(+), 7 deletions(-)
>
> diff --git a/ref-filter.c b/ref-filter.c
> index dd195007ce1..424a9cb50ae 100644
> --- a/ref-filter.c
> +++ b/ref-filter.c
> @@ -3244,10 +3244,31 @@ int filter_refs(struct ref_array *array, struct ref_filter *filter, unsigned int
>  	return ret;
>  }
>  
> +struct ref_sorting {
> +	struct ref_sorting *next;
> +	int atom; /* index into used_atom array (internal) */
> +	enum ref_sorting_order sort_flags;
> +};
> +
>  static inline int can_do_iterative_format(struct ref_filter *filter,
>  					  struct ref_sorting *sorting,
>  					  struct ref_format *format)
>  {
> +	/*
> +	 * Reference backends sort patterns lexicographically by refname, so if
> +	 * the sorting options ask for exactly that we are able to do iterative
> +	 * formatting.
> +	 *
> +	 * Note that we do not have to worry about multiple name patterns,
> +	 * either. Those get sorted and deduplicated eventually in
> +	 * `refs_for_each_fullref_in_prefixes()`, so we return names in the
> +	 * correct ordering here, too.
> +	 */
> +	if (sorting && (sorting->next ||
> +			sorting->sort_flags ||
> +			used_atom[sorting->atom].atom_type != ATOM_REFNAME))
> +		return 0;
> +
>  	/*
>  	 * Filtering & formatting results within a single ref iteration
>  	 * callback is not compatible with options that require
> @@ -3258,7 +3279,6 @@ static inline int can_do_iterative_format(struct ref_filter *filter,
>  	 */
>  	return !(filter->reachable_from ||
>  		 filter->unreachable_from ||
> -		 sorting ||

Just a small nit, because we remove `sorting` from this condition, I suggest to also remove the following comment above it:

	 * - sorting the filtered results
Otherwise no comments from my side.
-- 
Toon
Previous: Taylor BlauNext: Patrick Steinhardt
Message 9 of 12 in “ref-filter: format iteratively with lexicographic refname sorting”
  1. ref-filter: format iteratively with lexicographic refname sortingPatrick Steinhardt, Oct 16, 2024
  2. Taylor BlauOct 16, 2024
  3. Jeff KingOct 17, 2024
  4. Patrick SteinhardtOct 17, 2024
  5. karthik nayakOct 21, 2024
  6. Taylor BlauOct 21, 2024
  7. ref-filter: format iteratively with lexicographic refname sortingPatrick Steinhardt, Oct 17, 2024
  8. Taylor BlauOct 17, 2024
  9. Toon ClaesOct 21, 2024
  10. Patrick SteinhardtOct 21, 2024
  11. ref-filter: format iteratively with lexicographic refname sortingPatrick Steinhardt, Oct 21, 2024
  12. Taylor BlauOct 21, 2024

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.