Skip to content

Commit 1f93472

Browse files
felipecgitster
authored andcommitted
push: factor out the typical case
Only override dst on the odd case. This allows a preemptive break on the `simple` case. Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0add899 commit 1f93472

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

builtin/push.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,16 @@ static void setup_default_push_refspecs(struct remote *remote)
231231
if (!branch)
232232
die(_(message_detached_head_die), remote->name);
233233

234+
dst = branch->refname;
235+
234236
switch (push_default) {
235237
default:
236238
case PUSH_DEFAULT_UNSPECIFIED:
237239
case PUSH_DEFAULT_SIMPLE:
238-
if (same_remote)
239-
if (strcmp(branch->refname, get_upstream_ref(branch, remote->name)))
240-
die_push_simple(branch, remote);
241-
dst = branch->refname;
240+
if (!same_remote)
241+
break;
242+
if (strcmp(branch->refname, get_upstream_ref(branch, remote->name)))
243+
die_push_simple(branch, remote);
242244
break;
243245

244246
case PUSH_DEFAULT_UPSTREAM:
@@ -251,7 +253,6 @@ static void setup_default_push_refspecs(struct remote *remote)
251253
break;
252254

253255
case PUSH_DEFAULT_CURRENT:
254-
dst = branch->refname;
255256
break;
256257
}
257258

0 commit comments

Comments
 (0)