push: simplify setup_push_simple()

There's a safety check to make sure branch->refname isn't different from branch->merge[0]->src, otherwise we die(). Therefore we always push to branch->refname. Suggestions-by: Elijah Newren <newren@gmail.com> 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:32 UTC b8e8b98647f02e721fc3c1b5db6936ba7c1c1167
1 file changed +2 -8
builtin/push.c
+2 -8
@@ -225,14 +225,10 @@ static void setup_push_current(struct remote *remote, struct branch *branch)
225
226 static void setup_push_simple(struct remote *remote, struct branch *branch, int same_remote)
227 {
228 - const char *dst;
229 -
228 if (!branch)
229 die(_(message_detached_head_die), remote->name);
230
233 - if (!same_remote) {
234 - dst = branch->refname;
235 - } else {
231 + if (same_remote) {
232 if (!branch->merge_nr || !branch->merge || !branch->remote_name)
233 die(_("The current branch %s has no upstream branch.\n"
234 "To push the current branch and set the remote as upstream, use\n"
@@ -248,10 +244,8 @@ static void setup_push_simple(struct remote *remote, struct branch *branch, int
244 /* Additional safety */
245 if (strcmp(branch->refname, branch->merge[0]->src))
246 die_push_simple(branch, remote);
251 -
252 - dst = branch->merge[0]->src;
247 }
254 - refspec_appendf(&rs, "%s:%s", branch->refname, dst);
248 + refspec_appendf(&rs, "%s:%s", branch->refname, branch->refname);
249 }
250
251 static int is_same_remote(struct remote *remote)