push: trivial simplifications

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Felipe Contreras committed May 31, 2021 at 14:51 UTC d371a9ef4cfc4610989b0a3d71c79cbe19e0073a
1 file changed +3 -11
builtin/push.c
+3 -11
@@ -205,14 +205,12 @@ static const char *get_upstream_ref(struct branch *branch, const char *remote_na
205 static const char *setup_push_upstream(struct remote *remote, struct branch *branch,
206 int same_remote)
207 {
208 - const char *upstream_ref;
209 - upstream_ref = get_upstream_ref(branch, remote->name);
208 if (!same_remote)
209 die(_("You are pushing to remote '%s', which is not the upstream of\n"
210 "your current branch '%s', without telling me what to push\n"
211 "to update which remote branch."),
212 remote->name, branch->name);
215 - return upstream_ref;
213 + return get_upstream_ref(branch, remote->name);
214 }
215
216 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
220
221 static const char *setup_push_simple(struct remote *remote, struct branch *branch, int same_remote)
222 {
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)))
225 die_push_simple(branch, remote);
233 - }
226 return branch->refname;
227 }
228