Fix handling of large arguments passed by value.
[official-gcc.git] / contrib / git-add-vendor-branch.sh
blob8fa86682151384297a7dce76aa681ffbc0c5c5e6
1 #! /bin/sh -e
3 # Create a new upstream vendor branch.
5 # Usage:
6 # contrib/git-add-vendor-branch.sh <vendor>/<branch-name> <base>
8 usage ()
10 echo "Usage:"
11 echo " $0 <vendor>/<branch-name> <start-point>"
12 echo
13 echo "<vendor> must have already been set up using contrib/git-fetch-vendor.sh"
14 exit 1
17 if [ $# != 2 ]
18 then
19 usage
22 vendor=$(echo "$1" | sed -r "s:([^/]*)/.*$:\1:")
23 branch=$(echo "$1" | sed -r "s:[^/]*/(.*)$:\1:")
24 start=$2
26 # Sanity check the new branch argument. If there is no '/', then the
27 # vendor will be the same as the entire first argument.
28 if [ -z "$vendor" -o -z "$branch" -o ${vendor} = $1 ]
29 then
30 usage
33 # Check that we know about the vendor
34 url=$(git config --get "remote.vendors/${vendor}.url"||true)
35 if [ -z "$url" ]
36 then
37 echo "Cannot locate remote data for vendor ${vendor}. Have you set it up?"
38 exit 1
41 git branch --no-track ${vendor}/${branch} ${start}
42 git push vendors/${vendor} ${vendor}/${branch}:refs/vendors/${vendor}/heads/${branch}
43 git fetch -q vendors/${vendor}
44 git branch --set-upstream-to=remotes/vendors/${vendor}/${branch} ${vendor}/$branch
45 echo "You are now ready to check out ${vendor}/${branch}"
46 echo "To push the branch upstream, use:"
47 echo
48 echo "git push vendors/${vendor} ${vendor}/${branch}"