From patchwork Fri Oct 26 19:27:31 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: 10657773 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 011BE14BD for ; Fri, 26 Oct 2018 19:28:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6BA8286F9 for ; Fri, 26 Oct 2018 19:28:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DAFC62C748; Fri, 26 Oct 2018 19:28:03 +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 81667286F9 for ; Fri, 26 Oct 2018 19:28:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727851AbeJ0EGS (ORCPT ); Sat, 27 Oct 2018 00:06:18 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:44271 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726481AbeJ0EGK (ORCPT ); Sat, 27 Oct 2018 00:06:10 -0400 Received: by mail-wr1-f66.google.com with SMTP id d17-v6so2128317wre.11 for ; Fri, 26 Oct 2018 12:27: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=m8uKsA8NO0fr26TkXK5TqU2QYhmOKbVQmuurpcJ16X0=; b=GULAY+Y2Ddm4MH8e99tJJ13kgfcpB6pC2B/P8Hl3qM5w4CcsdEsFOjYZpBUjQlmK15 Ok4rQ5XLmq3QoL+nAUbx70doDpTT7lkajh9xR3+C7pkg1IhYewOFid2TQbc/0uqqo8Al gx/AXI/+RHveILdP5svsd1Mu4YWdtX6mKVz6Do/dZtgQRyU6k1wpDarX89lE8TkrTcZo GU0YGNlY1kizZ/jIXmMdbwNEVRNGqIVe4gKEb4UyHvJ2N2iBQIrS4MG0OKxNPRRSCPHb lzs8YONEYEzgXrbNHHTEIsU5RAmvjzfg7EgDF7AUpgrBLJbmgwzUFhyULTy13iUnhJTq ZD2Q== 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=m8uKsA8NO0fr26TkXK5TqU2QYhmOKbVQmuurpcJ16X0=; b=c/JfOacgZJf/WkH7Dx/YDBSXUtD6wK1vlOUkm3RM2r8xXho2BAN4qjOsdZUUY8Gri1 JvzwSADPQbezRut66cJ/wCEb/Jt0RInA+zhLGWVdQXFSfhMwYXOVjscTEiD/2E1GwXkd n41kloBz5oOW73qntsR37O1JRrGsRy1r3h/CQldeD2sd6132OeeV5kEY/In8oQSCnvTa yYTuA4fz2fMb7hPxOxr25djSQMwk5q6NOOSiki0zMwYAT5Xs2k6Zo+g0n73sGCYsTbx6 iTOE0LhLTXolvQBtVvQKBGHURsWDy6OQCrwrs/Q2+1UchOE2FWUyzXHImBrAF/kJLNQN aXiA== X-Gm-Message-State: AGRZ1gJ04XzUa8QKZejqcj/I1tys1HaRixsV6Hx0GuiEr+WM8+2v7C0z qsJm5ymfIvfcb+v4YVeS+Ix6V5HOJ3c= X-Google-Smtp-Source: AJdET5e20smZyDv8vJ0AcBMEvJaRD6nHOwqVgjzZiz5GrovSb1wazx6TUJVEu4Xud1nadEXbWKFY3Q== X-Received: by 2002:a5d:4911:: with SMTP id x17-v6mr6759320wrq.272.1540582071357; Fri, 26 Oct 2018 12:27:51 -0700 (PDT) Received: from u.nix.is ([2a01:4f8:190:5095::2]) by smtp.gmail.com with ESMTPSA id e196-v6sm10738981wmf.43.2018.10.26.12.27.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Oct 2018 12:27:50 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 4/7] push: move unqualified refname error into a function Date: Fri, 26 Oct 2018 19:27:31 +0000 Message-Id: <20181026192734.9609-5-avarab@gmail.com> X-Mailer: git-send-email 2.19.1.759.g500967bb5e In-Reply-To: References: 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 A follow-up change will extend this error message with the advice facility. Doing so would make the indentation too deeply nested for comfort. So let's split this into a helper function. There's no changes to the wording here. Just code moving & re-indentation, and re-flowing the "TRANSLATORS" comment. Signed-off-by: Ævar Arnfjörð Bjarmason --- remote.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/remote.c b/remote.c index f4b438ff74..c7a0b9c46f 100644 --- a/remote.c +++ b/remote.c @@ -1005,6 +1005,26 @@ static int match_explicit_lhs(struct ref *src, } } +static void show_push_unqualified_ref_name_error(const char *dst_value, + const char *matched_src_name) +{ + /* + * TRANSLATORS: "matches '%s'%" is the part of "git push + * :" push, and "being pushed ('%s')" is + * the . + */ + error(_("The destination you provided is not a full refname (i.e.,\n" + "starting with \"refs/\"). We tried to guess what you meant by:\n" + "\n" + "- Looking for a ref that matches '%s' on the remote side.\n" + "- Checking if the being pushed ('%s')\n" + " is a ref in \"refs/{heads,tags}/\". If so we add a corresponding\n" + " refs/{heads,tags}/ prefix on the remote side.\n" + "\n" + "Neither worked, so we gave up. You must fully-qualify the ref."), + dst_value, matched_src_name); +} + static int match_explicit(struct ref *src, struct ref *dst, struct ref ***dst_tail, struct refspec_item *rs) @@ -1049,22 +1069,8 @@ static int match_explicit(struct ref *src, struct ref *dst, matched_dst = make_linked_ref(dst_guess, dst_tail); free(dst_guess); } else { - /* - * TRANSLATORS: "matches '%s'%" is the - * part of "git push :" - * push, and "being pushed ('%s')" is the - * . - */ - error(_("The destination you provided is not a full refname (i.e.,\n" - "starting with \"refs/\"). We tried to guess what you meant by:\n" - "\n" - "- Looking for a ref that matches '%s' on the remote side.\n" - "- Checking if the being pushed ('%s')\n" - " is a ref in \"refs/{heads,tags}/\". If so we add a corresponding\n" - " refs/{heads,tags}/ prefix on the remote side.\n" - "\n" - "Neither worked, so we gave up. You must fully-qualify the ref."), - dst_value, matched_src->name); + show_push_unqualified_ref_name_error(dst_value, + matched_src->name); } break; default: