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

[PATCH] Re: Make "gitk" work better with dense revlists

From
Yann Dirson <ydirson@altern.org>
Date
Nov 15, 2005, 22:57 UTC
Message-ID
<20051115225740.GB28173@nowhere.earth>
Linus wrote:
>To generate the diff for a commit, gitk used to do
>
>	git-diff-tree -p -C $p $id

Although the "$p" reference is harmful to --dense mode, and redundant when we just want to look at a single commit, removing it breaks the "Diff this -> selected" and "Diff selected -> this" features.

A minimal fix would be at least make your change dependant on being in dense mode, and disable those extra features then (better than keeping them broken) if noone takes the lead to fix it.

Signed-off-by: Yann Dirson <ydirson@altern.org>
diff --git a/gitk b/gitk
index a9d37d9..f73ab41 100755
--- a/gitk
+++ b/gitk
@@ -2801,12 +2801,17 @@ proc addtocflist {ids} {
 }
 
 proc gettreediffs {ids} {
-    global treediff parents treepending
+    global treediff parents treepending isdense
     set treepending $ids
     set treediff {}
     set id [lindex $ids 0]
     set p [lindex $ids 1]
-    if [catch {set gdtf [open "|git-diff-tree -r $id" r]}] return
+    if {$isdense == 1} {
+       set range "$id"
+    } else {
+       set range "$p $id"
+    }
+    if [catch {set gdtf [open "|git-diff-tree -r $range" r]}] return
     fconfigure $gdtf -blocking 0
     fileevent $gdtf readable [list gettreediffline $gdtf $ids]
 }
@@ -2837,12 +2842,16 @@ proc gettreediffline {gdtf ids} {
 
 proc getblobdiffs {ids} {
     global diffopts blobdifffd diffids env curdifftag curtagstart
-    global difffilestart nextupdate diffinhdr treediffs
+    global difffilestart nextupdate diffinhdr treediffs isdense
 
     set id [lindex $ids 0]
     set p [lindex $ids 1]
     set env(GIT_DIFF_OPTS) $diffopts
-    set cmd [list | git-diff-tree -r -p -C $id]
+    if {$isdense == 1} {
+       set cmd [list | git-diff-tree -r -p -C $id]
+    } else {
+       set cmd [list | git-diff-tree -r -p -C $p $id]
+    }
     if {[catch {set bdf [open $cmd r]} err]} {
        puts "error getting diffs: $err"
        return
@@ -3299,16 +3308,21 @@ proc mstime {} {
 }
 
 proc rowmenu {x y id} {
-    global rowctxmenu idline selectedline rowmenuid
+    global rowctxmenu idline selectedline rowmenuid isdense
 
     if {![info exists selectedline] || $idline($id) eq $selectedline} {
-       set state disabled
+       set patchstate disabled
     } else {
-       set state normal
+       set patchstate normal
+    }
+    if {$isdense || $patchstate eq "disabled"} {
+       set diffstate disabled
+    } else {
+       set diffstate normal
     }
-    $rowctxmenu entryconfigure 0 -state $state
-    $rowctxmenu entryconfigure 1 -state $state
-    $rowctxmenu entryconfigure 2 -state $state
+    $rowctxmenu entryconfigure 0 -state $diffstate
+    $rowctxmenu entryconfigure 1 -state $diffstate
+    $rowctxmenu entryconfigure 2 -state $patchstate
     set rowmenuid $id
     tk_popup $rowctxmenu $x $y
 }
@@ -3653,6 +3667,7 @@ proc doquit {} {
 # defaults...
 set datemode 0
 set boldnames 0
+set isdense 0
 set diffopts "-U 5 -p"
 set wrcomcmd "git-diff-tree --stdin -p --pretty"
 
@@ -3678,6 +3693,10 @@ foreach arg $argv {
        "^$" { }
        "^-b" { set boldnames 1 }
        "^-d" { set datemode 1 }
+       "^--dense$" {
+           set isdense 1
+           lappend revtreeargs $arg
+       }
        default {
            lappend revtreeargs $arg
        }
-- 
Yann Dirson    <ydirson@altern.org> |
Debian-related: <dirson@debian.org> |   Support Debian GNU/Linux:
                                    |  Freedom, Power, Stability, Gratis
     http://ydirson.free.fr/        | Check <http://www.debian.org/>
Next: Yann Dirson
Message 1 of 2 in “Re: Make "gitk" work better with dense revlists”
  1. Re: Make "gitk" work better with dense revlistsYann Dirson, Nov 15, 2005
  2. Re: Make "gitk" work better with dense revlistsYann Dirson, Nov 19, 2005

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.