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

Re: [PATCH RFC v2 14/25] ref-filter: add is_cat flag

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 5, 2018, 21:19 UTC
Message-ID
<xmqq4lmv9lsm.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<0102016165b8b44c-a6d5c188-a9f2-4c5a-8cfb-6094af8f0163-000000@eu-west-1.amazonses.com>
Olga Telezhnaya <olyatelezhnaya@gmail.com> writes:
Show 15 quoted lines
> diff --git a/ref-filter.c b/ref-filter.c
> index 34a54db168265..91290b62450b3 100644
> --- a/ref-filter.c
> +++ b/ref-filter.c
> @@ -101,6 +101,7 @@ static struct used_atom {
>  } *used_atom;
>  static int used_atom_cnt, need_tagged, need_symref;
>  struct expand_data *cat_file_info;
> +static int is_cat = 0;
>   ...
> @@ -739,6 +740,7 @@ int verify_ref_format(struct ref_format *format)
>  	const char *cp, *sp;
>  
>  	cat_file_info = format->cat_file_data;
> +	is_cat = format->is_cat;

Eek. The global cat_file_info itself may already be bad enough, but now we have another one?

Hopefully these are all cleaned up in later steps in the series?
Show 36 quoted lines
>  	format->need_color_reset_at_eol = 0;
>  	for (cp = format->format; *cp && (sp = find_next(cp)); ) {
>  		const char *color, *ep = strchr(sp, ')');
> @@ -748,7 +750,7 @@ int verify_ref_format(struct ref_format *format)
>  			return error(_("malformed format string %s"), sp);
>  		/* sp points at "%(" and ep points at the closing ")" */
>  
> -		if (format->cat_file_data)
> +		if (is_cat)
>  			at = parse_ref_filter_atom(format, valid_cat_file_atom,
>  						   ARRAY_SIZE(valid_cat_file_atom), sp + 2, ep);
>  		else {
> @@ -1438,7 +1440,7 @@ int populate_value(struct ref_array_item *ref)
>  			ref->symref = "";
>  	}
>  
> -	if (cat_file_info && check_and_fill_for_cat(ref))
> +	if (is_cat && check_and_fill_for_cat(ref))
>  		return -1;
>  
>  	/* Fill in specials first */
> diff --git a/ref-filter.h b/ref-filter.h
> index 5c6e019998716..69271e8c39f40 100644
> --- a/ref-filter.h
> +++ b/ref-filter.h
> @@ -125,6 +125,7 @@ struct ref_format {
>  	 * hopefully would be reduced later.
>  	 */
>  	struct expand_data *cat_file_data;
> +	int is_cat;
>  };
>  
>  #define REF_FORMAT_INIT { NULL, 0, -1 }
>
> --
> https://github.com/git/git/pull/452
Previous: Olga TelezhnayaNext: Olga Telezhnaya
Message 21 of 26 in “ref-filter: get rid of goto”
  1. 01/25 ref-filter: get rid of gotoOlga Telezhnaya, Feb 5, 2018
  2. 08/25 ref-filter: reuse parse_ref_filter_atom()Olga Telezhnaya, Feb 5, 2018
  3. 05/25 cat-file: move struct expand_data into ref-filterOlga Telezhnaya, Feb 5, 2018
  4. 22/25 ref-filter: work with objectsize:diskOlga Telezhnaya, Feb 5, 2018
  5. 13/25 ref-filter: get rid of mark_atom_in_object_info()Olga Telezhnaya, Feb 5, 2018
  6. 06/25 cat-file: split expand_atom() into 2 functionsOlga Telezhnaya, Feb 5, 2018
  7. 16/25 cat-file: move skip_object_info into ref-filterOlga Telezhnaya, Feb 5, 2018
  8. 11/25 ref-filter: rename field in ref_array_item stuctOlga Telezhnaya, Feb 5, 2018
  9. 04/25 ref-filter: make valid_atom as function parameterOlga Telezhnaya, Feb 5, 2018
  10. 03/25 cat-file: reuse struct ref_formatOlga Telezhnaya, Feb 5, 2018
  11. 25/25 cat-file: update of docsOlga Telezhnaya, Feb 5, 2018
  12. 24/25 cat-file: tests for new atoms addedOlga Telezhnaya, Feb 5, 2018
  13. 15/25 ref_filter: add is_atom_used functionOlga Telezhnaya, Feb 5, 2018
  14. 10/25 ref-filter: make populate_value() globalOlga Telezhnaya, Feb 5, 2018
  15. 18/25 ref-filter: make valid_atom general againOlga Telezhnaya, Feb 5, 2018
  16. 02/25 ref-filter: add return value to some functionsOlga Telezhnaya, Feb 5, 2018
  17. 20/25 ref-filter: make populate_value() internal againOlga Telezhnaya, Feb 5, 2018
  18. 19/25 cat-file: reuse printing logic from ref-filterOlga Telezhnaya, Feb 5, 2018
  19. 12/25 cat-file: start reusing populate_value()Olga Telezhnaya, Feb 5, 2018
  20. 14/25 ref-filter: add is_cat flagOlga Telezhnaya, Feb 5, 2018
  21. Junio C HamanoFeb 5, 2018
  22. 21/25 ref-filter: unifying formatting of cat-file optsOlga Telezhnaya, Feb 5, 2018
  23. 09/25 cat-file: start use ref_array_item structOlga Telezhnaya, Feb 5, 2018
  24. 17/25 ref-filter: make cat_file_info independentOlga Telezhnaya, Feb 5, 2018
  25. 23/25 for-each-ref: tests for new atoms addedOlga Telezhnaya, Feb 5, 2018
  26. 07/25 cat-file: start migrating formatting to ref-filterOlga Telezhnaya, Feb 5, 2018

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.