From patchwork Fri Jan 24 14:16:28 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: 182961 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp636173ile; Fri, 24 Jan 2020 06:16:45 -0800 (PST) X-Google-Smtp-Source: APXvYqyfe3DiKRKK+Xo2vJDt2gh6TsVqdOTglG+KrzZF3BKFigENvwZzY9Ud4mug1IiGF7J/QBe6 X-Received: by 2002:a05:6830:18d4:: with SMTP id v20mr2874598ote.29.1579875405255; Fri, 24 Jan 2020 06:16:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579875405; cv=none; d=google.com; s=arc-20160816; b=he1i4QHIm3S5VAs1DnvYCQnUwwbpRpnd2CReY7Z7kzdotXCT8N5veqC2qFKW4rKVtC aiyghIyJe1MjJtYN0ZeAor33lpDpI9KWDOsOddHIfqe5riMDL47ACXZTiiFzPW81AAnW Tr5iiGWTMWyWJwcnAFpmAjT9kSNx6LcccpwL5lBi/sUscjO2LXQFmnLrt/RoYTT0UATL WXESRm0earpgXrjROA1pu1tFjmx1NXafWLNSMYVHVWIn+G+JCe31ZBW52OI0gortsQUO 8pw7lGx/OCdQw2ugeRKAznUFJbn1wlYMS5X3n2rl2Ao2CRCmfLHEQt3QgeaVpGcDyTR1 B6lg== 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=zcchMKdVangHW43RzfRfExtgJGHsmq1XQqwozDvcPmY=; b=hd8gC1YDc+ELl6NcWQyV7KWLfCj3PP8M9wJZvc8LaY7SoxvFTRAofP4FGrfZ8LpZ3l hWLfvexATucoptNC8KhS1BCFPRZrQ+2NfWA8UWWVvGnuy53qN4ghAMsVonMzAVBbjLHF VOWMfq4mCzig7rYnhiqt/zLYGq2irhTGfJehlQ5NQyyMQc6pxgbIUuQv2F5lGVCSP5aD NSLr+qYeE5ZBa8tQ0U+3EKJhXAhRNoSncxPxpHRBgVuDvQTlFFJVQfCys9stjuC0VIWW SCB2pcX5fzUQhz6/xXSKwkCYSnp6uwmUm4k0k+0/Nl4O8up7lfw0flL83IlrImlnPEMr P5AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=m3CxR4UN; spf=pass (google.com: domain of gcc-patches-return-518218-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-518218-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 94si1693674otw.297.2020.01.24.06.16.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Jan 2020 06:16:45 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-518218-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=m3CxR4UN; spf=pass (google.com: domain of gcc-patches-return-518218-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-518218-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=TzgVkrF0W3Uv1a5G82JcBMLqzTLrF/tLPsg+BZb+AEIbK0nbgx QqxyMbG/WgoZi+Ro0glI8Bw2y/zkVcv+jMfrWryRnsntXUVMIX38FzQL3It2c3al 9JVwGWQ+Im1Q6zOG4GQSp6Sq7kBGXM+jJdIgN/QE0MRo6uDtjDzncdAIA= 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=47LCm1c2XlV6cPw1TFRLEL+c21E=; b=m3CxR4UN0y8lxm3qrKN0 X38DEGNtYtvTGYLJ33cVkBrSnDm4moyxd62JEBMM3xJzWVD5WozEVEY6tXDFF4AK 5RPcI2KVRA8hmls7+5S0tImLk7e0WSYU9/AhCB8qbvbOBexNCbWbGkLMiB7Sysgs C3Qc3YW5z7B2l5/jUTfVQSw= Received: (qmail 77174 invoked by alias); 24 Jan 2020 14:16:33 -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 77165 invoked by uid 89); 24 Jan 2020 14:16:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=UD:git-add-user-branch.sh, git-add-user-branch.sh, startpoint, gitadduserbranchsh 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, 24 Jan 2020 14:16:31 +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 3B52E1007; Fri, 24 Jan 2020 06:16:30 -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 C748B3F6C4; Fri, 24 Jan 2020 06:16:29 -0800 (PST) To: "gcc-patches@gcc.gnu.org" From: "Richard Earnshaw (lists)" Subject: contrib: Change 'remote' for personal branches and add branch creation script Message-ID: <839eb291-976b-8cc1-378f-dcc72cd4629b@arm.com> Date: Fri, 24 Jan 2020 14:16:28 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 Whilst trying to convert the add vendor branch script to work with personal branches I encountered a minor issue where git would report ambiguous refs when checking out the new branch. It turns out that this is because git considers / to be ambiguous if both refs/heads// and refs/remotes// exist in the list of known branches. Having thought about this a bit, I think the best solution is to adopt something more like the vendors space and call the remote users/ (this also works better if you want to set up remotes to track other users branches as well). So this patch has two parts. 1) It updates gcc-git-customization.sh to set up the new 'remote' and converts any existing remote and branches tracking that to the new format 2) It adds a new script to set up a personal branch on the gcc git repository. I'll produce an update to wwwdocs/.../gitwrite.html to cover these changes shortly. R. * gcc-git-customization.sh: Use users/ for the personal remote rather than just . Convert any existing user branches to the new remote. * git-add-user-branch.sh: New file. diff --git a/contrib/gcc-git-customization.sh b/contrib/gcc-git-customization.sh index c16db747503..f3e48316ead 100755 --- a/contrib/gcc-git-customization.sh +++ b/contrib/gcc-git-customization.sh @@ -128,7 +128,7 @@ 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" + 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}" @@ -140,15 +140,36 @@ do git config --add "remote.vendors/${v}.fetch" "+refs/vendors/$v/tags/*:refs/tags/vendors/${v}/*" done -echo "Setting up tracking for personal namespace $remote_id in remotes/${new_pfx}" -git config "remote.${new_pfx}.url" "${url}" +# Convert the remote 'pfx' to users/pfx to avoid problems with ambiguous refs +# on user branches +old_remote=$(git config --get "remote.${old_pfx}.url") +if [ -n "${old_remote}" ] +then + echo "Migrating remote \"${old_pfx}\" to new remote \"users/${new_pfx}\"" + # Create a dummy fetch rule that will cause the subsequent prune to remove the old remote refs. + git config --replace-all "remote.${old_pfx}.fetch" "+refs/empty/*:refs/remotes/${old_pfx}/*" + # Remove any remotes + git remote prune ${old_pfx} + git config --remove-section "remote.${old_pfx}" + for br in $(git branch --list "${old_pfx}/*") + do + old_remote=$(git config --get "branch.${br}.remote") + if [ "${old_remote}" = "${old_pfx}" ] + then + git config "branch.${br}.remote" "users/${new_pfx}" + fi + done +fi + +echo "Setting up tracking for personal namespace $remote_id in remotes/users/${new_pfx}" +git config "remote.users/${new_pfx}.url" "${url}" if [ "x$pushurl" != "x" ] then - git config "remote.${new_pfx}.pushurl" "${pushurl}" + git config "remote.users/${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}" +git config --replace-all "remote.users/${new_pfx}.fetch" "+refs/users/${remote_id}/heads/*:refs/remotes/users/${new_pfx}/*" "refs/users/${remote_id}/heads/" +git config --replace-all "remote.users/${new_pfx}.fetch" "+refs/users/${remote_id}/tags/*:refs/tags/users/${new_pfx}/*" "refs/users/${remote_id}/tags/" +git config --replace-all "remote.users/${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 @@ -157,3 +178,5 @@ fi git config --unset-all "remote.${upstream}.fetch" "refs/users/${remote_id}/" git config --unset-all "remote.${upstream}.push" "refs/users/${remote_id}/" + +git fetch "users/${new_pfx}" diff --git a/contrib/git-add-user-branch.sh b/contrib/git-add-user-branch.sh new file mode 100755 index 00000000000..e014f7518fb --- /dev/null +++ b/contrib/git-add-user-branch.sh @@ -0,0 +1,46 @@ +#! /bin/sh -e + +# Create a new upstream user branch. + +# Usage: +# contrib/git-add-user-branch.sh [/] + +usage () +{ + echo "Usage:" + echo " $0 [/] " + echo + echo "personal space must already have been set up using" + echo "contrib/gcc-git-customization.sh" + exit 1 +} + +if [ $# != 2 ] +then + usage +fi + +userpfx=$(git config --get "gcc-config.userpfx") +user=$(git config --get "gcc-config.user") + +if [ -z "$userpfx" -o -z "$user" ] +then + usage +fi + +branch=$(echo "$1" | sed -r "s:(${userpfx}/)?(.*)$:\2:") +start=$2 + +# Sanity check the new branch argument. If there is no '/', then the +# vendor will be the same as the entire first argument. +if [ -z "$branch" ] +then + usage +fi + +git push users/${userpfx} ${start}:refs/users/${user}/heads/${branch} +git fetch -q users/${userpfx} +git branch ${userpfx}/${branch} remotes/users/${userpfx}/${branch} +echo "You are now ready to check out ${userpfx}/${branch}" +echo "To push the branch upstream use:" +echo " git push users/${userpfx} ${userpfx}/${branch}"