]>
git.ipfire.org Git - thirdparty/gcc.git/blob - contrib/gcc-git-customization.sh
e58220fb342695dfa23cc04de1c73cdcb5cb0ae6
3 # Script to add some local git customizations suitable for working
4 # with the GCC git repository
10 printf "%s [%s]? " "$question" "$default"
12 if [ "x$answer" = "x" ]
20 # Add a git command to find the git commit equivalent to legacy SVN revision NNN
21 git config
alias.svn-rev
'!f() { rev=$1; shift; git log --all --grep="^From-SVN: r\\?$rev\\b" "${@}"; } ; f'
23 # Add git commands to convert git commit to monotonically increasing revision number
25 git config
alias.gcc-descr
'!f() { "`git rev-parse --show-toplevel`/contrib/git-descr.sh" $@; } ; f'
26 git config
alias.gcc-undescr
'!f() { "`git rev-parse --show-toplevel`/contrib/git-undescr.sh" $@; } ; f'
28 git config
alias.gcc-verify
'!f() { "`git rev-parse --show-toplevel`/contrib/gcc-changelog/git_check_commit.py" $@; } ; f'
29 git config
alias.gcc-backport
'!f() { "`git rev-parse --show-toplevel`/contrib/git-backport.py" $@; } ; f'
30 git config
alias.gcc-fix-changelog
'!f() { "`git rev-parse --show-toplevel`/contrib/git-fix-changelog.py" $@; } ; f'
31 git config
alias.gcc-mklog
'!f() { "`git rev-parse --show-toplevel`/contrib/mklog.py" $@; } ; f'
32 git config
alias.gcc-commit-mklog
'!f() { "`git rev-parse --show-toplevel`/contrib/git-commit-mklog.py" "$@"; }; f'
33 git 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'
39 # Make diff on MD files use "(define" as a function marker.
40 # Use this in conjunction with a .gitattributes file containing
42 git config
diff.md.xfuncname
'^\(define.*$'
44 # Tell git send-email where patches go.
45 # ??? Maybe also set sendemail.tocmd to guess from MAINTAINERS?
46 git config sendemail.to
'gcc-patches@gcc.gnu.org'
48 set_user
=$
(git config
--get "user.name")
49 set_email
=$
(git config
--get "user.email")
51 if [ "x$set_user" = "x" ]
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
)
59 if [ "x$new_user" = "x" ]
61 new_user
="(no default)"
66 ask
"Your name" "${new_user}" new_user
67 if [ "x$new_user" = "x(no default)" ]
69 echo "Cannot continue, git needs to record your name against commits"
73 if [ "x$set_email" = "x" ]
75 new_email
="(no_default)"
80 ask
"Your email address (for git commits)" "${new_email}" new_email
81 if [ "x$new_email" = "x(no default)" ]
83 echo "Cannot continue, git needs to record your email address against commits"
87 if [ "x$set_user" != "x$new_user" ]
89 git config
"user.name" "$new_user"
92 if [ "x$set_email" != "x$new_email" ]
94 git config
"user.email" "$new_email"
97 upstream
=$
(git config
--get "gcc-config.upstream")
98 if [ "x$upstream" = "x" ]
102 ask
"Local name for upstream repository" "origin" upstream
104 v
=$
(git config
--get-all "remote.${upstream}.fetch")
107 echo "Remote $upstream does not seem to exist as a remote"
110 git config
"gcc-config.upstream" "$upstream"
112 remote_id
=$
(git config
--get "gcc-config.user")
113 if [ "x$remote_id" = "x" ]
115 # See if the url specifies the remote user name.
116 url
=$
(git config
--get "remote.$upstream.url")
119 # This is a pure guess, but for many people it might be OK.
122 remote_id
=$
(echo $url |
sed 's|^.*ssh://\(..*\)@gcc.gnu.org.*$|\1|')
123 if [ x
$remote_id = x
$url ]
130 ask
"Account name on gcc.gnu.org (for your personal branches area)" "$remote_id" remote_id
131 git config
"gcc-config.user" "$remote_id"
133 old_pfx
=$
(git config
--get "gcc-config.userpfx")
134 if [ "x$old_pfx" = "x" ]
139 echo "Local branch prefix for personal branches you want to share"
140 echo "(local branches starting <prefix>/ can be pushed directly to your"
141 ask
"personal area on the gcc server)" $old_pfx new_pfx
142 git config
"gcc-config.userpfx" "$new_pfx"
145 ask
"Install prepare-commit-msg git hook for 'git commit-mklog' alias" yes dohook
146 if [ "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"
153 install -c "`git rev-parse --show-toplevel`/contrib/prepare-commit-msg" "$hookdir"
155 echo " `git --version` is too old, cannot find hooks dir"
159 url
=$
(git config
--get "remote.${upstream}.url")
160 echo "Setting up tracking for personal namespace $remote_id in remotes/users/${new_pfx}"
161 git config
"remote.users/${new_pfx}.url" "${url}"
162 if [ "x$pushurl" != "x" ]
164 git config
"remote.users/${new_pfx}.pushurl" "${pushurl}"
166 git config
--replace-all "remote.users/${new_pfx}.fetch" "+refs/users/${remote_id}/heads/*:refs/remotes/users/${new_pfx}/*" "refs/users/${remote_id}/heads/"
167 git config
--replace-all "remote.users/${new_pfx}.fetch" "+refs/users/${remote_id}/tags/*:refs/tags/users/${new_pfx}/*" "refs/users/${remote_id}/tags/"
168 git config
--replace-all "remote.users/${new_pfx}.push" "refs/heads/${new_pfx}/*:refs/users/${remote_id}/heads/*" "refs/users/${remote_id}"
170 git fetch
"users/${new_pfx}"