git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v4, ping] gitk: let you easily specify lines of context in diff view

From
Steffen Prohaska <prohaska@zib.de>
Date
Aug 11, 2007, 15:30 UTC
Message-ID
<11868462503722-git-send-email-prohaska@zib.de>
In-Reply-To
<11856503182381-git-send-email-prohaska@zib.de>

More lines of context sometimes help to better understand a diff. This patch introduces a text field above the box displaying the blobdiffs. You can type in the number of lines of context that you wish to view. The number of lines of context is initially always set to 3.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
 gitk |   41 +++++++++++++++++++++++++++++++++++++++--
 1 files changed, 39 insertions(+), 2 deletions(-)
rebased to the current master, fixed one trailing whitespace.
Any chance to get this patch applied? It works for me.
    Steffen
diff --git a/gitk b/gitk
index f74ce51..2f86c7c 100755
--- a/gitk
+++ b/gitk
@@ -517,6 +517,7 @@ proc makewindow {} {
     global textfont mainfont uifont tabstop
     global findtype findtypemenu findloc findstring fstring geometry
     global entries sha1entry sha1string sha1but
+    global diffcontextstring diffcontext
     global maincursor textcursor curtextcursor
     global rowctxmenu fakerowmenu mergemax wrapcomment
     global highlight_files gdttype
@@ -731,7 +732,16 @@ proc makewindow {} {
 	-command changediffdisp -variable diffelide -value {0 1}
     radiobutton .bleft.mid.new -text "New version" \
 	-command changediffdisp -variable diffelide -value {1 0}
-    pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left
+    label .bleft.mid.labeldiffcontext -text "      Lines of context: " \
+    -font $uifont
+    spinbox .bleft.mid.diffcontext -width 5 -font $textfont \
+    -from 1 -increment 1 -to 10000000 \
+    -validate all -validatecommand "diffcontextvalidate %P" \
+    -textvariable diffcontextstring
+    .bleft.mid.diffcontext set $diffcontext
+    trace add variable diffcontextstring write diffcontextchange
+    lappend entries .bleft.mid.diffcontext
+    pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new .bleft.mid.labeldiffcontext .bleft.mid.diffcontext -side left
     set ctext .bleft.ctext
     text $ctext -background $bgcolor -foreground $fgcolor \
 	-tabs "[expr {$tabstop * $charspc}]" \
@@ -4985,12 +4995,37 @@ proc gettreediffline {gdtf ids} {
     return 0
 }
 
+# empty strings or integers accepted
+proc diffcontextvalidate {v} {
+    if {[string length $v] == 0} {
+	return 1
+    }
+    if {[string is integer $v]} {
+	if {$v > 0} {
+	    return 1
+	}
+    }
+    return 0
+}
+
+proc diffcontextchange {n1 n2 op} {
+    global diffcontextstring diffcontext
+
+    if {[string is integer $diffcontextstring]} {
+        if {$diffcontextstring > 0} {
+            set diffcontext $diffcontextstring
+		    reselectline
+        }
+    }
+}
+
 proc getblobdiffs {ids} {
     global diffopts blobdifffd diffids env
     global diffinhdr treediffs
+    global diffcontext
 
     set env(GIT_DIFF_OPTS) $diffopts
-    if {[catch {set bdf [open [diffcmd $ids {-p -C --no-commit-id}] r]} err]} {
+    if {[catch {set bdf [open [diffcmd $ids "-p -C --no-commit-id -U$diffcontext"] r]} err]} {
 	puts "error getting diffs: $err"
 	return
     }
@@ -7646,6 +7681,8 @@ set markingmatches 0
 
 set optim_delay 16
 
+set diffcontext 3
+
 set nextviewnum 1
 set curview 0
 set selectedview 0
-- 
1.5.3.rc4.31.g6adda
Previous: Steffen ProhaskaNext: Paul Mackerras
Message 7 of 10 in “gitk: let you easily specify lines of context in diff view”
  1. gitk: let you easily specify lines of context in diff viewSteffen Prohaska, Jul 26, 2007
  2. Paul MackerrasJul 26, 2007
  3. Steffen ProhaskaJul 27, 2007
  4. Paul MackerrasJul 27, 2007
  5. gitk: let you easily specify lines of context in diff viewSteffen Prohaska, Jul 27, 2007
  6. gitk: let you easily specify lines of context in diff viewSteffen Prohaska, Jul 28, 2007
  7. gitk: let you easily specify lines of context in diff viewSteffen Prohaska, Aug 11, 2007
  8. Paul MackerrasAug 12, 2007
  9. Steffen ProhaskaAug 12, 2007
  10. gitk: let you easily specify lines of context in diff viewSteffen Prohaska, Aug 12, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.