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

Re: git gui diff widget (was Re: [msysGit] Re: [cheetah] Questions about NOTES)

From
SPSteffen Prohaska <prohaska-wjoc1khpmeg@public.gmane.org>
Date
Jan 30, 2008, 21:14 UTC
Message-ID
<71B7B7C0-BDB3-4E50-8EB5-E45C3F1224F9@zib.de>
In-Reply-To
<1201679921.6348.10.camel-+NgBfe53rIlR1FB8S1TzorOUoyqYp7Dr@public.gmane.org>
On Jan 30, 2008, at 8:58 AM, Thomas Arcila wrote:
Show 10 quoted lines
> Here is a patch to gitk that allows to run an external diff viewer.
> I think it might be a suitable solution.
> It can be configured in Edit/Preferences/External diff tool.
>
> To see the diff between two files:
> - select revisions to diff
> - right click on a file in the patched files list view
> - choose "External diff"
>
> Any feedback is welcome.
The basic functionality works for me, however ...
Show 16 quoted lines
> Subject: [PATCH] gitk : External diff viewer.
>
> Right click on patched file list view gives "External diff" popup  
> menu entry,
> launching selected external diff tool.
>
> Signed-off-by: Thomas Arcila <tarcila-s5SjKpinsOs@public.gmane.org>
> ---
>  gitk |  109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
> ++++++++--
>  1 files changed, 105 insertions(+), 4 deletions(-)
>
> diff --git a/gitk-git/gitk b/gitk-git/gitk
> index 5560e4d..0e2c902 100755
> --- a/gitk-git/gitk
> +++ b/gitk-git/gitk
[...]
Show 18 quoted lines
> @@ -1747,6 +1762,78 @@ proc flist_hl {only} {
>      set gdttype [mc "touching paths:"]
>  }
>
> +proc external_diff {} {
> +  global gitktmpdir nullid nullid2
> +  global flist_menu_file
> +  global diffids
> +  global diffnum
> +  global gitdir extdifftool
> +
> +  set diffidto [lindex $diffids 0]
> +
> +  if {[llength $diffids] == 1} {
> +    # no reference commit given
> +    set diffidto [lindex $diffids 0]
> +    if {$diffidto eq $nullid || $diffidto eq $nullid2} {
> +      # diffing working copy with HEAD
That's not quite true.  nullid refers to the work tree but
nullid2 refers to the index. So
  - if $diffidto eq $nullid the work tree needs to be
    compared against the index
  - if $diffidto eq $nullid2 the index needs to be compared
    against HEAD.
Show 24 quoted lines
> +      set diffidfrom "HEAD"
> +    } else {
> +      # use parent commit
> +      global allparents
> +      set diffidfrom $allparents($diffidto)
> +    }
> +  } else {
> +    set diffidfrom [lindex $diffids 0]
> +    set diffidto [lindex $diffids 1]
> +  }
> +
> +  if {! [info exists diffnum]} {
> +    set diffnum 0
> +  } else {
> +    set diffnum [expr $diffnum + 1]
> +  }
> +
> +
> +  set diffdir [file join $gitktmpdir "$diffnum"]
> +  set diffok "true"
> +
> +  file mkdir $diffdir
> +  if {$diffidto eq $nullid || $diffidto eq $nullid2} {
> +    set difftofile [file join $gitdir ".." $flist_menu_file]
This needs to be modified, too.
Show 14 quoted lines
> +  } {
> +    set difftofile [file join $diffdir "\[$diffidto\] [file tail  
> $flist_menu_file]"]
> +    if {[catch {exec git show $diffidto:$flist_menu_file >  
> $difftofile} err]} {
> +      error_popup "\"$flist_menu_file\" [mc "cannot be found in  
> revision"] $diffidto. [mc "File has probably been created, \
> +                  deleted or renamed, in a different commit."]"
> +      set diffok "false"
> +    }
> +  }
> +
> +  if {$diffidfrom == $nullid || $diffidfrom == $nullid2} {
> +    set difffromfile [file join $gitdir ".." $flist_menu_file]
ditto.
Show 31 quoted lines
> +  } else {
> +    set difffromfile [file join $diffdir "\[$diffidfrom\] [file  
> tail $flist_menu_file]"]
> +    if {[catch {exec git show $diffidfrom:$flist_menu_file >  
> $difffromfile} err]} {
> +      error_popup "\"$flist_menu_file\" [mc "cannot be found in  
> revision"] $diffidfrom. [mc "File has probably been created, \
> +                  deleted or renamed, in a different commit."]"
> +      set diffok "false"
> +    }
> +  }
> +
> +  if {$diffok} {
> +    # here we don't use shellquote because \ and everything must  
> be escaped and not enclosed between ''
> +    set quotedextdifftool \"[string map {\" \\\" \\ \\\\ \  \\\ }  
> $extdifftool]\"
> +    set cmd [concat | $quotedextdifftool [shellarglist [list  
> $difffromfile $difftofile]]]
> +    if {[catch {set fl [open $cmd]} err]} {
> +      file delete -force [ file join $gitktmpdir $diffnum ]
> +      error_popup [mc "$extdifftool command failed: $err"]
> +    } else {
> +      fconfigure $fl -blocking 0
> +      filerun $fl [list file delete -force [file join $gitktmpdir  
> $diffnum]]
> +    }
> +  }
> +}
> +
>
Show 34 quoted lines
>  # Functions for adding and removing shell-type quoting
>
>  proc shellquote {str} {
> @@ -7802,9 +7889,13 @@ proc showtag {tag isnew} {
>
>  proc doquit {} {
>      global stopped
> +    global gitktmpdir
> +
>      set stopped 100
>      savestuff .
>      destroy .
> +
> +    catch {file delete -force $gitktmpdir}
>  }
>
>  proc mkfontdisp {font top which} {
> @@ -7933,7 +8024,7 @@ proc doprefs {} {
>      global maxwidth maxgraphpct
>      global oldprefs prefstop showneartags showlocalchanges
>      global bgcolor fgcolor ctext diffcolors selectbgcolor
> -    global tabstop limitdiffs
> +    global tabstop limitdiffs extdifftool
>
>      set top .gitkprefs
>      set prefstop $top
> @@ -7980,6 +8071,11 @@ proc doprefs {} {
>      pack $top.ldiff.b $top.ldiff.l -side left
>      grid x $top.ldiff -sticky w
>
> +    entry $top.extdifft -textvariable extdifftool
> +    button $top.extdiffb -text [mc "External diff tool" ] -font  
> optionfont -command {set extdifftool [tk_getOpenFile -title  
> "External diff tool" -multiple "false"]}
Could you wrap the line using \
	Steffen
Previous: Thomas Arcila
Message 4 of 4 in “git gui diff widget (was Re: [msysGit] Re: [cheetah] Questions about NOTES)”
  1. Steffen ProhaskaJan 30, 2008
  2. Shawn O. PearceJan 30, 2008
  3. Thomas ArcilaJan 30, 2008
  4. Steffen ProhaskaJan 30, 2008

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.