]>
Commit | Line | Data |
---|---|---|
f96af171 RE |
1 | #! /bin/sh -e |
2 | ||
3 | # Create a new upstream vendor branch. | |
4 | ||
5 | # Usage: | |
6 | # contrib/git-add-vendor-branch.sh <vendor>/<branch-name> <base> | |
7 | ||
8 | usage () | |
9 | { | |
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 | |
15 | } | |
16 | ||
17 | if [ $# != 2 ] | |
18 | then | |
19 | usage | |
20 | fi | |
21 | ||
22 | vendor=$(echo "$1" | sed -r "s:([^/]*)/.*$:\1:") | |
23 | branch=$(echo "$1" | sed -r "s:[^/]*/(.*)$:\1:") | |
24 | start=$2 | |
25 | ||
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 | |
31 | fi | |
32 | ||
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 | |
39 | fi | |
40 | ||
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}" |