public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Some local customization enhancements when using git
@ 2020-01-10 13:29 Richard Earnshaw (lists)
  2020-01-10 13:30 ` Richard Biener
  2020-01-10 14:27 ` Richard Earnshaw (lists)
  0 siblings, 2 replies; 13+ messages in thread
From: Richard Earnshaw (lists) @ 2020-01-10 13:29 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1024 bytes --]

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  <rearnsha@arm.com>

	* gcc-git-customization: New file.


[-- Attachment #2: gcc-git-conf.patch --]
[-- Type: text/x-patch, Size: 1974 bytes --]

diff --git a/contrib/gcc-git-customization b/contrib/gcc-git-customization
new file mode 100755
index 00000000000..7f1a13bdf79
--- /dev/null
+++ b/contrib/gcc-git-customization
@@ -0,0 +1,54 @@
+#!/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'
+
+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/"

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2020-01-15 10:51 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-10 13:29 Some local customization enhancements when using git Richard Earnshaw (lists)
2020-01-10 13:30 ` Richard Biener
2020-01-10 14:04   ` Richard Earnshaw (lists)
2020-01-10 14:13     ` Richard Earnshaw (lists)
2020-01-10 14:27 ` Richard Earnshaw (lists)
2020-01-13 12:50   ` [PATCH] contrib: git descr/undescr aliases Jakub Jelinek
2020-01-14 10:18     ` Roman Zhuykov
2020-01-14 10:22       ` Jakub Jelinek
2020-01-14 23:50         ` [PATCH] contrib: git descr/undescr aliases fix for older git Jakub Jelinek
2020-01-15 11:34           ` Richard Earnshaw (lists)
2020-01-14 23:39       ` [PATCH] contrib: git descr/undescr aliases Joseph Myers
2020-01-13 14:02   ` Some local customization enhancements when using git Richard Earnshaw (lists)
2020-01-13 16:03     ` Richard Earnshaw (lists)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).