From 4fa8ed59a182501166aa038757bf4e2438765da5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Fri, 19 Dec 2008 23:21:48 +0100 Subject: [PATCH] tg export (quilt): Implement numbering the patches MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: martin f. krafft --- README | 4 +++- tg-export.sh | 21 ++++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/README b/README index 0b1800e..1d38365 100644 --- 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) diff --git a/tg-export.sh b/tg-export.sh index b367aaf..9e6940f 100644 --- a/tg-export.sh +++ b/tg-export.sh @@ -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 } -- 2.30.2