diff mbox series

contrib: script to create a new vendor branch

Message ID 59281770-ec14-177e-b509-a53c86a4b7b7@arm.com
State New
Headers show
Series contrib: script to create a new vendor branch | expand

Commit Message

Richard Earnshaw (lists) Jan. 21, 2020, 1:29 p.m. UTC
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-bransh.sh: New file.

Comments

Richard Earnshaw (lists) Jan. 21, 2020, 1:36 p.m. UTC | #1
On 21/01/2020 13:29, Richard Earnshaw (lists) wrote:
> 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>
> 

Correction, the branch should be named <vendor>/<branch>, so the push 
should be

git push vendors/<vendor> <vendor>/<branch>

For example, for the ARM vendor, the push would be

git push vendors/ARM ARM/<branch>

R.

> 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-bransh.sh: New file.
> 
>
diff mbox series

Patch

diff --git a/contrib/git-add-vendor-branch.sh b/contrib/git-add-vendor-branch.sh
new file mode 100755
index 00000000000..04d39ed6b63
--- /dev/null
+++ b/contrib/git-add-vendor-branch.sh
@@ -0,0 +1,43 @@ 
+#! /bin/sh -xve
+
+# 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
+
+if [ -z "$vendor" -o -z "$branch" ]
+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 "Now ready to check out ${vendor}/${branch}"