Skip to content

Commit 1768aaf

Browse files
rscharfegitster
authored andcommitted
push: use skip_prefix() instead of starts_with()
Get rid of a magic number by using skip_prefix(). Signed-off-by: René Scharfe <[email protected]> Acked-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ec6ee0c commit 1768aaf

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

builtin/push.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ static struct string_list push_options_config = STRING_LIST_INIT_DUP;
6464
static const char *map_refspec(const char *ref,
6565
struct remote *remote, struct ref *local_refs)
6666
{
67+
const char *branch_name;
6768
struct ref *matched = NULL;
6869

6970
/* Does "ref" uniquely name our ref? */
@@ -84,8 +85,8 @@ static const char *map_refspec(const char *ref,
8485
}
8586

8687
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);
8990
if (branch->merge_nr == 1 && branch->merge[0]->src) {
9091
struct strbuf buf = STRBUF_INIT;
9192
strbuf_addf(&buf, "%s:%s",

0 commit comments

Comments
 (0)