1*4c3eb207Smrg#! /bin/sh -e 2*4c3eb207Smrg 3*4c3eb207Smrg# Create a new upstream user branch. 4*4c3eb207Smrg 5*4c3eb207Smrg# Usage: 6*4c3eb207Smrg# contrib/git-add-user-branch.sh [<personal-prefix>/]<branch-name> <base> 7*4c3eb207Smrg 8*4c3eb207Smrgusage () 9*4c3eb207Smrg{ 10*4c3eb207Smrg echo "Usage:" 11*4c3eb207Smrg echo " $0 [<personal-prefix>/]<branch-name> <start-point>" 12*4c3eb207Smrg echo 13*4c3eb207Smrg echo "personal space must already have been set up using" 14*4c3eb207Smrg echo "contrib/gcc-git-customization.sh" 15*4c3eb207Smrg exit 1 16*4c3eb207Smrg} 17*4c3eb207Smrg 18*4c3eb207Smrgif [ $# != 2 ] 19*4c3eb207Smrgthen 20*4c3eb207Smrg usage 21*4c3eb207Smrgfi 22*4c3eb207Smrg 23*4c3eb207Smrguserpfx=$(git config --get "gcc-config.userpfx") 24*4c3eb207Smrguser=$(git config --get "gcc-config.user") 25*4c3eb207Smrg 26*4c3eb207Smrgif [ -z "$userpfx" -o -z "$user" ] 27*4c3eb207Smrgthen 28*4c3eb207Smrg usage 29*4c3eb207Smrgfi 30*4c3eb207Smrg 31*4c3eb207Smrgbranch=$(echo "$1" | sed -r "s:(${userpfx}/)?(.*)$:\2:") 32*4c3eb207Smrgstart=$2 33*4c3eb207Smrg 34*4c3eb207Smrg# Sanity check the new branch argument. If there is no '/', then the 35*4c3eb207Smrg# vendor will be the same as the entire first argument. 36*4c3eb207Smrgif [ -z "$branch" ] 37*4c3eb207Smrgthen 38*4c3eb207Smrg usage 39*4c3eb207Smrgfi 40*4c3eb207Smrg 41*4c3eb207Smrggit push users/${userpfx} ${start}:refs/users/${user}/heads/${branch} 42*4c3eb207Smrggit fetch -q users/${userpfx} 43*4c3eb207Smrggit branch ${userpfx}/${branch} remotes/users/${userpfx}/${branch} 44*4c3eb207Smrgecho "You are now ready to check out ${userpfx}/${branch}" 45*4c3eb207Smrgecho "To push the branch upstream use:" 46*4c3eb207Smrgecho " git push users/${userpfx} ${userpfx}/${branch}" 47