From 2140880ff7d57563d057d744985027575260c0b8 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Wed, 10 Sep 2008 00:29:24 +0200 Subject: [PATCH] tg create -r BRANCH: Create branch based on a remote one --- README | 11 +++++++++++ tg-create.sh | 19 ++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/README b/README index fd88504..6d8253a 100644 --- 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 diff --git a/tg-create.sh b/tg-create.sh index fee7dff..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# }" -- 2.30.2