[PATCH TOPGIT] tg export (quilt): Implement numbering the patches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



To ease sending patches, with -n each patch gets a number prefix similar
to git format-patch.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>
---
 tg-export.sh |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/tg-export.sh b/tg-export.sh
index 06b9c8d..7a7d87a 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;;
 	-f)
 		flatten=true;;
+	-n)
+		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 "-n works only with the quilt driver";
+
 [ "$driver" = "quilt" ] || ! "$flatten" ||
 	die "-f 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
 }
-- 
1.5.6.5

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux