summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Contreras <felipe.contreras@gmail.com>2021-05-31 19:51:14 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-06-02 01:12:01 (GMT)
commit04159fba42b61ffa954dfb1fa13df1862c210ad8 (patch)
tree1d125e46b967b87a1b7422ef8d3f2182c512cea6
parent72739680fc912c6e8dedaf06af4969f8e52ffb4d (diff)
downloadgit-04159fba42b61ffa954dfb1fa13df1862c210ad8.zip
git-04159fba42b61ffa954dfb1fa13df1862c210ad8.tar.gz
git-04159fba42b61ffa954dfb1fa13df1862c210ad8.tar.bz2
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>
-rw-r--r--builtin/push.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/builtin/push.c b/builtin/push.c
index 0aa1d0f..f64b710 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -254,11 +254,20 @@ static void setup_default_push_refspecs(struct remote *remote)
int same_remote = is_same_remote(remote);
switch (push_default) {
- default:
case PUSH_DEFAULT_MATCHING:
refspec_append(&rs, ":");
return;
+ case PUSH_DEFAULT_NOTHING:
+ die(_("You didn't specify any refspecs to push, and "
+ "push.default is \"nothing\"."));
+ return;
+ default:
+ break;
+ }
+
+ switch (push_default) {
+ default:
case PUSH_DEFAULT_UNSPECIFIED:
case PUSH_DEFAULT_SIMPLE:
setup_push_simple(remote, branch, same_remote);
@@ -271,11 +280,6 @@ static void setup_default_push_refspecs(struct remote *remote)
case PUSH_DEFAULT_CURRENT:
setup_push_current(remote, branch);
return;
-
- case PUSH_DEFAULT_NOTHING:
- die(_("You didn't specify any refspecs to push, and "
- "push.default is \"nothing\"."));
- return;
}
}