From 8d92943bcdb6eea3819dce28d2ff48dd8a061b31 Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Sun, 3 Oct 2010 23:25:52 +0200 Subject: [PATCH] Let tg-update take a branch parameter MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Bert Wesarg Signed-off-by: Uwe Kleine-König --- README | 6 ++++-- contrib/tg-completion.bash | 7 ++++++- tg-update.sh | 20 +++++++++++++------- 3 files changed, 23 insertions(+), 10 deletions(-) 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" -- 2.30.2