X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=topgit.git;a=blobdiff_plain;f=tg-create.sh;h=6e8490742282f86f4bebf1908b0e0504e6753e6e;hp=fee7dff3ee9fdf5d1e29c31282cf73abdc9f7067;hb=c4c57a55aa1b825109f0ce0547994ad394812902;hpb=459c340fd5ac765ff1e5d82895b59b53b028aaca;ds=inline diff --git a/tg-create.sh b/tg-create.sh index fee7dff..6e84907 100644 --- a/tg-create.sh +++ b/tg-create.sh @@ -7,6 +7,7 @@ deps= # List of dependent branches restarted= # Set to 1 if we are picking up in the middle of base setup merge= # List of branches to be merged; subset of $deps name= +rname= # Remote branch to base this one on ## Parse options @@ -14,8 +15,10 @@ name= while [ -n "$1" ]; do arg="$1"; shift case "$arg" in + -r) + rname="$1"; shift;; -*) - echo "Usage: tg [...] create NAME [DEPS...]" >&2 + echo "Usage: tg [...] create NAME [DEPS...|-r RNAME]" >&2 exit 1;; *) if [ -z "$name" ]; then @@ -27,6 +30,20 @@ while [ -n "$1" ]; do done +## Fast-track creating branches based on remote ones + +if [ -n "$rname" ]; then + [ -n "$name" ] || die "no branch name given" + ! ref_exists "$name" || die "branch '$name' already exists" + has_remote "$rname" || die "no branch $rname in remote $base_remote" + + git update-ref "refs/top-bases/$name" "refs/remotes/$base_remote/top-bases/$rname" + git update-ref "refs/heads/$name" "refs/remotes/$base_remote/$rname" + info "Topic branch $name based on $base_remote : $rname set up." + exit 0 +fi + + ## Auto-guess dependencies deps="${deps# }" @@ -124,3 +141,5 @@ git add -f "$root_dir/.topmsg" info "Topic branch $name set up. Please fill .topmsg now and make initial commit." info "To abort: git rm -f .top* && git checkout ${deps%% *} && $tg delete $name" + +# vim:noet