Subject: Enhanced diff options for gitk (Re: --unified=0)

From: Ray Lehtiniemi <[email-masked]>
Date: Sat, 03 Feb 2007 15:12:51 -0700

On Saturday 03 February 2007 13:37, Junio C Hamano wrote:

> That's sick.

:-)  i actually only noticed it while testing this patch....

-- >8 --
[PATCH] Enhanced diff options for gitk.

The diff options box in the gitk preferences dialog
doesn't do much because the GIT_DIFF_OPTS environment
variable only honors the --unified option.

Adjust the usage of $diffopts and remove GIT_DIFF_OPTS
from gitk so that other diff options will be honored.

Signed-off-by: Ray Lehtiniemi <[email-masked]>
---
 gitk |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/gitk b/gitk
index 68cfd63..7ee19b7 100755
--- a/gitk
+++ b/gitk
@@ -4183,9 +4183,7 @@ proc mergediff {id l} {
 
     set diffmergeid $id
     set diffids $id
-    # this doesn't seem to actually affect anything...
-    set env(GIT_DIFF_OPTS) $diffopts
-    set cmd [concat | git diff-tree --no-commit-id --cc $id]
+    set cmd [concat | git diff-tree $diffopts --no-commit-id --cc $id]
     if {[catch {set mdf [open $cmd r]} err]} {
 	error_popup "Error getting merge diffs: $err"
 	return
@@ -4332,8 +4330,7 @@ proc getblobdiffs {ids} {
     global diffopts blobdifffd diffids env curdifftag curtagstart
     global nextupdate diffinhdr treediffs
 
-    set env(GIT_DIFF_OPTS) $diffopts
-    set cmd [concat | git diff-tree --no-commit-id -r -p -C $ids]
+    set cmd [concat | git diff-tree $diffopts --no-commit-id -r -p -C $ids]
     if {[catch {set bdf [open $cmd r]} err]} {
 	puts "error getting diffs: $err"
 	return
@@ -5896,7 +5893,7 @@ proc prefscan {} {
 }
 
 proc prefsok {} {
-    global maxwidth maxgraphpct
+    global maxwidth maxgraphpct diffopts
     global oldprefs prefstop showneartags
 
     catch {destroy $prefstop}
@@ -5906,6 +5903,8 @@ proc prefsok {} {
 	redisplay
     } elseif {$showneartags != $oldprefs(showneartags)} {
 	reselectline
+    } elseif {$diffopts != $oldprefs(diffopts)} {
+	reselectline
     }
 }
 
@@ -6188,7 +6187,7 @@ proc tcl_encoding {enc} {
 
 # defaults...
 set datemode 0
-set diffopts "-U 5 -p"
+set diffopts ""
 set wrcomcmd "git diff-tree --stdin -p --pretty"
 
 set gitencoding {}
-- 
1.5.0.rc3.28.g8bbd