Subject: Re: [PATCH v6] gitk: Use git-difftool for external diffs when available

From: David Aguilar <[email-masked]>
Date: Tue, 8 Jun 2010 01:10:42 -0700

Hello,

Is there anything else (besides sending this email) that I can
do to help move this patch along?

I got another "gitk read-only repo broken" email this week,
which is what reminded me... ;-)

It's been a while.  I just rebased the patch against the latest
master and it didn't have any conflicts.  Resend?

On Tue, Apr 20, 2010 at 01:11:19AM -0700, David Aguilar wrote:
> git-difftool's '--extcmd=frotz' was added in 1.7.0 and
> is the mechanism through which gitk launches the
> configured 'extdifftool'.  When 'extdifftool' is
> misconfigured an error dialog is used to display
> git-difftool's stdout and stderr.
> 
> The existing implementation moved into 'proc gitkextdiff'
> for use with git < 1.7.0.
> 
> One benefit of this change is that gitk's external diff
> no longer requires write-access to the current directory.
> 
> Signed-off-by: David Aguilar <[email-masked]>
> ---
> 
> Changes since last time:
> 
> * Errors are shown using 'proc error_popup'
> * The existing code moved into a tidy function
> 
>  gitk |   25 +++++++++++++++++++++++++
>  1 files changed, 25 insertions(+), 0 deletions(-)
> 
> diff --git a/gitk b/gitk
> index 1b0e09a..0533baf 100755
> --- a/gitk
> +++ b/gitk
> @@ -3361,6 +3361,7 @@ proc external_diff {} {
>      global flist_menu_file
>      global diffids
>      global extdifftool
> +    global git_version
>  
>      if {[llength $diffids] == 1} {
>          # no reference commit given
> @@ -3380,6 +3381,30 @@ proc external_diff {} {
>          set diffidfrom [lindex $diffids 0]
>          set diffidto [lindex $diffids 1]
>      }
> +    if {[package vcompare $git_version "1.7.0"] < 0} {
> +        gitkextdiff $diffidfrom $diffidto
> +        return
> +    }
> +
> +    set cmd [list "git" "difftool" "--no-prompt" "--extcmd=$extdifftool"]
> +    if {$diffidfrom ne $nullid && $diffidfrom ne $nullid2} {
> +        lappend cmd $diffidfrom
> +    }
> +    if {$diffidto ne $nullid && $diffidto ne $nullid2} {
> +        lappend cmd $diffidto
> +    }
> +    lappend cmd "--" $flist_menu_file
> +
> +    set pipe [open |$cmd r]
> +    set stdout [read $pipe]
> +    if {[catch {close $pipe} stderr] != 0} {
> +        error_popup "git-difftool: $stdout $stderr"
> +    }
> +}
> +
> +proc gitkextdiff {diffidfrom diffidto} {
> +    global flist_menu_file
> +    global extdifftool
>  
>      # make sure that several diffs wont collide
>      set diffdir [gitknewtmpdir]
> -- 
> 1.7.1.rc2.5.gddd02
> 

-- 
		David