Skip to contentSkip to conversation

guilt: add option guilt.diffstat

PATCH Superseded Wu Fengguang 3 participants 9 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 guilt |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
guilt renamed from guilt.orig +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
 #
#1 lore raw
Quoted 2 lines · Wu Fengguang

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

Good idea.

guilt __refresh_patch() · line 541

Quoted 13 lines
---
 guilt |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
guilt renamed from guilt.orig +1 -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

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.

Quoted 14 lines
guilt renamed from guilt.orig +3 -0
 			(
 				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
 #

guilt AUTOTAG_DEFAULT=1 · line 647

Quoted 10 lines
guilt renamed from guilt.orig +4 -0
@@ -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.

Signature · 2 lines
My public GPG key can be found at
http://www.josefsipek.net/gpg/public-0xC7958FFE.txt
#2 lore raw
Quoted 4 lines · On Friday 2008 December 12 22:43:57 Josef Jeff Sipek wrote:

guilt __refresh_patch() · line 541

Quoted 1 line
guilt renamed from guilt.orig +1 -0
+		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.

Signature · 4 lines
Boyd Stephen Smith Jr.                     ,= ,-_-. =. 
[email protected]                      ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' 
http://iguanasuicide.org/                      \_/     
#3 lore raw
Quoted 9 lines · Boyd Stephen Smith Jr.
Quoted 4 lines · On Friday 2008 December 12 22:43:57 Josef Jeff Sipek wrote:

guilt __refresh_patch() · line 541

Quoted 1 line
guilt renamed from guilt.orig +1 -0
+		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!

Quoted 2 lines

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.

Signature · 1 line
Penguin : Linux version 2.6.25.4 on an i386 machine (6135.73 BogoMips).
#4 lore raw
In reply to Josef Jeff Sipek

Hi Jeff,

Quoted 5 lines · Josef Jeff Sipek
Quoted 2 lines · Wu Fengguang

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

Good idea.

Thanks.

Quoted 1 line

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.

---

Documentation/guilt-refresh.txt +8 -2
index 9a0b4e8..7757bdc 100644
@@ -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
 ------
guilt +8 -1
index fabee17..12361da 100755
@@ -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
 #
#5 lore raw

PATCH RESEND 1/1 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.

---

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 +8 -1
@@ -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
 #
Documentation/guilt-refresh.txt +8 -2
@@ -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
 ------
#6 lore raw
Quoted 2 lines · Wu Fengguang

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.

Signature · 1 line
Humans were created by water to transport it upward.
#7 lore raw
Quoted 6 lines · Josef Jeff Sipek
Quoted 2 lines · Wu Fengguang

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

#8 lore raw
In reply to Wu Fengguang
Quoted 2 lines · Wu Fengguang

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.

Signature · 4 lines
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