Skip to content

Commit 87bd7fb

Browse files
rscharfegitster
authored andcommitted
fetch: convert strncmp() with strlen() to starts_with()
Using strncmp() and strlen() to check whether a string starts with another one requires repeating the prefix candidate. Use starts_with() instead, which reduces repetition and is more readable. Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3c2a3fd commit 87bd7fb

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

builtin/fetch.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,8 @@ static void filter_prefetch_refspec(struct refspec *rs)
448448
continue;
449449
if (!rs->items[i].dst ||
450450
(rs->items[i].src &&
451-
!strncmp(rs->items[i].src,
452-
ref_namespace[NAMESPACE_TAGS].ref,
453-
strlen(ref_namespace[NAMESPACE_TAGS].ref)))) {
451+
starts_with(rs->items[i].src,
452+
ref_namespace[NAMESPACE_TAGS].ref))) {
454453
int j;
455454

456455
free(rs->items[i].src);

0 commit comments

Comments
 (0)