Re: [PATCH] [GSOC] ref-filter: solve bugs caused by enumeration

2 messages, 2 authors, 2021-05-07 · open the first message on its own page

Re: [PATCH] [GSOC] ref-filter: solve bugs caused by enumeration

From: Junio C Hamano <hidden>
Date: 2021-05-07 04:49:53

ZheNing Hu [off-list ref] writes:
But I am afraid that the cost we paid for string matching here is too high,
If that is truly the concern (I do not know without measuring),
perhaps we should add a member next to the union to say which one of
the union members is valid, so that you can say

    if (atom->atom_type == ATOM_TYPE_REMOTE_REF &&
        atom->u.remote_ref.push)

(introduce an enum and define ATOM_TYPE_* after the member in the
union).

That would help futureproofing the code even further, as a new
synonym of "push" introduced laster [*] would not invalidate the check you are
adding there.


[Footnote]

* remote_ref_atom_parser() in the future may begin like so:

-	if (!strcmp(atom->name, "push") || starts_with(atom->name, "push:"))
+	if (!strcmp(atom->name, "push") || starts_with(atom->name, "push:") ||
+           !strcmp(atom->name, "a-synonym-for-push"))
		atom->u.remote_ref.push = 1;

Re: [PATCH] [GSOC] ref-filter: solve bugs caused by enumeration

From: ZheNing Hu <hidden>
Date: 2021-05-07 05:09:38

If that is truly the concern (I do not know without measuring),
perhaps we should add a member next to the union to say which one of
the union members is valid, so that you can say

    if (atom->atom_type == ATOM_TYPE_REMOTE_REF &&
        atom->u.remote_ref.push)

(introduce an enum and define ATOM_TYPE_* after the member in the
union).
Yes, I think so. Since the content of this part needs to be modified for
 the parsing of all atoms, I will put it in a separate topic to complete.
That would help futureproofing the code even further, as a new
synonym of "push" introduced laster [*] would not invalidate the check you are
adding there.
Yes, this enhances its generalization ability.
[Footnote]

* remote_ref_atom_parser() in the future may begin like so:

-       if (!strcmp(atom->name, "push") || starts_with(atom->name, "push:"))
+       if (!strcmp(atom->name, "push") || starts_with(atom->name, "push:") ||
+           !strcmp(atom->name, "a-synonym-for-push"))
                atom->u.remote_ref.push = 1;
--
ZheNing Hu
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help