diff options
author | Richard Earnshaw <rearnsha@arm.com> | 2020-01-22 10:06:50 +0000 |
---|---|---|
committer | Richard Earnshaw <rearnsha@arm.com> | 2020-01-22 10:06:50 +0000 |
commit | f96af171bee93486896407ccad0e1e4dc200bc0c (patch) | |
tree | 4afef3154d64f3e1600efd4a8f512c780e6ccff7 | |
parent | c892d8f58f6fed46c343bdb6dd4d365f08f801b8 (diff) | |
download | gcc-f96af171bee93486896407ccad0e1e4dc200bc0c.zip gcc-f96af171bee93486896407ccad0e1e4dc200bc0c.tar.gz gcc-f96af171bee93486896407ccad0e1e4dc200bc0c.tar.bz2 |
contrib: script to create a new vendor branch
This script is intended to create a new vendor branch. Doing so is
not completely obvious if you are not familiar with the upstream
structure, so this takes the pain out of getting it right.
It doesn't check out the branch locally, but does set everything up so
that, if you have push enabled for your vendor branches, then
git push vendors/<vendor> <branch>
will work as expected.
Run the script as
contrib/git-add-vendor-branch.sh <vendor>/<branch> <start-point>
the <vendor> space must have previously been set up in the way
git-fetch-vendor.sh expects.
* git-add-vendor-branch.sh: New file.
-rw-r--r-- | contrib/ChangeLog | 4 | ||||
-rwxr-xr-x | contrib/git-add-vendor-branch.sh | 48 |
2 files changed, 52 insertions, 0 deletions
diff --git a/contrib/ChangeLog b/contrib/ChangeLog index 8f112af..c5e4604 100644 --- a/contrib/ChangeLog +++ b/contrib/ChangeLog @@ -1,3 +1,7 @@ +2020-01-22 Richard Earnshaw <rearnsha@arm.com> + + * git-add-vendor-branch.sh: New file. + 2020-01-20 Richard Earnshaw <rearnsha@arm.com> * gcc-git-customization.sh: Check that user-supplied remote diff --git a/contrib/git-add-vendor-branch.sh b/contrib/git-add-vendor-branch.sh new file mode 100755 index 0000000..8fa8668 --- /dev/null +++ b/contrib/git-add-vendor-branch.sh @@ -0,0 +1,48 @@ +#! /bin/sh -e + +# Create a new upstream vendor branch. + +# Usage: +# contrib/git-add-vendor-branch.sh <vendor>/<branch-name> <base> + +usage () +{ + echo "Usage:" + echo " $0 <vendor>/<branch-name> <start-point>" + echo + echo "<vendor> must have already been set up using contrib/git-fetch-vendor.sh" + exit 1 +} + +if [ $# != 2 ] +then + usage +fi + +vendor=$(echo "$1" | sed -r "s:([^/]*)/.*$:\1:") +branch=$(echo "$1" | sed -r "s:[^/]*/(.*)$:\1:") +start=$2 + +# Sanity check the new branch argument. If there is no '/', then the +# vendor will be the same as the entire first argument. +if [ -z "$vendor" -o -z "$branch" -o ${vendor} = $1 ] +then + usage +fi + +# Check that we know about the vendor +url=$(git config --get "remote.vendors/${vendor}.url"||true) +if [ -z "$url" ] +then + echo "Cannot locate remote data for vendor ${vendor}. Have you set it up?" + exit 1 +fi + +git branch --no-track ${vendor}/${branch} ${start} +git push vendors/${vendor} ${vendor}/${branch}:refs/vendors/${vendor}/heads/${branch} +git fetch -q vendors/${vendor} +git branch --set-upstream-to=remotes/vendors/${vendor}/${branch} ${vendor}/$branch +echo "You are now ready to check out ${vendor}/${branch}" +echo "To push the branch upstream, use:" +echo +echo "git push vendors/${vendor} ${vendor}/${branch}" |