From patchwork Fri Oct 26 23:07:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 10657953 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7C54F13B5 for ; Fri, 26 Oct 2018 23:07:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7203A2C52D for ; Fri, 26 Oct 2018 23:07:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 662FD2CA40; Fri, 26 Oct 2018 23:07:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A97A2C52D for ; Fri, 26 Oct 2018 23:07:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728315AbeJ0Hqt (ORCPT ); Sat, 27 Oct 2018 03:46:49 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:41443 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727792AbeJ0Hqt (ORCPT ); Sat, 27 Oct 2018 03:46:49 -0400 Received: by mail-wr1-f68.google.com with SMTP id x12-v6so2809221wrw.8 for ; Fri, 26 Oct 2018 16:07:52 -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=Dhyh0a5Q4ZaOv+jNYAXOVcm28D6ttv4dilrANYN3DFU=; b=nqJcBpVbjCI4nTheZ+nrAwUzJ6Njbqnk7A3EwD2WeK65DJHJkw1gaIaZ9TCMKXs1My w0fhOgvzJLQL4Ye7Jr2SHb9ITPd/pB+1ZuHhF0DMnRah4yBINAbqx4fHScnK7i+Qkp38 8UwzEGbLIQT3bg0ekrbyX/xp5JYOqBTt9ggGHX3LNQOwD1hCamAxiHRlPJudp9gQRyV7 H/Pr8ney5A305W1v9iPV9rAkZZKUL4D6Xl8XJBpuDDaI5ZIDocOLylwcwAK8kE0oUEnb cvqjMjzbbHiWju1h8tprAVvmaNDsQWWetvx07Pdh/OZQd4lrJENmWhg8cVPjTAwgaGmf 3xTg== 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=Dhyh0a5Q4ZaOv+jNYAXOVcm28D6ttv4dilrANYN3DFU=; b=FSaJ20UJs2S2VJRRyNAwvJzIh12AF0C+y1yD4d6XQm3YIUJQm8uV4iT2FHCwaG6slw ITHkygp1HwRsa96Q2mjethUyxYnH8mV+IjGztXUUPkAt8HPVT0jcCMR0yP1cj/9CcooC OUa2924t6M5Llg3JC3hQwlUaxVorzAbVqfwf/s7VKQjJPRCoRpnCdsJui+ER8glZ+Bw7 /fbfeE3XK2mGNWA/kj0HdLUb7D6ldnY4hkO6jnhfoHeReedn4q0o0UvDb6/gxK3V6bxk k5viYn+JzbOqkMyDZVr0xI+xvO1LYkHN0YiT7SSLBYJVbVqUk4UZazh8n47EMLSykI3b 9ZDQ== X-Gm-Message-State: AGRZ1gKPNdO29uSUr4NTdKDKX0pAJ4XrNEEzRceg4qs/FP4cC24/Grgv Vhc9k96F7Cj16Xv780ZAmizxZ7duzpA= X-Google-Smtp-Source: AJdET5cGxlaAluiBGNCGkPaKGxw4qMtgKCr9aHGwkmvTr6zISoc14NRHsVSfSdHCL3cdUQ90O34i0g== X-Received: by 2002:adf:e28d:: with SMTP id v13-v6mr6712263wri.139.1540595271217; Fri, 26 Oct 2018 16:07:51 -0700 (PDT) Received: from u.nix.is ([2a01:4f8:190:5095::2]) by smtp.gmail.com with ESMTPSA id 4-v6sm5632830wmt.16.2018.10.26.16.07.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Oct 2018 16:07:50 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Stefan Beller , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v3 1/8] remote.c: add braces in anticipation of a follow-up change Date: Fri, 26 Oct 2018 23:07:34 +0000 Message-Id: <20181026230741.23321-2-avarab@gmail.com> X-Mailer: git-send-email 2.19.1.759.g500967bb5e In-Reply-To: <20181026192734.9609-1-avarab@gmail.com> References: <20181026192734.9609-1-avarab@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The CodingGuidelines say "When there are multiple arms to a conditional and some of them require braces, enclose even a single line block in braces for consistency.". Fix the code in match_explicit() to conform. While I'm at it change the if/else if/else in guess_ref() to use braces. This is not currently needed, but a follow-up change will add a new multi-line condition to that logic. Signed-off-by: Ævar Arnfjörð Bjarmason --- remote.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/remote.c b/remote.c index 81f4f01b00..18cae48daa 100644 --- a/remote.c +++ b/remote.c @@ -968,12 +968,13 @@ static char *guess_ref(const char *name, struct ref *peer) if (!r) return NULL; - if (starts_with(r, "refs/heads/")) + if (starts_with(r, "refs/heads/")) { strbuf_addstr(&buf, "refs/heads/"); - else if (starts_with(r, "refs/tags/")) + } else if (starts_with(r, "refs/tags/")) { strbuf_addstr(&buf, "refs/tags/"); - else + } else { return NULL; + } strbuf_addstr(&buf, name); return strbuf_detach(&buf, NULL); @@ -1038,21 +1039,22 @@ static int match_explicit(struct ref *src, struct ref *dst, case 1: break; case 0: - if (starts_with(dst_value, "refs/")) + if (starts_with(dst_value, "refs/")) { matched_dst = make_linked_ref(dst_value, dst_tail); - else if (is_null_oid(&matched_src->new_oid)) + } else if (is_null_oid(&matched_src->new_oid)) { error("unable to delete '%s': remote ref does not exist", dst_value); - else if ((dst_guess = guess_ref(dst_value, matched_src))) { + } else if ((dst_guess = guess_ref(dst_value, matched_src))) { matched_dst = make_linked_ref(dst_guess, dst_tail); free(dst_guess); - } else + } else { error("unable to push to unqualified destination: %s\n" "The destination refspec neither matches an " "existing ref on the remote nor\n" "begins with refs/, and we are unable to " "guess a prefix based on the source ref.", dst_value); + } break; default: matched_dst = NULL;