Skip to content

Commit 04159fb

Browse files
felipecgitster
authored andcommitted
push: split switch cases
We want all the cases that don't do anything with a branch first, and then the rest. That way we will be able to get the branch and die if there's a problem in the parent function, instead of inside the function of each mode. Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7273968 commit 04159fb

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

builtin/push.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,20 @@ static void setup_default_push_refspecs(struct remote *remote)
254254
int same_remote = is_same_remote(remote);
255255

256256
switch (push_default) {
257-
default:
258257
case PUSH_DEFAULT_MATCHING:
259258
refspec_append(&rs, ":");
260259
return;
261260

261+
case PUSH_DEFAULT_NOTHING:
262+
die(_("You didn't specify any refspecs to push, and "
263+
"push.default is \"nothing\"."));
264+
return;
265+
default:
266+
break;
267+
}
268+
269+
switch (push_default) {
270+
default:
262271
case PUSH_DEFAULT_UNSPECIFIED:
263272
case PUSH_DEFAULT_SIMPLE:
264273
setup_push_simple(remote, branch, same_remote);
@@ -271,11 +280,6 @@ static void setup_default_push_refspecs(struct remote *remote)
271280
case PUSH_DEFAULT_CURRENT:
272281
setup_push_current(remote, branch);
273282
return;
274-
275-
case PUSH_DEFAULT_NOTHING:
276-
die(_("You didn't specify any refspecs to push, and "
277-
"push.default is \"nothing\"."));
278-
return;
279283
}
280284
}
281285

0 commit comments

Comments
 (0)