chiark / gitweb /
tg export (quilt): Implement numbering the patches
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fri, 19 Dec 2008 22:21:48 +0000 (23:21 +0100)
committermartin f. krafft <madduck@debian.org>
Mon, 5 Jan 2009 15:47:22 +0000 (16:47 +0100)
To ease sending patches, with --numbered each patch gets a number prefix
similar to the output of git format-patch.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: martin f. krafft <madduck@debian.org>
README
tg-export.sh

diff --git a/README b/README
index 0b1800e59e297e06208b9a1f84faabf774242331..1d3836585b109449fd6475edad5a470700bff802 100644 (file)
--- a/README
+++ b/README
@@ -413,7 +413,9 @@ tg export
        branch.  So usually they end up in subdirectories of the output
        directory.  With option '--flatten' the names are mangled such that
        they end up directly in the output dir (i.e. slashed are substituted by
-       underscores).
+       underscores).  With '--numbered' (which implies '--flatten') the patch
+       names get a number as prefix to allow getting the order without
+       consulting the series file, which eases sending out the patches.
 
        Usage: tg export ([--collapse] BRANCH | --quilt DIR)
 
index b367aaffcdf43630a6a9bb016c3818909b9f213e..9e6940fcff23fc1a6bbd5ded2b9a7bf037ece54c 100644 (file)
@@ -8,6 +8,7 @@ branches=
 output=
 driver=collapse
 flatten=false
+numbered=false
 
 
 ## Parse options
@@ -19,6 +20,9 @@ while [ -n "$1" ]; do
                branches="$1"; shift;;
        --flatten)
                flatten=true;;
+       --numbered)
+               flatten=true;
+               numbered=true;;
        --quilt)
                driver=quilt;;
        --collapse)
@@ -37,6 +41,9 @@ done
 [ -z "$branches" -o "$driver" = "quilt" ] ||
        die "-b works only with the quilt driver"
 
+[ "$driver" = "quilt" ] || ! "$numbered" ||
+       die "--numbered works only with the quilt driver";
+
 [ "$driver" = "quilt" ] || ! "$flatten" ||
        die "--flatten works only with the quilt driver"
 
@@ -155,18 +162,26 @@ quilt()
                fi;
        fi;
 
-       filename="$output/$dn$bn";
-       if [ -e "$filename" ]; then
+       if [ -e "$playground/$_dep" ]; then
                # We've already seen this dep
                return
        fi
 
+       mkdir -p "$playground/$(dirname "$_dep")";
+       touch "$playground/$_dep";
+
        if branch_empty "$_dep"; then
                echo "Skip empty patch $_dep";
        else
+               if "$numbered"; then
+                       number="$(printf "%04u" $(($(cat "$playground/^number" 2>/dev/null) + 1)))";
+                       bn="$number-$bn";
+                       echo "$number" >"$playground/^number";
+               fi;
+
                echo "Exporting $_dep"
                mkdir -p "$output/$dn";
-               $tg patch "$_dep" >"$filename"
+               $tg patch "$_dep" >"$output/$dn$bn"
                echo "$dn$bn -p1" >>"$output/series"
        fi
 }