From: Bert Wesarg Date: Sun, 3 Oct 2010 21:25:52 +0000 (+0200) Subject: Let tg-update take a branch parameter X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;ds=inline;h=8d92943bcdb6eea3819dce28d2ff48dd8a061b31;p=topgit.git Let tg-update take a branch parameter Signed-off-by: Bert Wesarg Signed-off-by: Uwe Kleine-König --- diff --git a/README b/README index 9bab4de..dec299f 100644 --- a/README +++ b/README @@ -483,13 +483,15 @@ tg import tg update ~~~~~~~~~ - Update the current topic branch wrt. changes in the branches - it depends on and remote branches. + Update the current or specified topic branch wrt. changes in the + branches it depends on and remote branches. This is performed in two phases - first, changes within the dependencies are merged to the base, then the base is merged into the topic branch. The output will guide you in case of conflicts. + After the update the current branch is the specified one. + In case your dependencies are not up-to-date, tg update will first recurse into them and update these. diff --git a/contrib/tg-completion.bash b/contrib/tg-completion.bash index 0ee233c..5aabc92 100755 --- a/contrib/tg-completion.bash +++ b/contrib/tg-completion.bash @@ -423,7 +423,12 @@ _tg_summary () _tg_update () { - COMPREPLY=() + local cur="${COMP_WORDS[COMP_CWORD]}" + + case "$cur" in + *) + __tgcomp "$(__tg_topics)" + esac } ### }}} diff --git a/tg-update.sh b/tg-update.sh index 73280c6..b256c7c 100644 --- a/tg-update.sh +++ b/tg-update.sh @@ -8,13 +8,19 @@ name= ## Parse options -if [ -n "$1" ]; then - echo "Usage: tg [...] update" >&2 - exit 1 -fi - - -name="$(git symbolic-ref HEAD | sed 's#^refs/\(heads\|top-bases\)/##')" +while [ -n "$1" ]; do + arg="$1"; shift + case "$arg" in + -*) + echo "Usage: tg [...] update [NAME]" >&2 + exit 1;; + *) + [ -z "$name" ] || die "name already specified ($name)" + name="$arg";; + esac +done + +[ -n "$name" ] || name="$(git symbolic-ref HEAD | sed 's#^refs/\(heads\|top-bases\)/##')" base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" || die "not a TopGit-controlled branch"