chiark / gitweb /
tg create -r BRANCH: Create branch based on a remote one
authorPetr Baudis <pasky@suse.cz>
Tue, 9 Sep 2008 22:29:24 +0000 (00:29 +0200)
committerPetr Baudis <pasky@suse.cz>
Tue, 9 Sep 2008 22:29:24 +0000 (00:29 +0200)
README
tg-create.sh

diff --git a/README b/README
index fd88504a4aeceee0b8fcaa0aa3856ebc564583cc..6d8253a2f6789505d60385a88d7997f25997b2a1 100644 (file)
--- a/README
+++ b/README
@@ -233,6 +233,10 @@ tg create
        it will detect that you are on a topic branch base ref and
        resume the topic branch creation operation.
 
+       In an alternative use case, if '-r BRANCH' is given instead
+       of dependency list, the topic branch is created based on
+       the given remote branch.
+
 tg delete
 ~~~~~~~~~
        Remove a TopGit-controlled topic branch of given name
@@ -382,6 +386,13 @@ tg update
        In case your dependencies are not up-to-date, tg update
        will first recurse into them and update these.
 
+       If a remote branch update brings dependencies on branches
+       not yet instantiated locally, you can either bring in all
+       the new branches from the remote using 'tg remote --populate'
+       or only pick out the missing ones using 'tg create -r'
+       ('tg summary' will point out branches with incomplete
+       dependencies by showing an '!' near to them).
+
        TODO: tg update -a for updating all topic branches
 
 TODO: Some infrastructure for sharing topic branches between
index fee7dff3ee9fdf5d1e29c31282cf73abdc9f7067..6ee3f027d23e797ac80e07c1024b22aaedc461f5 100644 (file)
@@ -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# }"