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=dd95e6596876d38e1357435267c46f67783ebbe0;hb=4fe0a8e009776b8c66357f08ef8171bdc2c0f468;hpb=530ace6909e31e388089fce341353547730e9e67 diff --git a/tg-create.sh b/tg-create.sh index dd95e65..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# }" @@ -82,7 +99,7 @@ while [ -n "$merge" ]; do info "Merging $name base with $branch..." if ! git merge "$branch"; then - info "Please commit merge resolution and call: tg create" + info "Please commit merge resolution and call: $tg create" info "It is also safe to abort this operation using:" info "git reset --hard some_branch" info "(You are on a detached HEAD now.)" @@ -123,4 +140,6 @@ 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" +info "To abort: git rm -f .top* && git checkout ${deps%% *} && $tg delete $name" + +# vim:noet