From patchwork Wed Jun 24 14:46:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11623327 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A354F913 for ; Wed, 24 Jun 2020 14:46:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6E85D20823 for ; Wed, 24 Jun 2020 14:46:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fSqWya9j" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403931AbgFXOqp (ORCPT ); Wed, 24 Jun 2020 10:46:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391195AbgFXOql (ORCPT ); Wed, 24 Jun 2020 10:46:41 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15F4CC061573 for ; Wed, 24 Jun 2020 07:46:41 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id o11so2548210wrv.9 for ; Wed, 24 Jun 2020 07:46:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=WUPWeulKmQQH8FkbLGh+IcH9HZkPjnJ6yx1vD1e9ZYo=; b=fSqWya9j8cXdCQUzj+WUfqmwjiaPJmSUlZ28zHclKEStDAZjzS4z8YUP6UTyorlJtp is4gVLg5ZLi3oW/ZcAFK0gQOG/WYXYFhX0erJ9J7ACwj2ON1NJD8A7guPp6/8LPC9WIf MHOuP+eaNA3fKKUnRL9X01jj47lxXeWCA9btwKV1S4u/X8z3YqlIkF9SGU+EZIHAB+cH GafJ0/HYsFzbiPBg+0ImVYgu86BvyBOtFFPOTPAtMqZy5QUfn+yztNhnY9/VZrIaaXNH X84XoC4vHBAEdIigBt83B7KvFX6ncjjjtkEQU2bmEX6+1QiVc8W4Egzwtrql0+Vv4vGc Pw3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=WUPWeulKmQQH8FkbLGh+IcH9HZkPjnJ6yx1vD1e9ZYo=; b=U2Jft0thFFPZSqyw4SQEBh4xGQ/fKbQjSQI6/OX7uRzAA78qAwDeeaJsA2wrrWedve lnwhrqoDYPZ0dPlhYsRoRREt54B2iC7jpTSg2gdC0xG47ntOHzoM4FLEiLPL0KEYe6wd l9be2OTxGGmD0zJgB3zHHdh1r5w/MDAaq/lDrKgRwfP+U4q4apVLrap81KjyF+sHGFWw hjopjKyn7l9Qw3Y1//3HuAoWF0dKV6XKa38KiA2zINyRcMyCzbWCsB73gBIEnrzILvZ3 h7OlEMY9yUUulWxv6WIY2gDzA2HbYqfXpsOuosOeHOkxCBD+in/z8BOneB9XCtKzBpxi 89WQ== X-Gm-Message-State: AOAM531blb5BAXaPDEOcKb8HBMvWEPGTZRRdZcN6CCYz2aDwi5tYHdUz cHB53iziK99uMpqx7VOK7eLvXiqftik= X-Google-Smtp-Source: ABdhPJy+zymm1IOqbZPyVdRowOwZKaEB+2cnbmrr5N8WSZOSxQvV1wZFnzhL5WZ5ccdMZwrLoCnCcA== X-Received: by 2002:adf:916a:: with SMTP id j97mr11999448wrj.231.1593009998745; Wed, 24 Jun 2020 07:46:38 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id r12sm27151304wrc.22.2020.06.24.07.46.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 07:46:38 -0700 (PDT) Message-Id: In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Date: Wed, 24 Jun 2020 14:46:28 +0000 Subject: [PATCH v4 1/9] fmt-merge-msg: stop treating `master` specially Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: don@goodman-wilson.com, stolee@gmail.com, peff@peff.net, sandals@crustytoothpaste.net, Matt Rogers , Eric Sunshine , Taylor Blau , Phillip Wood , Alban Gruin , Johannes Sixt , Denton Liu , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Philippe Blain , Johannes Schindelin , Johannes Schindelin Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin In the context of many projects renaming their primary branch names away from `master`, Git wants to stop treating the `master` branch specially. Let's start with `git fmt-merge-msg`. Signed-off-by: Johannes Schindelin Signed-off-by: Đoàn Trần Công Danh --- fmt-merge-msg.c | 5 +- t/t1507-rev-parse-upstream.sh | 2 +- t/t4013-diff-various.sh | 4 +- t/t4013/diff.log_--decorate=full_--all | 2 +- t/t4013/diff.log_--decorate_--all | 2 +- ...--patch-with-stat_--summary_master_--_dir_ | 2 +- t/t4013/diff.log_--patch-with-stat_master | 2 +- .../diff.log_--patch-with-stat_master_--_dir_ | 2 +- ...ot_--cc_--patch-with-stat_--summary_master | 2 +- ..._--root_--patch-with-stat_--summary_master | 2 +- .../diff.log_--root_--patch-with-stat_master | 2 +- ...root_-c_--patch-with-stat_--summary_master | 2 +- t/t4013/diff.log_--root_-p_master | 2 +- t/t4013/diff.log_--root_master | 2 +- t/t4013/diff.log_-m_-p_--first-parent_master | 2 +- t/t4013/diff.log_-m_-p_master | 4 +- t/t4013/diff.log_-p_--first-parent_master | 2 +- t/t4013/diff.log_-p_master | 2 +- t/t4013/diff.log_master | 2 +- t/t4013/diff.show_--first-parent_master | 2 +- t/t4013/diff.show_-c_master | 2 +- t/t4013/diff.show_-m_master | 4 +- t/t4013/diff.show_master | 2 +- ...ot_--cc_--patch-with-stat_--summary_master | 2 +- ...root_-c_--patch-with-stat_--summary_master | 2 +- t/t4202-log.sh | 72 +++++++++---------- t/t6200-fmt-merge-msg.sh | 36 +++++----- t/t7600-merge.sh | 14 ++-- t/t7608-merge-messages.sh | 10 +-- 29 files changed, 94 insertions(+), 97 deletions(-) diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c index 72d32bd73b..cfb8ff2f33 100644 --- a/fmt-merge-msg.c +++ b/fmt-merge-msg.c @@ -451,10 +451,7 @@ static void fmt_merge_msg_title(struct strbuf *out, strbuf_addf(out, " of %s", srcs.items[i].string); } - if (!strcmp("master", current_branch)) - strbuf_addch(out, '\n'); - else - strbuf_addf(out, " into %s\n", current_branch); + strbuf_addf(out, " into %s\n", current_branch); } static void fmt_tag_signature(struct strbuf *tagbuf, diff --git a/t/t1507-rev-parse-upstream.sh b/t/t1507-rev-parse-upstream.sh index dfc0d96d8a..f213aa8053 100755 --- a/t/t1507-rev-parse-upstream.sh +++ b/t/t1507-rev-parse-upstream.sh @@ -137,7 +137,7 @@ test_expect_success 'merge my-side@{u} records the correct name' ' git branch -t new my-side@{u} && git merge -s ours new@{u} && git show -s --pretty=tformat:%s >actual && - echo "Merge remote-tracking branch ${SQ}origin/side${SQ}" >expect && + echo "Merge remote-tracking branch ${SQ}origin/side${SQ} into master" >expect && test_cmp expect actual ) ' diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index 3f60f7d96c..43267d6024 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -117,12 +117,12 @@ test_expect_success setup ' : <<\EOF ! [initial] Initial - * [master] Merge branch 'side' + * [master] Merge branch 'side' into master ! [rearrange] Rearranged lines in dir/sub ! [side] Side ---- + [rearrange] Rearranged lines in dir/sub - - [master] Merge branch 'side' + - [master] Merge branch 'side' into master * + [side] Side * [master^] Third * [master~2] Second diff --git a/t/t4013/diff.log_--decorate=full_--all b/t/t4013/diff.log_--decorate=full_--all index 3f9b872ece..c56783b985 100644 --- a/t/t4013/diff.log_--decorate=full_--all +++ b/t/t4013/diff.log_--decorate=full_--all @@ -31,7 +31,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a (refs/heads/side) Author: A U Thor diff --git a/t/t4013/diff.log_--decorate_--all b/t/t4013/diff.log_--decorate_--all index f5e20e1e14..1cbdc038f4 100644 --- a/t/t4013/diff.log_--decorate_--all +++ b/t/t4013/diff.log_--decorate_--all @@ -31,7 +31,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a (side) Author: A U Thor diff --git a/t/t4013/diff.log_--patch-with-stat_--summary_master_--_dir_ b/t/t4013/diff.log_--patch-with-stat_--summary_master_--_dir_ index a18f1472a9..f5b1b6516b 100644 --- a/t/t4013/diff.log_--patch-with-stat_--summary_master_--_dir_ +++ b/t/t4013/diff.log_--patch-with-stat_--summary_master_--_dir_ @@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Author: A U Thor diff --git a/t/t4013/diff.log_--patch-with-stat_master b/t/t4013/diff.log_--patch-with-stat_master index ae425c4672..af23803cdc 100644 --- a/t/t4013/diff.log_--patch-with-stat_master +++ b/t/t4013/diff.log_--patch-with-stat_master @@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Author: A U Thor diff --git a/t/t4013/diff.log_--patch-with-stat_master_--_dir_ b/t/t4013/diff.log_--patch-with-stat_master_--_dir_ index d5207cadf4..814098fbf8 100644 --- a/t/t4013/diff.log_--patch-with-stat_master_--_dir_ +++ b/t/t4013/diff.log_--patch-with-stat_master_--_dir_ @@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Author: A U Thor diff --git a/t/t4013/diff.log_--root_--cc_--patch-with-stat_--summary_master b/t/t4013/diff.log_--root_--cc_--patch-with-stat_--summary_master index 0fc1e8cd71..b927fe4a98 100644 --- a/t/t4013/diff.log_--root_--cc_--patch-with-stat_--summary_master +++ b/t/t4013/diff.log_--root_--cc_--patch-with-stat_--summary_master @@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master dir/sub | 2 ++ file0 | 3 +++ diff --git a/t/t4013/diff.log_--root_--patch-with-stat_--summary_master b/t/t4013/diff.log_--root_--patch-with-stat_--summary_master index dffc09dde9..6db3cea329 100644 --- a/t/t4013/diff.log_--root_--patch-with-stat_--summary_master +++ b/t/t4013/diff.log_--root_--patch-with-stat_--summary_master @@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Author: A U Thor diff --git a/t/t4013/diff.log_--root_--patch-with-stat_master b/t/t4013/diff.log_--root_--patch-with-stat_master index 55aa98012d..98e9c320c3 100644 --- a/t/t4013/diff.log_--root_--patch-with-stat_master +++ b/t/t4013/diff.log_--root_--patch-with-stat_master @@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Author: A U Thor diff --git a/t/t4013/diff.log_--root_-c_--patch-with-stat_--summary_master b/t/t4013/diff.log_--root_-c_--patch-with-stat_--summary_master index 019d85f7de..b61b1117ae 100644 --- a/t/t4013/diff.log_--root_-c_--patch-with-stat_--summary_master +++ b/t/t4013/diff.log_--root_-c_--patch-with-stat_--summary_master @@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master dir/sub | 2 ++ file0 | 3 +++ diff --git a/t/t4013/diff.log_--root_-p_master b/t/t4013/diff.log_--root_-p_master index b42c334439..345bd9e8a9 100644 --- a/t/t4013/diff.log_--root_-p_master +++ b/t/t4013/diff.log_--root_-p_master @@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Author: A U Thor diff --git a/t/t4013/diff.log_--root_master b/t/t4013/diff.log_--root_master index e8f46159da..db56b1fe6b 100644 --- a/t/t4013/diff.log_--root_master +++ b/t/t4013/diff.log_--root_master @@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Author: A U Thor diff --git a/t/t4013/diff.log_-m_-p_--first-parent_master b/t/t4013/diff.log_-m_-p_--first-parent_master index 7a0073f529..bcadb50e26 100644 --- a/t/t4013/diff.log_-m_-p_--first-parent_master +++ b/t/t4013/diff.log_-m_-p_--first-parent_master @@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master diff --git a/dir/sub b/dir/sub index cead32e..992913c 100644 diff --git a/t/t4013/diff.log_-m_-p_master b/t/t4013/diff.log_-m_-p_master index 9ca62a01ed..2acf43a9fb 100644 --- a/t/t4013/diff.log_-m_-p_master +++ b/t/t4013/diff.log_-m_-p_master @@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master diff --git a/dir/sub b/dir/sub index cead32e..992913c 100644 @@ -33,7 +33,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master diff --git a/dir/sub b/dir/sub index 7289e35..992913c 100644 diff --git a/t/t4013/diff.log_-p_--first-parent_master b/t/t4013/diff.log_-p_--first-parent_master index 3fc896d424..c6a5876d80 100644 --- a/t/t4013/diff.log_-p_--first-parent_master +++ b/t/t4013/diff.log_-p_--first-parent_master @@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 Author: A U Thor diff --git a/t/t4013/diff.log_-p_master b/t/t4013/diff.log_-p_master index bf1326dc36..1841cded94 100644 --- a/t/t4013/diff.log_-p_master +++ b/t/t4013/diff.log_-p_master @@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Author: A U Thor diff --git a/t/t4013/diff.log_master b/t/t4013/diff.log_master index a8f6ce5abd..f8ec445eb3 100644 --- a/t/t4013/diff.log_master +++ b/t/t4013/diff.log_master @@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a Author: A U Thor diff --git a/t/t4013/diff.show_--first-parent_master b/t/t4013/diff.show_--first-parent_master index 3dcbe473a0..94548f4598 100644 --- a/t/t4013/diff.show_--first-parent_master +++ b/t/t4013/diff.show_--first-parent_master @@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master diff --git a/dir/sub b/dir/sub index cead32e..992913c 100644 diff --git a/t/t4013/diff.show_-c_master b/t/t4013/diff.show_-c_master index 81aba8da96..1c46ed64fd 100644 --- a/t/t4013/diff.show_-c_master +++ b/t/t4013/diff.show_-c_master @@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master diff --combined dir/sub index cead32e,7289e35..992913c diff --git a/t/t4013/diff.show_-m_master b/t/t4013/diff.show_-m_master index 4ea2ee453d..7559fc22f8 100644 --- a/t/t4013/diff.show_-m_master +++ b/t/t4013/diff.show_-m_master @@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master diff --git a/dir/sub b/dir/sub index cead32e..992913c 100644 @@ -33,7 +33,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master diff --git a/dir/sub b/dir/sub index 7289e35..992913c 100644 diff --git a/t/t4013/diff.show_master b/t/t4013/diff.show_master index fb08ce0e46..57091c5d90 100644 --- a/t/t4013/diff.show_master +++ b/t/t4013/diff.show_master @@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master diff --cc dir/sub index cead32e,7289e35..992913c diff --git a/t/t4013/diff.whatchanged_--root_--cc_--patch-with-stat_--summary_master b/t/t4013/diff.whatchanged_--root_--cc_--patch-with-stat_--summary_master index 30aae7817b..5f13a71bb5 100644 --- a/t/t4013/diff.whatchanged_--root_--cc_--patch-with-stat_--summary_master +++ b/t/t4013/diff.whatchanged_--root_--cc_--patch-with-stat_--summary_master @@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master dir/sub | 2 ++ file0 | 3 +++ diff --git a/t/t4013/diff.whatchanged_--root_-c_--patch-with-stat_--summary_master b/t/t4013/diff.whatchanged_--root_-c_--patch-with-stat_--summary_master index d1d32bd34c..8acb88267b 100644 --- a/t/t4013/diff.whatchanged_--root_-c_--patch-with-stat_--summary_master +++ b/t/t4013/diff.whatchanged_--root_-c_--patch-with-stat_--summary_master @@ -4,7 +4,7 @@ Merge: 9a6d494 c7a2ab9 Author: A U Thor Date: Mon Jun 26 00:04:00 2006 +0000 - Merge branch 'side' + Merge branch 'side' into master dir/sub | 2 ++ file0 | 3 +++ diff --git a/t/t4202-log.sh b/t/t4202-log.sh index a0930599aa..fd9af658af 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -483,7 +483,7 @@ test_expect_success 'set up merge history' ' ' cat > expect <<\EOF -* Merge branch 'side' +* Merge branch 'side' into master |\ | * side-2 | * side-1 @@ -502,7 +502,7 @@ test_expect_success 'log --graph with merge' ' ' cat > expect <<\EOF -| | | * Merge branch 'side' +| | | * Merge branch 'side' into master | | | |\ | | | | * side-2 | | | | * side-1 @@ -521,7 +521,7 @@ test_expect_success 'log --graph --line-prefix="| | | " with merge' ' ' cat > expect.colors <<\EOF -* Merge branch 'side' +* Merge branch 'side' into master |\ | * side-2 | * side-1 @@ -555,7 +555,7 @@ cat > expect <<\EOF |\ Merge: A B | | Author: A U Thor | | -| | Merge branch 'side' +| | Merge branch 'side' into master | | | * commit tags/side-2 | | Author: A U Thor @@ -632,11 +632,11 @@ test_expect_success 'set up more tangled history' ' ' cat > expect <<\EOF -* Merge tag 'reach' +* Merge tag 'reach' into master |\ | \ | \ -*-. \ Merge tags 'octopus-a' and 'octopus-b' +*-. \ Merge tags 'octopus-a' and 'octopus-b' into master |\ \ \ * | | | seventh | | * | octopus-b @@ -646,14 +646,14 @@ cat > expect <<\EOF |/ / | * reach |/ -* Merge branch 'tangle' +* Merge branch 'tangle' into master |\ | * Merge branch 'side' (early part) into tangle | |\ | * \ Merge branch 'master' (early part) into tangle | |\ \ | * | | tangle-a -* | | | Merge branch 'side' +* | | | Merge branch 'side' into master |\ \ \ \ | * | | | side-2 | | |_|/ @@ -735,16 +735,16 @@ test_expect_success 'log.decorate configuration' ' test_expect_success 'decorate-refs with glob' ' cat >expect.decorate <<-\EOF && - Merge-tag-reach - Merge-tags-octopus-a-and-octopus-b + Merge-tag-reach-into-master + Merge-tags-octopus-a-and-octopus-b-into-master seventh octopus-b (octopus-b) octopus-a (octopus-a) reach EOF cat >expect.no-decorate <<-\EOF && - Merge-tag-reach - Merge-tags-octopus-a-and-octopus-b + Merge-tag-reach-into-master + Merge-tags-octopus-a-and-octopus-b-into-master seventh octopus-b octopus-a @@ -765,8 +765,8 @@ test_expect_success 'decorate-refs with glob' ' test_expect_success 'decorate-refs without globs' ' cat >expect.decorate <<-\EOF && - Merge-tag-reach - Merge-tags-octopus-a-and-octopus-b + Merge-tag-reach-into-master + Merge-tags-octopus-a-and-octopus-b-into-master seventh octopus-b octopus-a @@ -779,8 +779,8 @@ test_expect_success 'decorate-refs without globs' ' test_expect_success 'multiple decorate-refs' ' cat >expect.decorate <<-\EOF && - Merge-tag-reach - Merge-tags-octopus-a-and-octopus-b + Merge-tag-reach-into-master + Merge-tags-octopus-a-and-octopus-b-into-master seventh octopus-b (octopus-b) octopus-a (octopus-a) @@ -794,8 +794,8 @@ test_expect_success 'multiple decorate-refs' ' test_expect_success 'decorate-refs-exclude with glob' ' cat >expect.decorate <<-\EOF && - Merge-tag-reach (HEAD -> master) - Merge-tags-octopus-a-and-octopus-b + Merge-tag-reach-into-master (HEAD -> master) + Merge-tags-octopus-a-and-octopus-b-into-master seventh (tag: seventh) octopus-b (tag: octopus-b) octopus-a (tag: octopus-a) @@ -811,8 +811,8 @@ test_expect_success 'decorate-refs-exclude with glob' ' test_expect_success 'decorate-refs-exclude without globs' ' cat >expect.decorate <<-\EOF && - Merge-tag-reach (HEAD -> master) - Merge-tags-octopus-a-and-octopus-b + Merge-tag-reach-into-master (HEAD -> master) + Merge-tags-octopus-a-and-octopus-b-into-master seventh (tag: seventh) octopus-b (tag: octopus-b, octopus-b) octopus-a (tag: octopus-a, octopus-a) @@ -828,8 +828,8 @@ test_expect_success 'decorate-refs-exclude without globs' ' test_expect_success 'multiple decorate-refs-exclude' ' cat >expect.decorate <<-\EOF && - Merge-tag-reach (HEAD -> master) - Merge-tags-octopus-a-and-octopus-b + Merge-tag-reach-into-master (HEAD -> master) + Merge-tags-octopus-a-and-octopus-b-into-master seventh (tag: seventh) octopus-b (tag: octopus-b) octopus-a (tag: octopus-a) @@ -851,8 +851,8 @@ test_expect_success 'multiple decorate-refs-exclude' ' test_expect_success 'decorate-refs and decorate-refs-exclude' ' cat >expect.no-decorate <<-\EOF && - Merge-tag-reach (master) - Merge-tags-octopus-a-and-octopus-b + Merge-tag-reach-into-master (master) + Merge-tags-octopus-a-and-octopus-b-into-master seventh octopus-b octopus-a @@ -866,8 +866,8 @@ test_expect_success 'decorate-refs and decorate-refs-exclude' ' test_expect_success 'deocrate-refs and log.excludeDecoration' ' cat >expect.decorate <<-\EOF && - Merge-tag-reach (master) - Merge-tags-octopus-a-and-octopus-b + Merge-tag-reach-into-master (master) + Merge-tags-octopus-a-and-octopus-b-into-master seventh octopus-b (octopus-b) octopus-a (octopus-a) @@ -881,10 +881,10 @@ test_expect_success 'deocrate-refs and log.excludeDecoration' ' test_expect_success 'decorate-refs-exclude and simplify-by-decoration' ' cat >expect.decorate <<-\EOF && - Merge-tag-reach (HEAD -> master) + Merge-tag-reach-into-master (HEAD -> master) reach (tag: reach, reach) seventh (tag: seventh) - Merge-branch-tangle + Merge-branch-tangle-into-master Merge-branch-side-early-part-into-tangle (tangle) tangle-a (tag: tangle-a) EOF @@ -1068,7 +1068,7 @@ cat >expect <<\EOF |\ Merge: MERGE_PARENTS | | Author: A U Thor | | -| | Merge branch 'tangle' +| | Merge branch 'tangle' into master | | | * commit COMMIT_OBJECT_NAME | |\ Merge: MERGE_PARENTS @@ -1102,7 +1102,7 @@ cat >expect <<\EOF |\ \ \ \ Merge: MERGE_PARENTS | | | | | Author: A U Thor | | | | | -| | | | | Merge branch 'side' +| | | | | Merge branch 'side' into master | | | | | | * | | | commit COMMIT_OBJECT_NAME | | |_|/ Author: A U Thor @@ -1343,7 +1343,7 @@ cat >expect <<\EOF *** |\ Merge: MERGE_PARENTS *** | | Author: A U Thor *** | | -*** | | Merge branch 'tangle' +*** | | Merge branch 'tangle' into master *** | | *** | * commit COMMIT_OBJECT_NAME *** | |\ Merge: MERGE_PARENTS @@ -1377,7 +1377,7 @@ cat >expect <<\EOF *** |\ \ \ \ Merge: MERGE_PARENTS *** | | | | | Author: A U Thor *** | | | | | -*** | | | | | Merge branch 'side' +*** | | | | | Merge branch 'side' into master *** | | | | | *** | * | | | commit COMMIT_OBJECT_NAME *** | | |_|/ Author: A U Thor @@ -1540,8 +1540,8 @@ cat >expect <<-\EOF * reach | | A reach.t -* Merge branch 'tangle' -* Merge branch 'side' +* Merge branch 'tangle' into master +* Merge branch 'side' into master |\ | * side-2 | @@ -1562,8 +1562,8 @@ cat >expect <<-\EOF * reach | | reach.t -* Merge branch 'tangle' -* Merge branch 'side' +* Merge branch 'tangle' into master +* Merge branch 'side' into master |\ | * side-2 | diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh index e4c2a6eca4..2b3fd498d0 100755 --- a/t/t6200-fmt-merge-msg.sh +++ b/t/t6200-fmt-merge-msg.sh @@ -79,7 +79,7 @@ test_expect_success GPG 'set up a signed tag' ' ' test_expect_success 'message for merging local branch' ' - echo "Merge branch ${apos}left${apos}" >expected && + echo "Merge branch ${apos}left${apos} into master" >expected && git checkout master && git fetch . left && @@ -107,7 +107,7 @@ test_expect_success GPG 'message for merging local tag signed by unknown key' ' ' test_expect_success 'message for merging external branch' ' - echo "Merge branch ${apos}left${apos} of $(pwd)" >expected && + echo "Merge branch ${apos}left${apos} of $(pwd) into master" >expected && git checkout master && git fetch "$(pwd)" left && @@ -118,7 +118,7 @@ test_expect_success 'message for merging external branch' ' test_expect_success '[merge] summary/log configuration' ' cat >expected <<-EOF && - Merge branch ${apos}left${apos} + Merge branch ${apos}left${apos} into master # By Another Author (3) and A U Thor (2) # Via Another Committer @@ -160,7 +160,7 @@ test_expect_success 'setup FETCH_HEAD' ' test_expect_success 'merge.log=3 limits shortlog length' ' cat >expected <<-EOF && - Merge branch ${apos}left${apos} + Merge branch ${apos}left${apos} into master # By Another Author (3) and A U Thor (2) # Via Another Committer @@ -177,7 +177,7 @@ test_expect_success 'merge.log=3 limits shortlog length' ' test_expect_success 'merge.log=5 shows all 5 commits' ' cat >expected <<-EOF && - Merge branch ${apos}left${apos} + Merge branch ${apos}left${apos} into master # By Another Author (3) and A U Thor (2) # Via Another Committer @@ -195,7 +195,7 @@ test_expect_success 'merge.log=5 shows all 5 commits' ' test_expect_success '--log=5 with custom comment character' ' cat >expected <<-EOF && - Merge branch ${apos}left${apos} + Merge branch ${apos}left${apos} into master x By Another Author (3) and A U Thor (2) x Via Another Committer @@ -212,14 +212,14 @@ test_expect_success '--log=5 with custom comment character' ' ' test_expect_success 'merge.log=0 disables shortlog' ' - echo "Merge branch ${apos}left${apos}" >expected && + echo "Merge branch ${apos}left${apos} into master" >expected && git -c merge.log=0 fmt-merge-msg <.git/FETCH_HEAD >actual && test_cmp expected actual ' test_expect_success '--log=3 limits shortlog length' ' cat >expected <<-EOF && - Merge branch ${apos}left${apos} + Merge branch ${apos}left${apos} into master # By Another Author (3) and A U Thor (2) # Via Another Committer @@ -236,7 +236,7 @@ test_expect_success '--log=3 limits shortlog length' ' test_expect_success '--log=5 shows all 5 commits' ' cat >expected <<-EOF && - Merge branch ${apos}left${apos} + Merge branch ${apos}left${apos} into master # By Another Author (3) and A U Thor (2) # Via Another Committer @@ -253,13 +253,13 @@ test_expect_success '--log=5 shows all 5 commits' ' ' test_expect_success '--no-log disables shortlog' ' - echo "Merge branch ${apos}left${apos}" >expected && + echo "Merge branch ${apos}left${apos} into master" >expected && git fmt-merge-msg --no-log <.git/FETCH_HEAD >actual && test_cmp expected actual ' test_expect_success '--log=0 disables shortlog' ' - echo "Merge branch ${apos}left${apos}" >expected && + echo "Merge branch ${apos}left${apos} into master" >expected && git fmt-merge-msg --no-log <.git/FETCH_HEAD >actual && test_cmp expected actual ' @@ -300,7 +300,7 @@ test_expect_success 'fmt-merge-msg -m' ' test_expect_success 'setup: expected shortlog for two branches' ' cat >expected <<-EOF - Merge branches ${apos}left${apos} and ${apos}right${apos} + Merge branches ${apos}left${apos} and ${apos}right${apos} into master # By Another Author (3) and A U Thor (2) # Via Another Committer @@ -397,7 +397,7 @@ test_expect_success 'merge-msg with nothing to merge' ' test_expect_success 'merge-msg tag' ' cat >expected <<-EOF && - Merge tag ${apos}tag-r3${apos} + Merge tag ${apos}tag-r3${apos} into master * tag ${apos}tag-r3${apos}: Right #3 @@ -418,7 +418,7 @@ test_expect_success 'merge-msg tag' ' test_expect_success 'merge-msg two tags' ' cat >expected <<-EOF && - Merge tags ${apos}tag-r3${apos} and ${apos}tag-l5${apos} + Merge tags ${apos}tag-r3${apos} and ${apos}tag-l5${apos} into master * tag ${apos}tag-r3${apos}: Right #3 @@ -448,7 +448,7 @@ test_expect_success 'merge-msg two tags' ' test_expect_success 'merge-msg tag and branch' ' cat >expected <<-EOF && - Merge branch ${apos}left${apos}, tag ${apos}tag-r3${apos} + Merge branch ${apos}left${apos}, tag ${apos}tag-r3${apos} into master * tag ${apos}tag-r3${apos}: Right #3 @@ -479,7 +479,7 @@ test_expect_success 'merge-msg tag and branch' ' test_expect_success 'merge-msg lots of commits' ' { cat <<-EOF && - Merge branch ${apos}long${apos} + Merge branch ${apos}long${apos} into master * long: (35 commits) EOF @@ -516,7 +516,7 @@ test_expect_success 'merge-msg with "merging" an annotated tag' ' git fmt-merge-msg <.git/FETCH_HEAD >actual && { cat <<-\EOF - Merge tag '\''annote'\'' + Merge tag '\''annote'\'' into master An annotated one @@ -531,7 +531,7 @@ test_expect_success 'merge-msg with "merging" an annotated tag' ' git merge --no-commit --no-ff $annote && { cat <<-EOF - Merge tag '\''$annote'\'' + Merge tag '\''$annote'\'' into master An annotated one diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh index 5883a6adc3..1d45f9a4ed 100755 --- a/t/t7600-merge.sh +++ b/t/t7600-merge.sh @@ -14,9 +14,9 @@ Testing basic merge operations/option parsing. ! [c4] c4 ! [c5] c5 ! [c6] c6 - * [master] Merge commit 'c1' + * [master] Merge commit 'c1' into master -------- - - [master] Merge commit 'c1' + - [master] Merge commit 'c1' into master + * [c1] commit 1 + [c6] c6 + [c5] c5 @@ -44,8 +44,8 @@ test_write_lines '1 X' 2 '3 X' 4 '5 X' 6 7 8 '9 X' >result.1-3-5-9 test_write_lines 1 2 3 4 5 6 7 8 '9 Z' >result.9z create_merge_msgs () { - echo "Merge tag 'c2'" >msg.1-5 && - echo "Merge tags 'c2' and 'c3'" >msg.1-5-9 && + echo "Merge tag 'c2' into master" >msg.1-5 && + echo "Merge tags 'c2' and 'c3' into master" >msg.1-5-9 && { echo "Squashed commit of the following:" && echo && @@ -258,7 +258,7 @@ test_expect_success 'merge c3 with c7 with commit.cleanup = scissors' ' git commit --no-edit -a && cat >expect <<-\EOF && - Merge tag '"'"'c7'"'"' + Merge tag '"'"'c7'"'"' into master # ------------------------ >8 ------------------------ # Do not modify or remove the line above. @@ -808,10 +808,10 @@ test_expect_success 'merge with conflicted --autostash changes' ' ' cat >expected.branch <<\EOF -Merge branch 'c5-branch' (early part) +Merge branch 'c5-branch' (early part) into master EOF cat >expected.tag <<\EOF -Merge commit 'c5~1' +Merge commit 'c5~1' into master EOF test_expect_success 'merge early part of c2' ' diff --git a/t/t7608-merge-messages.sh b/t/t7608-merge-messages.sh index 8e7e0a5865..2af33f195b 100755 --- a/t/t7608-merge-messages.sh +++ b/t/t7608-merge-messages.sh @@ -16,7 +16,7 @@ test_expect_success 'merge local branch' ' git checkout master && test_commit master-2 && git merge local-branch && - check_oneline "Merge branch Qlocal-branchQ" + check_oneline "Merge branch Qlocal-branchQ into master" ' test_expect_success 'merge octopus branches' ' @@ -26,7 +26,7 @@ test_expect_success 'merge octopus branches' ' test_commit octopus-2 && git checkout master && git merge octopus-a octopus-b && - check_oneline "Merge branches Qoctopus-aQ and Qoctopus-bQ" + check_oneline "Merge branches Qoctopus-aQ and Qoctopus-bQ into master" ' test_expect_success 'merge tag' ' @@ -35,7 +35,7 @@ test_expect_success 'merge tag' ' git checkout master && test_commit master-3 && git merge tag-1 && - check_oneline "Merge tag Qtag-1Q" + check_oneline "Merge tag Qtag-1Q into master" ' test_expect_success 'ambiguous tag' ' @@ -44,7 +44,7 @@ test_expect_success 'ambiguous tag' ' git checkout master && test_commit master-4 && git merge ambiguous && - check_oneline "Merge tag QambiguousQ" + check_oneline "Merge tag QambiguousQ into master" ' test_expect_success 'remote-tracking branch' ' @@ -54,7 +54,7 @@ test_expect_success 'remote-tracking branch' ' git checkout master && test_commit master-5 && git merge origin/master && - check_oneline "Merge remote-tracking branch Qorigin/masterQ" + check_oneline "Merge remote-tracking branch Qorigin/masterQ into master" ' test_done From patchwork Wed Jun 24 14:46:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11623313 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 944FE14E3 for ; Wed, 24 Jun 2020 14:46:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A5AA20724 for ; Wed, 24 Jun 2020 14:46:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qdRqz7MN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403814AbgFXOqn (ORCPT ); Wed, 24 Jun 2020 10:46:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391165AbgFXOql (ORCPT ); Wed, 24 Jun 2020 10:46:41 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4147C0613ED for ; Wed, 24 Jun 2020 07:46:40 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id f139so2783836wmf.5 for ; Wed, 24 Jun 2020 07:46:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=/RkcaLH+FOI7K3NGSfKesvnyE2JyBJA3eXSOgEW0Wqw=; b=qdRqz7MNQZ7+YopdNJNCYiFYGgbJIAKnP7OKWH5QTEFi/MrCbJX7y5xCNlNO7/vOyD Y5VOe5C0u2F38Shlw5TA/f3wbTvYxzlVTzx6SP26WAYg35KighoiM4Ha22xB6WfculfM gKVPmaZuCKLnmrMubl5/ioaFqiApMbcoVpQHySiMagO9VMIV/FG0i4dOTxRJWqMjlO+f kNeAsmM8NG7JkEXhLw97Ev/9sI55nWCmb1nm3LQh4jE+GAGSxzuQ4AYeB5dwxf9cxnfa RfLw4j9RrOOodUKrrYlrr9IOqfv2HqGE2zprtOuV4y9pBSkxYA1JosREzZIqu8vKxSb3 V8iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=/RkcaLH+FOI7K3NGSfKesvnyE2JyBJA3eXSOgEW0Wqw=; b=ejtJ1Ml5h9ZTIdBe5SjwiBTYldZIHqklpx4orkS7fDbPOVFOOKUiCQZJk0Xc4pnYo8 U258V0/zvc1aP/x8ymRDz6OdxYFwyt9Hl3b8MsxI6YQ8FT+VR0qw8U1hZT3rNqbXxOa5 LXe/rgXZ0J+o3W8K3odSUSnaSVXyfDFsQG4ulceKaqNHGCaQRcbcj++V+pLvL0X9TAEz kj0JrBQcw6uAxQ8aeuC3Ebvl9R4QRFqRcJ2dqPfiDaH5KZiCnwy2JbcjPgBQraPmPivL KKiEmzopaxczagYcsgy3/w6iQL6wIIOjQ0OR5Wn9jXtRglRS0ELtJVq4eeqOGIVtbzOP PM5g== X-Gm-Message-State: AOAM532ZegGDqIFMGenC1y/pO2erVtiRdnr3pW/PpqJ1oJOY2f399UHE T4KelISRtaY2DnpPQQI85cQxfs43hlo= X-Google-Smtp-Source: ABdhPJww2LR2/PavUt08r0DLaC6U67+FQ2Gnr++qHtcmYiMAh4NyvtXKf0Oe9cEzyi9jcvkcK/zcNQ== X-Received: by 2002:a7b:c5c1:: with SMTP id n1mr29753915wmk.21.1593009999495; Wed, 24 Jun 2020 07:46:39 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 65sm7821931wma.48.2020.06.24.07.46.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 07:46:39 -0700 (PDT) Message-Id: <1216de51abee7f5614c4d639e42fce3308100830.1593009996.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Date: Wed, 24 Jun 2020 14:46:29 +0000 Subject: [PATCH v4 2/9] send-pack/transport-helper: avoid mentioning a particular branch Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: don@goodman-wilson.com, stolee@gmail.com, peff@peff.net, sandals@crustytoothpaste.net, Matt Rogers , Eric Sunshine , Taylor Blau , Phillip Wood , Alban Gruin , Johannes Sixt , Denton Liu , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Philippe Blain , Johannes Schindelin , Johannes Schindelin Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin When trying to push all matching branches, but none match, we offer a message suggesting to push the `master` branch. However, we want to step away from making that branch any more special than any other branch, so let's reword that message to mention no branch in particular. Signed-off-by: Johannes Schindelin --- send-pack.c | 2 +- t/t5528-push-default.sh | 6 ++++++ transport-helper.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/send-pack.c b/send-pack.c index 0abee22283..19eb9b04e4 100644 --- a/send-pack.c +++ b/send-pack.c @@ -406,7 +406,7 @@ int send_pack(struct send_pack_args *args, if (!remote_refs) { fprintf(stderr, "No refs in common and none specified; doing nothing.\n" - "Perhaps you should specify a branch such as 'master'.\n"); + "Perhaps you should specify a branch.\n"); return 0; } if (args->atomic && !atomic_supported) diff --git a/t/t5528-push-default.sh b/t/t5528-push-default.sh index 4d1e0c363e..f0a287d97d 100755 --- a/t/t5528-push-default.sh +++ b/t/t5528-push-default.sh @@ -98,6 +98,12 @@ test_expect_success 'push from/to new branch with upstream, matching and simple' test_push_failure upstream ' +test_expect_success '"matching" fails if none match' ' + git init --bare empty && + test_must_fail git push empty : 2>actual && + test_i18ngrep "Perhaps you should specify a branch" actual +' + test_expect_success 'push ambiguously named branch with upstream, matching and simple' ' git checkout -b ambiguous && test_config branch.ambiguous.remote parent1 && diff --git a/transport-helper.c b/transport-helper.c index a46afcb69d..8a711cda29 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -1046,7 +1046,7 @@ static int push_refs(struct transport *transport, if (!remote_refs) { fprintf(stderr, _("No refs in common and none specified; doing nothing.\n" - "Perhaps you should specify a branch such as 'master'.\n")); + "Perhaps you should specify a branch.\n")); return 0; } From patchwork Wed Jun 24 14:46:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11623325 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 68DDE14B7 for ; Wed, 24 Jun 2020 14:46:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D48020823 for ; Wed, 24 Jun 2020 14:46:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pDUPFtPP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403966AbgFXOqq (ORCPT ); Wed, 24 Jun 2020 10:46:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391287AbgFXOqm (ORCPT ); Wed, 24 Jun 2020 10:46:42 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE188C061795 for ; Wed, 24 Jun 2020 07:46:41 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id q15so2582943wmj.2 for ; Wed, 24 Jun 2020 07:46:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=jtKNRKyNK0pm+pzvtSrLPRTWgAmrhZfAuicDx7P3gtk=; b=pDUPFtPPl1gCpiRa2j+eb6XVnvqPO5q7dmokMplCmtsXTkYdFk+v36+CfbJaMXDihy I+RLz+8Q2uyGq7R9gyoOQX3y2jkeBP9Dfdhtm75ekW7V/89l2lOfictZsu0GPsttBKpe OoAtHRsXQ6p/h8HfPTuLQsUAO3NKm7eKAdwcGRFBSxJVGFIaLsEAGEEEs4kpFNN9pKsV J6Tl0SKN4o/mB4BrO5E3yHKQvJXop2aLHOjk+dlB9Qs890ABIWU71nq+Q2BXR0PABAlE N0m2z9HfjSJ1nAbggn0/XA4t7+Sj/Yjfqd7QFpZxnKBSOiZ9Cbcr8ZLyPLd1a4B3hjYl zTzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=jtKNRKyNK0pm+pzvtSrLPRTWgAmrhZfAuicDx7P3gtk=; b=tmjwyCm2VwPuGOnWrh8JdZWrojToGECobFW8Yr34ikTa1U2aT8KSYAGqdlf85gFQXD 9V/2hxsDko6nTYlwrPN9p3c8VHnwkbX325E5svRI+OyeSpwjkNkAzNqd83hqVnol5Ah8 vTvAF0B2cDuN2IpZC2ZtI63NyZVJ8zQJUqmXqtzgK/guZyP1LZJkXSBpt+5lyeChQr+h toPi5lYeU1P1Lem2/Qz3d0ExzSBfwVYNXD9Lmpiu1aqcAetmNG5ikPH6Br+zQM0UPJkD iarRcFLkC6/hdMu07TiZ8zuWUE/2x/chG5HSH/tVrnEluxYoNKxq3XZgkIJUjBCUnp3/ mHcw== X-Gm-Message-State: AOAM532AcSF6bh380XXvAoWWebtBahqeAlbXkjIwcI6yn0fSqBLO0dBV I9yMfaTO2vDbrzY+dL51YpEwEaCTUMk= X-Google-Smtp-Source: ABdhPJwg1lfoN6FVokvtGlmB3b3Odqo04Ce2MvGl+8GFMRCYMeawvERK7H4g6ib8ZXNx9pgh4pF3fA== X-Received: by 2002:a05:600c:218f:: with SMTP id e15mr17228355wme.63.1593010000452; Wed, 24 Jun 2020 07:46:40 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f16sm8533893wmh.27.2020.06.24.07.46.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 07:46:40 -0700 (PDT) Message-Id: <54563642dbf96fcb36993c2c2d36ebefaf220cce.1593009996.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Date: Wed, 24 Jun 2020 14:46:30 +0000 Subject: [PATCH v4 3/9] submodule: fall back to remote's HEAD for missing remote..branch Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: don@goodman-wilson.com, stolee@gmail.com, peff@peff.net, sandals@crustytoothpaste.net, Matt Rogers , Eric Sunshine , Taylor Blau , Phillip Wood , Alban Gruin , Johannes Sixt , Denton Liu , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Philippe Blain , Johannes Schindelin , Johannes Schindelin Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin When `remote..branch` is not configured, `git submodule update` currently falls back to using the branch name `master`. A much better idea, however, is to use the remote `HEAD`: on all Git servers running reasonably recent Git versions, the symref `HEAD` points to the main branch. Note: t7419 demonstrates that there _might_ be use cases out there that _expect_ `git submodule update --remote` to update submodules to the remote `master` branch even if the remote `HEAD` points to another branch. Arguably, this patch makes the behavior more intuitive, but there is a slight possibility that this might cause regressions in obscure setups. Even so, it should be okay to fix this behavior without anything like a longer transition period: - The `git submodule update --remote` command is not really common. - Current Git's behavior when running this command is outright confusing, unless the remote repository's current branch _is_ `master` (in which case the proposed behavior matches the old behavior). - If a user encounters a regression due to the changed behavior, the fix is actually trivial: setting `submodule..branch` to `master` will reinstate the old behavior. Helped-by: Philippe Blain Signed-off-by: Johannes Schindelin --- Documentation/git-submodule.txt | 12 ++++++------ Documentation/gitmodules.txt | 6 +++--- builtin/submodule--helper.c | 2 +- t/t7406-submodule-update.sh | 16 ++++++++++++++++ t/t7419-submodule-set-branch.sh | 7 +++++-- 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt index c9ed2bf3d5..7e5f995f77 100644 --- a/Documentation/git-submodule.txt +++ b/Documentation/git-submodule.txt @@ -183,7 +183,7 @@ set-branch (-d|--default) [--] :: Sets the default remote tracking branch for the submodule. The `--branch` option allows the remote branch to be specified. The `--default` option removes the submodule..branch configuration - key, which causes the tracking branch to default to 'master'. + key, which causes the tracking branch to default to the remote 'HEAD'. set-url [--] :: Sets the URL of the specified submodule to . Then, it will @@ -284,7 +284,7 @@ OPTIONS `.gitmodules` for `update --remote`. A special value of `.` is used to indicate that the name of the branch in the submodule should be the same name as the current branch in the current repository. If the - option is not specified, it defaults to 'master'. + option is not specified, it defaults to the remote 'HEAD'. -f:: --force:: @@ -322,10 +322,10 @@ OPTIONS the superproject's recorded SHA-1 to update the submodule, use the status of the submodule's remote-tracking branch. The remote used is branch's remote (`branch..remote`), defaulting to `origin`. - The remote branch used defaults to `master`, but the branch name may - be overridden by setting the `submodule..branch` option in - either `.gitmodules` or `.git/config` (with `.git/config` taking - precedence). + The remote branch used defaults to the remote `HEAD`, but the branch + name may be overridden by setting the `submodule..branch` + option in either `.gitmodules` or `.git/config` (with `.git/config` + taking precedence). + This works for any of the supported update procedures (`--checkout`, `--rebase`, etc.). The only change is the source of the target SHA-1. diff --git a/Documentation/gitmodules.txt b/Documentation/gitmodules.txt index 67275fd187..539b4e1997 100644 --- a/Documentation/gitmodules.txt +++ b/Documentation/gitmodules.txt @@ -49,9 +49,9 @@ submodule..update:: submodule..branch:: A remote branch name for tracking updates in the upstream submodule. - If the option is not specified, it defaults to 'master'. A special - value of `.` is used to indicate that the name of the branch in the - submodule should be the same name as the current branch in the + If the option is not specified, it defaults to the remote 'HEAD'. + A special value of `.` is used to indicate that the name of the branch + in the submodule should be the same name as the current branch in the current repository. See the `--remote` documentation in linkgit:git-submodule[1] for details. diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 46c03d2a12..f55f7b7704 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1981,7 +1981,7 @@ static const char *remote_submodule_branch(const char *path) free(key); if (!branch) - return "master"; + return "HEAD"; if (!strcmp(branch, ".")) { const char *refname = resolve_ref_unsafe("HEAD", 0, NULL, NULL); diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh index 4fb447a143..aa19ff3a2e 100755 --- a/t/t7406-submodule-update.sh +++ b/t/t7406-submodule-update.sh @@ -70,6 +70,22 @@ test_expect_success 'setup a submodule tree' ' ) ' +test_expect_success 'update --remote falls back to using HEAD' ' + test_create_repo main-branch-submodule && + test_commit -C main-branch-submodule initial && + + test_create_repo main-branch && + git -C main-branch submodule add ../main-branch-submodule && + git -C main-branch commit -m add-submodule && + + git -C main-branch-submodule switch -c hello && + test_commit -C main-branch-submodule world && + + git clone --recursive main-branch main-branch-clone && + git -C main-branch-clone submodule update --remote main-branch-submodule && + test_path_exists main-branch-clone/main-branch-submodule/world.t +' + test_expect_success 'submodule update detaching the HEAD ' ' (cd super/submodule && git reset --hard HEAD~1 diff --git a/t/t7419-submodule-set-branch.sh b/t/t7419-submodule-set-branch.sh index fd25f786a3..3b925c302f 100755 --- a/t/t7419-submodule-set-branch.sh +++ b/t/t7419-submodule-set-branch.sh @@ -52,12 +52,13 @@ test_expect_success 'test submodule set-branch --branch' ' ' test_expect_success 'test submodule set-branch --default' ' + test_commit -C submodule c && (cd super && git submodule set-branch --default submodule && ! grep branch .gitmodules && git submodule update --remote && cat <<-\EOF >expect && - a + c EOF git -C submodule show -s --pretty=%s >actual && test_cmp expect actual @@ -65,6 +66,7 @@ test_expect_success 'test submodule set-branch --default' ' ' test_expect_success 'test submodule set-branch -b' ' + test_commit -C submodule b && (cd super && git submodule set-branch -b topic submodule && grep "branch = topic" .gitmodules && @@ -78,12 +80,13 @@ test_expect_success 'test submodule set-branch -b' ' ' test_expect_success 'test submodule set-branch -d' ' + test_commit -C submodule d && (cd super && git submodule set-branch -d submodule && ! grep branch .gitmodules && git submodule update --remote && cat <<-\EOF >expect && - a + d EOF git -C submodule show -s --pretty=%s >actual && test_cmp expect actual From patchwork Wed Jun 24 14:46:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11623323 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 93E0214B7 for ; Wed, 24 Jun 2020 14:46:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7C1BB2082F for ; Wed, 24 Jun 2020 14:46:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JUjJlCJ4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391292AbgFXOqr (ORCPT ); Wed, 24 Jun 2020 10:46:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389253AbgFXOqm (ORCPT ); Wed, 24 Jun 2020 10:46:42 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CEC2C0613ED for ; Wed, 24 Jun 2020 07:46:42 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id g18so2580384wrm.2 for ; Wed, 24 Jun 2020 07:46:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=0X4OIh+5wlwwOufNlNxI8I6NYiLAwPFO7s8kaVL4YYQ=; b=JUjJlCJ4zx3GlgaG0Zzo46rtAS3Ljia52G69qYZ00yPVH+gf3ucJ/YwHzh4/HvNdfw M9OFe5YyjdngTx4pmAOrmAdsqYTwo/rc1sK9LHbTk1aMuZ2sX2KT5zgnFGtFsDBu0Wr4 5AcG8j14yTjtJ/LPl0XHn+9wYPJh6M4nRAprHeiZb30HNoBK+NLVk5G9d6O+Z8aTw4jP ehVTYExJ6AlL3OyalnOaYRuBwFakhxq1NE/kkj+iTisb3Xjm+Z8pjCfKPvZZyY7BRRvk rGh9HN2XvRkkk1XkotxgTppZHqSJoEncMiZZdwokoKS+Wtl8s7Af/a6OjEzsRY/ECXPq DymA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=0X4OIh+5wlwwOufNlNxI8I6NYiLAwPFO7s8kaVL4YYQ=; b=iTLnzV1P7RvUlJeq5L0LkpA5FNyKB26QcSpJqZVUr6Fac9hwUJzgXx2NFKlYF6twXj oz8ZYDEHPRDKJ0QQts9f0OmWRTgpotMQsTuHpN7gBpVHKDclHsZE1/bLTpCY6bu/BJ2n FoLskyzS8/ZLF4HCkACNwWFxR1Vl2WWSApUU1DTd8uYLsMlreNM+G8TAyI0SUN+4cjsR pTaweLmhH1m7YFpNwtpOp/xqdM9x91MMQ9UWnKiDlFcxsHA3rFuFms3wPEsG+B/5ZcJB sdrLCVhGTQiO93cl1ytunBzDyuaU0KeXNZNZ6d75LvM6LOYJwxEspWjgfp0Gtd4ynkgR xaaA== X-Gm-Message-State: AOAM5322ZUZbVEZw5UiKcGY1hTjN12iQpdT6ZyMXEDcWkezWZQ3UXYtk Nkzbpw14ksq1/6Om3g01xt97IbZyfas= X-Google-Smtp-Source: ABdhPJzImERDcFoH0QsEZh5vC743TrNQ1fS8iiJhe0ZuCmtHEvNKaKH626Sxa3tDL1YrrfGtGwIoZQ== X-Received: by 2002:adf:afc3:: with SMTP id y3mr32474730wrd.277.1593010001224; Wed, 24 Jun 2020 07:46:41 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f17sm6958386wrq.3.2020.06.24.07.46.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 07:46:40 -0700 (PDT) Message-Id: <1d723d35ed107e084a363b5eeb2b505dbe0c21eb.1593009996.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Date: Wed, 24 Jun 2020 14:46:31 +0000 Subject: [PATCH v4 4/9] docs: add missing diamond brackets Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: don@goodman-wilson.com, stolee@gmail.com, peff@peff.net, sandals@crustytoothpaste.net, Matt Rogers , Eric Sunshine , Taylor Blau , Phillip Wood , Alban Gruin , Johannes Sixt , Denton Liu , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Philippe Blain , Johannes Schindelin , Johannes Schindelin Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin There were a couple of instances in our manual pages that had an opening diamond bracket without a corresponding closing one. Signed-off-by: Johannes Schindelin --- Documentation/git-branch.txt | 2 +- Documentation/git-clone.txt | 2 +- Documentation/git-init.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index 135206ff4a..03c0824d52 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -12,7 +12,7 @@ SYNOPSIS [-v [--abbrev= | --no-abbrev]] [--column[=] | --no-column] [--sort=] [(--merged | --no-merged) []] - [--contains []] + [--contains []] [--no-contains []] [--points-at ] [--format=] [(-r | --remotes) | (-a | --all)] [--list] [...] diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt index 08d6045c4a..c898310099 100644 --- a/Documentation/git-clone.txt +++ b/Documentation/git-clone.txt @@ -259,7 +259,7 @@ maintain a branch with no references other than a single cloned branch. This is useful e.g. to maintain minimal clones of the default branch of some repository for search indexing. ---recurse-submodules[=]:: After the clone is created, initialize and clone submodules within based on the provided pathspec. If no pathspec is provided, all submodules are initialized and cloned. diff --git a/Documentation/git-init.txt b/Documentation/git-init.txt index adc6adfd38..f9467cc6a4 100644 --- a/Documentation/git-init.txt +++ b/Documentation/git-init.txt @@ -10,7 +10,7 @@ SYNOPSIS -------- [verse] 'git init' [-q | --quiet] [--bare] [--template=] - [--separate-git-dir ] [--object-format=] [--object-format=] [--shared[=]] [directory] From patchwork Wed Jun 24 14:46:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11623331 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C778E913 for ; Wed, 24 Jun 2020 14:47:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A7E7020781 for ; Wed, 24 Jun 2020 14:47:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="M+bCEOPf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404021AbgFXOrC (ORCPT ); Wed, 24 Jun 2020 10:47:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403926AbgFXOqo (ORCPT ); Wed, 24 Jun 2020 10:46:44 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6EDDC061573 for ; Wed, 24 Jun 2020 07:46:43 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id l2so1313057wmf.0 for ; Wed, 24 Jun 2020 07:46:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=YR5mgWvq8oel7pskivydUczFijobGIiMDxUn4vO8/EQ=; b=M+bCEOPfMRkn2cJcsK49iXFEoMjKNpyJ3N78nRAjVpc4e6BirfysxE6vYNUfvX+X0I Rk8FSgbdsGI2g7Fe05qLGFnoQkNnZSX5X16of1/krz/oc4BKdG2mD8GI7MvBLIu//Y6N li2nZu31QcrijYSEbl+jUdskY+6dPrcGJT639vbXgY6fPPjrERTwhB4MV1LFGXIAVFOV MFsW6zeZ/0jLSjWcR0o5xf1xYPzUTrvbiqPbTNzR8bzyhmE8yp31evoPXjkE7qxyslW6 ANjsfWl4llInYWuxYsiPEoNbAY2xNxEGcc37MVceoH9fbO/8lK3wlt9GsMusyErs8L30 f3Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=YR5mgWvq8oel7pskivydUczFijobGIiMDxUn4vO8/EQ=; b=HuXp3RfB9nzKX1QQe0vf1XoEVOBj+hWk37Dz5rSFy//3dy0gvzYqdDPU0pBUBCEa6M f9C3cc1Z6IhWC7q5I4KK330XCmT4rqHHDvCUYu5LkdrdEhth7IFLuYPTn+rBJfILtM79 Mxkc4gzJaOovasxfX2Kd3vwq2glletJ1CBWmGW7fleUpTN1ikborZEpltQeh32RHqeC2 0D+xpMP7SX/FnjuJwWJN7Jc5B/3BXL7P18S2zh6rKjKeyp+jbFleoTzUxkEPZrcGk6dB Igm+w4S6uyKS7cYM948/Go6k1V8zEdk83OMmj9+u1BvTH2xwwQ1t6Lm1pp2yo79VYnOt gtWA== X-Gm-Message-State: AOAM532tThT2SR341wfgveYiLEUx6WU7NNGX5MXq23U2kLfUgNnNiG7a +FZiUAFjT37YorqdujTNExOTKt5rMFA= X-Google-Smtp-Source: ABdhPJzI3i/LSuQhphtxSWOD1XPxx+uHgUhKtfeml+60f6xiOEPfjaIIvcnv3bniHikwqCeODpgmTg== X-Received: by 2002:a1c:ed17:: with SMTP id l23mr30052476wmh.175.1593010002188; Wed, 24 Jun 2020 07:46:42 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f13sm7978578wmb.33.2020.06.24.07.46.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 07:46:41 -0700 (PDT) Message-Id: <9edd4fd3b26cef4ff8ffb99be6647055ebb76ed6.1593009996.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Date: Wed, 24 Jun 2020 14:46:32 +0000 Subject: [PATCH v4 5/9] init: allow specifying the initial branch name for the new repository Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: don@goodman-wilson.com, stolee@gmail.com, peff@peff.net, sandals@crustytoothpaste.net, Matt Rogers , Eric Sunshine , Taylor Blau , Phillip Wood , Alban Gruin , Johannes Sixt , Denton Liu , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Philippe Blain , Johannes Schindelin , Johannes Schindelin Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin There is a growing number of projects and companies desiring to change the main branch name of their repositories (see e.g. https://twitter.com/mislav/status/1270388510684598272 for background on this). To change that branch name for new repositories, currently the only way to do that automatically is by copying all of Git's template directory, then hard-coding the desired default branch name into the `.git/HEAD` file, and then configuring `init.templateDir` to point to those copied template files. To make this process much less cumbersome, let's introduce a new option: `--initial-branch=`. Signed-off-by: Johannes Schindelin --- Documentation/git-init.txt | 7 +++++++ builtin/clone.c | 3 ++- builtin/init-db.c | 33 +++++++++++++++++++++++++++------ cache.h | 2 +- t/t0001-init.sh | 13 +++++++++++++ 5 files changed, 50 insertions(+), 8 deletions(-) diff --git a/Documentation/git-init.txt b/Documentation/git-init.txt index f9467cc6a4..ddfe265da5 100644 --- a/Documentation/git-init.txt +++ b/Documentation/git-init.txt @@ -11,6 +11,7 @@ SYNOPSIS [verse] 'git init' [-q | --quiet] [--bare] [--template=] [--separate-git-dir ] [--object-format=] + [-b | --initial-branch=] [--shared[=]] [directory] @@ -67,6 +68,12 @@ repository. + If this is reinitialization, the repository will be moved to the specified path. +-b :: + +Use the specified name for the initial branch in the newly created repository. +If not specified, fall back to the default name: `master`. + --shared[=(false|true|umask|group|all|world|everybody|0xxx)]:: Specify that the Git repository is to be shared amongst several users. This diff --git a/builtin/clone.c b/builtin/clone.c index 2a8e3aaaed..b751bdf13e 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -1111,7 +1111,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix) } } - init_db(git_dir, real_git_dir, option_template, GIT_HASH_UNKNOWN, INIT_DB_QUIET); + init_db(git_dir, real_git_dir, option_template, GIT_HASH_UNKNOWN, NULL, + INIT_DB_QUIET); if (real_git_dir) git_dir = real_git_dir; diff --git a/builtin/init-db.c b/builtin/init-db.c index 0b7222e718..8fdfc334ac 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -203,6 +203,7 @@ void initialize_repository_version(int hash_algo) static int create_default_files(const char *template_path, const char *original_git_dir, + const char *initial_branch, const struct repository_format *fmt) { struct stat st1; @@ -258,15 +259,26 @@ static int create_default_files(const char *template_path, die("failed to set up refs db: %s", err.buf); /* - * Create the default symlink from ".git/HEAD" to the "master" - * branch, if it does not exist yet. + * Point the HEAD symref to the initial branch with if HEAD does + * not yet exist. */ path = git_path_buf(&buf, "HEAD"); reinit = (!access(path, R_OK) || readlink(path, junk, sizeof(junk)-1) != -1); if (!reinit) { - if (create_symref("HEAD", "refs/heads/master", NULL) < 0) + char *ref; + + if (!initial_branch) + initial_branch = "master"; + + ref = xstrfmt("refs/heads/%s", initial_branch); + if (check_refname_format(ref, 0) < 0) + die(_("invalid initial branch name: '%s'"), + initial_branch); + + if (create_symref("HEAD", ref, NULL) < 0) exit(1); + free(ref); } initialize_repository_version(fmt->hash_algo); @@ -383,7 +395,8 @@ static void validate_hash_algorithm(struct repository_format *repo_fmt, int hash } int init_db(const char *git_dir, const char *real_git_dir, - const char *template_dir, int hash, unsigned int flags) + const char *template_dir, int hash, const char *initial_branch, + unsigned int flags) { int reinit; int exist_ok = flags & INIT_DB_EXIST_OK; @@ -425,7 +438,11 @@ int init_db(const char *git_dir, const char *real_git_dir, validate_hash_algorithm(&repo_fmt, hash); - reinit = create_default_files(template_dir, original_git_dir, &repo_fmt); + reinit = create_default_files(template_dir, original_git_dir, + initial_branch, &repo_fmt); + if (reinit && initial_branch) + warning(_("re-init: ignored --initial-branch=%s"), + initial_branch); create_object_directory(); @@ -528,6 +545,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) const char *template_dir = NULL; unsigned int flags = 0; const char *object_format = NULL; + const char *initial_branch = NULL; int hash_algo = GIT_HASH_UNKNOWN; const struct option init_db_options[] = { OPT_STRING(0, "template", &template_dir, N_("template-directory"), @@ -541,6 +559,8 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) OPT_BIT('q', "quiet", &flags, N_("be quiet"), INIT_DB_QUIET), OPT_STRING(0, "separate-git-dir", &real_git_dir, N_("gitdir"), N_("separate git dir from working tree")), + OPT_STRING('b', "initial-branch", &initial_branch, N_("name"), + N_("override the name of the initial branch")), OPT_STRING(0, "object-format", &object_format, N_("hash"), N_("specify the hash algorithm to use")), OPT_END() @@ -652,5 +672,6 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) UNLEAK(work_tree); flags |= INIT_DB_EXIST_OK; - return init_db(git_dir, real_git_dir, template_dir, hash_algo, flags); + return init_db(git_dir, real_git_dir, template_dir, hash_algo, + initial_branch, flags); } diff --git a/cache.h b/cache.h index 0f0485ecfe..654426460c 100644 --- a/cache.h +++ b/cache.h @@ -628,7 +628,7 @@ int path_inside_repo(const char *prefix, const char *path); int init_db(const char *git_dir, const char *real_git_dir, const char *template_dir, int hash_algo, - unsigned int flags); + const char *initial_branch, unsigned int flags); void initialize_repository_version(int hash_algo); void sanitize_stdfds(void); diff --git a/t/t0001-init.sh b/t/t0001-init.sh index 1edd5aeb8f..386c06b5dd 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@ -464,4 +464,17 @@ test_expect_success MINGW 'redirect std handles' ' grep "Needed a single revision" output.txt ' +test_expect_success '--initial-branch' ' + git init --initial-branch=hello initial-branch-option && + git -C initial-branch-option symbolic-ref HEAD >actual && + echo refs/heads/hello >expect && + test_cmp expect actual && + + : re-initializing should not change the branch name && + git init --initial-branch=ignore initial-branch-option 2>err && + test_i18ngrep "ignored --initial-branch" err && + git -C initial-branch-option symbolic-ref HEAD >actual && + grep hello actual +' + test_done From patchwork Wed Jun 24 14:46:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11623329 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E3A3114B7 for ; Wed, 24 Jun 2020 14:47:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C6C1B20823 for ; Wed, 24 Jun 2020 14:47:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NxbTQddC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403975AbgFXOrA (ORCPT ); Wed, 24 Jun 2020 10:47:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403955AbgFXOqp (ORCPT ); Wed, 24 Jun 2020 10:46:45 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB1EBC0613ED for ; Wed, 24 Jun 2020 07:46:44 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id j18so2581760wmi.3 for ; Wed, 24 Jun 2020 07:46:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=3rXUslYCSXhn8OXvH5V2fRYdXYmO54T6GIJcsiBJWmQ=; b=NxbTQddCXIXTE9ohCYb+5ny2H5bKau2+xWNLp2BZSIt6ilfeRto4nuXdgJdT3NIy2e F3UOMkGhhCJJbpD56Lf2eYzdUGTzNt6vU2jWjNeYyXtmUfU4a4/8Ig1j87RGm7Gs4rlK lNuyjXnz3axrwTuS8/NlU8HOF2tj2/2kDYH26JGpsI6evgcBidYV/pdTFd2uXRQpmksV Gr1J1nik/e9vqmc+gFLG7vgt6MFFLHSGmSWKu/JuipNwJy3bDz6wMlp51Z1gtz/qAsHL QwDaAeLBXGsue6SwQNOxE4UgXdWGbF/JNLTRLsiA8+Ku/DDPFb3hvBu27a+7MHpu1wll pw5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=3rXUslYCSXhn8OXvH5V2fRYdXYmO54T6GIJcsiBJWmQ=; b=QyfULckm1tPEklUVXWiFSCydLwtNX34SxusyuIkYnFcqqK7aTUpYaCZM/6malPWW4V UxURzNy46W8b9s+UCBs7IjbbbPYmArZSAp9YDMphHFP7CpZQcN3xQPfAYu4KQCOCIBqz LFlljgXvQW/RH2j4sPV2vwHSz4SNyY4DMvL0yEIePO5vw4g/4WYQ5LQy6SamrGK107/d JCTHTTWttWsiiqdPzpTn/0XrXe+aneqenzpRS2DLk32BN8ybdJQy9fd2BkBg987mKcIu ObQkzS3LmzZ8TvwJzdv5RyeHgUDDRTb2qBmfATT1m5FRxaGufhoffaDRXhwMF9dCNQ+l wMwg== X-Gm-Message-State: AOAM531/vxH9hf6F5h8wnZQEztZLaIT1tL8CjnXH8+UwqfxFgJH76W5u xvfuzkwemg68oaxPTZ1qeBzwuS1l9J4= X-Google-Smtp-Source: ABdhPJz7jWj7dFihBdwYbknB6cuZWGDEcU2ZS2Q6t31HD9I5Uydqg4mv3jTRhHf07E6nJ7xdz2IjwQ== X-Received: by 2002:a1c:1d04:: with SMTP id d4mr31705985wmd.156.1593010003182; Wed, 24 Jun 2020 07:46:43 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id d2sm27615176wrs.95.2020.06.24.07.46.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 07:46:42 -0700 (PDT) Message-Id: <7747eaa57de9324b7f7a46f86d1179ce751f76c9.1593009996.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Don Goodman-Wilson via GitGitGadget" Date: Wed, 24 Jun 2020 14:46:33 +0000 Subject: [PATCH v4 6/9] init: allow setting the default for the initial branch name via the config Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: don@goodman-wilson.com, stolee@gmail.com, peff@peff.net, sandals@crustytoothpaste.net, Matt Rogers , Eric Sunshine , Taylor Blau , Phillip Wood , Alban Gruin , Johannes Sixt , Denton Liu , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Philippe Blain , Johannes Schindelin , Don Goodman-Wilson Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Don Goodman-Wilson We just introduced the command-line option `--initial-branch=` to allow initializing a new repository with a different initial branch than the hard-coded one. To allow users to override the initial branch name more permanently (i.e. without having to specify the name manually for each and every `git init` invocation), let's introduce the `init.defaultBranch` config setting. Helped-by: Johannes Schindelin Helped-by: Derrick Stolee Signed-off-by: Don Goodman-Wilson --- Documentation/config/init.txt | 4 ++++ builtin/init-db.c | 2 +- refs.c | 30 ++++++++++++++++++++++++++++++ refs.h | 9 +++++++++ t/t0001-init.sh | 13 +++++++++++++ 5 files changed, 57 insertions(+), 1 deletion(-) diff --git a/Documentation/config/init.txt b/Documentation/config/init.txt index 46fa8c6a08..6ae4a38416 100644 --- a/Documentation/config/init.txt +++ b/Documentation/config/init.txt @@ -1,3 +1,7 @@ init.templateDir:: Specify the directory from which templates will be copied. (See the "TEMPLATE DIRECTORY" section of linkgit:git-init[1].) + +init.defaultBranch:: + Allows overriding the default branch name when initializing + a new repository. diff --git a/builtin/init-db.c b/builtin/init-db.c index 8fdfc334ac..cee64823cb 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -269,7 +269,7 @@ static int create_default_files(const char *template_path, char *ref; if (!initial_branch) - initial_branch = "master"; + initial_branch = git_default_branch_name(); ref = xstrfmt("refs/heads/%s", initial_branch); if (check_refname_format(ref, 0) < 0) diff --git a/refs.c b/refs.c index 224ff66c7b..b98dea5217 100644 --- a/refs.c +++ b/refs.c @@ -560,6 +560,36 @@ void expand_ref_prefix(struct argv_array *prefixes, const char *prefix) argv_array_pushf(prefixes, *p, len, prefix); } +char *repo_default_branch_name(struct repository *r) +{ + const char *config_key = "init.defaultbranch"; + const char *config_display_key = "init.defaultBranch"; + char *ret = NULL, *full_ref; + + if (repo_config_get_string(r, config_key, &ret) < 0) + die(_("could not retrieve `%s`"), config_display_key); + + if (!ret) + ret = xstrdup("master"); + + full_ref = xstrfmt("refs/heads/%s", ret); + if (check_refname_format(full_ref, 0)) + die(_("invalid branch name: %s = %s"), config_display_key, ret); + free(full_ref); + + return ret; +} + +const char *git_default_branch_name(void) +{ + static char *ret; + + if (!ret) + ret = repo_default_branch_name(the_repository); + + return ret; +} + /* * *string and *len will only be substituted, and *string returned (for * later free()ing) if the string passed in is a magic short-hand form diff --git a/refs.h b/refs.h index e010f8aec2..f212f8945e 100644 --- a/refs.h +++ b/refs.h @@ -154,6 +154,15 @@ int repo_dwim_log(struct repository *r, const char *str, int len, struct object_ int dwim_ref(const char *str, int len, struct object_id *oid, char **ref); int dwim_log(const char *str, int len, struct object_id *oid, char **ref); +/* + * Retrieves the default branch name for newly-initialized repositories. + * + * The return value of `repo_default_branch_name()` is an allocated string. The + * return value of `git_default_branch_name()` is a singleton. + */ +const char *git_default_branch_name(void); +char *repo_default_branch_name(struct repository *r); + /* * A ref_transaction represents a collection of reference updates that * should succeed or fail together. diff --git a/t/t0001-init.sh b/t/t0001-init.sh index 386c06b5dd..6d2467995e 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@ -477,4 +477,17 @@ test_expect_success '--initial-branch' ' grep hello actual ' +test_expect_success 'overridden default initial branch name (config)' ' + test_config_global init.defaultBranch nmb && + git init initial-branch-config && + git -C initial-branch-config symbolic-ref HEAD >actual && + grep nmb actual +' + +test_expect_success 'invalid default branch name' ' + test_config_global init.defaultBranch "with space" && + test_must_fail git init initial-branch-invalid 2>err && + test_i18ngrep "invalid branch name" err +' + test_done From patchwork Wed Jun 24 14:46:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11623317 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1469C913 for ; Wed, 24 Jun 2020 14:46:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EC3B920724 for ; Wed, 24 Jun 2020 14:46:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YtlgXB1K" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403976AbgFXOqs (ORCPT ); Wed, 24 Jun 2020 10:46:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403954AbgFXOqp (ORCPT ); Wed, 24 Jun 2020 10:46:45 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 623EBC061795 for ; Wed, 24 Jun 2020 07:46:45 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id o8so2581406wmh.4 for ; Wed, 24 Jun 2020 07:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=Q0pF5yj7wjNRE2JCBd7v1az84w+LZ8K2+6NNlyKt2yU=; b=YtlgXB1KhNiDcwY5o/6l5a5UNmzwb6RI9j3/tCdqzp7GVRDWf8iIkeAHKhZiEiL3uk HkkPyvKaynOYOCjxsBs1OEDUuUT4HumKzF6SbJn1+fL3KBlQQwd/yQgwvjy0VWtFbC+5 layqGgKiR5JvZrxqrxBHUsyOgKLWWT8eT4VGZ9bjEqWkHXDG6IZCE+KYpoIfaZmHHWA3 bt6dO/EI61FbEXN9QUNEbNNjQl9RYLxFIKcPmF4JMQe2fHWRAGrZ8P1ibTm5hTgCNKks T3k43rXauHK2FbakThjbq2mpR4xU4hgsvoHjris3/wa3i4qyZY0ldpewixj04LcOQyyD SCtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=Q0pF5yj7wjNRE2JCBd7v1az84w+LZ8K2+6NNlyKt2yU=; b=o+05tJliMoKcG4x3NfpG7Ncw65nPbv9zz0Wh+p8IYA6qnZbaiVDw2qmuaNYjgeqXAM 0iv5MhPpvXSNtJmXrSvnnhqNhy7qW7JkhsYgvSgVg9gdzlB1Fw+H9QVdZHMf/A73OI5f HdY9pfsKjwE24Gbm8WSCwXonBarAu60qdUIv/dYiOxxtSBr3Nz2aC7wWZTflpahH19jC pt7FzsEsoP6Wvr+kic2mLjslvzQLN1cUTnLdoaJPi+5VorenYgmmZGI94MsxfWYuX2OA XE/sXHLfTsnAzxnBnxgcK28DAJ9HkEydfIpxPHHzF8xR6FST98yO/Em0eNZ6YXen21kk 3bvQ== X-Gm-Message-State: AOAM530UBQx9zb8za5+3W0jXuxTHXmLRDA8jDGADtQjWYjd7pXm9QMZx vAgWH5vIrrYX4mHDWRiqarTH+RPbeO0= X-Google-Smtp-Source: ABdhPJzaZeP+OsJu27T8Me/w94koIL054O5QBuCageOfdclyroMzaJeiR2VR/3629PdNWfg3dsXdcg== X-Received: by 2002:a1c:48:: with SMTP id 69mr31208850wma.32.1593010004024; Wed, 24 Jun 2020 07:46:44 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a81sm8719330wmf.30.2020.06.24.07.46.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 07:46:43 -0700 (PDT) Message-Id: <1cff7705e43ef79902e03f1420d611c53429ea11.1593009996.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Date: Wed, 24 Jun 2020 14:46:34 +0000 Subject: [PATCH v4 7/9] clone: use configured default branch name when appropriate Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: don@goodman-wilson.com, stolee@gmail.com, peff@peff.net, sandals@crustytoothpaste.net, Matt Rogers , Eric Sunshine , Taylor Blau , Phillip Wood , Alban Gruin , Johannes Sixt , Denton Liu , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Philippe Blain , Johannes Schindelin , Johannes Schindelin Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin When cloning a repository without any branches, Git chooses a default branch name for the as-yet unborn branch. As part of the implicit initialization of the local repository, Git just learned to respect `init.defaultBranch` to choose a different initial branch name. We now really want that branch name to be used as a fall-back. Signed-off-by: Johannes Schindelin --- Documentation/config/init.txt | 4 ++-- builtin/clone.c | 10 +++++++--- t/t5606-clone-options.sh | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Documentation/config/init.txt b/Documentation/config/init.txt index 6ae4a38416..dc77f8c844 100644 --- a/Documentation/config/init.txt +++ b/Documentation/config/init.txt @@ -3,5 +3,5 @@ init.templateDir:: (See the "TEMPLATE DIRECTORY" section of linkgit:git-init[1].) init.defaultBranch:: - Allows overriding the default branch name when initializing - a new repository. + Allows overriding the default branch name e.g. when initializing + a new repository or when cloning an empty repository. diff --git a/builtin/clone.c b/builtin/clone.c index b751bdf13e..9a3f91b268 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -1267,9 +1267,13 @@ int cmd_clone(int argc, const char **argv, const char *prefix) remote_head_points_at = NULL; remote_head = NULL; option_no_checkout = 1; - if (!option_bare) - install_branch_config(0, "master", option_origin, - "refs/heads/master"); + if (!option_bare) { + const char *branch = git_default_branch_name(); + char *ref = xstrfmt("refs/heads/%s", branch); + + install_branch_config(0, branch, option_origin, ref); + free(ref); + } } write_refspec_config(src_ref_prefix, our_head_points_at, diff --git a/t/t5606-clone-options.sh b/t/t5606-clone-options.sh index 9e24ec88e6..286bfd93ac 100755 --- a/t/t5606-clone-options.sh +++ b/t/t5606-clone-options.sh @@ -35,4 +35,19 @@ test_expect_success 'redirected clone -v does show progress' ' ' +test_expect_success 'chooses correct default initial branch name' ' + git init --bare empty && + git -c init.defaultBranch=up clone empty whats-up && + test refs/heads/up = $(git -C whats-up symbolic-ref HEAD) && + test refs/heads/up = $(git -C whats-up config branch.up.merge) +' + +test_expect_success 'guesses initial branch name correctly' ' + git init --initial-branch=guess initial-branch && + test_commit -C initial-branch no-spoilers && + git -C initial-branch branch abc guess && + git clone initial-branch is-it && + test refs/heads/guess = $(git -C is-it symbolic-ref HEAD) +' + test_done From patchwork Wed Jun 24 14:46:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11623321 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D3C9E913 for ; Wed, 24 Jun 2020 14:46:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B2AE820781 for ; Wed, 24 Jun 2020 14:46:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E/28V9H2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403999AbgFXOqt (ORCPT ); Wed, 24 Jun 2020 10:46:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403975AbgFXOqq (ORCPT ); Wed, 24 Jun 2020 10:46:46 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4765FC061573 for ; Wed, 24 Jun 2020 07:46:46 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id g18so2580612wrm.2 for ; Wed, 24 Jun 2020 07:46:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=aWQJFrQmwkYFmyvGvoBAFj/ax2NjVkDgrCSbgR8HTgo=; b=E/28V9H2RhmsQKL+9UqQPeXFWQB7ZihArvk7ROq4i5Dx94MsOv0eUofZ5LiReFbqZ7 C91fIIYXcLNn8wZ5FPmrOF+SwEy8lORqRKvtqPTTUbfBGyCOEf0ZJjG6fXjHmKoQKCxx QsRi68Ezg/sJMiD6JNFiQAXXLBjOQUGk900KIaKCfrT2A2I5XUjJSEVpAgY71xGX1Vwb pocMqi1W6RkOfMoIoj/9kamXswkSDHTuaHIJVDNtl6ZyoAxjjXoF/fOuplKtR3QucXm7 R7D31xQIxXLaJQJqZamInxBAk5dzI3I/XD3qpwov/Rx/VAHXb2ZFwjonR2gdreoODAbS PqtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=aWQJFrQmwkYFmyvGvoBAFj/ax2NjVkDgrCSbgR8HTgo=; b=ljVYiAmMymcQSW/KhKzVnk08I7NBeFsdmK0zgyuBeucy6myjhvko0Z4N0/K2Gb0UNj 9VuvNbQWGsIFFOzNK6ANUGoco1K0D+O/724K4VCfwK4X8Hz3E0QpKiQVBlb55FQKmFXt WaXSHEzM5H0h4XiWk4MYteZvT6DiakxqVbsb14e6fBqi1Tx6Bg9uDvnLiEyoJvWHDzLx xwQZxdX21BqYL0wFYgaQjDesVzZ0kaxgXH3boVp/kX4pbnSHtnhJeX+GFb2OIiofpH+8 5fHGLryFBgDEbOTpK2CQ5U0wE+SDFDSmgiQ3TxKovmXMlDoJRkunIFXZhyVFPQ2DAL1X N86g== X-Gm-Message-State: AOAM531LzjnWHpqYYRnauDOELyM25pUYYVQ4ym7mpF8jtDLikHPF3hWc oqn/mUUMrFrrUaQJh+dMPQewRuaHUIk= X-Google-Smtp-Source: ABdhPJypbpuS1AvbCs211UuTp0h6jFrNUSI2cCEynjKUPu7P9iPhhXsEiqefj56Uc02AaPabvHd6cA== X-Received: by 2002:a5d:4e81:: with SMTP id e1mr16851962wru.22.1593010004911; Wed, 24 Jun 2020 07:46:44 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f2sm7989043wmj.39.2020.06.24.07.46.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 07:46:44 -0700 (PDT) Message-Id: <0a7c0bdfda0bd7af284d317531d0f3985a4077e5.1593009996.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Date: Wed, 24 Jun 2020 14:46:35 +0000 Subject: [PATCH v4 8/9] remote: use the configured default branch name when appropriate Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: don@goodman-wilson.com, stolee@gmail.com, peff@peff.net, sandals@crustytoothpaste.net, Matt Rogers , Eric Sunshine , Taylor Blau , Phillip Wood , Alban Gruin , Johannes Sixt , Denton Liu , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Philippe Blain , Johannes Schindelin , Johannes Schindelin Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin When guessing the default branch name of a remote, and there are no refs to guess from, we want to go with the preference specified by the user for the fall-back, i.e. the default name to be used for the initial branch of new repositories (because as far as the user is concerned, a remote that has no branches yet is a new repository). At the same time, when talking to an older Git server that does not report a symref for `HEAD` (but instead reports a commit hash), let's try to guess the configured default branch name first. If it does not match the reported commit hash, let's fall back to `master` as before. Signed-off-by: Johannes Schindelin --- remote.c | 14 +++++++++++--- t/t5606-clone-options.sh | 11 ++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/remote.c b/remote.c index 534c6426f1..bc46413e6a 100644 --- a/remote.c +++ b/remote.c @@ -276,7 +276,7 @@ static void read_branches_file(struct remote *remote) /* * The branches file would have URL and optionally - * #branch specified. The "master" (or specified) branch is + * #branch specified. The default (or specified) branch is * fetched and stored in the local branch matching the * remote name. */ @@ -284,7 +284,7 @@ static void read_branches_file(struct remote *remote) if (frag) *(frag++) = '\0'; else - frag = "master"; + frag = (char *)git_default_branch_name(); add_url_alias(remote, strbuf_detach(&buf, NULL)); strbuf_addf(&buf, "refs/heads/%s:refs/heads/%s", @@ -2097,8 +2097,16 @@ struct ref *guess_remote_head(const struct ref *head, if (head->symref) return copy_ref(find_ref_by_name(refs, head->symref)); - /* If refs/heads/master could be right, it is. */ + /* If a remote branch exists with the default branch name, let's use it. */ if (!all) { + char *ref = xstrfmt("refs/heads/%s", git_default_branch_name()); + + r = find_ref_by_name(refs, ref); + free(ref); + if (r && oideq(&r->old_oid, &head->old_oid)) + return copy_ref(r); + + /* Fall back to the hard-coded historical default */ r = find_ref_by_name(refs, "refs/heads/master"); if (r && oideq(&r->old_oid, &head->old_oid)) return copy_ref(r); diff --git a/t/t5606-clone-options.sh b/t/t5606-clone-options.sh index 286bfd93ac..e69427f881 100755 --- a/t/t5606-clone-options.sh +++ b/t/t5606-clone-options.sh @@ -47,7 +47,16 @@ test_expect_success 'guesses initial branch name correctly' ' test_commit -C initial-branch no-spoilers && git -C initial-branch branch abc guess && git clone initial-branch is-it && - test refs/heads/guess = $(git -C is-it symbolic-ref HEAD) + test refs/heads/guess = $(git -C is-it symbolic-ref HEAD) && + + git -c init.defaultBranch=none init --bare no-head && + git -C initial-branch push ../no-head guess abc && + git clone no-head is-it2 && + test_must_fail git -C is-it2 symbolic-ref refs/remotes/origin/HEAD && + git -C no-head update-ref --no-deref HEAD refs/heads/guess && + git -c init.defaultBranch=guess clone no-head is-it3 && + test refs/remotes/origin/guess = \ + $(git -C is-it3 symbolic-ref refs/remotes/origin/HEAD) ' test_done From patchwork Wed Jun 24 14:46:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11623319 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7AAB314B7 for ; Wed, 24 Jun 2020 14:46:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6322720781 for ; Wed, 24 Jun 2020 14:46:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cSzl2h5r" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404016AbgFXOqu (ORCPT ); Wed, 24 Jun 2020 10:46:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391295AbgFXOqr (ORCPT ); Wed, 24 Jun 2020 10:46:47 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2473CC061795 for ; Wed, 24 Jun 2020 07:46:47 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id q5so2556647wru.6 for ; Wed, 24 Jun 2020 07:46:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=u6JG8xbS+cKtoN0338qGgi/g2nWe5Hm26yJvKNYy4hY=; b=cSzl2h5rHH+WqGSoLm1UndzEEMvoEFEx99FfApQvhK2J49WxiQRFsNmhYx3nb0MAeL i6TlE3j8g+JmPo/XgAi3RDZ0JrEs8EpU8kl6eKh+gkF+eqpgpymK4CLZzGU1VT/O8pyF kzzlbofyXV3WLmhb0r42TnpBZ8+lLxWphpoTTxbmypnBDSrDkwnCSKVFd/9T+A4I3N6E bBbD3udlA2YPd4c3U+/pIaDtEPY1ozlp3BTCvNno8I3EedEfhawntK+vZFkR4zfhMGB6 JIWCXXjvdY8OZX90jh3BXnHd7BKP03D1XL9F6mDSg99Y9WLGT1LBz9DpdXg7zfXluI2k Pqag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=u6JG8xbS+cKtoN0338qGgi/g2nWe5Hm26yJvKNYy4hY=; b=SVAdbEzTy0oPiS8X2XrgnU3TpdOemDaBMU1metYhgRAwoHbXQXSGUbYdD0TjwU06x7 ttLO5KW5z5Cr8Vj42nnDXQetbJWmo4EUAdJ2xC/SimroPXYcbPEi6YeDE5j1Y2qzfKBs d3q4eNS5Pm9qHzGMtqNTdAbU6GKI+H13j/G+8Z4pPLJ8e9gYmVo0edozOkUv+Z0oVCCN TKKX1PTbuzZjlopJSlAyU9BvUDlANrNZpscJX4ztQTv2jwHpnVHPF0xkcC+zvgo1hYuk qhK+6+oY9Y0c4yP1p7jiQaSMg+csebGbdq/8dVUoVHqoCEpIKpEGTlVZRhEBp9UH66Zu EIww== X-Gm-Message-State: AOAM532xu3cA9NUgPB1U5LHSBBiPUWkJGEghY5hyR9bR+TXbDcvzeizV a21CCbEh5P+mV8DGUgYUiZ82baq84rk= X-Google-Smtp-Source: ABdhPJzyH7NuyCnL7ljbL+uTQGJg+netuH7TDuYuE5q6Pmoct64TAJGONfNDEhkrZthHixfv4yVF8g== X-Received: by 2002:adf:c44d:: with SMTP id a13mr10306256wrg.205.1593010005788; Wed, 24 Jun 2020 07:46:45 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id w17sm28792511wra.42.2020.06.24.07.46.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 07:46:45 -0700 (PDT) Message-Id: <6c72abf677db0776a124a34f3e58ec58c36dd93f.1593009996.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Date: Wed, 24 Jun 2020 14:46:36 +0000 Subject: [PATCH v4 9/9] testsvn: respect `init.defaultBranch` Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: don@goodman-wilson.com, stolee@gmail.com, peff@peff.net, sandals@crustytoothpaste.net, Matt Rogers , Eric Sunshine , Taylor Blau , Phillip Wood , Alban Gruin , Johannes Sixt , Denton Liu , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Philippe Blain , Johannes Schindelin , Johannes Schindelin Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin The default name of the initial branch in new repositories can now be configured. The `testsvn` remote helper translates the remote Subversion repository's branch name `trunk` to the hard-coded name `master`. Clearly, the intention was to make the name align with Git's defaults. So while we are not talking about a newly-created repository in the `testsvn` context, it is a newly-created _Git_ repository, si it _still_ makes sense to use the overridden default name for the initial branch whenever users configured it. Signed-off-by: Johannes Schindelin --- remote-testsvn.c | 10 +++++++--- t/t9020-remote-svn.sh | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/remote-testsvn.c b/remote-testsvn.c index 3af708c5b6..cde39b94fb 100644 --- a/remote-testsvn.c +++ b/remote-testsvn.c @@ -13,7 +13,7 @@ static const char *url; static int dump_from_file; static const char *private_ref; -static const char *remote_ref = "refs/heads/master"; +static char *remote_ref; static const char *marksfilename, *notes_ref; struct rev_note { unsigned int rev_nr; }; @@ -286,7 +286,7 @@ int cmd_main(int argc, const char **argv) private_ref_sb = STRBUF_INIT, marksfilename_sb = STRBUF_INIT, notes_ref_sb = STRBUF_INIT; static struct remote *remote; - const char *url_in; + const char *url_in, *remote_ref_short; setup_git_directory(); if (argc < 2 || argc > 3) { @@ -294,6 +294,9 @@ int cmd_main(int argc, const char **argv) return 1; } + remote_ref_short = git_default_branch_name(); + remote_ref = xstrfmt("refs/heads/%s", remote_ref_short); + remote = remote_get(argv[1]); url_in = (argc == 3) ? argv[2] : remote->url[0]; @@ -306,7 +309,8 @@ int cmd_main(int argc, const char **argv) url = url_sb.buf; } - strbuf_addf(&private_ref_sb, "refs/svn/%s/master", remote->name); + strbuf_addf(&private_ref_sb, "refs/svn/%s/%s", + remote->name, remote_ref_short); private_ref = private_ref_sb.buf; strbuf_addf(¬es_ref_sb, "refs/notes/%s/revs", remote->name); diff --git a/t/t9020-remote-svn.sh b/t/t9020-remote-svn.sh index 9fcfa969a9..754c4a3284 100755 --- a/t/t9020-remote-svn.sh +++ b/t/t9020-remote-svn.sh @@ -84,6 +84,12 @@ test_expect_success REMOTE_SVN 'incremental imports must lead to the same head' test_cmp master.good .git/refs/remotes/svnsim/master ' +test_expect_success REMOTE_SVN 'respects configured default initial branch' ' + git -c init.defaultBranch=trunk remote add -f trunk \ + "testsvn::file://$TEST_DIRECTORY/t9154/svn.dump" && + git rev-parse --verify refs/remotes/trunk/trunk +' + test_debug 'git branch -a' test_done