# [PATCH] guilt: add option guilt.diffstat

9 messages from 2008-12-13 to 2008-12-20. Participants: Wu Fengguang, Josef Jeff Sipek, Boyd Stephen Smith Jr..
Thread: https://gitlist.dev/t/16708

## Wu Fengguang, 2008-12-13 02:14

Subject: [PATCH] guilt: add option guilt.diffstat
Message-ID: <20081213021422.GA28249@localhost>
URL: https://gitlist.dev/e/20081213021422.GA28249%40localhost

```
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
@@ -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, 2008-12-13 04:43

Subject: Re: [PATCH] guilt: add option guilt.diffstat
Message-ID: <20081213044357.GD15407@josefsipek.net>
URL: https://gitlist.dev/e/20081213044357.GD15407%40josefsipek.net
In-Reply-To: <20081213021422.GA28249@localhost>

```
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.

> 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.

>  			(
>  				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., 2008-12-13 06:18

Subject: Re: [PATCH] guilt: add option guilt.diffstat
Message-ID: <200812130018.56061.bss03@volumehost.net>
URL: https://gitlist.dev/e/200812130018.56061.bss03%40volumehost.net
In-Reply-To: <20081213044357.GD15407@josefsipek.net>

```
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, 2008-12-13 06:23

Subject: Re: [PATCH] guilt: add option guilt.diffstat
Message-ID: <20081213062313.GE15407@josefsipek.net>
URL: https://gitlist.dev/e/20081213062313.GE15407%40josefsipek.net
In-Reply-To: <200812130018.56061.bss03@volumehost.net>

```
On Sat, Dec 13, 2008 at 12:18:50AM -0600, Boyd Stephen Smith Jr. wrote:
> 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, 2008-12-13 13:17

Subject: Re: [PATCH] guilt: add option guilt.diffstat
Message-ID: <20081213131700.GA8649@localhost>
URL: https://gitlist.dev/e/20081213131700.GA8649%40localhost
In-Reply-To: <20081213044357.GD15407@josefsipek.net>

```
Hi Jeff,

On Sat, Dec 13, 2008 at 06:43:57AM +0200, Josef Jeff Sipek wrote:
> 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>
---
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, 2008-12-18 11:26

Subject: [PATCH][RESEND] guilt: add option guilt.diffstat
Message-ID: <20081218112643.GA15416@localhost>
URL: https://gitlist.dev/e/20081218112643.GA15416%40localhost
In-Reply-To: <20081213131700.GA8649@localhost>

```
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
@@ -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, 2008-12-18 14:39

Subject: Re: [PATCH][RESEND] guilt: add option guilt.diffstat
Message-ID: <20081218143918.GM15407@josefsipek.net>
URL: https://gitlist.dev/e/20081218143918.GM15407%40josefsipek.net
In-Reply-To: <20081218112643.GA15416@localhost>

```
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, 2008-12-19 00:08

Subject: Re: [PATCH][RESEND] guilt: add option guilt.diffstat
Message-ID: <20081219000824.GA5562@localhost>
URL: https://gitlist.dev/e/20081219000824.GA5562%40localhost
In-Reply-To: <20081218143918.GM15407@josefsipek.net>

```
On Thu, Dec 18, 2008 at 04:39:18PM +0200, Josef Jeff Sipek wrote:
> 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, 2008-12-20 04:33

Subject: Re: [PATCH][RESEND] guilt: add option guilt.diffstat
Message-ID: <20081220043338.GS15407@josefsipek.net>
URL: https://gitlist.dev/e/20081220043338.GS15407%40josefsipek.net
In-Reply-To: <20081218112643.GA15416@localhost>

```
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

```
