]> git.ipfire.org Git - thirdparty/git.git/commitdiff
push: get rid of all the setup_push_* functions
authorFelipe Contreras <felipe.contreras@gmail.com>
Mon, 31 May 2021 19:51:19 +0000 (14:51 -0500)
committerJunio C Hamano <gitster@pobox.com>
Wed, 2 Jun 2021 01:12:02 +0000 (10:12 +0900)
Their code is much simpler now and can move into the parent function.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/push.c

index 43c039a2e3908957480bbcc98e452e404eb755d7..da406fc89072b1f370505ab12c74a80e934ef70b 100644 (file)
@@ -202,30 +202,6 @@ static const char *get_upstream_ref(struct branch *branch, const char *remote_na
        return branch->merge[0]->src;
 }
 
-static const char *setup_push_upstream(struct remote *remote, struct branch *branch,
-       int same_remote)
-{
-       if (!same_remote)
-               die(_("You are pushing to remote '%s', which is not the upstream of\n"
-                     "your current branch '%s', without telling me what to push\n"
-                     "to update which remote branch."),
-                   remote->name, branch->name);
-       return get_upstream_ref(branch, remote->name);
-}
-
-static const char *setup_push_current(struct remote *remote, struct branch *branch)
-{
-       return branch->refname;
-}
-
-static const char *setup_push_simple(struct remote *remote, struct branch *branch, int same_remote)
-{
-       if (same_remote)
-               if (strcmp(branch->refname, get_upstream_ref(branch, remote->name)))
-                       die_push_simple(branch, remote);
-       return branch->refname;
-}
-
 static int is_same_remote(struct remote *remote)
 {
        struct remote *fetch_remote = remote_get(NULL);
@@ -259,15 +235,23 @@ static void setup_default_push_refspecs(struct remote *remote)
        default:
        case PUSH_DEFAULT_UNSPECIFIED:
        case PUSH_DEFAULT_SIMPLE:
-               dst = setup_push_simple(remote, branch, same_remote);
+               if (same_remote)
+                       if (strcmp(branch->refname, get_upstream_ref(branch, remote->name)))
+                               die_push_simple(branch, remote);
+               dst = branch->refname;
                break;
 
        case PUSH_DEFAULT_UPSTREAM:
-               dst = setup_push_upstream(remote, branch, same_remote);
+               if (!same_remote)
+                       die(_("You are pushing to remote '%s', which is not the upstream of\n"
+                             "your current branch '%s', without telling me what to push\n"
+                             "to update which remote branch."),
+                           remote->name, branch->name);
+               dst = get_upstream_ref(branch, remote->name);
                break;
 
        case PUSH_DEFAULT_CURRENT:
-               dst = setup_push_current(remote, branch);
+               dst = branch->refname;
                break;
        }