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

Re: [PATCH 2/4] ref-filter: add empty values to technical fields

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 9, 2018, 22:39 UTC
Message-ID
<xmqqzhz09gqj.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<010201647e19c191-8c24e128-8822-4c77-b3bf-60fe17ecb62b-000000@eu-west-1.amazonses.com>
Olga Telezhnaya <olyatelezhnaya@gmail.com> writes:
Show 7 quoted lines
> Atoms like "align" or "end" do not have string representation.
> Earlier we had to go and parse whole object with a hope that we
> could fill their string representations. It's easier to fill them
> with an empty string before we start to work with whole object.
>
> Signed-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>
> ---

Just being curious, but is there any meaningful relationship between what was labelled as SOURCE_NONE in the previous step and what this step calls "technical fields"? Things like "upstream" (which is not affected by the contents of the object, but is affected by the ref in question) and "if" (which merely exists to construct the language syntax) would fall into quite different category, so one might be subset/superset of the other, but I am wondering if we can take advantage of more table-driven approach taken by the previous step.

Show 54 quoted lines
>  ref-filter.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/ref-filter.c b/ref-filter.c
> index 8611c24fd57d1..27733ef013bed 100644
> --- a/ref-filter.c
> +++ b/ref-filter.c
> @@ -1497,6 +1497,7 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)
>  			refname = get_symref(atom, ref);
>  		else if (starts_with(name, "upstream")) {
>  			const char *branch_name;
> +			v->s = "";
>  			/* only local branches may have an upstream */
>  			if (!skip_prefix(ref->refname, "refs/heads/",
>  					 &branch_name))
> @@ -1509,6 +1510,7 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)
>  			continue;
>  		} else if (atom->u.remote_ref.push) {
>  			const char *branch_name;
> +			v->s = "";
>  			if (!skip_prefix(ref->refname, "refs/heads/",
>  					 &branch_name))
>  				continue;
> @@ -1549,22 +1551,26 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)
>  			continue;
>  		} else if (starts_with(name, "align")) {
>  			v->handler = align_atom_handler;
> +			v->s = "";
>  			continue;
>  		} else if (!strcmp(name, "end")) {
>  			v->handler = end_atom_handler;
> +			v->s = "";
>  			continue;
>  		} else if (starts_with(name, "if")) {
>  			const char *s;
> -
> +			v->s = "";
>  			if (skip_prefix(name, "if:", &s))
>  				v->s = xstrdup(s);
>  			v->handler = if_atom_handler;
>  			continue;
>  		} else if (!strcmp(name, "then")) {
>  			v->handler = then_atom_handler;
> +			v->s = "";
>  			continue;
>  		} else if (!strcmp(name, "else")) {
>  			v->handler = else_atom_handler;
> +			v->s = "";
>  			continue;
>  		} else
>  			continue;
>
> --
> https://github.com/git/git/pull/520
Previous: Olga TelezhnayaNext: Оля Тележная
Message 8 of 10 in “ref-filter: add info_source to valid_atom”
  1. 1/4 ref-filter: add info_source to valid_atomOlga Telezhnaya, Jul 9, 2018
  2. 3/4 ref-filter: merge get_obj and get_objectOlga Telezhnaya, Jul 9, 2018
  3. SZEDER GáborJul 10, 2018
  4. Johannes SchindelinJul 10, 2018
  5. SZEDER GáborJul 10, 2018
  6. Оля ТележнаяJul 10, 2018
  7. 2/4 ref-filter: add empty values to technical fieldsOlga Telezhnaya, Jul 9, 2018
  8. Junio C HamanoJul 9, 2018
  9. Оля ТележнаяJul 10, 2018
  10. 4/4 ref-filter: use oid_object_info() to get objectOlga Telezhnaya, Jul 9, 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.