]> git.ipfire.org Git - thirdparty/git.git/commitdiff
push: trivial simplifications
authorFelipe Contreras <felipe.contreras@gmail.com>
Mon, 31 May 2021 19:51:18 +0000 (14:51 -0500)
committerJunio C Hamano <gitster@pobox.com>
Wed, 2 Jun 2021 01:12:01 +0000 (10:12 +0900)
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/push.c

index 933b1cc6c0e084fda56cabfe8d9a528f97f7f9ed..43c039a2e3908957480bbcc98e452e404eb755d7 100644 (file)
@@ -205,14 +205,12 @@ static const char *get_upstream_ref(struct branch *branch, const char *remote_na
 static const char *setup_push_upstream(struct remote *remote, struct branch *branch,
        int same_remote)
 {
-       const char *upstream_ref;
-       upstream_ref = get_upstream_ref(branch, remote->name);
        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 upstream_ref;
+       return get_upstream_ref(branch, remote->name);
 }
 
 static const char *setup_push_current(struct remote *remote, struct branch *branch)
@@ -222,15 +220,9 @@ static const char *setup_push_current(struct remote *remote, struct branch *bran
 
 static const char *setup_push_simple(struct remote *remote, struct branch *branch, int same_remote)
 {
-       if (same_remote) {
-               const char *upstream_ref;
-
-               upstream_ref = get_upstream_ref(branch, remote->name);
-
-               /* Additional safety */
-               if (strcmp(branch->refname, upstream_ref))
+       if (same_remote)
+               if (strcmp(branch->refname, get_upstream_ref(branch, remote->name)))
                        die_push_simple(branch, remote);
-       }
        return branch->refname;
 }