Skip to content

Commit d371a9e

Browse files
felipecgitster
authored andcommitted
push: trivial simplifications
Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 00458dc commit d371a9e

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

builtin/push.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,12 @@ static const char *get_upstream_ref(struct branch *branch, const char *remote_na
205205
static const char *setup_push_upstream(struct remote *remote, struct branch *branch,
206206
int same_remote)
207207
{
208-
const char *upstream_ref;
209-
upstream_ref = get_upstream_ref(branch, remote->name);
210208
if (!same_remote)
211209
die(_("You are pushing to remote '%s', which is not the upstream of\n"
212210
"your current branch '%s', without telling me what to push\n"
213211
"to update which remote branch."),
214212
remote->name, branch->name);
215-
return upstream_ref;
213+
return get_upstream_ref(branch, remote->name);
216214
}
217215

218216
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
222220

223221
static const char *setup_push_simple(struct remote *remote, struct branch *branch, int same_remote)
224222
{
225-
if (same_remote) {
226-
const char *upstream_ref;
227-
228-
upstream_ref = get_upstream_ref(branch, remote->name);
229-
230-
/* Additional safety */
231-
if (strcmp(branch->refname, upstream_ref))
223+
if (same_remote)
224+
if (strcmp(branch->refname, get_upstream_ref(branch, remote->name)))
232225
die_push_simple(branch, remote);
233-
}
234226
return branch->refname;
235227
}
236228

0 commit comments

Comments
 (0)