From 20a9c156198bf195b7d32ef9a73ba01b8b19f52c Mon Sep 17 00:00:00 2001 From: Olga Telezhnaya Date: Tue, 17 Jul 2018 08:22:57 +0000 Subject: [PATCH] ref-filter: fill empty fields with empty values 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. It is important to mention that we fill only these atoms that must contain nothing. So, if we could not fill the atom because, for example, the object is missing, we leave it with NULL. Signed-off-by: Olga Telezhnaia Signed-off-by: Junio C Hamano --- ref-filter.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ref-filter.c b/ref-filter.c index 8611c24fd5..27733ef013 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; -- 2.32.0.93.g670b81a890