[prev in list] [next in list] [prev in thread] [next in thread]
List: git
Subject: Re: [msysGit] Re: git gui diff widget (was Re: [msysGit] Re: [cheetah] Questions about NOTES)
From: Steffen Prohaska <prohaska () zib ! de>
Date: 2008-01-30 21:14:34
Message-ID: 71B7B7C0-BDB3-4E50-8EB5-E45C3F1224F9 () zib ! de
[Download RAW message or body]
On Jan 30, 2008, at 8:58 AM, Thomas Arcila wrote:
> 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 ...
> 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@mc.com>
> ---
> 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
[...]
> @@ -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.
> + 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.
> + } {
> + 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.
> + } 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]]
> + }
> + }
> +}
> +
>
> # 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
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic