From 97ce88672c1c2bd6decabc54f5ae1e08e4ea8f32 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Thu, 25 Sep 2008 02:03:02 +0200 Subject: [PATCH] tg export: With quilt driver, accept explicit list of branches --- README | 6 ++++-- tg-export.sh | 20 +++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/README b/README index 03eeec5..1893dc0 100644 --- 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 diff --git a/tg-export.sh b/tg-export.sh index 6098c1a..a7c459a 100644 --- a/tg-export.sh +++ b/tg-export.sh @@ -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 -- 2.30.2