chiark / gitweb /
tg-push: new command pushing a tgish branch
authorMarc Weber <marco-oweber@gmx.de>
Tue, 12 May 2009 08:54:51 +0000 (10:54 +0200)
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Tue, 12 May 2009 08:55:29 +0000 (10:55 +0200)
It pushes recursively all deps and bases together with the branch.

Signed-off-by: Marc Weber <marco-oweber@gmx.de>
Tested-and-acked-by: martin f. krafft <madduck@madduck.net>
[ukleinek: fixed some nitpicks and changed remote handling]
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Marc Weber <marco-oweber@gmx.de>
.gitignore
README
tg-push.sh [new file with mode: 0644]

index eb56446..2f6d991 100644 (file)
@@ -21,6 +21,8 @@
 /tg-import.txt
 /tg-remote
 /tg-remote.txt
+/tg-push
+/tg-push.txt
 /tg
 .*.swp
 
diff --git a/README b/README
index d2f095d..495c70b 100644 (file)
--- a/README
+++ b/README
@@ -480,6 +480,12 @@ tg update
 
        TODO: tg update -a for updating all topic branches
 
+tg push
+~~~~~~~
+       pushes a TopGit-controlled topic branch to a remote
+       repository.  By default the remote gets all dependencies
+       (both tgish and non-tgish) and bases pushed to.
+
 TODO: tg rename
 
 
diff --git a/tg-push.sh b/tg-push.sh
new file mode 100644 (file)
index 0000000..8d09a02
--- /dev/null
@@ -0,0 +1,75 @@
+#!/bin/sh
+# TopGit - A different patch queue manager
+# GPLv2
+
+## Parse options
+
+recurse_deps=true
+tgish_deps_only=false
+dry_run=
+
+while [ -n "$1" ]; do
+       arg="$1"; shift
+       case "$arg" in
+       --no-deps)
+               recurse_deps=false;;
+       --dry-run)
+               dry_run=--dry-run;;
+       --tgish-only)
+               tgish_deps_only=true;;
+       -h|--help)
+               echo "Usage: tg push [--dry-run] [--no-deps] [--tgish-only] [-r remote] branch*"
+               exit 0;;
+       -r)
+               remote="$1"
+               shift
+               ;;
+       *)
+               branches="$branches $arg";;
+       esac
+done
+
+if [ -z "$remote" ]; then
+       remote="$base_remote"
+fi
+
+if [ -z "$remote" ]; then
+       die "no remote location given. Either use -r remote argument or set topgit.remote"
+fi
+
+if [ -z "$branches" ]; then
+       branches="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')"
+fi
+
+for name in $branches; do
+       ref_exists "$name" || die "detached HEAD? Can't push $name"
+done
+
+push_branch()
+{
+       # if so desired omit non tgish deps
+       $tgish_deps_only && [ -z "$_dep_is_tgish" ] && return 0
+
+       echo "$_dep"
+       local base="top-bases/$_dep"
+       if ref_exists "$base"; then
+               echo "top-bases/$_dep"
+       else
+               echo "warning, no base found $base" 1>&2
+       fi
+}
+
+for name in $branches; do
+       list="$(
+               # deps
+               if $recurse_deps; then
+                       no_remotes=1 recurse_deps push_branch "$name"
+               fi
+               # current branch
+               _dep="$name"
+               _dep_is_tgish=1
+               push_branch "$name"
+       )"
+       echo "pushing:"; echo $list
+       git push $dry_run "$remote" $list
+done