From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 58968 invoked by alias); 10 Jan 2020 14:26:59 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 58339 invoked by uid 89); 10 Jan 2020 14:26:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.3 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; Fri, 10 Jan 2020 14:26:57 +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 BB358328; Fri, 10 Jan 2020 06:26:55 -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 38BF23F534; Fri, 10 Jan 2020 06:26:54 -0800 (PST) Subject: Re: Some local customization enhancements when using git From: "Richard Earnshaw (lists)" To: "gcc-patches@gcc.gnu.org" References: <54834f12-32b1-492f-fb9e-b2c74df23167@arm.com> Message-ID: <95dfd77a-3361-545e-8b86-01078304ae29@arm.com> Date: Fri, 10 Jan 2020 14:27:00 -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: <54834f12-32b1-492f-fb9e-b2c74df23167@arm.com> Content-Type: multipart/mixed; boundary="------------779AE3246120244E9454F375" X-SW-Source: 2020-01/txt/msg00555.txt.bz2 This is a multi-part message in MIME format. --------------779AE3246120244E9454F375 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-length: 1199 On 10/01/2020 13:23, Richard Earnshaw (lists) wrote: > This patch is intended to help with folks setting up a git work > environment for use with GCC following the transition to git.  It > currently does a couple of things. > > 1) Add an alias 'svn-rev' to git so that you can look up a legacy commit > by its svn revision number.  This enables you to type > git svn-rev 1234 > and git will show the commit log entry relating to SVN r1234. > > 2) Sets up tracking information for the user's private name area in the > git repo.  It tries to figure out some sensible answers to the data it > needs, but allows the user to override the values.  It then creates the > fetch and push entries that are needed for tracking the extra refs. This > implements one part of the recommendations that I've proposed in > svnwrite.html for dealing with private branches. > > It should be possible to run the script more than once and for it to > DTRT.  If you change your answers the configuration should be correctly > updated. > > 2020-01-10  Richard Earnshaw  > >     * gcc-git-customization: New file. > Updated to add better support for diff-ing .md files. R. --------------779AE3246120244E9454F375 Content-Type: text/x-patch; name="gcc-git-conf.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gcc-git-conf.patch" Content-length: 2167 diff --git a/contrib/gcc-git-customization b/contrib/gcc-git-customization new file mode 100755 index 00000000000..fd3c560f3ae --- /dev/null +++ b/contrib/gcc-git-customization @@ -0,0 +1,59 @@ +#!/bin/sh + +# Script to add some local git customizations suitable for working +# with the GCC git repository + +ask () { + question=$1 + default=$2 + var=$3 + echo -n $question "["$default"]? " + read answer + if [ "x$answer" = "x" ] + then + eval $var=$default + else + eval $var=$answer + fi +} + +# Add a git command to find the git commit equivalent to legacy SVN revision NNN +git config alias.svn-rev '!f() { rev=$1; shift; git log --all --grep="From-SVN: r$rev\\b" "${@}"; } ; f' + +# Make diff on MD files uses "(define" as a function marker. +# Use this in conjunction with a .gitattributes file containing +# *.md diff=md +git config diff.md.xfuncname '^\(define.*$' + +upstream=`git config --get "gcc-config.upstream"` +if [ "x$upstream" = "x" ] +then + upstream="origin" +fi +ask "Local name for upstream repository" "origin" upstream +git config "gcc-config.upstream" "$upstream" + +remote_id=`git config --get "gcc-config.user"` +if [ "x$remote_id" = "x" ] +then + # See if the url specifies the remote user name. + url=`git config --get "remote.$upstream.url"` + if [ "x$url" = "x" ] + then + # This is a pure guess, but for many people it might be OK. + remote_id=`whoami` + else + remote_id=`echo $url | sed -r "s|^.*ssh://(.+)@gcc.gnu.org.*$|\1|"` + if [ x$remote_id = x$url ] + then + remote_id=`whoami` + fi + fi +fi +ask "Account name on gcc.gnu.org" $remote_id remote_id +git config "gcc-config.user" "$remote_id" + +echo "Setting up tracking for private namespace $remote_id in remotes/$upstream/me" +git config --replace-all "remote.${upstream}.fetch" "+refs/users/${remote_id}/heads/*:refs/remotes/${upstream}/me/*" ":refs/remotes/${upstream}/me/" +git config --replace-all "remote.${upstream}.fetch" "+refs/users/${remote_id}/tags/*:refs/tags/me/*" ":refs/tags/me/" +git config --replace-all "remote.${upstream}.push" "+refs/heads/me/*:refs/users/${remote_id}/heads/*" "^\+refs/heads/me/" --------------779AE3246120244E9454F375--