threads / patch / 16452

patchtg export: implement skipping empty patches for quilt mode

Subject: [PATCH] tg export: implement skipping empty patches for quilt mode

## tl;dr

5 messages between Nov 24, 2008 and Nov 26, 2008. Diffs are folded; open one to read it.

replies: 4people: 3as markdown or json

Uwe Kleine-König· Nov 24, 2008, 21:56 UTC · lore
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 |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)
Show changes to tg-export.sh +14 −4
diff --git a/tg-export.sh b/tg-export.sh
index 52af88d..6f1d226 100644
--- a/tg-export.sh
+++ b/tg-export.sh
@@ -7,6 +7,7 @@ name=
 branches=
 output=
 driver=collapse
+skipempty=false
 
 
 ## Parse options
@@ -20,6 +21,8 @@ while [ -n "$1" ]; do
 		driver=quilt;;
 	--collapse)
 		driver=collapse;;
+	-n)
+		skipempty=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"
 
+! "$skipempty" || [ "$driver" = "quilt" ] ||
+	die "-n is only implemented for 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/##')"
@@ -140,10 +146,14 @@ quilt()
 		return
 	fi
 
-	echo "Exporting $_dep"
-	mkdir -p "$(dirname "$filename")"
-	$tg patch "$_dep" >"$filename"
-	echo "$_dep.diff -p1" >>"$output/series"
+	if "$skipempty" && 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"
+	fi
 }
 
 
-- 
1.5.6.5
martin f krafft· Nov 25, 2008, 08:45 UTC · re: Uwe Kleine-König · lore

Re: [PATCH] tg export: implement skipping empty patches for quilt mode

also sprach Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [2008.11.24.2256 +0100]:
> +skipempty=false

Any reason not to make it default? Why do we even need this option? Do empty quilt files ever have a purpose?

-- 
 .''`.   martin f. krafft <madduck@debian.org>
: :'  :  proud Debian developer, author, administrator, and user
`. `'`   http://people.debian.org/~madduck - http://debiansystem.info
  `-  Debian - when you have better things to do than fixing systems
 
"the husbands of very beautiful women
 belong to the criminal classes."
                                                        -- oscar wilde
Uwe Kleine-König· Nov 25, 2008, 20:54 UTC · re: martin f krafft · lore

Re: [PATCH] tg export: implement skipping empty patches for quilt mode

On Tue, Nov 25, 2008 at 09:45:31AM +0100, martin f krafft wrote:
Show 5 quoted lines
> also sprach Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [2008.11.24.2256 +0100]:
> > +skipempty=false
> 
> Any reason not to make it default? Why do we even need this option?
> Do empty quilt files ever have a purpose?

My first implementation did it unconditionally because I think this should be the default, too. Then I found in the tg-export section of README:

	TODO: -n option to prevent exporting of empty patches

I'm not sure if this was meant for collapse or quilt or both. I assumed the last and implemented -n as suggested.

Best regards Uwe

martin f krafft· Nov 26, 2008, 09:25 UTC · re: Uwe Kleine-König · lore

Re: [PATCH] tg export: implement skipping empty patches for quilt mode

also sprach Uwe Kleine-König <ukleinek@strlen.de> [2008.11.25.2154 +0100]:
> 	TODO: -n option to prevent exporting of empty patches
> 
> I'm not sure if this was meant for collapse or quilt or both.  I assumed
> the last and implemented -n as suggested.
Hm, except...
+! "$skipempty" || [ "$driver" = "quilt" ] ||
+       die "-n is only implemented for the quilt driver"
+
so you assumed "quilt", not both.
Anyway, Petr, I'd make this default for all drivers, unless you object.
-- 
 .''`.   martin f. krafft <madduck@debian.org>
: :'  :  proud Debian developer, author, administrator, and user
`. `'`   http://people.debian.org/~madduck - http://debiansystem.info
  `-  Debian - when you have better things to do than fixing systems
 
http://www.vcnet.com/bms/
Uwe Kleine-König· Nov 26, 2008, 09:47 UTC · re: martin f krafft · lore

Re: [PATCH] tg export: implement skipping empty patches for quilt mode

On Wed, Nov 26, 2008 at 10:25:42AM +0100, martin f krafft wrote:
Show 13 quoted lines
> also sprach Uwe Kleine-König <ukleinek@strlen.de> [2008.11.25.2154 +0100]:
> > 	TODO: -n option to prevent exporting of empty patches
> > 
> > I'm not sure if this was meant for collapse or quilt or both.  I assumed
> > the last and implemented -n as suggested.
> 
> Hm, except...
> 
> +! "$skipempty" || [ "$driver" = "quilt" ] ||
> +       die "-n is only implemented for the quilt driver"
> +
> 
> so you assumed "quilt", not both.
hmm, I *implemented* it only for quilt.  That's also the reason for not
having deleted the todo item.
 
> Anyway, Petr, I'd make this default for all drivers, unless you object.
Ack.

If you want I can prepare a patch, but probably it's easier for you to amend!?

Best regards Uwe

← back to recent threads