[PATCH TOPGIT] tg export: Implement flattening patch paths for quilt mode

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

 



The result of providing the new flag -f is that the exported patches are
all placed directly in the output directory, not in subdirectories.

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

diff --git a/tg-export.sh b/tg-export.sh
index 95aa346..06b9c8d 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;;
+	-f)
+		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 "-f 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
 }
 
-- 
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