]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fetch: use skip_prefix() instead of starts_with()
authorRené Scharfe <l.s.r@web.de>
Tue, 26 Nov 2019 11:18:26 +0000 (12:18 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 27 Nov 2019 02:17:22 +0000 (11:17 +0900)
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>
builtin/fetch.c

index 863c858fde9afb3daac09c7ecf83cf44834574d5..02e86196185de3a733a16adb627e843e4f1a6c7c 100644 (file)
@@ -954,18 +954,12 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
                                kind = "";
                                what = "";
                        }
-                       else if (starts_with(rm->name, "refs/heads/")) {
+                       else if (skip_prefix(rm->name, "refs/heads/", &what))
                                kind = "branch";
-                               what = rm->name + 11;
-                       }
-                       else if (starts_with(rm->name, "refs/tags/")) {
+                       else if (skip_prefix(rm->name, "refs/tags/", &what))
                                kind = "tag";
-                               what = rm->name + 10;
-                       }
-                       else if (starts_with(rm->name, "refs/remotes/")) {
+                       else if (skip_prefix(rm->name, "refs/remotes/", &what))
                                kind = "remote-tracking branch";
-                               what = rm->name + 13;
-                       }
                        else {
                                kind = "";
                                what = rm->name;