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 <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Felipe Contreras committed
May 31, 2021 at 14:51 UTC
04159fba42b61ffa954dfb1fa13df1862c210ad8
1 file changed
+10
-6
builtin/push.c
+10
-6
@@ -254,11 +254,20 @@ static void setup_default_push_refspecs(struct remote *remote)
254
int same_remote = is_same_remote(remote);
255
256
switch (push_default) {
257
- default:
257
case PUSH_DEFAULT_MATCHING:
258
refspec_append(&rs, ":");
259
return;
260
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:
271
case PUSH_DEFAULT_UNSPECIFIED:
272
case PUSH_DEFAULT_SIMPLE:
273
setup_push_simple(remote, branch, same_remote);
@@ -271,11 +280,6 @@ static void setup_default_push_refspecs(struct remote *remote)
280
case PUSH_DEFAULT_CURRENT:
281
setup_push_current(remote, branch);
282
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;
283
}
284
}
285