diff options
author | René Scharfe <l.s.r@web.de> | 2024-02-24 22:47:06 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-02-26 17:58:45 +0100 |
commit | 87bd7fbb9c3e165a68046e04bf12f5a76cae2965 (patch) | |
tree | 4ab413c3d9c3a1bf7cb12b1b1784697dfa253141 /builtin/fetch.c | |
parent | Git 2.44 (diff) | |
download | git-87bd7fbb9c3e165a68046e04bf12f5a76cae2965.tar.xz git-87bd7fbb9c3e165a68046e04bf12f5a76cae2965.zip |
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 <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/fetch.c')
-rw-r--r-- | builtin/fetch.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c index 3aedfd1bb6..0a7a1a3476 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -448,9 +448,8 @@ static void filter_prefetch_refspec(struct refspec *rs) continue; if (!rs->items[i].dst || (rs->items[i].src && - !strncmp(rs->items[i].src, - ref_namespace[NAMESPACE_TAGS].ref, - strlen(ref_namespace[NAMESPACE_TAGS].ref)))) { + starts_with(rs->items[i].src, + ref_namespace[NAMESPACE_TAGS].ref))) { int j; free(rs->items[i].src); |