summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorRichard Earnshaw <rearnsha@arm.com>2020-01-13 13:37:23 +0000
committerRichard Earnshaw <rearnsha@arm.com>2020-01-13 13:40:23 +0000
commit743d4d827b8c8215adbe130592e84861c9d4a758 (patch)
tree5eb51b408387cb86eb88fe4ea89266518e988c6c /contrib
parent12122f94b4dadcc096c97da13afbcbd13764e6e3 (diff)
contrib: Add script to help with customizing a git checkout for use with GCC
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 personal 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-13 Richard Earnshaw <rearnsha@arm.com> * gcc-git-customization: New file.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/ChangeLog4
-rwxr-xr-xcontrib/gcc-git-customization.sh69
2 files changed, 73 insertions, 0 deletions
diff --git a/contrib/ChangeLog b/contrib/ChangeLog
index b9c8fea6a16..ddaff4fc6d8 100644
--- a/contrib/ChangeLog
+++ b/contrib/ChangeLog
@@ -1,3 +1,7 @@
+2010-01-13 Richard Earnshaw <rearnsha@arm.com>
+
+ * gcc-git-customization.sh: New file.
+
2020-01-01 Jakub Jelinek <jakub@redhat.com>
* update-copyright.py: Add Mentor Graphics Corporation and Yoshinori
diff --git a/contrib/gcc-git-customization.sh b/contrib/gcc-git-customization.sh
new file mode 100755
index 00000000000..169c3a4d356
--- /dev/null
+++ b/contrib/gcc-git-customization.sh
@@ -0,0 +1,69 @@
+#!/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"
+
+old_pfx=`git config --get "gcc-config.userpfx"`
+if [ "x$old_pfx" = "x" ]
+then
+ old_pfx="me"
+fi
+echo "Local branch prefix for personal branches you want to share"
+echo "(local branches starting <prefix>/ 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}/"
+git config --replace-all "remote.${upstream}.push" "refs/heads/${new_pfx}/*:refs/users/${remote_id}/heads/*" "^\+?refs/heads/${old_pfx}/"