From patchwork Fri Oct 26 19:27:28 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: 10657761 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 E1F1817DE for ; Fri, 26 Oct 2018 19:27:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3B35286F9 for ; Fri, 26 Oct 2018 19:27:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7F3B2C748; Fri, 26 Oct 2018 19:27:49 +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 6F9B9286F9 for ; Fri, 26 Oct 2018 19:27:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726160AbeJ0EGE (ORCPT ); Sat, 27 Oct 2018 00:06:04 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:44263 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725783AbeJ0EGE (ORCPT ); Sat, 27 Oct 2018 00:06:04 -0400 Received: by mail-wr1-f66.google.com with SMTP id d17-v6so2128120wre.11 for ; Fri, 26 Oct 2018 12:27:46 -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=vTMmoG0D8SHnPNueuWFjJ3URVzlKLoryBE3Ot8ggUcMTOU6ecTJimc91FZs2q552R5 QRzik3CGa/j0usWbU3KjtVbTfmTqUbBo/JhPhqwHrPx1/mHGfABMfN5B/OBYOJjI7tdk 1U5uQNCjIjYZtPwXrYMYDvpScfqNOQNhslvK53qUUXGKj/Huh7vlWhxR4NINDSTWDJdX vBwCrJXepdxq6S2S5KfTh+ZNaSj9LCXx08uTLaKqOLW7HHr294PTQJzoLooGZ+bnlfp5 7e1tdTwmX5oZkwis24nmszDi3kHQWhASzhcWhucwzkbmmIcuwVJAnRO/O+O2o6FnY3yo H41g== 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=SEEahIXifIQC9dI3f4bXaKRWPlNQGjaq5kYkxnFj6hbGH9B+vzBQuMdg6OFN3ZH61o lLpWGvOvERJN+41Nz58jmty+TF9JZXPv9VeuoQ6F2gqsizWT6MyUg2K2IBiAwCSQZaar 22IX6yA5GN4SgEn9C+o323dUi5VpZQ2C7YnsXxrni9Wi6UVddViM5xBOHSEvJfuB9SQC 9v//WorUFdLEFPXkoTYjiuvue0+ggW9/QbNoApaQ8S9Qu/45jIiwyvSFVSTtE6p1SMdM +TEpXKSdG6/4elavf4lKQyXyAFALWY4JdizvUvJkmqJ8CUpFkmI+7tzB+qo+9LVdadpU 9kXw== X-Gm-Message-State: AGRZ1gIgPTkHVhOS+vlBEuGqw07D8c2976fkjbkv5IZgxc2D9dhTJsVj HlIT25466ajWPGQmYVgvX3/PNOhv X-Google-Smtp-Source: AJdET5fQo7wgaYQq9nPpRHEMZU76Mmw5ratUiRIXOEtcy24HaFznBxCm6W7Cjd+vwjmaH3nf4+cBtA== X-Received: by 2002:adf:83a4:: with SMTP id 33-v6mr6664118wre.13.1540582065755; Fri, 26 Oct 2018 12:27:45 -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.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Oct 2018 12:27:45 -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 1/7] remote.c: add braces in anticipation of a follow-up change Date: Fri, 26 Oct 2018 19:27:28 +0000 Message-Id: <20181026192734.9609-2-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 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; From patchwork Fri Oct 26 19:27:29 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: 10657763 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 CA29B109C for ; Fri, 26 Oct 2018 19:27:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAC56286F9 for ; Fri, 26 Oct 2018 19:27:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF1842CAF8; Fri, 26 Oct 2018 19:27:51 +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 2CAF9286F9 for ; Fri, 26 Oct 2018 19:27:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726441AbeJ0EGG (ORCPT ); Sat, 27 Oct 2018 00:06:06 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:41935 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725783AbeJ0EGG (ORCPT ); Sat, 27 Oct 2018 00:06:06 -0400 Received: by mail-wr1-f66.google.com with SMTP id x12-v6so2413220wrw.8 for ; Fri, 26 Oct 2018 12:27:48 -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=FVbnz0Oev/BCJSo2JozdSuJMl92t8hwHSpsWz1qmayQ=; b=GlIO2NTgxKUvyv2vl00roQ2s49/D9zKrofe453xLxKAoSnCJAYZ7himKsakUdWvPUl 1WQPNsNSSe17LXxir2ZGZtd4US8rAKgdS5+Baol+FG0RAKZFR30hebnDVLZzlz4IE7LE GqphJw5+2hZBLd6xQXYVMBBdz//B1VLIakmxuhTnYzD/W/Nl9pHhr0DbqnvC1M7XSLDA zJvdMZ0babIvGDHTNajdjfjaHGd0S9AvUoqCyDj5mxynL1n9GbZuMm2gRFUF9tEXTPTn BRJMGf2rqPsl99LC0X+cro5l/AADc7vV9PKekinlY2BhfLuCuO+rw7S6dj8YmwHWRqsR Q9Sw== 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=FVbnz0Oev/BCJSo2JozdSuJMl92t8hwHSpsWz1qmayQ=; b=gJ7EtEWg7j0Ll4jgDF0RuAyi89cghkNv9Cn6dk7vF2MZayaJzY7hF6lgYocm5guSu3 FnOHWcB6mcOSjAK+P6vVcuyoGN7NoHpeyiA9F979Jjwu97Yyi7vxBy90tEoL9pk4KLJS CUECxmVMzPrG5GaMdcSQWkByYcvjcZsAR403mENCxttLKJfRlsvgcqNMgcXqTnSImLHp 8RWCacjwOuowcul/B6R/GBDmce11QL3o1lL1t3oeYoSdfVAWdahJduF/PwXXkPfh8pQN kGg1Oh7dppAezaO/07KLTSVjlzqR0sVRgb0BV5Y6fGEWT59054qRVl54O3efYf2TetLL mt2A== X-Gm-Message-State: AGRZ1gJ3tATo3yqFrAFk/wfQK8fwwIHhk1CNTPA0WWhmzylnjLIdy3nk 5yL1Fa6EZLXB8y1kSdH6dKgauznx X-Google-Smtp-Source: AJdET5eITjwJq5vrB3vzpXh2kai8l+5Vx2u1G0bkVAHoaJb0mMFeNBZBiCQU6/Hg5qFNo7e8CyhXbw== X-Received: by 2002:a5d:6a05:: with SMTP id m5-v6mr4420837wru.5.1540582067245; Fri, 26 Oct 2018 12:27:47 -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.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Oct 2018 12:27:46 -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 2/7] i18n: remote.c: mark error(...) messages for translation Date: Fri, 26 Oct 2018 19:27:29 +0000 Message-Id: <20181026192734.9609-3-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 Mark up the error(...) messages in remote.c for translation. The likes of "unable to push to unqualified destination" are relatively big parts of the UI, i.e. error messages shown when "git push" fails. I don't think any of these are plumbing, an the entire test suite passes when running the tests with GIT_GETTEXT_POISON=1 (after building with GETTEXT_POISON). Signed-off-by: Ævar Arnfjörð Bjarmason --- remote.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/remote.c b/remote.c index 18cae48daa..5cb3d00bfb 100644 --- a/remote.c +++ b/remote.c @@ -406,7 +406,7 @@ static int handle_config(const char *key, const char *value, void *cb) if (!remote->receivepack) remote->receivepack = v; else - error("more than one receivepack given, using the first"); + error(_("more than one receivepack given, using the first")); } else if (!strcmp(subkey, "uploadpack")) { const char *v; if (git_config_string(&v, key, value)) @@ -414,7 +414,7 @@ static int handle_config(const char *key, const char *value, void *cb) if (!remote->uploadpack) remote->uploadpack = v; else - error("more than one uploadpack given, using the first"); + error(_("more than one uploadpack given, using the first")); } else if (!strcmp(subkey, "tagopt")) { if (!strcmp(value, "--no-tags")) remote->fetch_tags = -1; @@ -707,7 +707,7 @@ static void query_refspecs_multiple(struct refspec *rs, int find_src = !query->src; if (find_src && !query->dst) - error("query_refspecs_multiple: need either src or dst"); + error(_("query_refspecs_multiple: need either src or dst")); for (i = 0; i < rs->nr; i++) { struct refspec_item *refspec = &rs->items[i]; @@ -735,7 +735,7 @@ int query_refspecs(struct refspec *rs, struct refspec_item *query) char **result = find_src ? &query->src : &query->dst; if (find_src && !query->dst) - return error("query_refspecs: need either src or dst"); + return error(_("query_refspecs: need either src or dst")); for (i = 0; i < rs->nr; i++) { struct refspec_item *refspec = &rs->items[i]; @@ -996,12 +996,12 @@ static int match_explicit_lhs(struct ref *src, * way to delete 'other' ref at the remote end. */ if (try_explicit_object_name(rs->src, match) < 0) - return error("src refspec %s does not match any.", rs->src); + return error(_("src refspec %s does not match any."), rs->src); if (allocated_match) *allocated_match = 1; return 0; default: - return error("src refspec %s matches more than one.", rs->src); + return error(_("src refspec %s matches more than one."), rs->src); } } @@ -1041,32 +1041,33 @@ static int match_explicit(struct ref *src, struct ref *dst, case 0: if (starts_with(dst_value, "refs/")) { matched_dst = make_linked_ref(dst_value, dst_tail); + } else if (is_null_oid(&matched_src->new_oid)) { - error("unable to delete '%s': remote ref does not exist", + error(_("unable to delete '%s': remote ref does not exist"), dst_value); } else if ((dst_guess = guess_ref(dst_value, matched_src))) { matched_dst = make_linked_ref(dst_guess, dst_tail); free(dst_guess); } 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.", + 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; - error("dst refspec %s matches more than one.", + error(_("dst refspec %s matches more than one."), dst_value); break; } if (!matched_dst) return -1; if (matched_dst->peer_ref) - return error("dst ref %s receives from more than one src.", - matched_dst->name); + return error(_("dst ref %s receives from more than one src."), + matched_dst->name); else { matched_dst->peer_ref = allocated_src ? matched_src : @@ -1765,7 +1766,7 @@ int get_fetch_map(const struct ref *remote_refs, if (!starts_with((*rmp)->peer_ref->name, "refs/") || check_refname_format((*rmp)->peer_ref->name, 0)) { struct ref *ignore = *rmp; - error("* Ignoring funny ref '%s' locally", + error(_("* Ignoring funny ref '%s' locally"), (*rmp)->peer_ref->name); *rmp = (*rmp)->next; free(ignore->peer_ref); @@ -2133,7 +2134,7 @@ static int parse_push_cas_option(struct push_cas_option *cas, const char *arg, i else if (!colon[1]) oidclr(&entry->expect); else if (get_oid(colon + 1, &entry->expect)) - return error("cannot parse expected object name '%s'", colon + 1); + return error(_("cannot parse expected object name '%s'"), colon + 1); return 0; } From patchwork Fri Oct 26 19:27:30 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: 10657765 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 CFCAC109C for ; Fri, 26 Oct 2018 19:27:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFE72286F9 for ; Fri, 26 Oct 2018 19:27:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B39072C748; Fri, 26 Oct 2018 19:27:54 +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 45E7B286F9 for ; Fri, 26 Oct 2018 19:27:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726565AbeJ0EGJ (ORCPT ); Sat, 27 Oct 2018 00:06:09 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:54498 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725783AbeJ0EGJ (ORCPT ); Sat, 27 Oct 2018 00:06:09 -0400 Received: by mail-wm1-f68.google.com with SMTP id r63-v6so2507791wma.4 for ; Fri, 26 Oct 2018 12:27:51 -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=nSBuV7n+g9YowbXSlk6MUzDeKG/laSjqkg8wOl9aOJo=; b=YDdzwoQRp9pgiuRY5y3JJy5n6sWu9XaVOzdzW2Em1E3U1GTSamZPz/l60XU7P1iJS4 qrJUyWQyye/jb301DV+AVfwc1a0ddWbyqqBalB5Y5NocAx10KD4P/6uCxi/piRoJa4gl 6a/lRMs7luMW6WjsDS1o0bfTKk6yKJ3hcmL0KBUciLtMmT2PEP2iqIpIf8pJ1WxRfIhP bWAxIte9TOC+GcBkHckyT/JqczJu/t9ZjbllrgNim4vrQxoqY3hVoVrIBaGvJF5sevDx PgpEPAoosxJqSeUIcqdYMKgrrHSPPI6vW52OTj40DTueDHCukdcs90JmNlodLys24aE2 gmEQ== 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=nSBuV7n+g9YowbXSlk6MUzDeKG/laSjqkg8wOl9aOJo=; b=oPg8ZOZtMuj1ui8bham62himE2ArVkK3lCX8Nu1FsOuQJdOcAPHPsnhqZQIrmKHI20 Y96UvkxC3fABEuCwBNxgACzlQ+BjlvT25nZrRNfzAK0j76OCF0wKtUCxa7X0dg6CiJNu /ln+rZbaYTTgc3RGC4HSSuY877Cq0vBbv6LRRr0zI7El8SmyaPTngI0efpQSjrY0SP/U NsV3ZkfQYK+GxNilqglyY9J+gXd2dwkuxIDXwf5hdE0Ayj8HbsNW2KKTOobtg3//0Gc8 t+8rLtGGhnc3SfzZwtxqNvMQC0iaqUUcBDMaA825SOpw7z8TX4AMoiqFXRb0cM+wcD0p va4A== X-Gm-Message-State: AGRZ1gKxCWLSaIZV0wwOezJsQWEWjcvwulauNwmUjk9kW1gWb4MJUWPk kK6Vd9haCCvMmrkhF21+M/EzTODr X-Google-Smtp-Source: AJdET5c2CratzpIt53Cm2SSgjfCYJvQk+1yuKY7dsixGTXZfLzTVFc7y2x5ui3iy4wBdII+NDtgsbQ== X-Received: by 2002:a1c:7c16:: with SMTP id x22-v6mr6264096wmc.16.1540582069851; Fri, 26 Oct 2018 12:27:49 -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.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Oct 2018 12:27:49 -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 3/7] push: improve the error shown on unqualified push Date: Fri, 26 Oct 2018 19:27:30 +0000 Message-Id: <20181026192734.9609-4-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 Improve the error message added in f8aae12034 ("push: allow unqualified dest refspecs to DWIM", 2008-04-23), which before this change looks like this: $ git push avar v2.19.0^{commit}:newbranch -n error: unable to push to unqualified destination: newbranch The destination refspec neither matches an existing ref on the remote nor begins with refs/, and we are unable to guess a prefix based on the source ref. error: failed to push some refs to 'git@github.com:avar/git.git' This message needed to be read very carefully to spot how to fix the error, i.e. to push to refs/heads/newbranch. Now the message will look like this instead: $ ./git-push avar v2.19.0^{commit}:newbranch -n error: The destination you provided is not a full refname (i.e., starting with "refs/"). We tried to guess what you meant by: - Looking for a ref that matches 'newbranch' on the remote side. - Checking if the being pushed ('v2.19.0^{commit}') is a ref in "refs/{heads,tags}/". If so we add a corresponding refs/{heads,tags}/ prefix on the remote side. Neither worked, so we gave up. You must fully-qualify the ref. error: failed to push some refs to 'git@github.com:avar/git.git' This improvement is the result of on-list discussion in [1] and [2], as well as my own fixes / reformatting / phrasing on top. The suggestion by Jeff on-list was to make that second bullet point "Looking at the refname of the local source.". The version being added here is more verbose, but also more accurate. saying "local source" could refer to any ref in the local refstore, including something in refs/remotes/*. A later change will teach guess_ref() to infer a ref type from remote-tracking refs, so let's not confuse the two. While I'm at it, add a "TRANSLATORS" comment since the message has gotten more complex and it's not as clear what the two %s's refer to. 1. https://public-inbox.org/git/20181010205505.GB12949@sigill.intra.peff.net/ 2. https://public-inbox.org/git/xmqqbm81lb7c.fsf@gitster-ct.c.googlers.com/ Signed-off-by: Ævar Arnfjörð Bjarmason --- remote.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/remote.c b/remote.c index 5cb3d00bfb..f4b438ff74 100644 --- a/remote.c +++ b/remote.c @@ -1049,12 +1049,22 @@ static int match_explicit(struct ref *src, struct ref *dst, matched_dst = make_linked_ref(dst_guess, dst_tail); free(dst_guess); } 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); + /* + * 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); } break; default: 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: From patchwork Fri Oct 26 19:27:32 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: 10657769 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 B94CB14BD for ; Fri, 26 Oct 2018 19:28:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9EDD286F9 for ; Fri, 26 Oct 2018 19:28:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E5DB2C748; Fri, 26 Oct 2018 19:28:00 +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 E674A286F9 for ; Fri, 26 Oct 2018 19:27:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727829AbeJ0EGN (ORCPT ); Sat, 27 Oct 2018 00:06:13 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:42020 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726483AbeJ0EGM (ORCPT ); Sat, 27 Oct 2018 00:06:12 -0400 Received: by mail-wr1-f65.google.com with SMTP id y15-v6so2419049wru.9 for ; Fri, 26 Oct 2018 12:27:54 -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=LmFniehSpk6gcVQPXv2vS9z/weRkPike207dYgdf85k=; b=Uiz+0F6DDGtI/RlzXnyNHJUQfEYV4BiipFYMCjRRlfGBsrBujB9D8KD57Oh69v5mV3 +5pDyu9QVV5f9Bux5SOeHk7facsNes07yhdop2FnSvG2sK8FZ65XMyrm0BnPQU/XIfqE AUmudprCH/yNdrb7aA1al2hlj106w+xuMXYiU8T/sSFFbhKseSpBFfur5sLMek+PGv8o Mja8wt6m/jwR+X4PXeYoovoPCxEQ5I+r5nkJ54j+IbYUMZ/GqDi3eUiSJjkOtPvWLRDU hbCiYO5i0GIt1gsOHse7mt17tQywsk60OAGJbOBT9qNwBnAZ45SBBi4gTZuijJIlUxyu 1RdA== 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=LmFniehSpk6gcVQPXv2vS9z/weRkPike207dYgdf85k=; b=JlB+c99wbECRdb8K/IbLvx/ex4TwezTjquv+XJAJE+nu9X6Ge6QFOcH6/8vguUWDLU 3rR8yEeZU9IWuzvFyFBi2a7SN0JCw5knDvWIhEti4zKVSTXPUvHMg8gD5T3/c76PKu1F T4KLdyfB7dpiFZzdUVt3Sycys8QvGuwolFEeh41xgocQcR/yWZ3K4/WPFuLwd5twYE2S EunqPk3LHWHGgZ40z1S6X/I7+FjUYeN2G6MgntDWBKWBDcEeWUR18pZa/I4mOIzD1Fw+ yYd0agEvvIFMvT3xcMb9aN4q9PB9gLwxvMqQ3RgixkryBKsr6hhRfjP5i/aeISzUuwqy RVBA== X-Gm-Message-State: AGRZ1gLcKnVHrg7ZoxNJmhHn7hUtNSBPLp78QWPRUajiWDP+pWchbNZw TTLCOi7Rb3KBsuFgUEAK6A8Zzn9OYA8= X-Google-Smtp-Source: AJdET5dL6NYJk2k6J3ZugGuT3GSrj5Yy9XbUgnrTq59pnkOgfYJSPi6nynxn2AiKGniywUHqIk6+ZA== X-Received: by 2002:a5d:6403:: with SMTP id z3-v6mr6340131wru.64.1540582072867; Fri, 26 Oct 2018 12:27:52 -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.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Oct 2018 12:27:52 -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 5/7] push: add an advice on unqualified push Date: Fri, 26 Oct 2018 19:27:32 +0000 Message-Id: <20181026192734.9609-6-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 Add an advice to the recently improved error message added in f8aae12034 ("push: allow unqualified dest refspecs to DWIM", 2008-04-23). Now with advice.pushUnqualifiedRefName=true (on by default) we show a hint about how to proceed: $ ./git-push avar v2.19.0^{commit}:newbranch -n error: The destination you provided is not a full refname (i.e., starting with "refs/"). We tried to guess what you meant by: - Looking for a ref that matches newbranch on the remote side. - Looking at the refname of the local source. Neither worked, so we gave up. You must fully-qualify the ref. hint: The part of the refspec is a commit object. hint: Did you mean to create a new branch by pushing to hint: 'v2.19.0^{commit}:refs/heads/newbranch'? error: failed to push some refs to 'git@github.com:avar/git.git' When trying to push a tag, tree or a blob we suggest that perhaps the user meant to push them to refs/tags/ instead. The if/else duplication for all of OBJ_{COMMIT,TAG,TREE,BLOB} is unfortunate, but is required to correctly mark the messages for translation. See the discussion in <87r2gxebsi.fsf@evledraar.gmail.com> about that. Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/config.txt | 7 +++++++ advice.c | 2 ++ advice.h | 1 + remote.c | 37 +++++++++++++++++++++++++++++++++++++ t/t5505-remote.sh | 25 +++++++++++++++++++++++++ 5 files changed, 72 insertions(+) diff --git a/Documentation/config.txt b/Documentation/config.txt index 552827935a..8ca465702e 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -320,6 +320,13 @@ advice.*:: tries to overwrite a remote ref that points at an object that is not a commit-ish, or make the remote ref point at an object that is not a commit-ish. + pushUnqualifiedRefname:: + Shown when linkgit:git-push[1] gives up trying to + guess based on the source and destination refs what + remote ref namespace the source belongs in, but where + we can still suggest that the user push to either + refs/heads/* or refs/tags/* based on the type of the + source object. statusHints:: Show directions on how to proceed from the current state in the output of linkgit:git-status[1], in diff --git a/advice.c b/advice.c index 3561cd64e9..3089a4ca65 100644 --- a/advice.c +++ b/advice.c @@ -9,6 +9,7 @@ int advice_push_non_ff_matching = 1; int advice_push_already_exists = 1; int advice_push_fetch_first = 1; int advice_push_needs_force = 1; +int advice_push_unqualified_ref_name = 1; int advice_status_hints = 1; int advice_status_u_option = 1; int advice_commit_before_merge = 1; @@ -62,6 +63,7 @@ static struct { { "pushAlreadyExists", &advice_push_already_exists }, { "pushFetchFirst", &advice_push_fetch_first }, { "pushNeedsForce", &advice_push_needs_force }, + { "pushUnqualifiedRefName", &advice_push_unqualified_ref_name }, { "statusHints", &advice_status_hints }, { "statusUoption", &advice_status_u_option }, { "commitBeforeMerge", &advice_commit_before_merge }, diff --git a/advice.h b/advice.h index ab24df0fd0..9a2f8b5226 100644 --- a/advice.h +++ b/advice.h @@ -9,6 +9,7 @@ extern int advice_push_non_ff_matching; extern int advice_push_already_exists; extern int advice_push_fetch_first; extern int advice_push_needs_force; +extern int advice_push_unqualified_ref_name; extern int advice_status_hints; extern int advice_status_u_option; extern int advice_commit_before_merge; diff --git a/remote.c b/remote.c index c7a0b9c46f..93f802509d 100644 --- a/remote.c +++ b/remote.c @@ -13,6 +13,7 @@ #include "mergesort.h" #include "argv-array.h" #include "commit-reach.h" +#include "advice.h" enum map_direction { FROM_SRC, FROM_DST }; @@ -1008,6 +1009,9 @@ 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) { + struct object_id oid; + enum object_type type; + /* * TRANSLATORS: "matches '%s'%" is the part of "git push * :" push, and "being pushed ('%s')" is @@ -1023,6 +1027,39 @@ static void show_push_unqualified_ref_name_error(const char *dst_value, "\n" "Neither worked, so we gave up. You must fully-qualify the ref."), dst_value, matched_src_name); + + if (!advice_push_unqualified_ref_name) + return; + + if (get_oid(matched_src_name, &oid)) + BUG("'%s' is not a valid object, " + "match_explicit_lhs() should catch this!", + matched_src_name); + type = oid_object_info(the_repository, &oid, NULL); + if (type == OBJ_COMMIT) { + advise(_("The part of the refspec is a commit object.\n" + "Did you mean to create a new branch by pushing to\n" + "'%s:refs/heads/%s'?"), + matched_src_name, dst_value); + } else if (type == OBJ_TAG) { + advise(_("The part of the refspec is a tag object.\n" + "Did you mean to create a new tag by pushing to\n" + "'%s:refs/tags/%s'?"), + matched_src_name, dst_value); + } else if (type == OBJ_TREE) { + advise(_("The part of the refspec is a tree object.\n" + "Did you mean to tag a new tree by pushing to\n" + "'%s:refs/tags/%s'?"), + matched_src_name, dst_value); + } else if (type == OBJ_BLOB) { + advise(_("The part of the refspec is a blob object.\n" + "Did you mean to tag a new blob by pushing to\n" + "'%s:refs/tags/%s'?"), + matched_src_name, dst_value); + } else { + BUG("'%s' should be commit/tag/tree/blob, is '%d'", + matched_src_name, type); + } } static int match_explicit(struct ref *src, struct ref *dst, diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index d2a2cdd453..2e58721f98 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -1222,4 +1222,29 @@ test_expect_success 'add remote matching the "insteadOf" URL' ' git remote add backup xyz@example.com ' +test_expect_success 'unqualified refspec DWIM and advice' ' + test_when_finished "(cd test && git tag -d some-tag)" && + ( + cd test && + git tag -a -m "Some tag" some-tag master && + for type in commit tag tree blob + do + if test "$type" = "blob" + then + oid=$(git rev-parse some-tag:file) + else + oid=$(git rev-parse some-tag^{$type}) + fi && + test_must_fail git push origin $oid:dst 2>err && + test_i18ngrep "error: The destination you" err && + test_i18ngrep "hint: Did you mean" err && + test_must_fail git -c advice.pushUnqualifiedRefName=false \ + push origin $oid:dst 2>err && + test_i18ngrep "error: The destination you" err && + test_i18ngrep ! "hint: Did you mean" err + done + ) +' + + test_done From patchwork Fri Oct 26 19:27:33 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: 10657767 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 AC78714BD for ; Fri, 26 Oct 2018 19:27:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E0462BEEF for ; Fri, 26 Oct 2018 19:27:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91FE62CB8D; Fri, 26 Oct 2018 19:27:59 +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 21D8F2BEEF for ; Fri, 26 Oct 2018 19:27:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727844AbeJ0EGO (ORCPT ); Sat, 27 Oct 2018 00:06:14 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:52328 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727811AbeJ0EGO (ORCPT ); Sat, 27 Oct 2018 00:06:14 -0400 Received: by mail-wm1-f65.google.com with SMTP id 189-v6so2517001wmw.2 for ; Fri, 26 Oct 2018 12:27:56 -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=iqP4ifgdyK4zyDNdbbZLEqxXMcAsbdFVTcoO9nvJutA=; b=N1eNc+Y4C63zGWgo6IYyckhXtWoG3XgmO9JmzlRFZeoBIpQF7KJXGnMSxRmO16r9kE r9+bC8SaLVz6OnYSWfczf1zajf+yqBgJ0sTN3pft1jcio2iE2rIBfrIOI0c6WtSWc1YI xqvRrMlU5X2L2SJc04X+Uaawaq/NRugAwAim9g2jLo+gKiQt6ed02hNZCotCHTt0g4kJ Zisl2vM1s51PSm6G3NpSe3ZsQ0mA/ZB/r2QZVzIQHjTg9d4mICWdhuWRNHDOwxHP/Q0v W+KzaiPOsIeZot6eVPewQcEZQ4NRyeX/yvhagoySFhEqFKUFyMiwKMHgPe2ggathH02G avFg== 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=iqP4ifgdyK4zyDNdbbZLEqxXMcAsbdFVTcoO9nvJutA=; b=AULSNNHUWDYnwczfrI7jo3hDAzHcvOuoCz3FHVVMzi/rL5SdPMRxGsxI5SkTxnnZZ2 TzP5YzE3aISVOZuWCcnXXwCCbw7j3oRl0RqvJcyeZo2htVRUEnYVfykVZZvidWVRsAFt 6haU1s5XE7deZmnyqUsCpLxX2TSGUeYA7uUsXu6LxsfZwhg+EpFskSzhwLyc8gnj80B9 uvmXWOZ6WbwoA6HZU82pgvkT7iJaUZsMbYU/wVN47u3T5E2baNOOM2WtlTpDl4WJP/qg THZ9EssDAXIqdfW7K4XRR3zBlH8+nXlWRzs7p8muUY+GGsUvTUANL+I9I8J1HQTqeqWS hHQg== X-Gm-Message-State: AGRZ1gIKlk0xpZTVJIxb2onlAyJ4rHKTBNp1QlWJa6+cstSSexPi4Uen FJtt3WRL2S16lqSv5g/kv5WKzxCq2+o= X-Google-Smtp-Source: AJdET5cWPerzWV8TYoi2OWEFyum2A0uZ8LjngfmX6ZEC49UEw9fUxN/+s8WG5lyn5KV4X1LC4GHrQg== X-Received: by 2002:a1c:981:: with SMTP id 123-v6mr6373406wmj.130.1540582074903; Fri, 26 Oct 2018 12:27:54 -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.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Oct 2018 12:27:54 -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 6/7] push: test that doesn't DWYM if is unqualified Date: Fri, 26 Oct 2018 19:27:33 +0000 Message-Id: <20181026192734.9609-7-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 Add a test asserting that "git push origin :" where is a branch, tag, tree or blob in refs/remotes/* doesn't DWYM when is unqualified. This has never worked, but there's been no test for this behavior. See f88395ac23 ("Renaming push.", 2005-08-03), bb9fca80ce ("git-push: Update description of refspecs and add examples", 2007-06-09) and f8aae12034 ("push: allow unqualified dest refspecs to DWIM", 2008-04-23) which are most relevant commits that have changed or documented the behavior of this feature in the past. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t5505-remote.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index 2e58721f98..979a13b415 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -1246,5 +1246,33 @@ test_expect_success 'unqualified refspec DWIM and advice' ' ) ' +test_expect_success 'refs/remotes/* refspec and unqualified DWIM and advice' ' + ( + cd two && + git tag -a -m "Some tag" some-tag master && + git update-ref refs/trees/my-head-tree HEAD^{tree} && + git update-ref refs/blobs/my-file-blob HEAD:file + ) && + ( + cd test && + git config --add remote.two.fetch "+refs/tags/*:refs/remotes/two-tags/*" && + git config --add remote.two.fetch "+refs/trees/*:refs/remotes/two-trees/*" && + git config --add remote.two.fetch "+refs/blobs/*:refs/remotes/two-blobs/*" && + git fetch --no-tags two && + + test_must_fail git push origin refs/remotes/two/another:dst 2>err && + test_i18ngrep "error: The destination you" err && + + test_must_fail git push origin refs/remotes/two-tags/some-tag:dst-tag 2>err && + test_i18ngrep "error: The destination you" err && + + test_must_fail git push origin refs/remotes/two-trees/my-head-tree:dst-tree 2>err && + test_i18ngrep "error: The destination you" err && + + test_must_fail git push origin refs/remotes/two-blobs/my-file-blob:dst-blob 2>err && + test_i18ngrep "error: The destination you" err + ) +' + test_done From patchwork Fri Oct 26 19:27: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: 10657771 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 23C2A109C for ; Fri, 26 Oct 2018 19:28:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14C15286F9 for ; Fri, 26 Oct 2018 19:28:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 092572C748; Fri, 26 Oct 2018 19:28:02 +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 83D5E286F9 for ; Fri, 26 Oct 2018 19:28:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727845AbeJ0EGQ (ORCPT ); Sat, 27 Oct 2018 00:06:16 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:52333 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726483AbeJ0EGP (ORCPT ); Sat, 27 Oct 2018 00:06:15 -0400 Received: by mail-wm1-f68.google.com with SMTP id 189-v6so2517061wmw.2 for ; Fri, 26 Oct 2018 12:27:57 -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=WO52Esx7LxXhQWvq4InBQlre6hFeAOB1Z13N24I2YGs=; b=H3U1sZthzJNf2x+hicRXwm6D+SWMRbeBzN/X3aRBjMx3yvYQjRqwtjnQc7fSKXNbmr Avsewgoj2JjBkB7UyLP5nNZsniC9Ps4EmESywdqOS0IAaHQNhIP4XN5l1yo/jAtDGZiU nBPMFPSjf5yihfgIVqBAqmujdOY8BMy29A598p+1/AyBE95ApnWCAC53vA9ZYdWGt6Rv pfoA8jJ+I+5A9HoLBSu/FUuGV0wAu3W2KAQgXeiIHfxFBLAh++z4rk2xb/KmU4n44vfs op62FHiLul88hTc2uy2CsSpC1bKnO7C+eiHJUMl5Qw+Y13gicJrvCl+G+g3sqOk7S6QA w/GA== 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=WO52Esx7LxXhQWvq4InBQlre6hFeAOB1Z13N24I2YGs=; b=s3RkxqYfqVCrAkdDDQqm0qOL90qXSZofSCe+jZng6LMcNTFoNCKRgaXhMCzjLi8WoQ eXORrRVrLwhcuSgDBe1vJeAwUWra+Z42KJKFjeRhKC7tI+LcaPlmHzif9SAoOEXFAzri 4DoI22e13xn1s3+qIUKPIen6AQjqNYCOLuaacfEJN1eP9S9OM7KFVDlx4JmEi2BnPWDO +D18gHe8Mlb9ajIhTOY2CIRuQpzr7rNDU/0BwLSnCNRXizY0k078wZweMvRyAf5eqtUq JDBu8j4AVE91l3SA1ms1ha3rm7Tpi1hlEQFu7ncNypaIxH8wkDhpBMmVw2Ya8z1W96tJ Tj6g== X-Gm-Message-State: AGRZ1gLRFh+GsduFVovyBzfP6dKcLsRHj+8gXYyHwQyS9/W9DrXwuRlG GoaoWieBOFYUeOMO8GUR/geJ2j2/rKY= X-Google-Smtp-Source: AJdET5fzbHvyEieUoIhmlfiFfaA6LVjQH99o+/HnPJa/F5DN7vZVrFdpESOcwfEWTzqyVp3MN5ZDWw== X-Received: by 2002:a1c:1f92:: with SMTP id f140-v6mr1858610wmf.105.1540582076452; Fri, 26 Oct 2018 12:27:56 -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.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Oct 2018 12:27:55 -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 7/7] push: add DWYM support for "git push refs/remotes/...:" Date: Fri, 26 Oct 2018 19:27:34 +0000 Message-Id: <20181026192734.9609-8-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 Add DWYM support for pushing a ref in refs/remotes/* when the ref is unqualified, e.g.: git push origin refs/remotes/origin/master:upstream-master Before this we wouldn't know what do do with refs/remotes/origin/master, now we'll look it up and discover that it's a commit (or tag) and add a refs/{heads,tags}/ prefix to as appropriate. I'm bending over backwards and assuming that someone might have hacked in remote tracking tags (see [1] for a discussion of how that can be done), but punting on any tree or blob objects found under refs/remotes/*. This is the first use of the %N$ style of printf format in the *.[ch] files in our codebase, but it's supported by POSIX[2] and there's existing uses for it in po/*.po files, so hopefully it won't cause any trouble. It's more obvious for translators than to have a 3rd argument to the function identical to the 2nd, by re-using the 2nd it's clear that we're continuing to talk about the part of the refspec. 1. https://public-inbox.org/git/87zi1jxjqn.fsf@evledraar.gmail.com/ 2. http://pubs.opengroup.org/onlinepubs/7908799/xsh/fprintf.html Signed-off-by: Ævar Arnfjörð Bjarmason --- remote.c | 20 +++++++++++++++++++- t/t5505-remote.sh | 14 +++++++++----- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/remote.c b/remote.c index 93f802509d..c243e3d89e 100644 --- a/remote.c +++ b/remote.c @@ -973,6 +973,21 @@ static char *guess_ref(const char *name, struct ref *peer) strbuf_addstr(&buf, "refs/heads/"); } else if (starts_with(r, "refs/tags/")) { strbuf_addstr(&buf, "refs/tags/"); + } else if (starts_with(r, "refs/remotes/")) { + struct object_id oid; + enum object_type type; + + if (get_oid(peer->name, &oid)) + BUG("'%s' is not a valid object, " + "match_explicit_lhs() should catch this!", + peer->name); + type = oid_object_info(the_repository, &oid, NULL); + if (type == OBJ_COMMIT) + strbuf_addstr(&buf, "refs/heads/"); + else if (type == OBJ_TAG) + strbuf_addstr(&buf, "refs/tags/"); + else + return NULL; } else { return NULL; } @@ -1024,8 +1039,11 @@ static void show_push_unqualified_ref_name_error(const char *dst_value, "- 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" + "- Checking if the being pushed ('%2$s')\n" + " is a commit or tag in \"refs/remotes/*\". Then we infer a\n" + " corresponding refs/{heads,tags} on the remote side.\n" "\n" - "Neither worked, so we gave up. You must fully-qualify the ref."), + "None of those worked, so we gave up. You must fully-qualify the ref."), dst_value, matched_src_name); if (!advice_push_unqualified_ref_name) diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index 979a13b415..a6337b50e4 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -1260,11 +1260,15 @@ test_expect_success 'refs/remotes/* refspec and unqualified DWIM and git config --add remote.two.fetch "+refs/blobs/*:refs/remotes/two-blobs/*" && git fetch --no-tags two && - test_must_fail git push origin refs/remotes/two/another:dst 2>err && - test_i18ngrep "error: The destination you" err && - - test_must_fail git push origin refs/remotes/two-tags/some-tag:dst-tag 2>err && - test_i18ngrep "error: The destination you" err && + echo commit >expected && + git push origin refs/remotes/two/another:dst && + git -C ../one cat-file -t refs/heads/dst >actual && + test_cmp expected actual && + + echo tag >expected && + git push origin refs/remotes/two-tags/some-tag:dst-tag && + git -C ../one cat-file -t refs/tags/dst-tag >actual && + test_cmp expected actual && test_must_fail git push origin refs/remotes/two-trees/my-head-tree:dst-tree 2>err && test_i18ngrep "error: The destination you" err && From patchwork Fri Oct 26 23:07:41 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: 10657967 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 38F3B13B5 for ; Fri, 26 Oct 2018 23:08:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CB4B2C52D for ; Fri, 26 Oct 2018 23:08:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20F4C2CA40; Fri, 26 Oct 2018 23:08:07 +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 B200C2C52D for ; Fri, 26 Oct 2018 23:08:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728363AbeJ0HrB (ORCPT ); Sat, 27 Oct 2018 03:47:01 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:38053 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727792AbeJ0HrB (ORCPT ); Sat, 27 Oct 2018 03:47:01 -0400 Received: by mail-wm1-f65.google.com with SMTP id b14-v6so2810113wmj.3 for ; Fri, 26 Oct 2018 16:08:03 -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=Q5SYLTwt3ilyMFBfk5d3JP7vP3ggm5zAmyJ5IivU50A=; b=FvjZdjEknp0q9VYUzDqVGOOdiNXvP1yR+qiFZlsC+bTl+QgK3NrIYT9IpmlqWiewCG tPkYBENOjFUIuh4o+i01QnJVnvcBq2Nq0bQ81ZRY4h9bzMSkW3Y16vkg9TopNm+aRGAU 1q9XEtvpSU3FpI4w4ezuYNYLYSHxbl/9Ab63og0gdAOSIMGlrIV8Ntx/3WfryCqlth/T +X42VMEA87XFXieXMZDgMMAkPcqACYTD7YsjXpAWK/5K8PUHkUB988Go6PI+iBjYQGgj SYwGCQVGhtEejpruBKdUlAuefPEN/qWXqy9WCA6Y8wf22KO2H4nowNE1iBKjUc3FE8+U fXQA== 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=Q5SYLTwt3ilyMFBfk5d3JP7vP3ggm5zAmyJ5IivU50A=; b=trnnCuuBi65UMwHlFxjMOZ1A7Jo0Z/prujRUSdPQLzN3R0/F0gp6jaep3JVWGsJmQH wx/ivnLOq0SVNellVvK9ROTigno3mmbn/vXbL2PssflQx5oWtwhxZ52gPhOWTncuxNGF kIy1a/XvYftz60VbDZw1H6cYS8IeCsGBCRDqqRfxgFhRLgsC8Z8+SHiSkRzn0YjA0/Xp l97mAVSO2+4PACKMX/kAmza2g0jfEJfi3aBB+LEzpgi4bdRRGRFZAqNr5ZGsXbZ5r/U8 Oh5H0mXemNsEzXQoOONeo41GWtGPI+M3DCs11ypQSVCGvWLA6aDQNCwm+dG9CNyZukfX hl3g== X-Gm-Message-State: AGRZ1gJp3OxQIh4Fr0aE1E29lAOPfp/khZyfYlgAsApmzpxeRXxZqmZg gxh1LTJGqmtJ3BzlrE7yHTaRzOTuWAU= X-Google-Smtp-Source: AJdET5fqhbjpXiHbzGROwkeZcanSKOc+96NYV5ihICfzphrlyGFmqFwBk/c28Hz3l6vKnljs1f9TEA== X-Received: by 2002:a1c:4c14:: with SMTP id z20-v6mr6570669wmf.89.1540595282654; Fri, 26 Oct 2018 16:08:02 -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.08.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Oct 2018 16:08:00 -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 8/8] push doc: document the DWYM behavior pushing to unqualified Date: Fri, 26 Oct 2018 23:07:41 +0000 Message-Id: <20181026230741.23321-9-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 Document the DWYM behavior that kicks in when pushing to an unqualified reference. This behavior was added in f88395ac23 ("Renaming push.", 2005-08-03) and f8aae12034 ("push: allow unqualified dest refspecs to DWIM", 2008-04-23), and somewhat documented in bb9fca80ce ("git-push: Update description of refspecs and add examples", 2007-06-09), but has never been fully documented. The closest we got to having documented it was the description in the commit message for f8aae12034, which I've borrowed from in writing this documentation. Let's also refer to this new documentation from the existing documentation we had (added in bb9fca80ce). Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/git-push.txt | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt index a5fc54aeab..fb95c2e395 100644 --- a/Documentation/git-push.txt +++ b/Documentation/git-push.txt @@ -73,6 +73,30 @@ be omitted--such a push will update a ref that `` normally updates without any `` on the command line. Otherwise, missing `:` means to update the same ref as the ``. + +If doesn't start with `refs/` (e.g. `refs/heads/master`) we will +try to infer where in `refs/*` on the destination it +belongs based on the the type of being pushed and whether +is ambiguous. ++ +-- +* If unambiguously refers to a ref on the remote, + then push to that ref. + +* If resolves to a ref starting with refs/heads/ or refs/tags/, + then prepend that to . + +* If starts with refs/remotes/ check if that reference refers to + a commit or tag, then refs/heads/ or refs/tags/ to as + appropriate. + +* Other ambiguity resolutions might be added in the future, but for + now any other cases will error out with an error indicating what we + tried, and depending on the `advice.pushUnqualifiedRefname` + configuration (see linkgit:git-config[1]) suggest what refs/ + namespace you may have wanted to push to. + +-- ++ The object referenced by is used to update the reference on the remote side. Whether this is allowed depends on where in `refs/*` the reference lives as described in detail below, in @@ -591,6 +615,9 @@ the ones in the examples below) can be configured as the default for `refs/remotes/satellite/master`) in the `mothership` repository; do the same for `dev` and `satellite/dev`. + +See the section describing `...` above for a discussion of +the matching semantics. ++ This is to emulate `git fetch` run on the `mothership` using `git push` that is run in the opposite direction in order to integrate the work done on `satellite`, and is often necessary when you can