mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-20 09:35:05 +08:00
612137e171
Whilst trying to convert the add vendor branch script to work with personal branches I encountered a minor issue where git would report ambiguous refs when checking out the new branch. It turns out that this is because git considers <me>/<topic> to be ambiguous if both refs/heads/<me>/<topic> and refs/remotes/<me>/<topic> exist in the list of known branches. Having thought about this a bit, I think the best solution is to adopt something more like the vendors space and call the remote users/<me> (this also works better if you want to set up remotes to track other users branches as well). So this patch has two parts. 1) It updates gcc-git-customization.sh to set up the new 'remote' and converts any existing remote and branches tracking that to the new format 2) It adds a new script to set up a personal branch on the gcc git repository. * gcc-git-customization.sh: Use users/<pfx> for the personal remote rather than just <pfx>. Convert any existing personal branches to the new remote. * git-add-user-branch.sh: New file.
47 lines
1.1 KiB
Bash
Executable File
47 lines
1.1 KiB
Bash
Executable File
#! /bin/sh -e
|
|
|
|
# Create a new upstream user branch.
|
|
|
|
# Usage:
|
|
# contrib/git-add-user-branch.sh [<personal-prefix>/]<branch-name> <base>
|
|
|
|
usage ()
|
|
{
|
|
echo "Usage:"
|
|
echo " $0 [<personal-prefix>/]<branch-name> <start-point>"
|
|
echo
|
|
echo "personal space must already have been set up using"
|
|
echo "contrib/gcc-git-customization.sh"
|
|
exit 1
|
|
}
|
|
|
|
if [ $# != 2 ]
|
|
then
|
|
usage
|
|
fi
|
|
|
|
userpfx=$(git config --get "gcc-config.userpfx")
|
|
user=$(git config --get "gcc-config.user")
|
|
|
|
if [ -z "$userpfx" -o -z "$user" ]
|
|
then
|
|
usage
|
|
fi
|
|
|
|
branch=$(echo "$1" | sed -r "s:(${userpfx}/)?(.*)$:\2:")
|
|
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 "$branch" ]
|
|
then
|
|
usage
|
|
fi
|
|
|
|
git push users/${userpfx} ${start}:refs/users/${user}/heads/${branch}
|
|
git fetch -q users/${userpfx}
|
|
git branch ${userpfx}/${branch} remotes/users/${userpfx}/${branch}
|
|
echo "You are now ready to check out ${userpfx}/${branch}"
|
|
echo "To push the branch upstream use:"
|
|
echo " git push users/${userpfx} ${userpfx}/${branch}"
|