diff --git a/contrib/gcc-git-customization.sh b/contrib/gcc-git-customization.sh index b24948d9874c..914d868f7bdb 100755 --- a/contrib/gcc-git-customization.sh +++ b/contrib/gcc-git-customization.sh @@ -7,7 +7,7 @@ ask () { question=$1 default=$2 var=$3 - echo -n $question "["$default"]? " + printf "%s [%s]? " "$question" "$default" read answer if [ "x$answer" = "x" ] then @@ -110,7 +110,7 @@ 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|") + remote_id=$(echo $url | sed 's|^.*ssh://\(..*\)@gcc.gnu.org.*$|\1|') if [ x$remote_id = x$url ] then remote_id=$(whoami) @@ -118,7 +118,7 @@ then fi fi -ask "Account name on gcc.gnu.org (for your personal branches area)" $remote_id remote_id +ask "Account name on gcc.gnu.org (for your personal branches area)" "$remote_id" remote_id git config "gcc-config.user" "$remote_id" old_pfx=$(git config --get "gcc-config.userpfx") @@ -135,16 +135,20 @@ git config "gcc-config.userpfx" "$new_pfx" echo ask "Install prepare-commit-msg git hook for 'git commit-mklog' alias" yes dohook if [ "x$dohook" = xyes ]; then - hookdir=`git rev-parse --git-path hooks` - if [ -f "$hookdir/prepare-commit-msg" ]; then - echo " Moving existing prepare-commit-msg hook to prepare-commit-msg.bak" - mv "$hookdir/prepare-commit-msg" "$hookdir/prepare-commit-msg.bak" + hookdir=`git rev-parse --git-path hooks 2>/dev/null` + if [ $? -eq 0 ]; then + if [ -f "$hookdir/prepare-commit-msg" ]; then + echo " Moving existing prepare-commit-msg hook to prepare-commit-msg.bak" + mv "$hookdir/prepare-commit-msg" "$hookdir/prepare-commit-msg.bak" + fi + install -c "`git rev-parse --show-toplevel`/contrib/prepare-commit-msg" "$hookdir" + else + echo " `git --version` is too old, cannot find hooks dir" fi - install -c "`git rev-parse --show-toplevel`/contrib/prepare-commit-msg" "$hookdir" fi # Scan the existing settings to see if there are any we need to rewrite. -vendors=$(git config --get-all "remote.${upstream}.fetch" "refs/vendors/" | sed -r "s:.*refs/vendors/([^/]+)/.*:\1:" | sort | uniq) +vendors=$(git config --get-all "remote.${upstream}.fetch" "refs/vendors/" | sed 's:.*refs/vendors/\([^/][^/]*\)/.*:\1:' | sort | uniq) url=$(git config --get "remote.${upstream}.url") pushurl=$(git config --get "remote.${upstream}.pushurl") for v in $vendors