X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=topgit.git;a=blobdiff_plain;f=tg-create.sh;h=6ee3f027d23e797ac80e07c1024b22aaedc461f5;hp=dd95e6596876d38e1357435267c46f67783ebbe0;hb=13cdd66678ff97a90507dc42924189944ec7aeb3;hpb=530ace6909e31e388089fce341353547730e9e67 diff --git a/tg-create.sh b/tg-create.sh index dd95e65..6ee3f02 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,4 @@ 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"