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
Оля Тележная <olyatelezhnaya@gmail.com>
Date
Jul 10, 2018, 07:51 UTC
Message-ID
<CAL21Bm=jHiwcau=KoX5cmnZ+8NwQi5ms=GqK52s6GWdaXddraA@mail.gmail.com>
In-Reply-To
<xmqqzhz09gqj.fsf@gitster-ct.c.googlers.com>
2018-07-10 1:39 GMT+03:00 Junio C Hamano <gitster@pobox.com>:
Show 18 quoted lines
> Olga Telezhnaya <olyatelezhnaya@gmail.com> writes:
>
>> 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.

Sorry that it was not clear enough. SOURCE_NONE fields are the fields that do not require object info. By "technical fields" in this particular commit I mean fields that will never be filled. So, it's a good idea to fill such fields with an empty string and do not take them into account later (when we are thinking whether we need to get and parse an object or not). I guess we do not need to mark these "technical fields" in a special way: we don't need this information. Moreover, some of the fields that I filled with an empty string here, sometimes have non-empty representation, and I changed nothing for such cases.

Show 56 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: Junio C HamanoNext: Olga Telezhnaya
Message 9 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.