]> git.ipfire.org Git - thirdparty/gcc.git/blame_incremental - contrib/gcc-git-customization.sh
x86: Emit label only for __mcount_loc section
[thirdparty/gcc.git] / contrib / gcc-git-customization.sh
... / ...
CommitLineData
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 printf "%s [%s]? " "$question" "$default"
11 read answer
12 if [ "x$answer" = "x" ]
13 then
14 eval $var=\$default
15 else
16 eval $var=\$answer
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
23# Add git commands to convert git commit to monotonically increasing revision number
24# and vice versa
25git config alias.gcc-descr '!f() { "`git rev-parse --show-toplevel`/contrib/git-descr.sh" $@; } ; f'
26git config alias.gcc-undescr '!f() { "`git rev-parse --show-toplevel`/contrib/git-undescr.sh" $@; } ; f'
27
28git config alias.gcc-verify '!f() { "`git rev-parse --show-toplevel`/contrib/gcc-changelog/git_check_commit.py" $@; } ; f'
29git config alias.gcc-backport '!f() { "`git rev-parse --show-toplevel`/contrib/git-backport.py" $@; } ; f'
30git config alias.gcc-fix-changelog '!f() { "`git rev-parse --show-toplevel`/contrib/git-fix-changelog.py" $@; } ; f'
31git config alias.gcc-mklog '!f() { "`git rev-parse --show-toplevel`/contrib/mklog.py" $@; } ; f'
32git config alias.gcc-commit-mklog '!f() { "`git rev-parse --show-toplevel`/contrib/git-commit-mklog.py" "$@"; }; f'
33git config alias.gcc-style '!f() {
34 check=`git rev-parse --show-toplevel`/contrib/check_GNU_style.py;
35 arg=; if [ $# -ge 1 ] && [ "$1" != "-f" ]; then arg="$1"; shift;
36 elif [ $# -eq 3 ]; then arg="$3"; set -- "$1" "$2"; fi
37 git show $arg | $check "$@" -; }; f'
38
39# Make diff on MD files use "(define" as a function marker.
40# Use this in conjunction with a .gitattributes file containing
41# *.md diff=md
42git config diff.md.xfuncname '^\(define.*$'
43
44# Tell git send-email where patches go.
45# ??? Maybe also set sendemail.tocmd to guess from MAINTAINERS?
46git config sendemail.to 'gcc-patches@gcc.gnu.org'
47
48set_user=$(git config --get "user.name")
49set_email=$(git config --get "user.email")
50
51if [ "x$set_user" = "x" ]
52then
53 # Try to guess the user's name by looking it up in the password file
54 if type getent >/dev/null 2>&1; then
55 new_user=$(getent passwd $(whoami) | awk -F: '{ print $5 }')
56 elif [ $(uname -s) = Darwin ]; then
57 new_user=$(id -F 2>/dev/null)
58 fi
59 if [ "x$new_user" = "x" ]
60 then
61 new_user="(no default)"
62 fi
63else
64 new_user=$set_user
65fi
66ask "Your name" "${new_user}" new_user
67if [ "x$new_user" = "x(no default)" ]
68then
69 echo "Cannot continue, git needs to record your name against commits"
70 exit 1
71fi
72
73if [ "x$set_email" = "x" ]
74then
75 new_email="(no_default)"
76else
77 new_email=$set_email
78fi
79
80ask "Your email address (for git commits)" "${new_email}" new_email
81if [ "x$new_email" = "x(no default)" ]
82then
83 echo "Cannot continue, git needs to record your email address against commits"
84 exit 1
85fi
86
87if [ "x$set_user" != "x$new_user" ]
88then
89 git config "user.name" "$new_user"
90fi
91
92if [ "x$set_email" != "x$new_email" ]
93then
94 git config "user.email" "$new_email"
95fi
96
97upstream=$(git config --get "gcc-config.upstream")
98if [ "x$upstream" = "x" ]
99then
100 upstream="origin"
101fi
102ask "Local name for upstream repository" "origin" upstream
103
104v=$(git config --get-all "remote.${upstream}.fetch")
105if [ "x$v" = "x" ]
106then
107 echo "Remote $upstream does not seem to exist as a remote"
108 exit 1
109fi
110git config "gcc-config.upstream" "$upstream"
111
112remote_id=$(git config --get "gcc-config.user")
113if [ "x$remote_id" = "x" ]
114then
115 # See if the url specifies the remote user name.
116 url=$(git config --get "remote.$upstream.url")
117 if [ "x$url" = "x" ]
118 then
119 # This is a pure guess, but for many people it might be OK.
120 remote_id=$(whoami)
121 else
122 remote_id=$(echo $url | sed 's|^.*ssh://\(..*\)@gcc.gnu.org.*$|\1|')
123 if [ x$remote_id = x$url ]
124 then
125 remote_id=$(whoami)
126 fi
127 fi
128fi
129
130ask "Account name on gcc.gnu.org (for your personal branches area)" "$remote_id" remote_id
131git config "gcc-config.user" "$remote_id"
132
133old_pfx=$(git config --get "gcc-config.userpfx")
134if [ "x$old_pfx" = "x" ]
135then
136 old_pfx="me"
137fi
138echo
139echo "Local branch prefix for personal branches you want to share"
140echo "(local branches starting <prefix>/ can be pushed directly to your"
141ask "personal area on the gcc server)" $old_pfx new_pfx
142git config "gcc-config.userpfx" "$new_pfx"
143
144echo
145ask "Install prepare-commit-msg git hook for 'git commit-mklog' alias" yes dohook
146if [ "x$dohook" = xyes ]; then
147 hookdir=`git rev-parse --git-path hooks 2>/dev/null`
148 if [ $? -eq 0 ]; then
149 if [ -f "$hookdir/prepare-commit-msg" ]; then
150 echo " Moving existing prepare-commit-msg hook to prepare-commit-msg.bak"
151 mv "$hookdir/prepare-commit-msg" "$hookdir/prepare-commit-msg.bak"
152 fi
153 install -c "`git rev-parse --show-toplevel`/contrib/prepare-commit-msg" "$hookdir"
154 else
155 echo " `git --version` is too old, cannot find hooks dir"
156 fi
157fi
158
159url=$(git config --get "remote.${upstream}.url")
160echo "Setting up tracking for personal namespace $remote_id in remotes/users/${new_pfx}"
161git config "remote.users/${new_pfx}.url" "${url}"
162if [ "x$pushurl" != "x" ]
163then
164 git config "remote.users/${new_pfx}.pushurl" "${pushurl}"
165fi
166git config --replace-all "remote.users/${new_pfx}.fetch" "+refs/users/${remote_id}/heads/*:refs/remotes/users/${new_pfx}/*" "refs/users/${remote_id}/heads/"
167git config --replace-all "remote.users/${new_pfx}.fetch" "+refs/users/${remote_id}/tags/*:refs/tags/users/${new_pfx}/*" "refs/users/${remote_id}/tags/"
168git config --replace-all "remote.users/${new_pfx}.push" "refs/heads/${new_pfx}/*:refs/users/${remote_id}/heads/*" "refs/users/${remote_id}"
169
170git fetch "users/${new_pfx}"