push: make setup_push_* return the dst
All of the setup_push_* functions are appending a refspec. Do this only once on the parent function. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
65c63a0054
commit
00458dc5f1
@ -202,8 +202,8 @@ static const char *get_upstream_ref(struct branch *branch, const char *remote_na
|
|||||||
return branch->merge[0]->src;
|
return branch->merge[0]->src;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setup_push_upstream(struct remote *remote, struct branch *branch,
|
static const char *setup_push_upstream(struct remote *remote, struct branch *branch,
|
||||||
int same_remote)
|
int same_remote)
|
||||||
{
|
{
|
||||||
const char *upstream_ref;
|
const char *upstream_ref;
|
||||||
upstream_ref = get_upstream_ref(branch, remote->name);
|
upstream_ref = get_upstream_ref(branch, remote->name);
|
||||||
@ -212,16 +212,15 @@ static void setup_push_upstream(struct remote *remote, struct branch *branch,
|
|||||||
"your current branch '%s', without telling me what to push\n"
|
"your current branch '%s', without telling me what to push\n"
|
||||||
"to update which remote branch."),
|
"to update which remote branch."),
|
||||||
remote->name, branch->name);
|
remote->name, branch->name);
|
||||||
|
return upstream_ref;
|
||||||
refspec_appendf(&rs, "%s:%s", branch->refname, upstream_ref);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setup_push_current(struct remote *remote, struct branch *branch)
|
static const char *setup_push_current(struct remote *remote, struct branch *branch)
|
||||||
{
|
{
|
||||||
refspec_appendf(&rs, "%s:%s", branch->refname, branch->refname);
|
return branch->refname;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setup_push_simple(struct remote *remote, struct branch *branch, int same_remote)
|
static const char *setup_push_simple(struct remote *remote, struct branch *branch, int same_remote)
|
||||||
{
|
{
|
||||||
if (same_remote) {
|
if (same_remote) {
|
||||||
const char *upstream_ref;
|
const char *upstream_ref;
|
||||||
@ -232,7 +231,7 @@ static void setup_push_simple(struct remote *remote, struct branch *branch, int
|
|||||||
if (strcmp(branch->refname, upstream_ref))
|
if (strcmp(branch->refname, upstream_ref))
|
||||||
die_push_simple(branch, remote);
|
die_push_simple(branch, remote);
|
||||||
}
|
}
|
||||||
refspec_appendf(&rs, "%s:%s", branch->refname, branch->refname);
|
return branch->refname;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int is_same_remote(struct remote *remote)
|
static int is_same_remote(struct remote *remote)
|
||||||
@ -245,6 +244,7 @@ static void setup_default_push_refspecs(struct remote *remote)
|
|||||||
{
|
{
|
||||||
struct branch *branch;
|
struct branch *branch;
|
||||||
int same_remote = is_same_remote(remote);
|
int same_remote = is_same_remote(remote);
|
||||||
|
const char *dst;
|
||||||
|
|
||||||
switch (push_default) {
|
switch (push_default) {
|
||||||
case PUSH_DEFAULT_MATCHING:
|
case PUSH_DEFAULT_MATCHING:
|
||||||
@ -267,17 +267,19 @@ static void setup_default_push_refspecs(struct remote *remote)
|
|||||||
default:
|
default:
|
||||||
case PUSH_DEFAULT_UNSPECIFIED:
|
case PUSH_DEFAULT_UNSPECIFIED:
|
||||||
case PUSH_DEFAULT_SIMPLE:
|
case PUSH_DEFAULT_SIMPLE:
|
||||||
setup_push_simple(remote, branch, same_remote);
|
dst = setup_push_simple(remote, branch, same_remote);
|
||||||
return;
|
break;
|
||||||
|
|
||||||
case PUSH_DEFAULT_UPSTREAM:
|
case PUSH_DEFAULT_UPSTREAM:
|
||||||
setup_push_upstream(remote, branch, same_remote);
|
dst = setup_push_upstream(remote, branch, same_remote);
|
||||||
return;
|
break;
|
||||||
|
|
||||||
case PUSH_DEFAULT_CURRENT:
|
case PUSH_DEFAULT_CURRENT:
|
||||||
setup_push_current(remote, branch);
|
dst = setup_push_current(remote, branch);
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refspec_appendf(&rs, "%s:%s", branch->refname, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char message_advice_pull_before_push[] =
|
static const char message_advice_pull_before_push[] =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user