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 <olyatelezhnaya@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Olga Telezhnaya committed
Jul 17, 2018 at 08:22 UTC
20a9c156198bf195b7d32ef9a73ba01b8b19f52c
1 file changed
+7
-1
ref-filter.c
+7
-1
@@ -1497,6 +1497,7 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)
1497
refname = get_symref(atom, ref);
1498
else if (starts_with(name, "upstream")) {
1499
const char *branch_name;
1500
+ v->s = "";
1501
/* only local branches may have an upstream */
1502
if (!skip_prefix(ref->refname, "refs/heads/",
1503
&branch_name))
@@ -1509,6 +1510,7 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)
1510
continue;
1511
} else if (atom->u.remote_ref.push) {
1512
const char *branch_name;
1513
+ v->s = "";
1514
if (!skip_prefix(ref->refname, "refs/heads/",
1515
&branch_name))
1516
continue;
@@ -1549,22 +1551,26 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)
1551
continue;
1552
} else if (starts_with(name, "align")) {
1553
v->handler = align_atom_handler;
1554
+ v->s = "";
1555
continue;
1556
} else if (!strcmp(name, "end")) {
1557
v->handler = end_atom_handler;
1558
+ v->s = "";
1559
continue;
1560
} else if (starts_with(name, "if")) {
1561
const char *s;
1558
-
1562
+ v->s = "";
1563
if (skip_prefix(name, "if:", &s))
1564
v->s = xstrdup(s);
1565
v->handler = if_atom_handler;
1566
continue;
1567
} else if (!strcmp(name, "then")) {
1568
v->handler = then_atom_handler;
1569
+ v->s = "";
1570
continue;
1571
} else if (!strcmp(name, "else")) {
1572
v->handler = else_atom_handler;
1573
+ v->s = "";
1574
continue;
1575
} else
1576
continue;