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