git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] tg-export: add flag -n to get numbered patches

From
Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date
Nov 26, 2008, 21:17 UTC
Message-ID
<1227734255-30425-1-git-send-email-u.kleine-koenig@pengutronix.de>

This eases sending the patches out in the right order using git send-email. Of course this only works nicely if all patches end in the same directory (e.g. all dependant patches use the same prefix)

Note this patch depends a bit on my previous one that deprecates using -n for not exporting empty patches.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Cc: martin f. krafft <madduck@debian.org>
Cc: Petr Baudis <pasky@suse.cz>
---
 tg-export.sh |   26 +++++++++++++++++++++++---
 1 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/tg-export.sh b/tg-export.sh
index f133fb8..b667b82 100644
--- a/tg-export.sh
+++ b/tg-export.sh
@@ -7,6 +7,7 @@ name=
 branches=
 output=
 driver=collapse
+numbered=false
 
 
 ## Parse options
@@ -20,6 +21,8 @@ while [ -n "$1" ]; do
 		driver=quilt;;
 	--collapse)
 		driver=collapse;;
+	-n)
+		numbered=true;;
 	-*)
 		echo "Usage: tg [...] export ([--collapse] NEWBRANCH | [-b BRANCH1,BRANCH2...] --quilt DIRECTORY)" >&2
 		exit 1;;
@@ -34,6 +37,9 @@ done
 [ -z "$branches" -o "$driver" = "quilt" ] ||
 	die "-b works only with the quilt driver"
 
+[ "$driver" = "quilt" ] || ! "$numbered" ||
+	die "-n 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/##')"
@@ -134,19 +140,31 @@ quilt()
 		return
 	fi
 
-	filename="$output/$_dep.diff"
-	if [ -e "$filename" ]; then
+	if "$numbered"; then
+		number=$(printf "%04u" $((number + 1)))
+		bn="$(basename "$_dep.diff")";
+		dn="$(dirname "$_dep.diff")";
+		num_dep="$dn/$number-$bn"
+	else
+		num_dep="$_dep.diff";
+	fi
+	filename="$output/$num_dep"
+
+	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
 		echo "Exporting $_dep"
 		mkdir -p "$(dirname "$filename")"
 		$tg patch "$_dep" >"$filename"
-		echo "$_dep.diff -p1" >>"$output/series"
+		echo "$num_dep.diff -p1" >>"$output/series"
 	fi
 }
 
@@ -166,6 +184,8 @@ elif [ "$driver" = "quilt" ]; then
 		die "target directory already exists: $output"
 
 	mkdir -p "$output"
+
+	number="0000";
 fi
 
 
-- 
1.5.6.5
Message 1 of 1 in “tg-export: add flag -n to get numbered patches”
  1. tg-export: add flag -n to get numbered patchesUwe Kleine-König, Nov 26, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.