Skip to content

Commit bf73282

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fe8321e commit bf73282

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

fetch-pack.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,16 @@ static int tip_oids_contain(struct oidset *tip_oids,
543543
return oidset_contains(tip_oids, id);
544544
}
545545

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+
546556
static void filter_refs(struct fetch_pack_args *args,
547557
struct ref **refs,
548558
struct ref **sought, int nr_sought)
@@ -591,15 +601,8 @@ static void filter_refs(struct fetch_pack_args *args,
591601

592602
/* Append unmatched requests to the list */
593603
for (i = 0; i < nr_sought; i++) {
594-
struct object_id oid;
595-
const char *p;
596-
597604
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))
603606
continue;
604607

605608
if ((allow_unadvertised_object_request &

0 commit comments

Comments
 (0)