From patchwork Thu Jan 16 17:06:08 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: 182862 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp8530749ile; Thu, 16 Jan 2020 09:06:37 -0800 (PST) X-Google-Smtp-Source: APXvYqw05kfUETz2SqK8R4mOCniEZDehYPvHMrvq5lEFgrMQ5zW/E/gloOx+JBSRIt4GoKZuDL6N X-Received: by 2002:aca:5083:: with SMTP id e125mr48652oib.96.1579194397030; Thu, 16 Jan 2020 09:06:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579194397; cv=none; d=google.com; s=arc-20160816; b=zXhqDF9/K5eDTS8CpomacVG0JX8HwP4MzIXnSNU+R/i61PS3ekrtdCpb1qabr/10ae Y8xJ0U7Bwi/nc4swhXoRWikcBK4HqSxfSdnefx2SmwtWOHDwsF9QCcFFzpV3n/DQ9+Nx 9kc8JiqL0D54SQDwnJUy3cFUN4YgfqIAMPfwZetpmKiEwGUqJTMTSLLzzjBIUsQ+LAYA UJhfdFUpaawpSh2HtuBfkXovpiy8SC6lA5VOPRnz6uMtaUafc+vFAOzIXkx91Qt1dUI0 7HpYL5FiT1Ra6nd5UqxAkTzAVDJ3VadqTAps4o4VLJvwjGabghOmCPNqfwFlSdnrmPx9 1HOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:date:message-id:subject:from:to :delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature; bh=0PF5yVvU7Faf7jEQ25hh76yd6p+MbcgkobTvBGEa8NI=; b=qTYyaQxs64vstgS50tKPJ+43O2f8x9NRonGetD/FCVEwvDLU6M+te/trEodsVyAXcb Q60wyK4hFGJs8UwlNrWz9cBcTXaJTy2s3BFX4PpCiUUcUeDJ1MmA9oE3h59Anbj3IOIf QQ3ZIgIkyF8itnYnOtgYVrLUNnTf04Yfqk2A9g2+mKA7VAkOgKEeoMTt/2iJzTsMMKLA mIMy+Skuq4HQKMIzweV9D5cuoAmiHjrW1tTK7IqZnYnxIgjMZysspaX+yEHBqOoyL8YI brYAqZmSr5AVCjA31iqh4JAwfq+WnMM0itJq5Aje84WuRVn5wSo+1aywUslhgwn1GdeU 338A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=JItlOXKp; spf=pass (google.com: domain of gcc-patches-return-517535-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-517535-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 j143si11266492oib.16.2020.01.16.09.06.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jan 2020 09:06:37 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-517535-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=JItlOXKp; spf=pass (google.com: domain of gcc-patches-return-517535-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-517535-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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=azpQaopAIEWf0Vkv7swmVoPlvwsYUO1kRV+27OPfL3Ts7wQTzV m4prZkJaTtSZi8Ji+sGiOSXKaAyuFMOTX5j0+Kp9QgfuHONX7BXPOH5G+aiV9HHw p3Zj8VsLb51gwBGP+zxKVaHKDGKwtexBGIi13C+yriUGiizpEo6LxpEyo= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=xyWCtQ3/mHXvmdoIzhpUWSebESA=; b=JItlOXKpR13rgbDBkPs3 obbx9XEbeORIuAuIiDJLeN/BYimAsNYhUBbSETeJMdZmfPdP3KMaKRsFszdg4SL5 8jy8o0RAU6Sdc2+ateNxxLO/o4GSnP4vST0lfc8XmFTNuZW49MYok7Q9eytmnSLS /SeYu7R/Z6UERXbBhN770nQ= Received: (qmail 40287 invoked by alias); 16 Jan 2020 17:06:25 -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 40261 invoked by uid 89); 16 Jan 2020 17:06:24 -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, SPF_PASS 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; Thu, 16 Jan 2020 17:06:14 +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 A07D91396; Thu, 16 Jan 2020 09:06:12 -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 4C09B3F534; Thu, 16 Jan 2020 09:06:12 -0800 (PST) To: "gcc-patches@gcc.gnu.org" From: "Richard Earnshaw (lists)" Subject: contrib: New remotes structure for vendor and personal refs Message-ID: <5b1cede7-76d5-1b1f-533e-75af5bed84b5@arm.com> Date: Thu, 16 Jan 2020 17:06:08 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 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 vendor-. 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 vendor- 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). 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. * 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. I'll wait a bit before pushing this, just in case someone spots an issue. R. diff --git a/contrib/gcc-git-customization.sh b/contrib/gcc-git-customization.sh index 26f4389bcc8..b62397314c6 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") @@ -113,22 +120,38 @@ 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 vendor-$v" + git config --unset-all "remote.${upstream}.fetch" "refs/vendors/$v/" + git config --unset-all "remote.${upstream}.push" "refs/vendors/$v/" + git config "remote.vendor-${v}.url" "${url}" + if [ "x$pushurl" != "x" ] + then + git config "remote.vendor-${v}.pushurl" "${pushurl}" + fi + git config --add "remote.vendor-${v}.fetch" "+refs/vendors/$v/heads/*:refs/remotes/vendor-${v}/*" + git config --add "remote.vendor-${v}.fetch" "+refs/vendors/$v/tags/*:refs/tags/vendor-${v}/*" +done + +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 + 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}" -push_rule=$(git config --get "remote.${upstream}.push") -if [ "x$push_rule" != "x" ] +if [ "$old_pfx" != "$new_pfx" -a "$old_pfx" != "${upstream}" ] 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 --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..75b0f110927 100755 --- a/contrib/git-fetch-vendor.sh +++ b/contrib/git-fetch-vendor.sh @@ -1,20 +1,30 @@ #!/bin/sh +upstream=`git config --get "gcc-config.upstream"` +if [ x"$upstream" = x ] +then + echo "Config gcc-config.upstream not set, run contrib/gcc-git-customization" + exit 1 +fi + if [ $# != 1 ] then echo "Usage: $0 " + echo "The following vendors are already known:" + git ls-remote ${upstream} "*/vendors/*" | sed -r "s:.*/vendors/([^/]+)/.*:\1:"|sort|uniq exit 1 fi vendor=$1 -upstream=`git config --get "gcc-config.upstream"` -if [ x"$upstream" = x ] + +echo "setting up git to fetch vendor ${vendor} to remotes/vendor-${vendor}" +url=$(git config --get "remote.${upstream}.url") +pushurl=$(git config --get "remote.${upstream}.pushurl") +git config "remote.vendor-${vendor}.url" "${url}" +if [ "x$pushurl" != "x" ] then - echo "Config gcc-config.upstream not set, run contrib/gcc-git-customization" - exit 1 + git config "remote.vendor-${vendor}.pushurl" "${pushurl}" 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 +git config --replace-all "remote.vendor-${vendor}.fetch" "+refs/vendors/${vendor}/heads/*:refs/remotes/vendor-${vendor}/*" ":refs/remotes/vendor-${vendor}/" +git config --replace-all "remote.vendor-${vendor}.fetch" "+refs/vendors/${vendor}/tags/*:refs/tags/${vendor}/*" ":refs/tags/${vendor}/" +git fetch vendor-${vendor}