push: trivial simplifications

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Felipe Contreras 2021-05-31 14:51:18 -05:00 committed by Junio C Hamano
parent 00458dc5f1
commit d371a9ef4c
1 changed files with 3 additions and 11 deletions

View File

@ -205,14 +205,12 @@ static const char *get_upstream_ref(struct branch *branch, const char *remote_na
static const char *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;
upstream_ref = get_upstream_ref(branch, remote->name);
if (!same_remote) if (!same_remote)
die(_("You are pushing to remote '%s', which is not the upstream of\n" die(_("You are pushing to remote '%s', which is not the upstream of\n"
"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; return get_upstream_ref(branch, remote->name);
} }


static const char *setup_push_current(struct remote *remote, struct branch *branch) static const char *setup_push_current(struct remote *remote, struct branch *branch)
@ -222,15 +220,9 @@ static const char *setup_push_current(struct remote *remote, struct branch *bran


static const char *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; if (strcmp(branch->refname, get_upstream_ref(branch, remote->name)))

upstream_ref = get_upstream_ref(branch, remote->name);

/* Additional safety */
if (strcmp(branch->refname, upstream_ref))
die_push_simple(branch, remote); die_push_simple(branch, remote);
}
return branch->refname; return branch->refname;
} }