chiark / gitweb /
tg export: With quilt driver, accept explicit list of branches
authorPetr Baudis <pasky@suse.cz>
Thu, 25 Sep 2008 00:03:02 +0000 (02:03 +0200)
committerPetr Baudis <pasky@suse.cz>
Thu, 25 Sep 2008 00:03:02 +0000 (02:03 +0200)
README
tg-export.sh

diff --git a/README b/README
index 03eeec511849f8ef78206910839260b5a37b2f54..1893dc0973093da0da231c76b4bfde734fabcc8c 100644 (file)
--- a/README
+++ b/README
@@ -395,6 +395,10 @@ tg export
        and an argument specifying the directory
        where the quilt series should be saved.
 
+       With '--quilt', you can also pass '-b' parameter followed by
+       a comma-separated explicit list of branches to export. This
+       mode of operation is currently not supported with collapse.
+
        Usage: tg export ([--collapse] BRANCH | --quilt DIR)
 
        TODO: Make stripping of non-essential headers configurable
@@ -402,8 +406,6 @@ tg export
        TODO: --mbox option for other mode of operation
        TODO: -n option to prevent exporting of empty patches
        TODO: -a option to export all branches
-       TODO: Allow branches to be exported to be passed as arguments, default
-             to the current branch if none are specified
        TODO: For quilt exporting, use a temporary branch and remove it when
              done - this would allow producing conflict-less series
 
index 6098c1a8b4580914aee5143cafaf8b035237e376..a7c459a17f37c14696edfba30e121ce3ca10996e 100644 (file)
@@ -4,6 +4,7 @@
 # GPLv2
 
 name=
+branches=
 output=
 driver=collapse
 
@@ -13,12 +14,14 @@ driver=collapse
 while [ -n "$1" ]; do
        arg="$1"; shift
        case "$arg" in
+       -b)
+               branches="$1"; shift;;
        --quilt)
                driver=quilt;;
        --collapse)
                driver=collapse;;
        -*)
-               echo "Usage: tg [...] export ([--collapse] NEWBRANCH | --quilt DIRECTORY)" >&2
+               echo "Usage: tg [...] export [-b BRANCH1,BRANCH2...] ([--collapse] NEWBRANCH | --quilt DIRECTORY)" >&2
                exit 1;;
        *)
                [ -z "$output" ] || die "output already specified ($output)"
@@ -31,6 +34,9 @@ name="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')"
 base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" ||
        die "not on a TopGit-controlled branch"
 
+[ -z "$branches" -o "$driver" = "quilt" ] ||
+       die "-b works only with the quilt driver"
+
 
 playground="$(mktemp -d -t tg-export.XXXXXX)"
 trap 'rm -rf "$playground"' EXIT
@@ -167,8 +173,16 @@ driver()
 
 # Call driver on all the branches - this will happen
 # in topological order.
-recurse_deps driver "$name"
-(_ret=0; _dep="$name"; _name=""; _dep_is_tgish=1; driver)
+if [ -z "$branches" ]; then
+       recurse_deps driver "$name"
+       (_ret=0; _dep="$name"; _name=""; _dep_is_tgish=1; driver)
+else
+       echo "$branches" | tr ',' '\n' | while read _dep; do
+               _dep_is_tgish=1
+               $driver
+       done
+       name="$(echo "$branches" | sed 's/.*,//')"
+fi
 
 
 if [ "$driver" = "collapse" ]; then