libgo: update to final Go1.14 release
[official-gcc.git] / contrib / git-fetch-vendor.sh
blob15303629b5c34125805db1f94eeec886aba1aa8f
1 #!/bin/sh
3 usage ()
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
11 # Should we insert a "push" refspec to enable pushing to the vendor branch?
12 enable_push=no
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"
18 exit 1
21 case $# in
23 # vendor names never start with -, so catch this in case user wrote something like --help.
24 case "$1" in
25 -*)
26 usage
29 vendor=$1
31 esac
34 vendor=$2
35 if [ "$1" = "--enable-push" ]
36 then
37 enable_push=yes
38 else
39 usage
43 usage
45 esac
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}"
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"
66 git fetch vendors/${vendor}