Convert remaining callers of sha1_array_lookup to object_id

There are a very small number of callers which don't already use struct object_id. Convert them. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Mar 31, 2017 at 01:39 UTC 4ce3621a6dd3f98dab3c588b7f53f81b8404df32
3 files changed +26 -26
bisect.c
+7 -7
@@ -754,9 +754,9 @@ static void handle_bad_merge_base(void)
754 exit(1);
755 }
756
757 -static void handle_skipped_merge_base(const unsigned char *mb)
757 +static void handle_skipped_merge_base(const struct object_id *mb)
758 {
759 - char *mb_hex = sha1_to_hex(mb);
759 + char *mb_hex = oid_to_hex(mb);
760 char *bad_hex = oid_to_hex(current_bad_oid);
761 char *good_hex = join_sha1_array_hex(&good_revs, ' ');
762
@@ -787,16 +787,16 @@ static void check_merge_bases(int no_checkout)
787 result = get_merge_bases_many(rev[0], rev_nr - 1, rev + 1);
788
789 for (; result; result = result->next) {
790 - const unsigned char *mb = result->item->object.oid.hash;
791 - if (!hashcmp(mb, current_bad_oid->hash)) {
790 + const struct object_id *mb = &result->item->object.oid;
791 + if (!oidcmp(mb, current_bad_oid)) {
792 handle_bad_merge_base();
793 - } else if (0 <= sha1_array_lookup(&good_revs, mb)) {
793 + } else if (0 <= sha1_array_lookup(&good_revs, mb->hash)) {
794 continue;
795 - } else if (0 <= sha1_array_lookup(&skipped_revs, mb)) {
795 + } else if (0 <= sha1_array_lookup(&skipped_revs, mb->hash)) {
796 handle_skipped_merge_base(mb);
797 } else {
798 printf(_("Bisecting: a merge base must be tested\n"));
799 - exit(bisect_checkout(mb, no_checkout));
799 + exit(bisect_checkout(mb->hash, no_checkout));
800 }
801 }
802
builtin/pack-objects.c
+8 -8
@@ -2670,14 +2670,14 @@ static int has_sha1_pack_kept_or_nonlocal(const unsigned char *sha1)
2670 */
2671 static struct sha1_array recent_objects;
2672
2673 -static int loosened_object_can_be_discarded(const unsigned char *sha1,
2673 +static int loosened_object_can_be_discarded(const struct object_id *oid,
2674 unsigned long mtime)
2675 {
2676 if (!unpack_unreachable_expiration)
2677 return 0;
2678 if (mtime > unpack_unreachable_expiration)
2679 return 0;
2680 - if (sha1_array_lookup(&recent_objects, sha1) >= 0)
2680 + if (sha1_array_lookup(&recent_objects, oid->hash) >= 0)
2681 return 0;
2682 return 1;
2683 }
@@ -2686,7 +2686,7 @@ static void loosen_unused_packed_objects(struct rev_info *revs)
2686 {
2687 struct packed_git *p;
2688 uint32_t i;
2689 - const unsigned char *sha1;
2689 + struct object_id oid;
2690
2691 for (p = packed_git; p; p = p->next) {
2692 if (!p->pack_local || p->pack_keep)
@@ -2696,11 +2696,11 @@ static void loosen_unused_packed_objects(struct rev_info *revs)
2696 die("cannot open pack index");
2697
2698 for (i = 0; i < p->num_objects; i++) {
2699 - sha1 = nth_packed_object_sha1(p, i);
2700 - if (!packlist_find(&to_pack, sha1, NULL) &&
2701 - !has_sha1_pack_kept_or_nonlocal(sha1) &&
2702 - !loosened_object_can_be_discarded(sha1, p->mtime))
2703 - if (force_object_loose(sha1, p->mtime))
2699 + nth_packed_object_oid(&oid, p, i);
2700 + if (!packlist_find(&to_pack, oid.hash, NULL) &&
2701 + !has_sha1_pack_kept_or_nonlocal(oid.hash) &&
2702 + !loosened_object_can_be_discarded(&oid, p->mtime))
2703 + if (force_object_loose(oid.hash, p->mtime))
2704 die("unable to force loose object");
2705 }
2706 }
ref-filter.c
+11 -11
@@ -1677,22 +1677,22 @@ static int filter_pattern_match(struct ref_filter *filter, const char *refname)
1677 * the need to parse the object via parse_object(). peel_ref() might be a
1678 * more efficient alternative to obtain the pointee.
1679 */
1680 -static const unsigned char *match_points_at(struct sha1_array *points_at,
1681 - const unsigned char *sha1,
1682 - const char *refname)
1680 +static const struct object_id *match_points_at(struct sha1_array *points_at,
1681 + const struct object_id *oid,
1682 + const char *refname)
1683 {
1684 - const unsigned char *tagged_sha1 = NULL;
1684 + const struct object_id *tagged_oid = NULL;
1685 struct object *obj;
1686
1687 - if (sha1_array_lookup(points_at, sha1) >= 0)
1688 - return sha1;
1689 - obj = parse_object(sha1);
1687 + if (sha1_array_lookup(points_at, oid->hash) >= 0)
1688 + return oid;
1689 + obj = parse_object(oid->hash);
1690 if (!obj)
1691 die(_("malformed object at '%s'"), refname);
1692 if (obj->type == OBJ_TAG)
1693 - tagged_sha1 = ((struct tag *)obj)->tagged->oid.hash;
1694 - if (tagged_sha1 && sha1_array_lookup(points_at, tagged_sha1) >= 0)
1695 - return tagged_sha1;
1693 + tagged_oid = &((struct tag *)obj)->tagged->oid;
1694 + if (tagged_oid && sha1_array_lookup(points_at, tagged_oid->hash) >= 0)
1695 + return tagged_oid;
1696 return NULL;
1697 }
1698
@@ -1772,7 +1772,7 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,
1772 if (!filter_pattern_match(filter, refname))
1773 return 0;
1774
1775 - if (filter->points_at.nr && !match_points_at(&filter->points_at, oid->hash, refname))
1775 + if (filter->points_at.nr && !match_points_at(&filter->points_at, oid, refname))
1776 return 0;
1777
1778 /*