@matheusbsbs / matheus-bagliano / commits / a6293f5d28
Fork 0

fetch: use skip_prefix() instead of starts_with()

Get rid of magic numbers by letting skip_prefix() set the pointer "what". Signed-off-by: René Scharfe <l.s.r@web.de> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Nov 26, 2019 at 12:18 UTC a6293f5d28763580dd1035d3c6b018b42be7e25a
1 file changed +3 -9
builtin/fetch.c
+3 -9
@@ -954,18 +954,12 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
954 kind = "";
955 what = "";
956 }
957 - else if (starts_with(rm->name, "refs/heads/")) {
957 + else if (skip_prefix(rm->name, "refs/heads/", &what))
958 kind = "branch";
959 - what = rm->name + 11;
960 - }
961 - else if (starts_with(rm->name, "refs/tags/")) {
959 + else if (skip_prefix(rm->name, "refs/tags/", &what))
960 kind = "tag";
963 - what = rm->name + 10;
964 - }
965 - else if (starts_with(rm->name, "refs/remotes/")) {
961 + else if (skip_prefix(rm->name, "refs/remotes/", &what))
962 kind = "remote-tracking branch";
967 - what = rm->name + 13;
968 - }
963 else {
964 kind = "";
965 what = rm->name;