From 99df827e21e8c36214b57c3d4cd7c16453c3439f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Fri, 19 Dec 2008 22:40:33 +0100 Subject: [PATCH] tg export (quilt): Implement flattening patch paths MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The result of providing the new flag --flatten is that the exported patches are all placed directly in the output directory, not in subdirectories below it. Signed-off-by: Uwe Kleine-König Signed-off-by: martin f. krafft --- README | 6 ++++++ tg-export.sh | 23 ++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/README b/README index 8be0d17..0b1800e 100644 --- a/README +++ b/README @@ -409,6 +409,12 @@ tg export a comma-separated explicit list of branches to export. This mode of operation is currently not supported with collapse. + In '--quilt' mode the patches are named like the originating topgit + 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). + Usage: tg export ([--collapse] BRANCH | --quilt DIR) TODO: Make stripping of non-essential headers configurable diff --git a/tg-export.sh b/tg-export.sh index 95aa346..b367aaf 100644 --- a/tg-export.sh +++ b/tg-export.sh @@ -7,6 +7,7 @@ name= branches= output= driver=collapse +flatten=false ## Parse options @@ -16,6 +17,8 @@ while [ -n "$1" ]; do case "$arg" in -b) branches="$1"; shift;; + --flatten) + flatten=true;; --quilt) driver=quilt;; --collapse) @@ -34,6 +37,9 @@ done [ -z "$branches" -o "$driver" = "quilt" ] || die "-b works only with the quilt driver" +[ "$driver" = "quilt" ] || ! "$flatten" || + die "--flatten works only with the quilt driver" + if [ -z "$branches" ]; then # this check is only needed when no branches have been passed name="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')" @@ -138,7 +144,18 @@ quilt() return fi - filename="$output/$_dep.diff" + if "$flatten"; then + bn="$(echo "$_dep.diff" | sed -e 's#_#__#g' -e 's#/#_#g')"; + dn=""; + else + bn="$(basename "$_dep.diff")"; + dn="$(dirname "$_dep.diff")/"; + if [ "x$dn" = "x./" ]; then + dn=""; + fi; + fi; + + filename="$output/$dn$bn"; if [ -e "$filename" ]; then # We've already seen this dep return @@ -148,9 +165,9 @@ quilt() echo "Skip empty patch $_dep"; else echo "Exporting $_dep" - mkdir -p "$(dirname "$filename")" + mkdir -p "$output/$dn"; $tg patch "$_dep" >"$filename" - echo "$_dep.diff -p1" >>"$output/series" + echo "$dn$bn -p1" >>"$output/series" fi } -- 2.30.2