fetch-pack: factor out is_unmatched_ref()

Move the code to determine if a request is unmatched to its own little helper. This allows us to reuse it in a subsequent patch. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Oct 4, 2018 at 17:09 UTC bf73282c0b34bfc7772f952496b06150cceb5dae
1 file changed +11 -8
fetch-pack.c
+11 -8
@@ -543,6 +543,16 @@ static int tip_oids_contain(struct oidset *tip_oids,
543 return oidset_contains(tip_oids, id);
544 }
545
546 +static int is_unmatched_ref(const struct ref *ref)
547 +{
548 + struct object_id oid;
549 + const char *p;
550 + return ref->match_status == REF_NOT_MATCHED &&
551 + !parse_oid_hex(ref->name, &oid, &p) &&
552 + *p == '\0' &&
553 + oideq(&oid, &ref->old_oid);
554 +}
555 +
556 static void filter_refs(struct fetch_pack_args *args,
557 struct ref **refs,
558 struct ref **sought, int nr_sought)
@@ -591,15 +601,8 @@ static void filter_refs(struct fetch_pack_args *args,
601
602 /* Append unmatched requests to the list */
603 for (i = 0; i < nr_sought; i++) {
594 - struct object_id oid;
595 - const char *p;
596 -
604 ref = sought[i];
598 - if (ref->match_status != REF_NOT_MATCHED)
599 - continue;
600 - if (parse_oid_hex(ref->name, &oid, &p) ||
601 - *p != '\0' ||
602 - !oideq(&oid, &ref->old_oid))
605 + if (!is_unmatched_ref(ref))
606 continue;
607
608 if ((allow_unadvertised_object_request &