| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
usage () |
| 4 |
{ |
| 5 |
echo "Usage: $0 [--enable-push] <vendor>" |
| 6 |
echo "The following vendors are already known:" |
| 7 |
git ls-remote ${upstream} "*/vendors/*" | sed -r "s:.*/vendors/([^/]+)/.*:\1:"|sort|uniq |
| 8 |
exit 1 |
| 9 |
} |
| 10 |
|
| 11 |
# Should we insert a "push" refspec to enable pushing to the vendor branch? |
| 12 |
enable_push=no |
| 13 |
|
| 14 |
upstream=`git config --get "gcc-config.upstream"` |
| 15 |
if [ x"$upstream" = x ] |
| 16 |
then |
| 17 |
echo "Config gcc-config.upstream not set, run contrib/gcc-git-customization.sh" |
| 18 |
exit 1 |
| 19 |
fi |
| 20 |
|
| 21 |
case $# in |
| 22 |
1) |
| 23 |
# vendor names never start with -, so catch this in case user wrote something like --help. |
| 24 |
case "$1" in |
| 25 |
-*) |
| 26 |
usage |
| 27 |
;; |
| 28 |
*) |
| 29 |
vendor=$1 |
| 30 |
;; |
| 31 |
esac |
| 32 |
;; |
| 33 |
2) |
| 34 |
vendor=$2 |
| 35 |
if [ "$1" = "--enable-push" ] |
| 36 |
then |
| 37 |
enable_push=yes |
| 38 |
else |
| 39 |
usage |
| 40 |
fi |
| 41 |
;; |
| 42 |
*) |
| 43 |
usage |
| 44 |
;; |
| 45 |
esac |
| 46 |
|
| 47 |
|
| 48 |
echo "setting up git to fetch vendor ${vendor} to remotes/vendors/${vendor}" |
| 49 |
url=$(git config --get "remote.${upstream}.url") |
| 50 |
pushurl=$(git config --get "remote.${upstream}.pushurl") |
| 51 |
git config "remote.vendors/${vendor}.url" "${url}" |
| 52 |
if [ "x$pushurl" != "x" ] |
| 53 |
then |
| 54 |
git config "remote.vendors/${vendor}.pushurl" "${pushurl}" |
| 55 |
fi |
| 56 |
git config --replace-all "remote.vendors/${vendor}.fetch" "+refs/vendors/${vendor}/heads/*:refs/remotes/vendors/${vendor}/*" "refs/vendors/${vendor}/heads" |
| 57 |
git config --replace-all "remote.vendors/${vendor}.fetch" "+refs/vendors/${vendor}/tags/*:refs/tags/vendors/${vendor}/*" "refs/vendors/${vendor}/tags" |
| 58 |
if [ "$enable_push" = "yes" ] |
| 59 |
then |
| 60 |
echo "Warning: take care when pushing that you only push the changes you intend." |
| 61 |
echo "E.g. use \"git push vendors/${vendor} HEAD\" to push the current branch" |
| 62 |
git config --replace-all "remote.vendors/${vendor}.push" "refs/heads/${vendor}/*:refs/vendors/${vendor}/heads/*" |
| 63 |
else |
| 64 |
git config --unset-all "remote.vendors/${vendor}.push" |
| 65 |
fi |
| 66 |
git fetch vendors/${vendor} |