chiark / gitweb /
tg depend add: Add dependency
authorPetr Baudis <pasky@suse.cz>
Wed, 24 Sep 2008 17:03:29 +0000 (19:03 +0200)
committerPetr Baudis <pasky@suse.cz>
Wed, 24 Sep 2008 17:03:29 +0000 (19:03 +0200)
README
tg-depend.sh [new file with mode: 0644]

diff --git a/README b/README
index 5fe7d0968ab1de18da77bb4263420e4141c9d5e0..7b117b89f44a836ecafe4e5077d7f33980a78209 100644 (file)
--- a/README
+++ b/README
@@ -253,6 +253,19 @@ tg delete
 
        TODO: '-a' to delete all empty branches, depfix, revert
 
+tg depend
+~~~~~~~~~
+       Change dependencies of a TopGit-controlled topic branch.
+       This should have several subcommands, but only 'add' is
+       supported right now.
+
+       The 'add' subcommand takes an argument of a topic branch
+       to be added, adds it to '.topdeps', performs a commit and
+       then updates your topic branch accordingly. If you want to
+       do other things related to the dependency addition, like
+       adjusting '.topmsg', prepare them in the index before
+       calling 'tg depend add'.
+
 tg info
 ~~~~~~~
        Show a summary information about the current or specified
diff --git a/tg-depend.sh b/tg-depend.sh
new file mode 100644 (file)
index 0000000..af78808
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/sh
+# TopGit - A different patch queue manager
+# (c) Petr Baudis <pasky@suse.cz>  2008
+# GPLv2
+
+name=
+
+
+## Parse options
+
+subcmd="$1"; shift
+[ "$subcmd" = "add" ] || die "unknown subcommand ($subcmd)"
+
+while [ -n "$1" ]; do
+       arg="$1"; shift
+       case "$arg" in
+       -*)
+               echo "Usage: tg [...] depend add NAME" >&2
+               exit 1;;
+       *)
+               [ -z "$name" ] || die "name already specified ($name)"
+               name="$arg";;
+       esac
+done
+
+
+## Sanity checks
+
+[ -n "$name" ] || die "no branch name specified"
+branchrev="$(git rev-parse --verify "$name" 2>/dev/null)" ||
+       die "invalid branch name: $name"
+baserev="$(git rev-parse --verify "refs/top-bases/$name" 2>/dev/null)" ||
+       die "not a TopGit topic branch: $name"
+
+
+## Record new dependency
+
+echo "$name" >>.topdeps
+git add .topdeps
+git commit -m"New TopGit dependency: $name"
+$tg update