Revert "Merge branch 'ps/contains-id-error-message' into next"
[gitweb.git] / ref-filter.c
index 18c0b8e5dd30bab753bf53a7f8f5c0dba3738d50..45fc56216aaa8fd084a10514f6f4912878ab1627 100644 (file)
@@ -1354,15 +1354,31 @@ static const char *get_refname(struct used_atom *atom, struct ref_array_item *re
        return show_ref(&atom->u.refname, ref->refname);
 }
 
+static void get_object(struct ref_array_item *ref, const struct object_id *oid,
+                      int deref, struct object **obj)
+{
+       int eaten;
+       unsigned long size;
+       void *buf = get_obj(oid, obj, &size, &eaten);
+       if (!buf)
+               die(_("missing object %s for %s"),
+                   oid_to_hex(oid), ref->refname);
+       if (!*obj)
+               die(_("parse_object_buffer failed on %s for %s"),
+                   oid_to_hex(oid), ref->refname);
+
+       grab_values(ref->value, deref, *obj, buf, size);
+       if (!eaten)
+               free(buf);
+}
+
 /*
  * Parse the object referred by ref, and grab needed value.
  */
 static void populate_value(struct ref_array_item *ref)
 {
-       void *buf;
        struct object *obj;
-       int eaten, i;
-       unsigned long size;
+       int i;
        const struct object_id *tagged;
 
        ref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));
@@ -1478,22 +1494,12 @@ static void populate_value(struct ref_array_item *ref)
        for (i = 0; i < used_atom_cnt; i++) {
                struct atom_value *v = &ref->value[i];
                if (v->s == NULL)
-                       goto need_obj;
+                       break;
        }
-       return;
-
- need_obj:
-       buf = get_obj(&ref->objectname, &obj, &size, &eaten);
-       if (!buf)
-               die(_("missing object %s for %s"),
-                   oid_to_hex(&ref->objectname), ref->refname);
-       if (!obj)
-               die(_("parse_object_buffer failed on %s for %s"),
-                   oid_to_hex(&ref->objectname), ref->refname);
+       if (used_atom_cnt <= i)
+               return;
 
-       grab_values(ref->value, 0, obj, buf, size);
-       if (!eaten)
-               free(buf);
+       get_object(ref, &ref->objectname, 0, &obj);
 
        /*
         * If there is no atom that wants to know about tagged
@@ -1514,16 +1520,7 @@ static void populate_value(struct ref_array_item *ref)
         * is not consistent with what deref_tag() does
         * which peels the onion to the core.
         */
-       buf = get_obj(tagged, &obj, &size, &eaten);
-       if (!buf)
-               die(_("missing object %s for %s"),
-                   oid_to_hex(tagged), ref->refname);
-       if (!obj)
-               die(_("parse_object_buffer failed on %s for %s"),
-                   oid_to_hex(tagged), ref->refname);
-       grab_values(ref->value, 1, obj, buf, size);
-       if (!eaten)
-               free(buf);
+       get_object(ref, tagged, 1, &obj);
 }
 
 /*
@@ -2000,25 +1997,6 @@ static void do_merge_filter(struct ref_filter_cbdata *ref_cbdata)
        free(to_clear);
 }
 
-static int add_str_to_commit_list(struct string_list_item *item, void *commit_list)
-{
-       struct object_id oid;
-       struct commit *commit;
-
-       if (get_oid(item->string, &oid)) {
-               error(_("malformed object name %s"), item->string);
-               exit(1);
-       }
-       commit = lookup_commit_reference(&oid);
-       if (!commit) {
-               error(_("no such commit %s"), item->string);
-               exit(1);
-       }
-       commit_list_insert(commit, commit_list);
-
-       return 0;
-}
-
 /*
  * API for filtering a set of refs. Based on the type of refs the user
  * has requested, we iterate through those refs and apply filters
@@ -2031,10 +2009,6 @@ int filter_refs(struct ref_array *array, struct ref_filter *filter, unsigned int
        int ret = 0;
        unsigned int broken = 0;
 
-       /* Convert string representation and add to commit list. */
-       for_each_string_list(&filter->with_commit_strs, add_str_to_commit_list, &filter->with_commit);
-       for_each_string_list(&filter->no_commit_strs, add_str_to_commit_list, &filter->no_commit);
-
        ref_cbdata.array = array;
        ref_cbdata.filter = filter;