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>
This commit is contained in:

committed by
Junio C Hamano

parent
ec6ee0c07a
commit
1768aaf01d
@ -64,6 +64,7 @@ static struct string_list push_options_config = STRING_LIST_INIT_DUP;
|
|||||||
static const char *map_refspec(const char *ref,
|
static const char *map_refspec(const char *ref,
|
||||||
struct remote *remote, struct ref *local_refs)
|
struct remote *remote, struct ref *local_refs)
|
||||||
{
|
{
|
||||||
|
const char *branch_name;
|
||||||
struct ref *matched = NULL;
|
struct ref *matched = NULL;
|
||||||
|
|
||||||
/* Does "ref" uniquely name our ref? */
|
/* Does "ref" uniquely name our ref? */
|
||||||
@ -84,8 +85,8 @@ static const char *map_refspec(const char *ref,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (push_default == PUSH_DEFAULT_UPSTREAM &&
|
if (push_default == PUSH_DEFAULT_UPSTREAM &&
|
||||||
starts_with(matched->name, "refs/heads/")) {
|
skip_prefix(matched->name, "refs/heads/", &branch_name)) {
|
||||||
struct branch *branch = branch_get(matched->name + 11);
|
struct branch *branch = branch_get(branch_name);
|
||||||
if (branch->merge_nr == 1 && branch->merge[0]->src) {
|
if (branch->merge_nr == 1 && branch->merge[0]->src) {
|
||||||
struct strbuf buf = STRBUF_INIT;
|
struct strbuf buf = STRBUF_INIT;
|
||||||
strbuf_addf(&buf, "%s:%s",
|
strbuf_addf(&buf, "%s:%s",
|
||||||
|
Reference in New Issue
Block a user