threads / patch / 16708

patchguilt: add option guilt.diffstat

Subject: [PATCH] guilt: add option guilt.diffstat

## tl;dr

9 messages between Dec 13, 2008 and Dec 20, 2008. Diffs are folded; open one to read it.

replies: 8people: 3as markdown or json

Wu Fengguang· Dec 13, 2008, 02:14 UTC · lore

Introduce option guilt.diffstat so that we don't have to type "guilt refresh --diffstat" in its full form every time.

Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
 guilt |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

--- guilt.orig 2008-12-13 09:53:32.000000000 +0800 +++ guilt 2008-12-13 10:01:03.000000000 +0800

Show changes to diff +8 −1
@@ -538,7 +538,7 @@ __refresh_patch()
 
 		[ ! -z "$4" ] && diffopts="-C -M --find-copies-harder"
 		
-		if [ ! -z "$5" ]; then
+		if [ -n "$5" -o "x$diffstat" = "x1" ]; then
 			(
 				echo "---"
 				git diff --stat $diffopts "$2"
@@ -627,6 +627,9 @@ guilt_push_diff_context=1
 # default autotag value
 AUTOTAG_DEFAULT=1
 
+# default diffstat value
+DIFFSTAT_DEFAULT=0
+
 #
 # Parse any part of .git/config that belongs to us
 #
@@ -635,6 +638,10 @@ AUTOTAG_DEFAULT=1
 autotag=`git config guilt.autotag`
 [ -z "$autotag" ] && autotag=$AUTOTAG_DEFAULT
 
+# generate diffstat?
+diffstat=`git config guilt.diffstat`
+[ -z "$diffstat" ] && diffstat=$DIFFSTAT_DEFAULT
+
 #
 # The following gets run every time this file is source'd
 #
Josef Jeff Sipek· Dec 13, 2008, 04:43 UTC · re: Wu Fengguang · lore

Re: [PATCH] guilt: add option guilt.diffstat

On Sat, Dec 13, 2008 at 10:14:22AM +0800, Wu Fengguang wrote:
> Introduce option guilt.diffstat so that we don't have to type
> "guilt refresh --diffstat" in its full form every time.
Good idea.
Show 13 quoted lines
> Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
> ---
>  guilt |    9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> --- guilt.orig	2008-12-13 09:53:32.000000000 +0800
> +++ guilt	2008-12-13 10:01:03.000000000 +0800
> @@ -538,7 +538,7 @@ __refresh_patch()
>  
>  		[ ! -z "$4" ] && diffopts="-C -M --find-copies-harder"
>  		
> -		if [ ! -z "$5" ]; then
> +		if [ -n "$5" -o "x$diffstat" = "x1" ]; then

Why the 'x' thing? I've seen it is some scripts before, but I can't think of a reason to use it if the variable is surrounded in quotation marks.

Show 24 quoted lines
>  			(
>  				echo "---"
>  				git diff --stat $diffopts "$2"
> @@ -627,6 +627,9 @@ guilt_push_diff_context=1
>  # default autotag value
>  AUTOTAG_DEFAULT=1
>  
> +# default diffstat value
> +DIFFSTAT_DEFAULT=0
> +
>  #
>  # Parse any part of .git/config that belongs to us
>  #
> @@ -635,6 +638,10 @@ AUTOTAG_DEFAULT=1
>  autotag=`git config guilt.autotag`
>  [ -z "$autotag" ] && autotag=$AUTOTAG_DEFAULT
>  
> +# generate diffstat?
> +diffstat=`git config guilt.diffstat`
> +[ -z "$diffstat" ] && diffstat=$DIFFSTAT_DEFAULT
> +
>  #
>  # The following gets run every time this file is source'd
>  #
Could you throw a quick note into the manpages?
Thanks,
Josef 'Jeff' Sipek.
-- 
My public GPG key can be found at
http://www.josefsipek.net/gpg/public-0xC7958FFE.txt
Boyd Stephen Smith Jr.· Dec 13, 2008, 06:18 UTC · re: Josef Jeff Sipek · lore

Re: [PATCH] guilt: add option guilt.diffstat

On Friday 2008 December 12 22:43:57 Josef Jeff Sipek wrote:
>> +		if [ -n "$5" -o "x$diffstat" = "x1" ]; then
>
>Why the 'x' thing? I've seen it is some scripts before, but I can't think of
>a reason to use it if the variable is surrounded in quotation marks.

'[' or test see the arguments after they are unquoted (normally). So, if "$diffstat" is "-n" it might try and do the -n test, rather than the = test.

It could be re-written as "1" == "${diffstat}" instead to avoid the x, but it's not a big deal (to me). That also looks backwards to a lot of people.

-- 
Boyd Stephen Smith Jr.                     ,= ,-_-. =. 
bss03@volumehost.net                      ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' 
http://iguanasuicide.org/                      \_/     
Josef Jeff Sipek· Dec 13, 2008, 06:23 UTC · re: Boyd Stephen Smith Jr. · lore

Re: [PATCH] guilt: add option guilt.diffstat

On Sat, Dec 13, 2008 at 12:18:50AM -0600, Boyd Stephen Smith Jr. wrote:
Show 9 quoted lines
> On Friday 2008 December 12 22:43:57 Josef Jeff Sipek wrote:
> >> +		if [ -n "$5" -o "x$diffstat" = "x1" ]; then
> >
> >Why the 'x' thing? I've seen it is some scripts before, but I can't think of
> >a reason to use it if the variable is surrounded in quotation marks.
> 
> '[' or test see the arguments after they are unquoted (normally).  So, 
> if "$diffstat" is "-n" it might try and do the -n test, rather than the = 
> test.
Oh. I haven't even thought of that posibility!
> It could be re-written as "1" == "${diffstat}" instead to avoid the x, but 
> it's not a big deal (to me).  That also looks backwards to a lot of people.
Including me.
Thanks for the info.
Josef 'Jeff' Sipek.
-- 
Penguin : Linux version 2.6.25.4 on an i386 machine (6135.73 BogoMips).
Wu Fengguang· Dec 13, 2008, 13:17 UTC · re: Josef Jeff Sipek · lore

Re: [PATCH] guilt: add option guilt.diffstat

Hi Jeff,
On Sat, Dec 13, 2008 at 06:43:57AM +0200, Josef Jeff Sipek wrote:
Show 5 quoted lines
> On Sat, Dec 13, 2008 at 10:14:22AM +0800, Wu Fengguang wrote:
> > Introduce option guilt.diffstat so that we don't have to type
> > "guilt refresh --diffstat" in its full form every time.
> 
> Good idea.
Thanks.
> Could you throw a quick note into the manpages?

Sure. Here is the updated patch. This time I used "git-config --bool" to ensure diffstat will be either "true" or "false":

        The type specifier can be either --int or --bool, which will
        make git-config ensure that the variable(s) are of the given
        type and convert the value to the canonical form (simple
        decimal number for int, a "true" or "false" string for bool).
        If no type specifier is passed, no checks or transformations
        are performed on the value.

Thanks, Fengguang --- guilt: add option guilt.diffstat

Introduce option guilt.diffstat so that we don't have to type "guilt refresh --diffstat" in its full form every time.

Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
Show changes to 2 files +16 −3

Documentation/guilt-refresh.txt, guilt

diff --git a/Documentation/guilt-refresh.txt b/Documentation/guilt-refresh.txt
index 9a0b4e8..7757bdc 100644
--- a/Documentation/guilt-refresh.txt
+++ b/Documentation/guilt-refresh.txt
@@ -20,8 +20,14 @@ OPTIONS
 	format (e.g., rename and copy detection).
 
 --diffstat::
-	Include a diffstat output in the patch file. Useful for cases where
-	patches will be submitted with other tools.
+Include a diffstat output in the patch file. Useful for cases where
+patches will be submitted with other tools.
++
+If the command line option is omitted, the corresponding git-config
+option "guilt.diffstat" will be queried. So this would enable diffstat
+output by default:
+
+	git config --global guilt.diffstat true
 
 Author
 ------
diff --git a/guilt b/guilt
index fabee17..12361da 100755
--- a/guilt
+++ b/guilt
@@ -544,7 +544,7 @@ __refresh_patch()
 
 		[ ! -z "$4" ] && diffopts="-C -M --find-copies-harder"
 		
-		if [ ! -z "$5" ]; then
+		if [ -n "$5" -o $diffstat = "true" ]; then
 			(
 				echo "---"
 				git diff --stat $diffopts "$2"
@@ -633,6 +633,9 @@ guilt_push_diff_context=1
 # default autotag value
 AUTOTAG_DEFAULT=1
 
+# default diffstat value: true or false
+DIFFSTAT_DEFAULT="false"
+
 #
 # Parse any part of .git/config that belongs to us
 #
@@ -641,6 +644,10 @@ AUTOTAG_DEFAULT=1
 autotag=`git config guilt.autotag`
 [ -z "$autotag" ] && autotag=$AUTOTAG_DEFAULT
 
+# generate diffstat?
+diffstat=`git config --bool guilt.diffstat`
+[ -z "$diffstat" ] && diffstat=$DIFFSTAT_DEFAULT
+
 #
 # The following gets run every time this file is source'd
 #
Wu Fengguang· Dec 18, 2008, 11:26 UTC · re: Wu Fengguang · lore

[PATCH][RESEND] guilt: add option guilt.diffstat

Introduce option guilt.diffstat so that we don't have to type "guilt refresh --diffstat" in its full form every time.

Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
Jeff: This patch is against the latest guilt v0.32-rc1.
 Documentation/guilt-refresh.txt |   10 ++++++++--
 guilt                           |    9 ++++++++-
 2 files changed, 16 insertions(+), 3 deletions(-)

--- guilt.orig/guilt +++ guilt/guilt

Show changes to diff +16 −3
@@ -646,7 +646,7 @@ __refresh_patch()
 
 		[ ! -z "$4" ] && diffopts="-C -M --find-copies-harder"
 		
-		if [ ! -z "$5" ]; then
+		if [ -n "$5" -o $diffstat = "true" ]; then
 			(
 				echo "---"
 				git diff --stat $diffopts "$2"
@@ -737,10 +737,17 @@ guilt_hook()
 # used for: git apply -C <val>
 guilt_push_diff_context=1
 
+# default diffstat value: true or false
+DIFFSTAT_DEFAULT="false"
+
 #
 # Parse any part of .git/config that belongs to us
 #
 
+# generate diffstat?
+diffstat=`git config --bool guilt.diffstat`
+[ -z "$diffstat" ] && diffstat=$DIFFSTAT_DEFAULT
+
 #
 # The following gets run every time this file is source'd
 #
--- guilt.orig/Documentation/guilt-refresh.txt
+++ guilt/Documentation/guilt-refresh.txt
@@ -20,8 +20,14 @@ OPTIONS
 	format (e.g., rename and copy detection).
 
 --diffstat::
-	Include a diffstat output in the patch file. Useful for cases where
-	patches will be submitted with other tools.
+Include a diffstat output in the patch file. Useful for cases where
+patches will be submitted with other tools.
++
+If the command line option is omitted, the corresponding git-config
+option "guilt.diffstat" will be queried. So this would enable diffstat
+output by default:
+
+	git config --global guilt.diffstat true
 
 Author
 ------
Josef Jeff Sipek· Dec 18, 2008, 14:39 UTC · re: Wu Fengguang · lore

Re: [PATCH][RESEND] guilt: add option guilt.diffstat

On Thu, Dec 18, 2008 at 07:26:43PM +0800, Wu Fengguang wrote:
> Introduce option guilt.diffstat so that we don't have to type
> "guilt refresh --diffstat" in its full form every time.

I haven't forgotten about this. I'll try to apply it tonight/tomorrow morning.

Jeff.
-- 
Humans were created by water to transport it upward.
Wu Fengguang· Dec 19, 2008, 00:08 UTC · re: Josef Jeff Sipek · lore

Re: [PATCH][RESEND] guilt: add option guilt.diffstat

On Thu, Dec 18, 2008 at 04:39:18PM +0200, Josef Jeff Sipek wrote:
Show 6 quoted lines
> On Thu, Dec 18, 2008 at 07:26:43PM +0800, Wu Fengguang wrote:
> > Introduce option guilt.diffstat so that we don't have to type
> > "guilt refresh --diffstat" in its full form every time.
> 
> I haven't forgotten about this. I'll try to apply it tonight/tomorrow
> morning.

Thank you. This refreshed patch resolved merge conflict against the latest git tree :)

Thanks, Fengguang

Josef Jeff Sipek· Dec 20, 2008, 04:33 UTC · re: Wu Fengguang · lore

Re: [PATCH][RESEND] guilt: add option guilt.diffstat

On Thu, Dec 18, 2008 at 07:26:43PM +0800, Wu Fengguang wrote:
> Introduce option guilt.diffstat so that we don't have to type
> "guilt refresh --diffstat" in its full form every time.
Applied.
Thanks,
Josef 'Jeff' Sipek.
-- 
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like
that.
		- Linus Torvalds

← back to recent threads