http-push: convert process_ls_object and descendants to object_id
[gitweb.git] / ref-filter.c
index 3a640448fd83e6cf0bda8ddda081757d5941361e..56fc990a5267e6d6d5c9d8e6cf1a6d02cc058120 100644 (file)
@@ -677,13 +677,13 @@ int verify_ref_format(const char *format)
  * by the "struct object" representation, set *eaten as well---it is a
  * signal from parse_object_buffer to us not to free the buffer.
  */
-static void *get_obj(const unsigned char *sha1, struct object **obj, unsigned long *sz, int *eaten)
+static void *get_obj(const struct object_id *oid, struct object **obj, unsigned long *sz, int *eaten)
 {
        enum object_type type;
-       void *buf = read_sha1_file(sha1, &type, sz);
+       void *buf = read_sha1_file(oid->hash, &type, sz);
 
        if (buf)
-               *obj = parse_object_buffer(sha1, type, *sz, buf, eaten);
+               *obj = parse_object_buffer(oid->hash, type, *sz, buf, eaten);
        else
                *obj = NULL;
        return buf;
@@ -1293,7 +1293,7 @@ static void populate_value(struct ref_array_item *ref)
        struct object *obj;
        int eaten, i;
        unsigned long size;
-       const unsigned char *tagged;
+       const struct object_id *tagged;
 
        ref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));
 
@@ -1366,14 +1366,14 @@ static void populate_value(struct ref_array_item *ref)
                                v->s = xstrdup(buf + 1);
                        }
                        continue;
-               } else if (!deref && grab_objectname(name, ref->objectname, v, atom)) {
+               } else if (!deref && grab_objectname(name, ref->objectname.hash, v, atom)) {
                        continue;
                } else if (!strcmp(name, "HEAD")) {
                        const char *head;
-                       unsigned char sha1[20];
+                       struct object_id oid;
 
                        head = resolve_ref_unsafe("HEAD", RESOLVE_REF_READING,
-                                                 sha1, NULL);
+                                                 oid.hash, NULL);
                        if (head && !strcmp(ref->refname, head))
                                v->s = "*";
                        else
@@ -1415,13 +1415,13 @@ static void populate_value(struct ref_array_item *ref)
        return;
 
  need_obj:
-       buf = get_obj(ref->objectname, &obj, &size, &eaten);
+       buf = get_obj(&ref->objectname, &obj, &size, &eaten);
        if (!buf)
                die(_("missing object %s for %s"),
-                   sha1_to_hex(ref->objectname), ref->refname);
+                   oid_to_hex(&ref->objectname), ref->refname);
        if (!obj)
                die(_("parse_object_buffer failed on %s for %s"),
-                   sha1_to_hex(ref->objectname), ref->refname);
+                   oid_to_hex(&ref->objectname), ref->refname);
 
        grab_values(ref->value, 0, obj, buf, size);
        if (!eaten)
@@ -1438,7 +1438,7 @@ static void populate_value(struct ref_array_item *ref)
         * If it is a tag object, see if we use a value that derefs
         * the object, and if we do grab the object it refers to.
         */
-       tagged = ((struct tag *)obj)->tagged->oid.hash;
+       tagged = &((struct tag *)obj)->tagged->oid;
 
        /*
         * NEEDSWORK: This derefs tag only once, which
@@ -1449,10 +1449,10 @@ static void populate_value(struct ref_array_item *ref)
        buf = get_obj(tagged, &obj, &size, &eaten);
        if (!buf)
                die(_("missing object %s for %s"),
-                   sha1_to_hex(tagged), ref->refname);
+                   oid_to_hex(tagged), ref->refname);
        if (!obj)
                die(_("parse_object_buffer failed on %s for %s"),
-                   sha1_to_hex(tagged), ref->refname);
+                   oid_to_hex(tagged), ref->refname);
        grab_values(ref->value, 1, obj, buf, size);
        if (!eaten)
                free(buf);
@@ -1704,7 +1704,7 @@ static struct ref_array_item *new_ref_array_item(const char *refname,
 {
        struct ref_array_item *ref;
        FLEX_ALLOC_STR(ref, refname, refname);
-       hashcpy(ref->objectname, objectname);
+       hashcpy(ref->objectname.hash, objectname);
        ref->flag = flag;
 
        return ref;
@@ -1782,7 +1782,7 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,
         * non-commits early. The actual filtering is done later.
         */
        if (filter->merge_commit || filter->with_commit || filter->no_commit || filter->verbose) {
-               commit = lookup_commit_reference_gently(oid->hash, 1);
+               commit = lookup_commit_reference_gently(oid, 1);
                if (!commit)
                        return 0;
                /* We perform the filtering for the '--contains' option... */
@@ -2090,7 +2090,7 @@ int parse_opt_ref_sorting(const struct option *opt, const char *arg, int unset)
 int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)
 {
        struct ref_filter *rf = opt->value;
-       unsigned char sha1[20];
+       struct object_id oid;
        int no_merged = starts_with(opt->long_name, "no");
 
        if (rf->merge) {
@@ -2105,10 +2105,10 @@ int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)
                ? REF_FILTER_MERGED_OMIT
                : REF_FILTER_MERGED_INCLUDE;
 
-       if (get_sha1(arg, sha1))
+       if (get_oid(arg, &oid))
                die(_("malformed object name %s"), arg);
 
-       rf->merge_commit = lookup_commit_reference_gently(sha1, 0);
+       rf->merge_commit = lookup_commit_reference_gently(&oid, 0);
        if (!rf->merge_commit)
                return opterror(opt, "must point to a commit", 0);