Convert the verify_pack callback to struct object_id
[gitweb.git] / ref-filter.c
index 1e392730057ce97dab8be4b05dfa7c610e10fdce..e1d18ac0d144806c1ea703e173ee2021b50cc4b0 100644 (file)
@@ -1678,22 +1678,22 @@ static int filter_pattern_match(struct ref_filter *filter, const char *refname)
  * the need to parse the object via parse_object(). peel_ref() might be a
  * more efficient alternative to obtain the pointee.
  */
-static const unsigned char *match_points_at(struct sha1_array *points_at,
-                                           const unsigned char *sha1,
-                                           const char *refname)
+static const struct object_id *match_points_at(struct oid_array *points_at,
+                                              const struct object_id *oid,
+                                              const char *refname)
 {
-       const unsigned char *tagged_sha1 = NULL;
+       const struct object_id *tagged_oid = NULL;
        struct object *obj;
 
-       if (sha1_array_lookup(points_at, sha1) >= 0)
-               return sha1;
-       obj = parse_object(sha1);
+       if (oid_array_lookup(points_at, oid) >= 0)
+               return oid;
+       obj = parse_object(oid->hash);
        if (!obj)
                die(_("malformed object at '%s'"), refname);
        if (obj->type == OBJ_TAG)
-               tagged_sha1 = ((struct tag *)obj)->tagged->oid.hash;
-       if (tagged_sha1 && sha1_array_lookup(points_at, tagged_sha1) >= 0)
-               return tagged_sha1;
+               tagged_oid = &((struct tag *)obj)->tagged->oid;
+       if (tagged_oid && oid_array_lookup(points_at, tagged_oid) >= 0)
+               return tagged_oid;
        return NULL;
 }
 
@@ -1773,7 +1773,7 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,
        if (!filter_pattern_match(filter, refname))
                return 0;
 
-       if (filter->points_at.nr && !match_points_at(&filter->points_at, oid->hash, refname))
+       if (filter->points_at.nr && !match_points_at(&filter->points_at, oid, refname))
                return 0;
 
        /*
@@ -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);