]> git.ipfire.org Git - thirdparty/gcc.git/blame - contrib/gcc-git-customization.sh
[GCC][PATCH][AArch64]Add ACLE intrinsics for bfdot for ARMv8.6 Extension
[thirdparty/gcc.git] / contrib / gcc-git-customization.sh
CommitLineData
743d4d82
RE
1#!/bin/sh
2
3# Script to add some local git customizations suitable for working
4# with the GCC git repository
5
6ask () {
7 question=$1
8 default=$2
9 var=$3
10 echo -n $question "["$default"]? "
11 read answer
12 if [ "x$answer" = "x" ]
13 then
545f5fad 14 eval $var=\"$default\"
743d4d82 15 else
545f5fad 16 eval $var=\"$answer\"
743d4d82
RE
17 fi
18}
19
20# Add a git command to find the git commit equivalent to legacy SVN revision NNN
21git config alias.svn-rev '!f() { rev=$1; shift; git log --all --grep="From-SVN: r\\?$rev\\b" "${@}"; } ; f'
22
e19db6a2
JJ
23# Add git commands to convert git commit to monotonically increasing revision number
24# and vice versa
2588197b 25git config alias.gcc-descr \!"f() { if test \${1:-no} = --full; then c=\${2:-master}; r=\$(git describe --all --abbrev=40 --match 'basepoints/gcc-[0-9]*' \$c | sed -n 's,^\\(tags/\\)\\?basepoints/gcc-,r,p'); expr match \${r:-no} '^r[0-9]\\+\$' >/dev/null && r=\${r}-0-g\$(git rev-parse \${2:-master}); else c=\${1:-master}; r=\$(git describe --all --match 'basepoints/gcc-[0-9]*' \$c | sed -n 's,^\\(tags/\\)\\?basepoints/gcc-\\([0-9]\\+\\)-\\([0-9]\\+\\)-g[0-9a-f]*\$,r\\2-\\3,p;s,^\\(tags/\\)\\?basepoints/gcc-\\([0-9]\\+\\)\$,r\\2-0,p'); fi; if test -n \$r; then o=\$(git config --get gcc-config.upstream); rr=\$(echo \$r | sed -n 's,^r\\([0-9]\\+\\)-[0-9]\\+\\(-g[0-9a-f]\\+\\)\\?\$,\\1,p'); if git rev-parse --verify --quiet \${o:-origin}/releases/gcc-\$rr >/dev/null; then m=releases/gcc-\$rr; else m=master; fi; git merge-base --is-ancestor \$c \${o:-origin}/\$m && \echo \${r}; fi; }; f"
6ff7efb7 26git config alias.gcc-undescr \!"f() { o=\$(git config --get gcc-config.upstream); r=\$(echo \$1 | sed -n 's,^r\\([0-9]\\+\\)-[0-9]\\+\$,\\1,p'); n=\$(echo \$1 | sed -n 's,^r[0-9]\\+-\\([0-9]\\+\\)\$,\\1,p'); test -z \$r && echo Invalid id \$1 && exit 1; h=\$(git rev-parse --verify --quiet \${o:-origin}/releases/gcc-\$r); test -z \$h && h=\$(git rev-parse --verify --quiet \${o:-origin}/master); p=\$(git describe --all --match 'basepoints/gcc-'\$r \$h | sed -n 's,^\\(tags/\\)\\?basepoints/gcc-[0-9]\\+-\\([0-9]\\+\\)-g[0-9a-f]*\$,\\2,p;s,^\\(tags/\\)\\?basepoints/gcc-[0-9]\\+\$,0,p'); git rev-parse --verify \$h~\$(expr \$p - \$n); }; f"
e19db6a2 27
affb7b66 28# Make diff on MD files use "(define" as a function marker.
743d4d82
RE
29# Use this in conjunction with a .gitattributes file containing
30# *.md diff=md
31git config diff.md.xfuncname '^\(define.*$'
32
545f5fad
RE
33set_user=$(git config --get "user.name")
34set_email=$(git config --get "user.email")
35
36if [ "x$set_user" = "x" ]
37then
38 # Try to guess the user's name by looking it up in the password file
39 new_user=$(getent passwd $(whoami) | awk -F: '{ print $5 }')
40 if [ "x$new_user" = "x" ]
41 then
42 new_user="(no default)"
43 fi
44else
45 new_user=$set_user
46fi
47ask "Your name" "${new_user}" new_user
48if [ "x$new_user" = "x(no default)" ]
49then
50 echo "Cannot continue, git needs to record your name against commits"
51 exit 1
52fi
53
54if [ "x$set_email" = "x" ]
55then
56 new_email="(no_default)"
57else
58 new_email=$set_email
59fi
60
61ask "Your email address (for git commits)" "${new_email}" new_email
62if [ "x$new_email" = "x(no default)" ]
63then
64 echo "Cannot continue, git needs to record your email address against commits"
65 exit 1
66fi
67
68if [ "x$set_user" != "x$new_user" ]
69then
70 git config "user.name" "$new_user"
71fi
72
73if [ "x$set_email" != "x$new_email" ]
74then
75 git config "user.email" "$new_email"
76fi
77
78upstream=$(git config --get "gcc-config.upstream")
743d4d82
RE
79if [ "x$upstream" = "x" ]
80then
81 upstream="origin"
82fi
83ask "Local name for upstream repository" "origin" upstream
84git config "gcc-config.upstream" "$upstream"
85
545f5fad 86remote_id=$(git config --get "gcc-config.user")
743d4d82
RE
87if [ "x$remote_id" = "x" ]
88then
89 # See if the url specifies the remote user name.
545f5fad 90 url=$(git config --get "remote.$upstream.url")
743d4d82
RE
91 if [ "x$url" = "x" ]
92 then
93 # This is a pure guess, but for many people it might be OK.
545f5fad 94 remote_id=$(whoami)
743d4d82 95 else
545f5fad 96 remote_id=$(echo $url | sed -r "s|^.*ssh://(.+)@gcc.gnu.org.*$|\1|")
743d4d82
RE
97 if [ x$remote_id = x$url ]
98 then
545f5fad 99 remote_id=$(whoami)
743d4d82
RE
100 fi
101 fi
102fi
e6107422 103ask "Account name on gcc.gnu.org (for your personal branches area)" $remote_id remote_id
743d4d82
RE
104git config "gcc-config.user" "$remote_id"
105
545f5fad 106old_pfx=$(git config --get "gcc-config.userpfx")
743d4d82
RE
107if [ "x$old_pfx" = "x" ]
108then
109 old_pfx="me"
110fi
111echo "Local branch prefix for personal branches you want to share"
112echo "(local branches starting <prefix>/ can be pushed directly to your"
113ask "personal area on the gcc server)" $old_pfx new_pfx
114git config "gcc-config.userpfx" "$new_pfx"
115
116echo "Setting up tracking for personal namespace $remote_id in remotes/$upstream/${new_pfx}"
117git config --replace-all "remote.${upstream}.fetch" "+refs/users/${remote_id}/heads/*:refs/remotes/${upstream}/${new_pfx}/*" ":refs/remotes/${upstream}/${old_pfx}/"
118git config --replace-all "remote.${upstream}.fetch" "+refs/users/${remote_id}/tags/*:refs/tags/${new_pfx}/*" ":refs/tags/${old_pfx}/"
e6107422 119
545f5fad 120push_rule=$(git config --get "remote.${upstream}.push")
e6107422
RE
121if [ "x$push_rule" != "x" ]
122then
123 echo "***********************************************"
124 echo " Warning"
125 echo "***********************************************"
126 echo
127 echo "Old versions of this script used to add custom push"
128 echo "rules to simplify pushing to personal branches."
129 echo "Your configuration contains such rules, but we no-longer"
130 echo "recommend doing this."
131 echo
132 echo "To delete these rules run:"
133 echo " git config --unset-all \"remote.${upstream}.push\""
134fi