@matheusbsbs / matheus-bagliano / commits / 1768aaf01d
Fork 0

push: use skip_prefix() instead of starts_with()

Get rid of a magic number by using skip_prefix(). 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 16:18 UTC 1768aaf01d3f57af8c4182d5887d219456f4a094
1 file changed +3 -2
builtin/push.c
+3 -2
@@ -64,6 +64,7 @@ static struct string_list push_options_config = STRING_LIST_INIT_DUP;
64 static const char *map_refspec(const char *ref,
65 struct remote *remote, struct ref *local_refs)
66 {
67 + const char *branch_name;
68 struct ref *matched = NULL;
69
70 /* Does "ref" uniquely name our ref? */
@@ -84,8 +85,8 @@ static const char *map_refspec(const char *ref,
85 }
86
87 if (push_default == PUSH_DEFAULT_UPSTREAM &&
87 - starts_with(matched->name, "refs/heads/")) {
88 - struct branch *branch = branch_get(matched->name + 11);
88 + skip_prefix(matched->name, "refs/heads/", &branch_name)) {
89 + struct branch *branch = branch_get(branch_name);
90 if (branch->merge_nr == 1 && branch->merge[0]->src) {
91 struct strbuf buf = STRBUF_INIT;
92 strbuf_addf(&buf, "%s:%s",