]> git.ipfire.org Git - thirdparty/git.git/commit - ws.c
convert trivial uses of strncmp() to skip_prefix()
authorJeff King <peff@peff.net>
Sat, 7 Jan 2023 13:26:44 +0000 (08:26 -0500)
committerJunio C Hamano <gitster@pobox.com>
Sun, 8 Jan 2023 01:34:37 +0000 (10:34 +0900)
commitd43b99322bd0ca4a371901bcf6705f1282143a2b
tree7c114210e465f0e2bddfc25b2cc281521c4e65b0
parent20869d1a1d30e9a64c66953a0f4c7245089009cf
convert trivial uses of strncmp() to skip_prefix()

As with the previous patch, using skip_prefix() is more readable and
less error-prone than a raw strncmp(), because it avoids a
manually-computed length. These cases differ from the previous patch
that uses starts_with() because they care about the value after the
matched prefix.

We can convert these to use skip_prefix() by introducing an extra
variable to hold the out-pointer.

Note in the case in ws.c that to get rid of the magic number "9"
completely, we also switch out "len" for recomputing the pointer
difference. These are equivalent because "len" is always "ep - string".

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/remote-ext.c
ws.c