From patchwork Fri Jan 17 11:21:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Richard Earnshaw \(lists\)" X-Patchwork-Id: 182875 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp9510515ile; Fri, 17 Jan 2020 03:21:33 -0800 (PST) X-Google-Smtp-Source: APXvYqzWAmnqPaUXlU1fvtu90M7UQZcD9UOi9DD0Tcpjy5917avWLns7eLgitOO2o9jSfW+CmbdN X-Received: by 2002:a54:488d:: with SMTP id r13mr2903870oic.115.1579260093574; Fri, 17 Jan 2020 03:21:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579260093; cv=none; d=google.com; s=arc-20160816; b=YqNH6Pbbsthqp1msGgGdgRc2L3e/b60h+qtuQc39AWHWmENKu92OYoJX5LQsX/x+6G aOSEIagaevnxICFsuVOxG7ehYAPy4BXkzel8dXb8ZIcsVWf6eo409Nt57sszCqctmW3A LxcSHrucAFdszDoKnI5S+cmbyajj/8RTBb4hpEoZL4td/gK5uzIVIOlTRoK9kDNjOvye LKfUOfY7oYhHPVzl/u7PGZIBLTKzCwJBM2/RePAZNIiE4gxKGxSGi/pbKbC0d+cdYZEC c1VVnfDc8kHpYLzFaSCSgIcKaRmvIJkC5TX6SOvzgCjBlrh+z1+JWI86lpjjeF9lVZFF Uy3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:mime-version:user-agent:date:message-id:references:to :from:subject:delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature; bh=DyEQgDjunrWNYxP9y0Z7+6lrE1IiF3djjtdW73n4P1o=; b=TjMQuqcmTy0WckXDi8YOME6V3pNbREsJaBRDz2c5oq9ZMLIO5MHWD6du+ppaGkHH1Y CEGWZdQ9FGeqenKiArlxEePhkJWEU460SteNWfPnAGXJa3DRVtavlGSYuEDb6nJdhdWS Q3sjdrkw8Xjllh5IyZ+O/TCSLQaxps6k0D9gs3XgfXqRzHw4z+e1bz0FY/wx4QL2lSLs 5ZttyDf4SyxhRYDK2NWnNCEBKdINgsI1aturPr8oXs7rHQdne8/Cs87kHiSdVZBww26l l8mEycxcCoJrt8+ukdA85NQzzJq4XZWyn++pfwAZIZlMTFxCHRhIqwbixkRQjiGASfG2 0Z6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=t7i5EilO; spf=pass (google.com: domain of gcc-patches-return-517587-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-517587-patch=linaro.org@gcc.gnu.org" Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id l14si14672394otk.225.2020.01.17.03.21.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Jan 2020 03:21:33 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-517587-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=t7i5EilO; spf=pass (google.com: domain of gcc-patches-return-517587-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-517587-patch=linaro.org@gcc.gnu.org" DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:references:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=q8G1bAeN00U5n3xHc O6KTcuptSNK7ZkyYlJ8+v5xLEQHwpUBdxCWkUYeQNXTqIWCS4Djvi/Oy7pqzS4iz mHvL73UbwstnBOw0VtAS4GCODQVLT9h4kn9oIoDSEgkONklETRxNQ/eJvp/5NVVe 7DJhF1LPDRD3VHfkzwTMK1zey0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:references:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=7MKKWcZs5WJXXD322jVXPvZ 9Nzk=; b=t7i5EilODbMyAuJpCO9HgHsfcDRmn0FB7orjYkLRcJEQzjK2Qsfue4t 54hyyUhdjo70bGVV1mVUw1YGCDZBBDfktw+uLsqiA5dzqqBCD7rpyPDudZHFjw0J lkAzVLdUtMiXAzTonETNKkP4Eet35ZfqYwLylG+q/ACdJNijBNr4= Received: (qmail 6035 invoked by alias); 17 Jan 2020 11:21:21 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 6024 invoked by uid 89); 17 Jan 2020 11:21:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 17 Jan 2020 11:21:10 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4215311D4; Fri, 17 Jan 2020 03:21:09 -0800 (PST) Received: from e120077-lin.cambridge.arm.com (e120077-lin.cambridge.arm.com [10.2.78.81]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E1D203F68E; Fri, 17 Jan 2020 03:21:08 -0800 (PST) Subject: [v2] contrib: New remotes structure for vendor and personal refs From: "Richard Earnshaw (lists)" To: "gcc-patches@gcc.gnu.org" References: <5b1cede7-76d5-1b1f-533e-75af5bed84b5@arm.com> Message-ID: <86a1f7a7-04ff-3c65-9229-ce2c7995264f@arm.com> Date: Fri, 17 Jan 2020 11:21:07 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <5b1cede7-76d5-1b1f-533e-75af5bed84b5@arm.com> The initial structure for vendor and personal branches makes use of the default remote (normally origin) for the upstream repository). Unfortunately, this causes some confusion, especially for personal branches because a push will not push to the correct upstream location. This can be 'fixed' by adding a push refspec for the remote, but that has the unfortunate consequence of breaking the push.default behaviour for git push, and it becomes too easy to accidentally commit something unintended to the main parts of the repository. To work around this, this patch changes the configuration to use separate 'remotes' for these additional refs, with one remote for the personal space and another remote for each vendor's space. The personal space is called after the user's preferred branch-space prefix (default 'me'), the vendor spaces are called vendors/. As far as possible, I've made the script automatically restructure any existing fetch or push lines that earlier versions of the scripts may have created - the gcc-git-customization.sh script will convert all vendor refs that it can find, so it is not necessary to re-add any vendors you've already added. You might, however, want to run git remote prune after running to clean up any stale upstream-refs that might still be in your local repo, and then git fetch vendors/ or git fetch to re-populate the remotes/ structures. Also, for any branch you already have that tracks a personal or vendor branch upstream, you might need to run git config branch..remote so that merges and pushes go to the right place (I haven't attempted to automate this last part). For vendors, the new structure means that git checkout -b / remotes/vendors// will correctly set up a remote tracking branch. Please be aware that if you have multiple personal branches set up, then git push will still consider all of them for pushing. If you only want to push one branch, then either write git push HEAD or git push /branch as appropriate. And don't forget '-n' (--dry-run) to see what would be done if this were not a dry run. Finally, now that the vendors spaces are isolated from each other and from the other spaces, I've added an option "--enable-push" to git-fetch-vendor.sh. If passed, then a "push" spec will be added for that vendor to enable pushing to the upstream. If you re-run the script for the same vendor without the option, the push spec will be removed. * gcc-git-customization.sh: New personal and vendor layout. Convert any existing fetch/push rules to new layout. * git-fetch-vendor.sh: New vendor layout. Add --enable-push option. diff --git a/contrib/gcc-git-customization.sh b/contrib/gcc-git-customization.sh index 26f4389bcc8..c16db747503 100755 --- a/contrib/gcc-git-customization.sh +++ b/contrib/gcc-git-customization.sh @@ -81,6 +81,13 @@ then upstream="origin" fi ask "Local name for upstream repository" "origin" upstream + +v=$(git config --get-all "remote.${upstream}.fetch") +if [ "x$v" = "x" ] +then + echo "Remote $upstream does not seem to exist as a remote" + exit 1 +fi git config "gcc-config.upstream" "$upstream" remote_id=$(git config --get "gcc-config.user") @@ -100,6 +107,7 @@ then fi fi fi + ask "Account name on gcc.gnu.org (for your personal branches area)" $remote_id remote_id git config "gcc-config.user" "$remote_id" @@ -108,27 +116,44 @@ if [ "x$old_pfx" = "x" ] then old_pfx="me" fi +echo echo "Local branch prefix for personal branches you want to share" echo "(local branches starting / can be pushed directly to your" ask "personal area on the gcc server)" $old_pfx new_pfx git config "gcc-config.userpfx" "$new_pfx" -echo "Setting up tracking for personal namespace $remote_id in remotes/$upstream/${new_pfx}" -git config --replace-all "remote.${upstream}.fetch" "+refs/users/${remote_id}/heads/*:refs/remotes/${upstream}/${new_pfx}/*" ":refs/remotes/${upstream}/${old_pfx}/" -git config --replace-all "remote.${upstream}.fetch" "+refs/users/${remote_id}/tags/*:refs/tags/${new_pfx}/*" ":refs/tags/${old_pfx}/" +# Scan the existing settings to see if there are any we need to rewrite. +vendors=$(git config --get-all "remote.${upstream}.fetch" "refs/vendors/" | sed -r "s:.*refs/vendors/([^/]+)/.*:\1:" | sort | uniq) +url=$(git config --get "remote.${upstream}.url") +pushurl=$(git config --get "remote.${upstream}.pushurl") +for v in $vendors +do + echo "Migrating vendor $v to new remote vendors/$v" + git config --unset-all "remote.${upstream}.fetch" "refs/vendors/$v/" + git config --unset-all "remote.${upstream}.push" "refs/vendors/$v/" + git config "remote.vendors/${v}.url" "${url}" + if [ "x$pushurl" != "x" ] + then + git config "remote.vendors/${v}.pushurl" "${pushurl}" + fi + git config --add "remote.vendors/${v}.fetch" "+refs/vendors/$v/heads/*:refs/remotes/vendors/${v}/*" + git config --add "remote.vendors/${v}.fetch" "+refs/vendors/$v/tags/*:refs/tags/vendors/${v}/*" +done -push_rule=$(git config --get "remote.${upstream}.push") -if [ "x$push_rule" != "x" ] +echo "Setting up tracking for personal namespace $remote_id in remotes/${new_pfx}" +git config "remote.${new_pfx}.url" "${url}" +if [ "x$pushurl" != "x" ] then - echo "***********************************************" - echo " Warning" - echo "***********************************************" - echo - echo "Old versions of this script used to add custom push" - echo "rules to simplify pushing to personal branches." - echo "Your configuration contains such rules, but we no-longer" - echo "recommend doing this." - echo - echo "To delete these rules run:" - echo " git config --unset-all \"remote.${upstream}.push\"" + git config "remote.${new_pfx}.pushurl" "${pushurl}" fi +git config --replace-all "remote.${new_pfx}.fetch" "+refs/users/${remote_id}/heads/*:refs/remotes/${new_pfx}/*" ":refs/remotes/${old_pfx}/" +git config --replace-all "remote.${new_pfx}.fetch" "+refs/users/${remote_id}/tags/*:refs/tags/${new_pfx}/*" ":refs/tags/${old_pfx}/" +git config --replace-all "remote.${new_pfx}.push" "refs/heads/${new_pfx}/*:refs/users/${remote_id}/heads/*" ":refs/users/${remote_id}" + +if [ "$old_pfx" != "$new_pfx" -a "$old_pfx" != "${upstream}" ] +then + git config --remove-section "remote.${old_pfx}" +fi + +git config --unset-all "remote.${upstream}.fetch" "refs/users/${remote_id}/" +git config --unset-all "remote.${upstream}.push" "refs/users/${remote_id}/" diff --git a/contrib/git-fetch-vendor.sh b/contrib/git-fetch-vendor.sh index d2d3ed56ad7..15303629b5c 100755 --- a/contrib/git-fetch-vendor.sh +++ b/contrib/git-fetch-vendor.sh @@ -1,12 +1,16 @@ #!/bin/sh -if [ $# != 1 ] -then - echo "Usage: $0 " +usage () +{ + echo "Usage: $0 [--enable-push] " + echo "The following vendors are already known:" + git ls-remote ${upstream} "*/vendors/*" | sed -r "s:.*/vendors/([^/]+)/.*:\1:"|sort|uniq exit 1 -fi +} + +# Should we insert a "push" refspec to enable pushing to the vendor branch? +enable_push=no -vendor=$1 upstream=`git config --get "gcc-config.upstream"` if [ x"$upstream" = x ] then @@ -14,7 +18,49 @@ then exit 1 fi -echo "setting up git to fetch vendor ${vendor} to remotes/${upstream}/${vendor}" -git config --replace-all "remote.${upstream}.fetch" "+refs/vendors/${vendor}/heads/*:refs/remotes/${upstream}/${vendor}/*" ":refs/remotes/${upstream}/${vendor}/" -git config --replace-all "remote.${upstream}.fetch" "+refs/vendors/${vendor}/tags/*:refs/tags/${vendor}/*" ":refs/tags/${vendor}/" -git fetch +case $# in + 1) + # vendor names never start with -, so catch this in case user wrote something like --help. + case "$1" in + -*) + usage + ;; + *) + vendor=$1 + ;; + esac + ;; + 2) + vendor=$2 + if [ "$1" = "--enable-push" ] + then + enable_push=yes + else + usage + fi + ;; + *) + usage + ;; +esac + + +echo "setting up git to fetch vendor ${vendor} to remotes/vendors/${vendor}" +url=$(git config --get "remote.${upstream}.url") +pushurl=$(git config --get "remote.${upstream}.pushurl") +git config "remote.vendors/${vendor}.url" "${url}" +if [ "x$pushurl" != "x" ] +then + git config "remote.vendors/${vendor}.pushurl" "${pushurl}" +fi +git config --replace-all "remote.vendors/${vendor}.fetch" "+refs/vendors/${vendor}/heads/*:refs/remotes/vendors/${vendor}/*" "refs/vendors/${vendor}/heads" +git config --replace-all "remote.vendors/${vendor}.fetch" "+refs/vendors/${vendor}/tags/*:refs/tags/vendors/${vendor}/*" "refs/vendors/${vendor}/tags" +if [ "$enable_push" = "yes" ] +then + echo "Warning: take care when pushing that you only push the changes you intend." + echo "E.g. use \"git push vendors/${vendor} HEAD\" to push the current branch" + git config --replace-all "remote.vendors/${vendor}.push" "refs/heads/${vendor}/*:refs/vendors/${vendor}/heads/*" +else + git config --unset-all "remote.vendors/${vendor}.push" +fi +git fetch vendors/${vendor}