From patchwork Mon May 31 19:51:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12289937 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A15C8C47082 for ; Mon, 31 May 2021 19:51:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A3B4606A5 for ; Mon, 31 May 2021 19:51:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231585AbhEaTxK (ORCPT ); Mon, 31 May 2021 15:53:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230519AbhEaTxJ (ORCPT ); Mon, 31 May 2021 15:53:09 -0400 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A05EC061574 for ; Mon, 31 May 2021 12:51:29 -0700 (PDT) Received: by mail-oi1-x233.google.com with SMTP id a13so7843123oid.9 for ; Mon, 31 May 2021 12:51:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a3esfwa0ioPNHMlz0GR2X8p05KfASrhzJA4HO3JEBek=; b=FO3KVb8FevPVoPYjZ6dUyWRBELE6he/oAxjoqtSwDMKX6lZFVh/HWu2MHUiGn3hpqi APINgxcY7Tj9alfXHfznzsm1a0PyVJl2AZXop6xoPRg7EA5iwf7zttDPaJe1BsQvXOUj DG/E7X8jwf4KunmUuRCcTQA9Ous+F2KeqUoGPh8Axo5rKJdbIThj8qqvo3DkjS7Xbf3z vk6uZZ8y7nDFChKxWP9dp+NlnWFLhopNIiVd1qOCx672ZsxNmkVscShY1KPhS2Ox1LIh M9SGz55F7NiUFumZjuJ8iE1QZTSueNdRVl8ARNxhcwlDiXU/3saFLkstae2/louvAfwI JvQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a3esfwa0ioPNHMlz0GR2X8p05KfASrhzJA4HO3JEBek=; b=k7PTeq3SDVso9ep0m1Zot3y/NmWR6D5MBHbFjLSARG3gbzC6VohYIHDOPNTsZaRdns wzLt1C7T7435rBAhAglPjOJoB9smI7/xg2faR7g2iNZx4Txv+qszMIJCueeuDtaxWYJu nRrNiIJHFBl0DNPemnFNdEdp1ADQiPPfurqimhTF8RhuADVh7EZTsp16vMM7LEwk9ClD pDQPFPVgaoI8qUatXx9duf1mAXxrJ8EunV2LoB7zNfQZ1op0CE/RrSz4Lg+3K9kmIfVF btJatl2ydqqTKcxB0sHyy+2tazAoYaQIOE6coiZ4ammyBuxbm9S7++F+5Ui4Cpe4jr/P n47w== X-Gm-Message-State: AOAM531Qauta25+LCT7SBTd5e0w2ZyZuB4bqpAuNYRjkap5ipulOlqPf RatO92gBsfJWKu/AVIvpTl2ooWglJORrtQ== X-Google-Smtp-Source: ABdhPJzinsxZNX57GQIHELYBWxMPk5bXq+ryECdx78g6HAarle8fw+DQFHMtZFJeOizj+iNXLioGCw== X-Received: by 2002:a05:6808:159d:: with SMTP id t29mr445839oiw.112.1622490688173; Mon, 31 May 2021 12:51:28 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id h7sm1028195oib.49.2021.05.31.12.51.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 12:51:27 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Junio C Hamano , Elijah Newren , Brandon Williams , =?utf-8?q?Ren=C3=A9_Scharfe?= , Felipe Contreras Subject: [PATCH v2 01/13] push: create new get_upstream_ref() helper Date: Mon, 31 May 2021 14:51:12 -0500 Message-Id: <20210531195124.218325-2-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.rc0 In-Reply-To: <20210531195124.218325-1-felipe.contreras@gmail.com> References: <20210531193237.216726-1-felipe.contreras@gmail.com> <20210531195124.218325-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This code is duplicated among multiple functions. No functional changes. Signed-off-by: Felipe Contreras --- builtin/push.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/builtin/push.c b/builtin/push.c index 29fea70ff1..e3e792c69c 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -185,29 +185,37 @@ static const char message_detached_head_die[] = "\n" " git push %s HEAD:\n"); -static void setup_push_upstream(struct remote *remote, struct branch *branch, - int same_remote) +static const char *get_upstream_ref(struct branch *branch, const char *remote_name) { - if (!branch) - die(_(message_detached_head_die), remote->name); if (!branch->merge_nr || !branch->merge || !branch->remote_name) die(_("The current branch %s has no upstream branch.\n" "To push the current branch and set the remote as upstream, use\n" "\n" " git push --set-upstream %s %s\n"), branch->name, - remote->name, + remote_name, branch->name); if (branch->merge_nr != 1) die(_("The current branch %s has multiple upstream branches, " "refusing to push."), branch->name); + + return branch->merge[0]->src; +} + +static void setup_push_upstream(struct remote *remote, struct branch *branch, + int same_remote) +{ + const char *upstream_ref; + if (!branch) + die(_(message_detached_head_die), remote->name); + 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); - refspec_appendf(&rs, "%s:%s", branch->refname, branch->merge[0]->src); + refspec_appendf(&rs, "%s:%s", branch->refname, upstream_ref); } static void setup_push_current(struct remote *remote, struct branch *branch) @@ -223,20 +231,12 @@ static void setup_push_simple(struct remote *remote, struct branch *branch, int die(_(message_detached_head_die), remote->name); if (same_remote) { - if (!branch->merge_nr || !branch->merge || !branch->remote_name) - die(_("The current branch %s has no upstream branch.\n" - "To push the current branch and set the remote as upstream, use\n" - "\n" - " git push --set-upstream %s %s\n"), - branch->name, - remote->name, - branch->name); - if (branch->merge_nr != 1) - die(_("The current branch %s has multiple upstream branches, " - "refusing to push."), branch->name); + const char *upstream_ref; + + upstream_ref = get_upstream_ref(branch, remote->name); /* Additional safety */ - if (strcmp(branch->refname, branch->merge[0]->src)) + if (strcmp(branch->refname, upstream_ref)) die_push_simple(branch, remote); } refspec_appendf(&rs, "%s:%s", branch->refname, branch->refname); From patchwork Mon May 31 19:51:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12289939 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DD22C47082 for ; Mon, 31 May 2021 19:51:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C5EBC61057 for ; Mon, 31 May 2021 19:51:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231995AbhEaTx1 (ORCPT ); Mon, 31 May 2021 15:53:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230523AbhEaTxK (ORCPT ); Mon, 31 May 2021 15:53:10 -0400 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9911AC061574 for ; Mon, 31 May 2021 12:51:30 -0700 (PDT) Received: by mail-oi1-x22f.google.com with SMTP id v22so13270562oic.2 for ; Mon, 31 May 2021 12:51:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8h2/LLawg3qJwTAKsFMDPknmeDU7m4nmA9ynwHx4AsQ=; b=ubFCoaKEBoDDfd8KKaUmlAq7vm/b9ViOR6jThDhpM4WolctG9MtFUT9sykxBH591W8 hPvpYWXJUgn+QzL+yChyFEfaA+KNmN3LVwASdO4nUzt7FdCXo5zPjYXeKNbosNodSM1z 4XtcXlZZX9cjaK2xrgu0Cu+Kk4AZo1bIRJUAxLE8aLpHQ4dT7Zo1LYMLpx4V8YM9howF vuLfomdf+hQ4+bbn8dAtEcfLYLGMcPD88jPaQXAMWSVo8zhz1MYY94qJRCxrdskVU843 BavVg7ugQzUJQOui1XatmXjca48bb+sUVyeMuNFQSFQr7eyQvoUyzTX8KfwYSSYEw8YZ a7uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8h2/LLawg3qJwTAKsFMDPknmeDU7m4nmA9ynwHx4AsQ=; b=TxmQnrBTpAbO/eMglsvKmVrcqK8t6YP61ibYj3f2+moAVmAtWW3JYqElLTFa7rMqN3 FKcKbuNEXjYUrx1L1xW3YTmmJe7EiCflJdEQqAwaMW02M75iTTSBGuGNvQB/cUweG+xm TfEez+Dq9bBlfPPyP2bwVjzrGvkFH3ICH7knu7Y6i4VUTYLYWIi4vFhLQs64Q7PwOK6x YPghtngKyk2QFY6qDd7B2FjFCzGQl/bmpAYWCt9JBH+BgDkKhZw4u3p5gPmb886ypu3X WqnP0F+kZhlvrl92b16cCvZkG8miiK5BnZ9YpdL9fLlI7GhdkttB5v12dx+5DqBLUuv5 UStg== X-Gm-Message-State: AOAM530vPxmdKrebQasXnL6XeNzj6JRAMXC57fZ0KCcS6cYYczbWesld JI62TtTucA0lgDJBnXg5FYsyee5E54KJ6g== X-Google-Smtp-Source: ABdhPJxFHfzeN8+LQi+OJd7uQUcZm35eNZYxmWV9UqZGMjScFY2I9M0KZz2tnNzxzRe7SKth641Gkw== X-Received: by 2002:a54:4192:: with SMTP id 18mr474430oiy.84.1622490689800; Mon, 31 May 2021 12:51:29 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id w6sm3245019otj.5.2021.05.31.12.51.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 12:51:29 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Junio C Hamano , Elijah Newren , Brandon Williams , =?utf-8?q?Ren=C3=A9_Scharfe?= , Felipe Contreras Subject: [PATCH v2 02/13] push: return immediately in trivial switch case Date: Mon, 31 May 2021 14:51:13 -0500 Message-Id: <20210531195124.218325-3-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.rc0 In-Reply-To: <20210531195124.218325-1-felipe.contreras@gmail.com> References: <20210531193237.216726-1-felipe.contreras@gmail.com> <20210531195124.218325-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There's no need to break when nothing else will be executed. Will help next patches. Signed-off-by: Felipe Contreras --- builtin/push.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/builtin/push.c b/builtin/push.c index e3e792c69c..0aa1d0f07d 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -257,25 +257,25 @@ static void setup_default_push_refspecs(struct remote *remote) default: case PUSH_DEFAULT_MATCHING: refspec_append(&rs, ":"); - break; + return; case PUSH_DEFAULT_UNSPECIFIED: case PUSH_DEFAULT_SIMPLE: setup_push_simple(remote, branch, same_remote); - break; + return; case PUSH_DEFAULT_UPSTREAM: setup_push_upstream(remote, branch, same_remote); - break; + return; case PUSH_DEFAULT_CURRENT: setup_push_current(remote, branch); - break; + return; case PUSH_DEFAULT_NOTHING: die(_("You didn't specify any refspecs to push, and " "push.default is \"nothing\".")); - break; + return; } } From patchwork Mon May 31 19:51:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12289941 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1909DC47080 for ; Mon, 31 May 2021 19:51:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F2A0861057 for ; Mon, 31 May 2021 19:51:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231686AbhEaTx3 (ORCPT ); Mon, 31 May 2021 15:53:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231663AbhEaTxS (ORCPT ); Mon, 31 May 2021 15:53:18 -0400 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BF41C06174A for ; Mon, 31 May 2021 12:51:32 -0700 (PDT) Received: by mail-oi1-x233.google.com with SMTP id x15so13246381oic.13 for ; Mon, 31 May 2021 12:51:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JDwlh8AXPMncEEFKLEk3U6unvHtClflb0YM1CVsYvK0=; b=klxFVkZrr4zHPgO2vQCaZ9727LsWLXlS7Yk1QO9hMPAlpe34fzP/3DtTflcd/PbpZ8 bKHWmJSudkTMvlxQXQ2jDGUgbkg6p+k2CbGbgBTXyl7R2dATq17oiNryvgxFy6mcDSt4 OQ+dxilnIblFzYgUyuhuaUcKc3TOrpTY63yVQuunmDppjFH8ibpZKoP1sOcqBSWSrxJD 2cZny77EE+VDrMRLwHR11uh6z7QcJ4hwNfFQX3L7yxQ9IUmGQPg432nlKTT92ES7mys7 VKKN+QM20G/e+Vn6GdoJZHewMIq+SXr0UWrTlLaE0USoq2tNIxp0z9sUSNrS7wpYT0CI cP3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JDwlh8AXPMncEEFKLEk3U6unvHtClflb0YM1CVsYvK0=; b=JL6XdYU3mLRBrBmTpUH7wPAPgH44JT29NbuWwexyq20Y/jIg/vwAsXRmGzEVZVCqdd Nf1M38zziWI+oCqDp8A/bG2317YETHHNFskbe8sovcFLkNlh+E8VUcgb9yra/8zWkOuU fIb7J9hFC+TVB7Xubgl8kCYIuj63Z55tfXlmbaxrmLDWz2kjn54sBDPRFOVr1pvFwG2Y J/Pf7yk7kNShOQxK7E5VFz6wen4dqW5iZWKvYLTIZy9qbWaqz3OHRDKoGjkyQ/FyYR8t YBwnYU3m3Se9pbQTlCN2YBVyDWZYlxZmM7mGNFgRk3VIbF2YmZUlKXPnKXaU8++3evNo Y09w== X-Gm-Message-State: AOAM530UiOs3BWWj4ld20I2H+ZPyCDtZZFzP+yuQ+59yvMw+pqT/gDNg aXSEgFlclwi0HtxG6eysnP8h5Y2gs8cgFQ== X-Google-Smtp-Source: ABdhPJwkNfO9bWTBzFIJCHqww2bjr7vYUz3g6RrE9DniV39LMXf3VmeDOhRx2OnF/Mz/YAWSWowtfQ== X-Received: by 2002:aca:400b:: with SMTP id n11mr14913127oia.111.1622490691305; Mon, 31 May 2021 12:51:31 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id k14sm789809ooi.21.2021.05.31.12.51.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 12:51:31 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Junio C Hamano , Elijah Newren , Brandon Williams , =?utf-8?q?Ren=C3=A9_Scharfe?= , Felipe Contreras Subject: [PATCH v2 03/13] push: split switch cases Date: Mon, 31 May 2021 14:51:14 -0500 Message-Id: <20210531195124.218325-4-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.rc0 In-Reply-To: <20210531195124.218325-1-felipe.contreras@gmail.com> References: <20210531193237.216726-1-felipe.contreras@gmail.com> <20210531195124.218325-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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 --- builtin/push.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/builtin/push.c b/builtin/push.c index 0aa1d0f07d..f64b7100f0 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; } } From patchwork Mon May 31 19:51:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12289943 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1CC5C47080 for ; Mon, 31 May 2021 19:51:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6E403606A5 for ; Mon, 31 May 2021 19:51:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231991AbhEaTxd (ORCPT ); Mon, 31 May 2021 15:53:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231670AbhEaTxS (ORCPT ); Mon, 31 May 2021 15:53:18 -0400 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7E67C061761 for ; Mon, 31 May 2021 12:51:33 -0700 (PDT) Received: by mail-oi1-x233.google.com with SMTP id j75so13240900oih.10 for ; Mon, 31 May 2021 12:51:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dM/vcJtcCTnsgieWfjKS9QmxIRDhtjTu4AEpdHnLJ2w=; b=IAWPfuR3MPEV3gAsdqFQrzGk//nTGvElOU+c5tbMaqLxi0aRld/Mmh44SEiohDNsTW J+urfb0V9HfD48t82gXEB1fKfEroW84OJ57+dbf/DxmINJg4+xwfYgcFkPDUpSA3o5JE dsx/AtS+toO51XB5iqu+jkkaHG7fH/2/eN/TN2bZsrRmANtlr4gDtnXB4OagNgoY76DO z1gl9s+ASDt2zVheJWBmhKsvIGRyRmyOf3fLW9b1f0s/CRN2vGY6kUbmWRVgiQOw6iKq cfuCsnzpMKAGu3zBJ71eZ3k4EGXeknsbagV8dTUZ8QSQItSHj55agEmeFu+uUxjlO9/N LtCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dM/vcJtcCTnsgieWfjKS9QmxIRDhtjTu4AEpdHnLJ2w=; b=Ea2iN02XcdyKP/pUIzA6+v6RfIF/mOXF7Hdp8D7BW77o4euMr9alX+fCbuC8Uw1Oli fYLRv68Lohyne7RKDygLHw0mQ9GMWGyZXk7okKYtaZATv2YJar+tYCjUKNFKX+C+unxv 75qrkNUzZlGqhEAI4karSFDXV4+/pgJ1CpZqCEx9AqyvrdfVq9ZCLub4lNhZj+zJ6q83 S+29IjvC3uNG4+Eq/eabgLCIDCeqyo4QQXrmwOx1N4ke/fcAOd2a6rLvfI79jjl/eclN 2KqkjKhkj96ALDdEItwjd3HSCBgpiPBOfCidvderBIJBgXAKsLXmFcjwpXMVGHNrMWPv ti1A== X-Gm-Message-State: AOAM533Te+W/MlFeHkuyqobRSMC8UZ5MYj8FtWJFk10caZQvJOwhCLVq nCCvna5FrTuzEs/Ti8eYW4b1DUA4ev/FXw== X-Google-Smtp-Source: ABdhPJyEgFnjfo6j14j5jH3Cy/i24jOyxOfsvMP+nSFWplroOk+Ayce4EjQkbeNwkwOYxGiIG3E/og== X-Received: by 2002:a05:6808:b08:: with SMTP id s8mr436258oij.162.1622490692913; Mon, 31 May 2021 12:51:32 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id x9sm3240317oto.79.2021.05.31.12.51.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 12:51:32 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Junio C Hamano , Elijah Newren , Brandon Williams , =?utf-8?q?Ren=C3=A9_Scharfe?= , Felipe Contreras Subject: [PATCH v2 04/13] push: factor out null branch check Date: Mon, 31 May 2021 14:51:15 -0500 Message-Id: <20210531195124.218325-5-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.rc0 In-Reply-To: <20210531195124.218325-1-felipe.contreras@gmail.com> References: <20210531193237.216726-1-felipe.contreras@gmail.com> <20210531195124.218325-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org No need to do it in every single function. Signed-off-by: Felipe Contreras --- builtin/push.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/builtin/push.c b/builtin/push.c index f64b7100f0..8fcbd2878d 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -206,8 +206,6 @@ static void setup_push_upstream(struct remote *remote, struct branch *branch, int same_remote) { const char *upstream_ref; - if (!branch) - die(_(message_detached_head_die), remote->name); 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" @@ -220,16 +218,11 @@ static void setup_push_upstream(struct remote *remote, struct branch *branch, static void setup_push_current(struct remote *remote, struct branch *branch) { - if (!branch) - die(_(message_detached_head_die), remote->name); refspec_appendf(&rs, "%s:%s", branch->refname, branch->refname); } static void setup_push_simple(struct remote *remote, struct branch *branch, int same_remote) { - if (!branch) - die(_(message_detached_head_die), remote->name); - if (same_remote) { const char *upstream_ref; @@ -266,6 +259,9 @@ static void setup_default_push_refspecs(struct remote *remote) break; } + if (!branch) + die(_(message_detached_head_die), remote->name); + switch (push_default) { default: case PUSH_DEFAULT_UNSPECIFIED: From patchwork Mon May 31 19:51:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12289945 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF2C6C47080 for ; Mon, 31 May 2021 19:51:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8710E60232 for ; Mon, 31 May 2021 19:51:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232114AbhEaTxg (ORCPT ); Mon, 31 May 2021 15:53:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231726AbhEaTx0 (ORCPT ); Mon, 31 May 2021 15:53:26 -0400 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30841C0613CE for ; Mon, 31 May 2021 12:51:35 -0700 (PDT) Received: by mail-oi1-x22d.google.com with SMTP id d21so13228974oic.11 for ; Mon, 31 May 2021 12:51:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lImqJ1uhmVCEhO9rOMRITpdlXQIFJE6VqL3intGO/7k=; b=SvgBFlmg49b8I+eo7It392KTAKjPuGboXPrd27h87u2gv1lkAD5lvNGei1UHKJv+/Q oivroJufnsiXOjfsv48euT97tpk0U+OsXu84lApv5lrbqWbkXbBomeVsmeKqzzABrfjr 2ZANkbj0qEFBd3XKs7cgfRIJsmWADimjNjVZPLXnQcVZ4lgpwHH4k9aeC62uNPgQ+POH CZM5I6gZgtAyBl84N2fZV5KFGqOil/FsU4y24EIyC9TvJkY5EH9hQqSBuK3oZssn3wYW BR1iDpn2ZMHSb/WsZciiYyaDvBQSQF70ge/nwShpBW4Rm0cB/oraST5f5lSSI70kq8gu +7AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lImqJ1uhmVCEhO9rOMRITpdlXQIFJE6VqL3intGO/7k=; b=pSvY/PiFQqoWf4rbPNVfsUyW8X7KPI4z4VZFSqW1j+v+Tw1jix4jqpdgctHYAaKQ7J 2NxMfOQV1cpMtcfATmM+qNJzRZFcPJntmuoxX/WpVH7csgi5C9RrbbAbUbMUaXoMUoLg +G4NxCTGOqPFjDd2OheRCKQfMH5YkFin6I//MWaxrGBuWE3HQrHjV5xBqfTVJ20je6j2 op8itB9grtOfIRwrWaA2s0R3+W/TP1EMbGLCNTw2Fkq4hKrd/+EiG7rpI7FaCpox6Ks4 NfnEqRImOtbal5C8BZCyj5NtY2tqqxEABOErlPU+tnVulbKmr0m5Yxi0f+Zm+GUPEPJr 6IdA== X-Gm-Message-State: AOAM532zhTWt/dj5gDGwGevz8SYfGGe/3T/24zPorFuOBKbd+PjO9JzB aT1jFqJKTp09qY9kFMRBo+8SEs7mlnq6Ww== X-Google-Smtp-Source: ABdhPJxN2dsoveUbQ+piF83SUBhrpa9iji/3CRVTICH7ldiMV8BpmTbsgfyAeos7MgRql8V+FALZCA== X-Received: by 2002:aca:edc3:: with SMTP id l186mr7780746oih.43.1622490694296; Mon, 31 May 2021 12:51:34 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id c19sm3003681oiw.7.2021.05.31.12.51.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 12:51:34 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Junio C Hamano , Elijah Newren , Brandon Williams , =?utf-8?q?Ren=C3=A9_Scharfe?= , Felipe Contreras Subject: [PATCH v2 05/13] push: only get the branch when needed Date: Mon, 31 May 2021 14:51:16 -0500 Message-Id: <20210531195124.218325-6-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.rc0 In-Reply-To: <20210531195124.218325-1-felipe.contreras@gmail.com> References: <20210531193237.216726-1-felipe.contreras@gmail.com> <20210531195124.218325-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- builtin/push.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builtin/push.c b/builtin/push.c index 8fcbd2878d..d9f9d20f39 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -243,7 +243,7 @@ static int is_same_remote(struct remote *remote) static void setup_default_push_refspecs(struct remote *remote) { - struct branch *branch = branch_get(NULL); + struct branch *branch; int same_remote = is_same_remote(remote); switch (push_default) { @@ -259,6 +259,7 @@ static void setup_default_push_refspecs(struct remote *remote) break; } + branch = branch_get(NULL); if (!branch) die(_(message_detached_head_die), remote->name); From patchwork Mon May 31 19:51:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12289971 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07337C47080 for ; Mon, 31 May 2021 19:52:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E2BBD610A8 for ; Mon, 31 May 2021 19:52:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232064AbhEaTxx (ORCPT ); Mon, 31 May 2021 15:53:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231652AbhEaTx2 (ORCPT ); Mon, 31 May 2021 15:53:28 -0400 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 777D8C0613ED for ; Mon, 31 May 2021 12:51:36 -0700 (PDT) Received: by mail-oi1-x22a.google.com with SMTP id v22so13270755oic.2 for ; Mon, 31 May 2021 12:51:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5y+1hcx5nAvL0NKZ8rJGO72mGkp0ylm1nXlnVS7QB8E=; b=BOHkJfcFV4/d7Is9l32tfUEPbnQagNLJVa0mfAwY8e01bJ0ek+fYrojsqjrekXio1p oA4qVweLSBYBP9aRqKRKGx6d72gcd/yq4+MH8W5JEjI8A3o+wRjMrcC6gkAb2vYFBwWK hWcWFfduwiGnbiCml4z/zgiXK3T/rL+UhUpcl+/dorBDxL2TNigeOE2Ibshylt8g4DQ4 QH3uxqS1RY9IFBLewtBWbnKgJMY1WH5FeyACDEUQE38/AGtvEAx4ZfJ267S45/+UIONP Mak3QpAfTBjmo7IGUfdmqPcmjDL3eA3irbYVIFln6DT+a0ZXinB2yEFf3MIt4v174uly fmng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5y+1hcx5nAvL0NKZ8rJGO72mGkp0ylm1nXlnVS7QB8E=; b=DWyv7EDmLxN1op6dUT8Tiv9KGRW/KYKOjJU0WMvTQY+rPUtT6TlkLym+vLxRHrykb4 aFVOOEUZv6Yw9rWg2/nnq2HkrGXP+dQjLHhIoXMHTVo2wYcJ44yGq+B4Vxp4HjmhO6nr 6mVLxpWUQfGhvmsASRKC9+HEpg8aD+L98FVuZOk9eJTJXIwVbk3AdnI5/J844q65j8Fa 7DyKWuJ5Vr8YyKGvDCggYOZ/y9g/fmkb33JG9+ser3KOXMBkjJEe+hKrZHBWBygiG5+o ooTwpbDHdpaB9tWLrp3fmgnJleFyWazRHfw/JB2oxLTKBChCre6u7bDfKvCCUjzsiZ4K 7pjA== X-Gm-Message-State: AOAM531urcYtxI9Mc4+Lf1ptd6KAgKc/Vm1IqzcBtWdSU3eYHjJ1AKpn f/Xvt3nLIgyq5RSglBmBNYXlK36KmzIWmA== X-Google-Smtp-Source: ABdhPJwH3Xzw0GWbXPQPjENc16R6scLN2HGvZVDCCQZSTe+9GZS2cGELM+OA3yZgytTYfeeYeXGVLQ== X-Received: by 2002:aca:6505:: with SMTP id m5mr14551980oim.93.1622490695825; Mon, 31 May 2021 12:51:35 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id c17sm3396825otn.45.2021.05.31.12.51.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 12:51:35 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Junio C Hamano , Elijah Newren , Brandon Williams , =?utf-8?q?Ren=C3=A9_Scharfe?= , Felipe Contreras Subject: [PATCH v2 06/13] push: make setup_push_* return the dst Date: Mon, 31 May 2021 14:51:17 -0500 Message-Id: <20210531195124.218325-7-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.rc0 In-Reply-To: <20210531195124.218325-1-felipe.contreras@gmail.com> References: <20210531193237.216726-1-felipe.contreras@gmail.com> <20210531195124.218325-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org All of the setup_push_* functions are appending a refspec. Do this only once on the parent function. Signed-off-by: Felipe Contreras --- builtin/push.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/builtin/push.c b/builtin/push.c index d9f9d20f39..933b1cc6c0 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -202,8 +202,8 @@ static const char *get_upstream_ref(struct branch *branch, const char *remote_na return branch->merge[0]->src; } -static void setup_push_upstream(struct remote *remote, struct branch *branch, - int same_remote) +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); @@ -212,16 +212,15 @@ static void setup_push_upstream(struct remote *remote, struct branch *branch, "your current branch '%s', without telling me what to push\n" "to update which remote branch."), remote->name, branch->name); - - refspec_appendf(&rs, "%s:%s", branch->refname, upstream_ref); + return upstream_ref; } -static void setup_push_current(struct remote *remote, struct branch *branch) +static const char *setup_push_current(struct remote *remote, struct branch *branch) { - refspec_appendf(&rs, "%s:%s", branch->refname, branch->refname); + return branch->refname; } -static void setup_push_simple(struct remote *remote, struct branch *branch, int same_remote) +static const char *setup_push_simple(struct remote *remote, struct branch *branch, int same_remote) { if (same_remote) { const char *upstream_ref; @@ -232,7 +231,7 @@ static void setup_push_simple(struct remote *remote, struct branch *branch, int if (strcmp(branch->refname, upstream_ref)) die_push_simple(branch, remote); } - refspec_appendf(&rs, "%s:%s", branch->refname, branch->refname); + return branch->refname; } static int is_same_remote(struct remote *remote) @@ -245,6 +244,7 @@ static void setup_default_push_refspecs(struct remote *remote) { struct branch *branch; int same_remote = is_same_remote(remote); + const char *dst; switch (push_default) { case PUSH_DEFAULT_MATCHING: @@ -267,17 +267,19 @@ static void setup_default_push_refspecs(struct remote *remote) default: case PUSH_DEFAULT_UNSPECIFIED: case PUSH_DEFAULT_SIMPLE: - setup_push_simple(remote, branch, same_remote); - return; + dst = setup_push_simple(remote, branch, same_remote); + break; case PUSH_DEFAULT_UPSTREAM: - setup_push_upstream(remote, branch, same_remote); - return; + dst = setup_push_upstream(remote, branch, same_remote); + break; case PUSH_DEFAULT_CURRENT: - setup_push_current(remote, branch); - return; + dst = setup_push_current(remote, branch); + break; } + + refspec_appendf(&rs, "%s:%s", branch->refname, dst); } static const char message_advice_pull_before_push[] = From patchwork Mon May 31 19:51:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12289963 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 517AEC47082 for ; Mon, 31 May 2021 19:52:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 329F560232 for ; Mon, 31 May 2021 19:52:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232244AbhEaTxk (ORCPT ); Mon, 31 May 2021 15:53:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231971AbhEaTx1 (ORCPT ); Mon, 31 May 2021 15:53:27 -0400 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0630CC06138A for ; Mon, 31 May 2021 12:51:38 -0700 (PDT) Received: by mail-oi1-x233.google.com with SMTP id b25so13301449oic.0 for ; Mon, 31 May 2021 12:51:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=V0DXeCnh9HhrADX+XgqelUhO7gy6X8yn1spfFru5JxI=; b=ZFaGwqfDEAINFpuSbSzFW3eQ0Q7lNUVH/vNTfNzDUoUp0tpM3HmLqJNJ8KPKuQYNep bLwThi/kptnDEFh+CvEUQ4qziNtMdVpPSaJNpmHoACb9WBV1bRnxjhLn/iCYlAukDCRo vaKQ48BSfRHF+r/sW0XyLrHQeKS0hSJsq7CA9ukeiAmImJLf2wJA3fWfKFp5J+tKvgkN JDeAEJJIaLPkST2lElMrry5HcoWZwpNix2gGlnfD4nfFZOGTLbYxqPEYUmvc8zi3dA74 soUOSkuce30Ar7ljv2HvcEUIHolrUMTxyTwxhi8NJ79yAH9B59uXcga/AsktJQ5wJ2MJ AKyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=V0DXeCnh9HhrADX+XgqelUhO7gy6X8yn1spfFru5JxI=; b=VdtTG8fsPjgGp0d/Ikzl3+tby7J9yj35ndb4YlHf1UlTuCbFjRdl24gCsxcjN8z4EO OMYExpk+/KNCN7paRECVvyGu+Gk0PXANT509ckB4BABLxBIrxANGXvE2j3Ba94VRqJUp y8Vay/aWzQsCCmyJJumooWml+Ns4IXXSkzaMLMvuNuY/vzFCS85n67gOrtreBinW5Tcq tX+y36q8r8i/CRXqiIVqvpBtBKZ1GbaRjLamJHQg/rKUxqdwOG0BaIlDSU7EaORsoOb9 rxKlNKGK/9huWuKrGM2MLfa1JNuDzKtLf0tppDMumT97nAdFYuwAZ+I7OXgjpxkesStx VbuA== X-Gm-Message-State: AOAM531/y8f7GQGyiwyF/XXBD+zI5POf9C0UXExNnTj1W+LQ+xRP3bRR EvbYpO5MQteucDWDw/k5MKWR+9TwXkffSQ== X-Google-Smtp-Source: ABdhPJwwJH8HIJMqyOkqyqEPgNysuJ2mfOI1L+nssX68O90m6bIacaYjn6eSFI1ifxeMIs9mkE59uw== X-Received: by 2002:a05:6808:1281:: with SMTP id a1mr15042979oiw.143.1622490697437; Mon, 31 May 2021 12:51:37 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id e29sm2990588oiy.53.2021.05.31.12.51.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 12:51:37 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Junio C Hamano , Elijah Newren , Brandon Williams , =?utf-8?q?Ren=C3=A9_Scharfe?= , Felipe Contreras Subject: [PATCH v2 07/13] push: trivial simplifications Date: Mon, 31 May 2021 14:51:18 -0500 Message-Id: <20210531195124.218325-8-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.rc0 In-Reply-To: <20210531195124.218325-1-felipe.contreras@gmail.com> References: <20210531193237.216726-1-felipe.contreras@gmail.com> <20210531195124.218325-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- builtin/push.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/builtin/push.c b/builtin/push.c index 933b1cc6c0..43c039a2e3 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -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; } From patchwork Mon May 31 19:51:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12289947 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C10E5C47082 for ; Mon, 31 May 2021 19:51:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A59ED60232 for ; Mon, 31 May 2021 19:51:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231678AbhEaTxi (ORCPT ); Mon, 31 May 2021 15:53:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231983AbhEaTx1 (ORCPT ); Mon, 31 May 2021 15:53:27 -0400 Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3EB5C06138C for ; Mon, 31 May 2021 12:51:39 -0700 (PDT) Received: by mail-ot1-x333.google.com with SMTP id i12-20020a05683033ecb02903346fa0f74dso12036949otu.10 for ; Mon, 31 May 2021 12:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BBv9Ocb3RpnLTQOyYiLEiqCMsnvb/2lKPrHee59KIfw=; b=Co4O2XkUOSwRXEFSuhdJNGaE1LnKOgMr0J1msObPmV/XGjFH9oL1RJRhIqMXoRvkxd UODZZ9yeb6EonK4uZw5dghtJNfjVV5WMRUZzRxXkcGCGcPe5ua1arZHUs6+Ur/sylu82 p32J3Tz85kCdG/XO8w+ebsTTeDE42241q3pMxe1hW55N81GjwEwn/JO8vb5Soap9Uccn rlMpRmGd7ahHERYJRUHpW3xcdfGKCl8mR1meO3QIN9Ot4MGvqECFzCMNMNGLmKH2tv4y Xngatwh/tWuctLDE/1w6iRRa3vTakvmIQbUlUyHSLOfreUKoSBB0BaQnkDbI5fKvieFh QXwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BBv9Ocb3RpnLTQOyYiLEiqCMsnvb/2lKPrHee59KIfw=; b=fwu+ihJODhJaIHl39PGu3dxo4GpTIbSg9e/TjpKErYbaQdz1Te176OsdlphTJCkBNb Eaaf8FTg8bHEnHRo7tmNqy2NTmHJPNL4iSoaXGodbAYMyA/kQHeTrA7Kv6zKzXBwBVok 5x2668VpMu6kUQWUntp3wZu1Zp6/kpFf7mLWd6GPBdQJL/YkaI3/1lfwYKJ6vVM4uKne kCf0AAg4ZCWqFdKaQeg9kyW6utBNPJ7SujG11MqDm2UgLvFycZGB/KrbNpDE2ZC7y9R/ Jm9gqrHHsFD81P2i+vDAIzXxsH0f/i7eL+Bu5lsANpJjyLLhChwVE/y/Ns5MmKJEmnex q8XQ== X-Gm-Message-State: AOAM531jTgD9uMz1ox1FPTBf3WOreH2JE0W/KNBE9Ym6G7hMuCWBSd5n vZQY+a4sFcpCibt1/V++QHxo73Lo8rEJOg== X-Google-Smtp-Source: ABdhPJxbXxbiLySOPmahGsZO2z/Vy7m5YUFDIbp0KA/mhWDGzwQ1HQY4haFPRMW9KKxV1Z5AXIDGLw== X-Received: by 2002:a9d:7747:: with SMTP id t7mr18668417otl.96.1622490699106; Mon, 31 May 2021 12:51:39 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id f13sm3391455ote.46.2021.05.31.12.51.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 12:51:38 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Junio C Hamano , Elijah Newren , Brandon Williams , =?utf-8?q?Ren=C3=A9_Scharfe?= , Felipe Contreras Subject: [PATCH v2 08/13] push: get rid of all the setup_push_* functions Date: Mon, 31 May 2021 14:51:19 -0500 Message-Id: <20210531195124.218325-9-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.rc0 In-Reply-To: <20210531195124.218325-1-felipe.contreras@gmail.com> References: <20210531193237.216726-1-felipe.contreras@gmail.com> <20210531195124.218325-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Their code is much simpler now and can move into the parent function. Signed-off-by: Felipe Contreras --- builtin/push.c | 38 +++++++++++--------------------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/builtin/push.c b/builtin/push.c index 43c039a2e3..da406fc890 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -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; } From patchwork Mon May 31 19:51:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12289965 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57E01C47083 for ; Mon, 31 May 2021 19:52:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 40EE4610A8 for ; Mon, 31 May 2021 19:52:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232245AbhEaTxn (ORCPT ); Mon, 31 May 2021 15:53:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231987AbhEaTx1 (ORCPT ); Mon, 31 May 2021 15:53:27 -0400 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5734FC06138D for ; Mon, 31 May 2021 12:51:41 -0700 (PDT) Received: by mail-ot1-x331.google.com with SMTP id c31-20020a056830349fb02903a5bfa6138bso5111504otu.7 for ; Mon, 31 May 2021 12:51:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=arkdH6h0iHEweocugnM6/TEXI4DmhTzrnJKQs8rHWos=; b=WOZTxPrtpmm7TBUWj/43WzzWEnlr5cdar2bENWA9Ozavn6pxNrtOkRh/7IbYlaP5OB Luz490rvHh6gJMGeXnbarRfQZGVUu/SjynfAYi5U0XuM9DLGBHTrISCN5JQ6iZi8GdMy aXE0PCwke1na75f20kjMGdZ3WnCAvnAcWLTuALfTqHYuuxMohCNow6mmKlHSLwsnwCCj SYfUEsx4iWDnqygsGJgrqymWCHgl19yTpv/0BTKjDLb0UEzkJ7Bhu68cpEbDwgipKSPM 5HSRVkDtmuKahWZIKz4vkPMcPhgWWwwo3QtFKUaQkkWNTgYBzgChGA6zEiTpz/sk4Eo7 3DZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=arkdH6h0iHEweocugnM6/TEXI4DmhTzrnJKQs8rHWos=; b=q4MSvRIqNv7wscJnAWdvvxdTKVAhT3j/IR6XArIyrdKtoSMmO2Whr9bG8mGyvCM1sR HBbxI3Kz2AD4BdxTmuuWQU2GUekCAeMgg2+YZXEV+IxcCPQlA5WlwadWnwpj1TWKUo8g evVBI9fQ7WUgf60VKRIeAQUmBUldQiQAXv6EZgHKSQh5vjdi6lhiGOKNGfItp22PX31W VzuF6c0hv81AEikWwMbvQqGp8xD/B8HRyPkjLc2SD5nOqmvi4mVc1fIqAPJDWtpWNg6y 6V33seXbR7jPmIeZMpNdjS7N795Ed3Fq085pyx9gVgUn6kb4+8j6+lOZjvjWigRYkqSf acBg== X-Gm-Message-State: AOAM5311KPDf3ZhjFQ+5Db9LtQB/4sm+eXpjcDf0zzZqElSBKc1cWy7+ 4dg/9fvoHnCZ7+QXo4unXgfTaLz6QJBK+A== X-Google-Smtp-Source: ABdhPJzCaGW35OLy7PFGmhNkE8/90T3aTYdBClgUqqiheYxXaiDAYlnASIuxhXPwXjV/6mCOvTq1Uw== X-Received: by 2002:a9d:51c7:: with SMTP id d7mr17549982oth.51.1622490700533; Mon, 31 May 2021 12:51:40 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id e83sm2949893oia.40.2021.05.31.12.51.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 12:51:40 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Junio C Hamano , Elijah Newren , Brandon Williams , =?utf-8?q?Ren=C3=A9_Scharfe?= , Felipe Contreras Subject: [PATCH v2 09/13] push: factor out the typical case Date: Mon, 31 May 2021 14:51:20 -0500 Message-Id: <20210531195124.218325-10-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.rc0 In-Reply-To: <20210531195124.218325-1-felipe.contreras@gmail.com> References: <20210531193237.216726-1-felipe.contreras@gmail.com> <20210531195124.218325-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Only override dst on the odd case. This allows a preemptive break on the `simple` case. Signed-off-by: Felipe Contreras --- builtin/push.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/builtin/push.c b/builtin/push.c index da406fc890..b5e951bf59 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -231,14 +231,16 @@ static void setup_default_push_refspecs(struct remote *remote) if (!branch) die(_(message_detached_head_die), remote->name); + dst = branch->refname; + switch (push_default) { default: case PUSH_DEFAULT_UNSPECIFIED: case PUSH_DEFAULT_SIMPLE: - if (same_remote) - if (strcmp(branch->refname, get_upstream_ref(branch, remote->name))) - die_push_simple(branch, remote); - dst = branch->refname; + if (!same_remote) + break; + if (strcmp(branch->refname, get_upstream_ref(branch, remote->name))) + die_push_simple(branch, remote); break; case PUSH_DEFAULT_UPSTREAM: @@ -251,7 +253,6 @@ static void setup_default_push_refspecs(struct remote *remote) break; case PUSH_DEFAULT_CURRENT: - dst = branch->refname; break; } From patchwork Mon May 31 19:51:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12289975 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD14FC47080 for ; Mon, 31 May 2021 19:52:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B3EED610A8 for ; Mon, 31 May 2021 19:52:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232382AbhEaTx6 (ORCPT ); Mon, 31 May 2021 15:53:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231673AbhEaTx2 (ORCPT ); Mon, 31 May 2021 15:53:28 -0400 Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BEB5C06138E for ; Mon, 31 May 2021 12:51:42 -0700 (PDT) Received: by mail-ot1-x32b.google.com with SMTP id i23-20020a9d68d70000b02902dc19ed4c15so12077747oto.0 for ; Mon, 31 May 2021 12:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=McPziOCQHzAjrbbNGE5pKs4zaSi25jfHamrn0TD08MA=; b=Sn0ymddCWYummtbIZRaQxguoYgjSNwOVuMCb3PxFfWT5CZWK/uOEmK8GYce+eSXas4 Fc7stV5Ei23JL2YiVmgFlVWr1iDffpovwgAWZbKBH1LxheCuTRaug3vCOVUyxnweTlff EmG6ZSDPQ1Ke9c1BwWvob/AkXLR4B97XSyoSkq+SKQ+YnAc1mtZ4N8VMSCgwvM7mTzpG 0W7XZ6PXT5pRdizQKrNlN44W3yy3u+QnQrpTLx8oR4FW9AGEZ4hQY107SiQER0kgYZ2R D/zCOLZ6Wa2FKCuJiup6CrOtrIRvXDWMkL1Wa0fUiHgX/FLy6DJkMZroZp5YLKC5de1/ E94g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=McPziOCQHzAjrbbNGE5pKs4zaSi25jfHamrn0TD08MA=; b=NzvlbAuCVhg/QzuUgmPflnWIpu6WhGzyGcaeNhnzNBDuPEB4gWj2+hxIyZjiKdhzXS z/JeEPC/VqU7Op7RPwwRM/l0gHxau0VGly17LzTxUOHbvwYPusT2uY+qAAt04byBCS5L DLhGPVFpCX3CW+lLg8Iy+rcAjAQjcWgjQVCTBkesuUA8fmywUAXf8QdZIgrI3ghnAll3 Xol2rOMPLoffmRC7Atbaq/MOtrKT01pjTo5rTNLd8jSXyvF1dLPWXXkyZ+5A160tBe6Q ofiEzHzB+C3JeDxGcTVd1foDej5oI3RKXAPoTYVLNvDQ6kOmqQ60KQAIAhT+vcZeAM4i P6rw== X-Gm-Message-State: AOAM5336FFvLHamNjmxJfnTFegjoRwhycnnx1HRhs5bYhu22kCZphRxL qqkMHYsdrpQGedUCE+84+lcogOdBx1R/IA== X-Google-Smtp-Source: ABdhPJwTMaqga7DiRx2aZUWBBQpPOfYaS9n1GmdF9LGgbJb9ZrUnrsgunFwL/U4EbWD+BedVwwnCuw== X-Received: by 2002:a05:6830:15c9:: with SMTP id j9mr17325124otr.73.1622490702056; Mon, 31 May 2021 12:51:42 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id z9sm2998790oog.25.2021.05.31.12.51.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 12:51:41 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Junio C Hamano , Elijah Newren , Brandon Williams , =?utf-8?q?Ren=C3=A9_Scharfe?= , Felipe Contreras Subject: [PATCH v2 10/13] push: remove redundant check Date: Mon, 31 May 2021 14:51:21 -0500 Message-Id: <20210531195124.218325-11-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.rc0 In-Reply-To: <20210531195124.218325-1-felipe.contreras@gmail.com> References: <20210531193237.216726-1-felipe.contreras@gmail.com> <20210531195124.218325-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org If fetch_remote is NULL (i.e. the branch remote is invalid), then it can't possibly be same as remote, which can't be NULL. The check is redundant, and so is the extra variable. Also, fix the Yoda condition: we want to check if remote is the same as the branch remote, not the other way around. Signed-off-by: Felipe Contreras --- builtin/push.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/builtin/push.c b/builtin/push.c index b5e951bf59..aa22d6a8e5 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -204,8 +204,7 @@ static const char *get_upstream_ref(struct branch *branch, const char *remote_na static int is_same_remote(struct remote *remote) { - struct remote *fetch_remote = remote_get(NULL); - return (!fetch_remote || fetch_remote == remote); + return remote == remote_get(NULL); } static void setup_default_push_refspecs(struct remote *remote) From patchwork Mon May 31 19:51:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12289969 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D22DFC47080 for ; Mon, 31 May 2021 19:52:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B7CD26127C for ; Mon, 31 May 2021 19:52:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232292AbhEaTxt (ORCPT ); Mon, 31 May 2021 15:53:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231624AbhEaTx2 (ORCPT ); Mon, 31 May 2021 15:53:28 -0400 Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8593BC06138F for ; Mon, 31 May 2021 12:51:44 -0700 (PDT) Received: by mail-oi1-x230.google.com with SMTP id b25so13301658oic.0 for ; Mon, 31 May 2021 12:51:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8XK9cpcF7wdu7UmhfR9mf1LNs8M7THc6tpxy3SzJQSU=; b=kDkjqaSWzOdf8tZatmyBFlfACTu33MpGblwj3UYh/TdJYyKE9nf4AIC1a1Dh6qszgj bW5fedPBEMpOhMt2A5k7wXOR7HnsE2tLyUaZbAh9uVXSYeTNAdlE3+cugm0FgeGBKPhr Y7DCJoKdyHl+ZwM5Bdk6FaZ2v/3qL8BYac1kE0j507T5ijTcP/Ki1FA7N6XRY6fUmDp9 0ZmJ9ZmF/eNBlmaH+yVncrD3dS/rx3sx/rKgMdspdiUtzF5PI3TyV2aS9RTienGp8eLa wFkD6pd6kOpCDTNmodvHvFB8BeAaHt4eQB71QHnyOdVVHcjytm5OfabVSC56V/lR2ZIZ Es9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8XK9cpcF7wdu7UmhfR9mf1LNs8M7THc6tpxy3SzJQSU=; b=aaxKkQBrz38uTmdPp1rdEAbQu2CByBeArBMHAHwlIu11YPHcz7LoLdwmUwiDBCh0gh gHPhJgdkSY4Yw9UuqL/uDZHjnvF32ULvcy07/vS6Tm3NPqrS9uaymvsH+mi4scWEejLq uyNpDcP7WGetLadXnlDcHHwLN9XJ5UT9gYj3SQaIowGcI0PFnUru6Y/hO9+9sWuMNlOO p/vC01WW8Fi23kHoQxyrT4FaCqBFzKW+sjgdDulKlDRnRf05hnRnFW4flYp8fLSfv0Aa +qPRAzUw5HDaRGX4GGPa1lob6uel6Ks31VbgHiDzZzp7dImCnnK/kN1eT46eFh+z23eX CNsw== X-Gm-Message-State: AOAM530Lc/fh9yTAFcn0Cd+9dpPNOv8VnYDfsXkLjAxA2SQrG2xjflu4 hoDWl+n+LguP6iyoSJGbs5sUno0Uo1Yhlw== X-Google-Smtp-Source: ABdhPJwYOU+I0qFxMKk1taQWnveI1iCxFipYO+lp+770pnVwFT4C7+/yEWCwi+kcnIAUUUtfWmslsg== X-Received: by 2002:aca:48f:: with SMTP id 137mr454525oie.75.1622490703709; Mon, 31 May 2021 12:51:43 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id m1sm3314170otq.12.2021.05.31.12.51.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 12:51:43 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Junio C Hamano , Elijah Newren , Brandon Williams , =?utf-8?q?Ren=C3=A9_Scharfe?= , Felipe Contreras Subject: [PATCH v2 11/13] push: remove trivial function Date: Mon, 31 May 2021 14:51:22 -0500 Message-Id: <20210531195124.218325-12-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.rc0 In-Reply-To: <20210531195124.218325-1-felipe.contreras@gmail.com> References: <20210531193237.216726-1-felipe.contreras@gmail.com> <20210531195124.218325-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org It's a single line that is used in a single place, and the variable has the same name as the function. Signed-off-by: Felipe Contreras --- builtin/push.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/builtin/push.c b/builtin/push.c index aa22d6a8e5..a873f8da92 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -202,15 +202,10 @@ static const char *get_upstream_ref(struct branch *branch, const char *remote_na return branch->merge[0]->src; } -static int is_same_remote(struct remote *remote) -{ - return remote == remote_get(NULL); -} - static void setup_default_push_refspecs(struct remote *remote) { struct branch *branch; - int same_remote = is_same_remote(remote); + int same_remote = remote == remote_get(NULL); const char *dst; switch (push_default) { From patchwork Mon May 31 19:51:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12289967 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2B5EC47080 for ; Mon, 31 May 2021 19:52:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9891F61057 for ; Mon, 31 May 2021 19:52:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232282AbhEaTxr (ORCPT ); Mon, 31 May 2021 15:53:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232046AbhEaTx2 (ORCPT ); Mon, 31 May 2021 15:53:28 -0400 Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF21CC061342 for ; Mon, 31 May 2021 12:51:45 -0700 (PDT) Received: by mail-ot1-x334.google.com with SMTP id 69-20020a9d0a4b0000b02902ed42f141e1so12051417otg.2 for ; Mon, 31 May 2021 12:51:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6URlOP1ONBZ6Vqo+XShekSQNy6aEwQTFBhGxFSlmDVY=; b=cGrG/oZgBME1ma4PSJ5AREeT63Hadn0meBRoEZxiAPCpOVL9r6PzvFnC3B1nEiDmIl 36IxjNuYZU6o/e96gNSqxKTy1UK2nm6guAYVsTvfNyukC/E7GTZn9rEMxReSO3oRnywx UDrwDonMNjvFopMLVzmfJmBorUPB0K7HbfrlHCU21nz2Ut2SKjbhNTAFY2jwROk2vLrC nG4vdW/44DKsjur6UZ4mg7zYQ4aX8yQYp3f+G6A1Gtckij5BeZeGz3kQYpTrADjOr+gk mz89zg9fyTyHwOnp4nMtfOPlkfDXjmQtWlk6OUXoKX267G0ry49rcobmd1QRtixE04gW Qp5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6URlOP1ONBZ6Vqo+XShekSQNy6aEwQTFBhGxFSlmDVY=; b=BU1jQnV3hQjTlBwlPotBH+xBt322OJ9Ul0wxJpJYepFNZGsShtqBwvvB8zFB6K0q5n vIxq1xYdP2UHSfjQDErq0QkF7ODNKQDszne+sxbYDsVjy/io8Tct8LzG2tjd945UaE6R G/6C3npjK4zbZzfTgw90PEeiZKh9xxp5IgeQTOfm8swgpEIJCD2UfA1a0f3PWeuBF4Ia 80zwN2iDKmApQ/1uUo2TXtREX7AKSur92ovtSB6i/fP6tmhvDsb8DDxFpRBYaDL5Sy6M GWGEmwZhD1rTfdd59gDuRY4VVqZgzPtEYB6e/PSrKgMXeS+kJHPz31zOaGPscqxHPqLv I/pw== X-Gm-Message-State: AOAM531G7reaKW42GyHyI1+DIalky4+zXuDTtPUaWDdiDVu2lmX1rxow xCkpj/yUNxDmv3jLI+Ghq0EdoJx9aFdvUw== X-Google-Smtp-Source: ABdhPJxMCkZjh2RaJgGISatlVNLd1Vd2M9pblEj1s7t/ZYxbIZEufWdb2Zb3S6Ht803kjar2F2b1cw== X-Received: by 2002:a05:6830:25d4:: with SMTP id d20mr3209687otu.83.1622490705160; Mon, 31 May 2021 12:51:45 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id q14sm3265785ota.31.2021.05.31.12.51.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 12:51:44 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Junio C Hamano , Elijah Newren , Brandon Williams , =?utf-8?q?Ren=C3=A9_Scharfe?= , Felipe Contreras Subject: [PATCH v2 12/13] push: only check same_remote when needed Date: Mon, 31 May 2021 14:51:23 -0500 Message-Id: <20210531195124.218325-13-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.rc0 In-Reply-To: <20210531195124.218325-1-felipe.contreras@gmail.com> References: <20210531193237.216726-1-felipe.contreras@gmail.com> <20210531195124.218325-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- builtin/push.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builtin/push.c b/builtin/push.c index a873f8da92..f3916c66d1 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -205,8 +205,8 @@ static const char *get_upstream_ref(struct branch *branch, const char *remote_na static void setup_default_push_refspecs(struct remote *remote) { struct branch *branch; - int same_remote = remote == remote_get(NULL); const char *dst; + int same_remote; switch (push_default) { case PUSH_DEFAULT_MATCHING: @@ -226,6 +226,7 @@ static void setup_default_push_refspecs(struct remote *remote) die(_(message_detached_head_die), remote->name); dst = branch->refname; + same_remote = remote == remote_get(NULL); switch (push_default) { default: From patchwork Mon May 31 19:51:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12289973 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65106C47080 for ; Mon, 31 May 2021 19:52:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4A97261057 for ; Mon, 31 May 2021 19:52:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232358AbhEaTxz (ORCPT ); Mon, 31 May 2021 15:53:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230523AbhEaTx2 (ORCPT ); Mon, 31 May 2021 15:53:28 -0400 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A22DC061574 for ; Mon, 31 May 2021 12:51:47 -0700 (PDT) Received: by mail-oi1-x22d.google.com with SMTP id v22so13271143oic.2 for ; Mon, 31 May 2021 12:51:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6hhxrYUF9xXALnAcO6sx0a9D+jTam16Q7fRpD20psQI=; b=YpwPS9MNpcDc+Rjry165KwXh8+jcF0jtyp/2zYD2L7x798Fe7RieroRBmpoxGpXB9O DbS+QFk7hD2IieCQ1grR3xWfaBmL2CvwoI+ZQHWnjLqGCG4x2d1HtsZt81lUdUpV1geh +GAkSha6YWhpsCy8lr2xNTRewbkinVRUnbYZPzP5e7p231eegTVvvJRfVJLmcOSHDcfl JHWaYSqhRmiwgKV7dBAJRz2tsctkgATieIDXiKVUmy4cmW/XwMZtpLcTGcl2W40ovtOT qNMB6L68uHuQdUVIr9GbdCKjQmH54RPeLh9s9ZHo6UOiJ/lY8wN6qX735p8w51PJn4gZ o6jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6hhxrYUF9xXALnAcO6sx0a9D+jTam16Q7fRpD20psQI=; b=SFBckXftvCrVnTagqcGunx0h0LP5Ya2y/NdWFxpgy4gOThSkkAvdCu28R8N3vTmSvi TPrOLnuEzXkXh2oK0+U3eNGCqZgBaSeBY0awqHgPXz+tjQLFYRDV+SHZR73QCiQoWDCA CKTxg8LazDkOAej8cgrLl5tgSFJqBulhTfT8Oje/oLYdfcfoqEeNJ8xouy4v0PPPsS6S t0W6ss6KSoyjzT9MKhhWPV6L0KjCdPSdn73gNulQPEoEXSMaoy6q4Xn5VqJ/KUbci3ye GCvDJ7gUGKDTEvIhChUURm35xDU41qwDW6LBycTPs7qOS698DlOgKBMq2bhjTnbEl3vi ihjA== X-Gm-Message-State: AOAM533Lje3Cxcy3ml5zInOLdzjyeafUwLhJTLHCvkShHnkt2DmI8IQn Y6PW19U10xiNdPdcCm8Mt9dX4HWCDWAz9Q== X-Google-Smtp-Source: ABdhPJwxPm6o9qm8OPEJKXSsplcthegwFOHm/SlL9zr4TmjbgD86BiUR/kG3h/EhluWFgFA6c3z7bw== X-Received: by 2002:aca:ac13:: with SMTP id v19mr5358346oie.128.1622490706778; Mon, 31 May 2021 12:51:46 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id e22sm3223137otl.74.2021.05.31.12.51.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 12:51:46 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Junio C Hamano , Elijah Newren , Brandon Williams , =?utf-8?q?Ren=C3=A9_Scharfe?= , Felipe Contreras Subject: [PATCH v2 13/13] push: don't get a full remote object Date: Mon, 31 May 2021 14:51:24 -0500 Message-Id: <20210531195124.218325-14-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.rc0 In-Reply-To: <20210531195124.218325-1-felipe.contreras@gmail.com> References: <20210531193237.216726-1-felipe.contreras@gmail.com> <20210531195124.218325-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org All we need to know is that their names are the same. Additionally this might be easier to parse for some since remote_for_branch is more descriptive than remote_get(NULL). Signed-off-by: Felipe Contreras --- builtin/push.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/push.c b/builtin/push.c index f3916c66d1..e8b10a9b7e 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -226,7 +226,7 @@ static void setup_default_push_refspecs(struct remote *remote) die(_(message_detached_head_die), remote->name); dst = branch->refname; - same_remote = remote == remote_get(NULL); + same_remote = !strcmp(remote->name, remote_for_branch(branch, NULL)); switch (push_default) { default: