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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Olga Telezhnaya <olyatelezhnaya@xxxxxxxxx> 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@xxxxxxxxx>
> ---

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. 


>  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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux