Skip to content

Commit b8e8b98

Browse files
felipecgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6b010c8 commit b8e8b98

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

builtin/push.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,10 @@ static void setup_push_current(struct remote *remote, struct branch *branch)
225225

226226
static void setup_push_simple(struct remote *remote, struct branch *branch, int same_remote)
227227
{
228-
const char *dst;
229-
230228
if (!branch)
231229
die(_(message_detached_head_die), remote->name);
232230

233-
if (!same_remote) {
234-
dst = branch->refname;
235-
} else {
231+
if (same_remote) {
236232
if (!branch->merge_nr || !branch->merge || !branch->remote_name)
237233
die(_("The current branch %s has no upstream branch.\n"
238234
"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
248244
/* Additional safety */
249245
if (strcmp(branch->refname, branch->merge[0]->src))
250246
die_push_simple(branch, remote);
251-
252-
dst = branch->merge[0]->src;
253247
}
254-
refspec_appendf(&rs, "%s:%s", branch->refname, dst);
248+
refspec_appendf(&rs, "%s:%s", branch->refname, branch->refname);
255249
}
256250

257251
static int is_same_remote(struct remote *remote)

0 commit comments

Comments
 (0)