>From 3f85abb6c3b411db0936a706df1acf077e88bf87 Mon Sep 17 00:00:00 2001 From: Pierre Marc Dumuid <pierre.dumuid@xxxxxxxxxxxxxxx> Date: Mon, 10 Sep 2007 10:53:47 +0930 Subject: [PATCH] Addition of a GUI compare button This commit adds a button to gitk to easily look at diffs between a commit and its first parent. It uses the GUI tool selected in merge.tool to visualize the diff, erroring out if none was specified. TO FIX: * When the "tree" view is selected, the files in subdirectories don't work. * The ability to flag what are files and what aren't in the file list. (i.e. 'Comments') * There is little differentation between the 'Not committed but checked in" and 'Not committed and not checked in". * Removing of temporary files. (ideas: use the 'after' tcl command) Signed-off-by: Pierre Marc Dumuid <pierre.dumuid@xxxxxxxxxxxxxxx> --- gitk | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 62 insertions(+), 1 deletions(-) diff --git a/gitk b/gitk index 300fdce..4eaf0b9 100755 --- a/gitk +++ b/gitk @@ -737,7 +737,9 @@ proc makewindow {} { -command changediffdisp -variable diffelide -value {1 0} label .bleft.mid.labeldiffcontext -text " Lines of context: " \ -font $uifont - pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left + button .bleft.top.guidiff -text "GUI diff" -command doguidiff \ + -font $uifont + pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new .bleft.top.guidiff -side left spinbox .bleft.mid.diffcontext -width 5 -font $textfont \ -from 1 -increment 1 -to 10000000 \ -validate all -validatecommand "diffcontextvalidate %P" \ @@ -5332,6 +5334,65 @@ proc incrsearch {name ix op} { } } +proc doguidiff {} { + global cflist sha1string + + set taglist [$cflist tag ranges highlight] + set from [lindex $taglist 0] + set to [lindex $taglist 1] + + set fname [$cflist get $from $to] + + if {[catch {set merge_tool [exec git-config merge.tool]} err]} { + error_popup "Sorry, 'merge.tool' not defined in git-config" + return + } + + if {$sha1string eq "0000000000000000000000000000000000000000" + || $sha1string eq "0000000000000000000000000000000000000001" + } { + if {[catch {exec git cat-file -p HEAD:$fname > .gitk_diffolder} err]} { + error_popup "Invalid file, '$fname' selected for comparison" + return + } + set olderfile ".gitk_diffolder" + set newerfile $fname + set oldertitle "(Older)" + set newertitle "(Uncommitted)" + } else { + if {[catch {exec git cat-file -p $sha1string^:$fname > .gitk_diffolder} err] + || [catch {exec git cat-file -p $sha1string:$fname > .gitk_diffnewer} err] } { + error_popup "Invalid file, '$fname' selected for comparison." + return + } + set olderfile ".gitk_diffolder" + set newerfile ".gitk_diffnewer" + set oldertitle "(Older)" + set newertitle "(Newer)" + } + + switch -regexp $merge_tool { + "kdiff3" { + exec kdiff3 --L1 "$fname $oldertitle" --L2 "$fname $newertitle" $olderfile $newerfile & + } + "meld|opendiff|vimdiff|xxdiff" { + exec $merge_tool $olderfile $newerfile & + } + "tkdiff" { + exec $merge_tool -L "$fname $oldertitle" -L "$fname $newertitle" $olderfile $newerfile & + } + "vimdiff" { + exec $merge_tool $olderfile $newerfile + } + "emerge" { + exec emacs -f emerge-files-command $olderfile $newerfile & + } + default { + show_error {} "No merge.tool defined." + } + } +} + proc dosearch {} { global sstring ctext searchstring searchdirn -- 1.5.2.4 - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html