From: Heiko Hund <hhund@astaro.com>
To: git@vger.kernel.org
Cc: Heiko Hund <hhund@astaro.com>
Subject: [TopGit PATCH] --strip option for tg export
Date: Thu, 12 Nov 2009 11:15:08 +0100 [thread overview]
Message-ID: <1258020908-31714-1-git-send-email-hhund@astaro.com> (raw)
This introduces the '--strip[=N]' option for 'tg export --quilt' to enable
export of a flat quilt series, even if the tg branch names are structured
hierarchically.
It may be useful if you - like me - structure your topgit branches like
"t/<NN>/<NAME>" to keep the overview in git, but don't want the exported
quilt series to be spread across subdirectories.
In contrast to '--flatten' this option removes the first 'N' or all
subdirectories from the topgit branch name, while keeping compatible with
the existing options. The remaining ones can still be flattened. Patch
names can still get numbered.
Signed-off-by: Heiko Hund <hhund@astaro.com>
---
README | 8 +++++---
tg-export.sh | 47 +++++++++++++++++++++++++++++++++++++----------
2 files changed, 42 insertions(+), 13 deletions(-)
diff --git a/README b/README
index 495c70b..44b60e1 100644
--- a/README
+++ b/README
@@ -429,9 +429,11 @@ tg export
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). With '--numbered' (which implies '--flatten') the patch
- names get a number as prefix to allow getting the order without
+ they end up directly in the output dir (i.e. slashes are substituted by
+ underscores). With option '--strip[=N]' the first 'N' subdirectories (all
+ if no 'N' is given) get stripped off. Names are always '--strip'ped
+ before '--flatten'ed. With option '--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 | --linearize)] BRANCH | --quilt DIR)
diff --git a/tg-export.sh b/tg-export.sh
index a16c290..a65c731 100644
--- a/tg-export.sh
+++ b/tg-export.sh
@@ -9,6 +9,8 @@ output=
driver=collapse
flatten=false
numbered=false
+strip=false
+stripval=0
## Parse options
@@ -23,6 +25,17 @@ while [ -n "$1" ]; do
--numbered)
flatten=true;
numbered=true;;
+ --strip*)
+ val=${arg#*=}
+ if [ "$val" = "--strip" ]; then
+ strip=true
+ stripval=9999
+ elif [ -n "$val" -a "x$(echo $val | sed -e 's/[0-9]//g')" = "x" ]; then
+ strip=true
+ stripval=$val
+ else
+ die "invalid parameter $arg"
+ fi;;
--quilt)
driver=quilt;;
--collapse)
@@ -49,6 +62,9 @@ done
[ "$driver" = "quilt" ] || ! "$flatten" ||
die "--flatten works only with the quilt driver"
+[ "$driver" = "quilt" ] || ! "$strip" ||
+ die "--strip 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/##')"
@@ -162,16 +178,27 @@ quilt()
return
fi
- 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;
+ _dep_tmp=$_dep
+
+ if "$strip"; then
+ i=$stripval
+ while [ "$i" -gt 0 ]; do
+ [ "$_dep_tmp" = "${_dep_tmp#*/}" ] && break
+ _dep_tmp=${_dep_tmp#*/}
+ i=$((i - 1))
+ done
+ fi
+
+ bn="$(basename "$_dep_tmp.diff")"
+ dn="$(dirname "$_dep_tmp.diff")/"
+ [ "x$dn" = "x./" ] && dn=""
+
+ if "$flatten" && [ "$dn" ]; then
+ bn="$(echo "$_dep_tmp.diff" | sed -e 's#_#__#g' -e 's#/#_#g')"
+ dn=""
+ fi
+
+ unset _dep_tmp
if [ -e "$playground/$_dep" ]; then
# We've already seen this dep
--
tg: (f59e4f9..) strip_param_for_export (depends on: 0.8)
reply other threads:[~2009-11-12 10:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1258020908-31714-1-git-send-email-hhund@astaro.com \
--to=hhund@astaro.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).