@@ -1065,16 +1065,6 @@ static const char *do_grab_oid(const char *field, const struct object_id *oid,
}
}
-static int grab_oid(const char *name, const char *field, const struct object_id *oid,
- struct atom_value *v, struct used_atom *atom)
-{
- if (starts_with(name, field)) {
- v->s = xstrdup(do_grab_oid(field, oid, atom));
- return 1;
- }
- return 0;
-}
-
/* See grab_values */
static void grab_common_values(struct atom_value *val, int deref, struct expand_data *oi)
{
@@ -1100,8 +1090,9 @@ static void grab_common_values(struct atom_value *val, int deref, struct expand_
}
} else if (atom_type == ATOM_DELTABASE)
v->s = xstrdup(oid_to_hex(&oi->delta_base_oid));
- else if (atom_type == ATOM_OBJECTNAME && deref)
- grab_oid(name, "objectname", &oi->oid, v, &used_atom[i]);
+ else if (atom_type == ATOM_OBJECTNAME && deref) {
+ v->s = xstrdup(do_grab_oid("objectname", &oi->oid, &used_atom[i]));
+ }
}
}
@@ -1142,9 +1133,10 @@ static void grab_commit_values(struct atom_value *val, int deref, struct object
continue;
if (deref)
name++;
- if (atom_type == ATOM_TREE &&
- grab_oid(name, "tree", get_commit_tree_oid(commit), v, &used_atom[i]))
+ if (atom_type == ATOM_TREE) {
+ v->s = xstrdup(do_grab_oid("tree", get_commit_tree_oid(commit), &used_atom[i]));
continue;
+ }
if (atom_type == ATOM_NUMPARENT) {
v->value = commit_list_count(commit->parents);
v->s = xstrfmt("%lu", (unsigned long)v->value);
@@ -1917,9 +1909,9 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)
v->s = xstrdup(buf + 1);
}
continue;
- } else if (!deref && atom_type == ATOM_OBJECTNAME &&
- grab_oid(name, "objectname", &ref->objectname, v, atom)) {
- continue;
+ } else if (!deref && atom_type == ATOM_OBJECTNAME) {
+ v->s = xstrdup(do_grab_oid("objectname", &ref->objectname, atom));
+ continue;
} else if (atom_type == ATOM_HEAD) {
if (atom->u.head && !strcmp(ref->refname, atom->u.head))
v->s = xstrdup("*");