X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gitk;h=f23fc161981359b51cf4da78222cf83bd70b02b2;hb=21ac8a8d0b8d95058e8fc7121ab7e653ab948c9e;hp=4d427e23c6c49d75adff01d2cf91f331892c857f;hpb=0cc08ff7ddaf4360966bdedf006af041cdf6f7d9;p=git.git diff --git a/gitk b/gitk index 4d427e23c..f23fc1619 100755 --- a/gitk +++ b/gitk @@ -2,7 +2,7 @@ # Tcl ignores the next line -*- tcl -*- \ exec wish "$0" -- "$@" -# Copyright © 2005-2008 Paul Mackerras. All rights reserved. +# Copyright © 2005-2009 Paul Mackerras. All rights reserved. # This program is free software; it may be used, copied, modified # and distributed under the terms of the GNU General Public Licence, # either version 2, or (at your option) any later version. @@ -130,7 +130,8 @@ proc unmerged_files {files} { } proc parseviewargs {n arglist} { - global vdatemode vmergeonly vflags vdflags vrevs vfiltered vorigargs + global vdatemode vmergeonly vflags vdflags vrevs vfiltered vorigargs env + global worddiff git_version set vdatemode($n) 0 set vmergeonly($n) 0 @@ -168,7 +169,7 @@ proc parseviewargs {n arglist} { lappend diffargs $arg } "--raw" - "--patch-with-raw" - "--patch-with-stat" - - "--name-only" - "--name-status" - "--color" - "--color-words" - + "--name-only" - "--name-status" - "--color" - "--log-size" - "--pretty=*" - "--decorate" - "--abbrev-commit" - "--cc" - "-z" - "--header" - "--parents" - "--boundary" - "--no-color" - "-g" - "--walk-reflogs" - "--no-walk" - @@ -177,6 +178,18 @@ proc parseviewargs {n arglist} { # These cause our parsing of git log's output to fail, or else # they're options we want to set ourselves, so ignore them. } + "--color-words*" - "--word-diff=color" { + # These trigger a word diff in the console interface, + # so help the user by enabling our own support + if {[package vcompare $git_version "1.7.2"] >= 0} { + set worddiff [mc "Color words"] + } + } + "--word-diff*" { + if {[package vcompare $git_version "1.7.2"] >= 0} { + set worddiff [mc "Markup words"] + } + } "--stat=*" - "--numstat" - "--shortstat" - "--summary" - "--check" - "--exit-code" - "--quiet" - "--topo-order" - "--full-history" - "--dense" - "--sparse" - @@ -210,6 +223,9 @@ proc parseviewargs {n arglist} { # git rev-parse doesn't understand --merge lappend revargs --gitk-symmetric-diff-marker MERGE_HEAD...HEAD } + "--no-replace-objects" { + set env(GIT_NO_REPLACE_OBJECTS) "1" + } "-*" { # Other flag arguments including - if {[string is digit -strict [string range $arg 1 end]]} { @@ -310,6 +326,7 @@ proc start_rev_list {view} { global viewactive viewinstances vmergeonly global mainheadid viewmainheadid viewmainheadid_orig global vcanopt vflags vrevs vorigargs + global show_notes set startmsecs [clock clicks -milliseconds] set commitidx($view) 0 @@ -358,8 +375,8 @@ proc start_rev_list {view} { } if {[catch { - set fd [open [concat | git log --no-color -z --pretty=raw --parents \ - --boundary $args "--" $files] r] + set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \ + --parents --boundary $args "--" $files] r] } err]} { error_popup "[mc "Error executing git log:"] $err" return 0 @@ -453,6 +470,7 @@ proc updatecommits {} { global mainheadid viewmainheadid viewmainheadid_orig pending_select global isworktree global varcid vposids vnegids vflags vrevs + global show_notes set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == "true"}] rereadrefs @@ -505,8 +523,8 @@ proc updatecommits {} { set args $vorigargs($view) } if {[catch { - set fd [open [concat | git log --no-color -z --pretty=raw --parents \ - --boundary $args "--" $vfilelimit($view)] r] + set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \ + --parents --boundary $args "--" $vfilelimit($view)] r] } err]} { error_popup "[mc "Error executing git log:"] $err" return @@ -989,6 +1007,18 @@ proc removefakerow {id} { drawvisible } +proc real_children {vp} { + global children nullid nullid2 + + set kids {} + foreach id $children($vp) { + if {$id ne $nullid && $id ne $nullid2} { + lappend kids $id + } + } + return $kids +} + proc first_real_child {vp} { global children nullid nullid2 @@ -1798,13 +1828,13 @@ proc make_transient {window origin} { } } -proc show_error {w top msg} { +proc show_error {w top msg {mc mc}} { global NS if {![info exists NS]} {set NS ""} if {[wm state $top] eq "withdrawn"} { wm deiconify $top } message $w.m -text $msg -justify center -aspect 400 pack $w.m -side top -fill x -padx 20 -pady 20 - ${NS}::button $w.ok -default active -text [mc OK] -command "destroy $top" + ${NS}::button $w.ok -default active -text [$mc OK] -command "destroy $top" pack $w.ok -side bottom -fill x bind $top "grab $top; focus $top" bind $top "destroy $top" @@ -1862,8 +1892,11 @@ proc setoptions {} { option add *Menubutton.font uifont startupFile option add *Label.font uifont startupFile option add *Message.font uifont startupFile - option add *Entry.font uifont startupFile + option add *Entry.font textfont startupFile + option add *Text.font textfont startupFile option add *Labelframe.font uifont startupFile + option add *Spinbox.font textfont startupFile + option add *Listbox.font mainfont startupFile } # Make a menu and submenus. @@ -1952,6 +1985,8 @@ proc makewindow {} { global fprogitem fprogcoord lastprogupdate progupdatepending global rprogitem rprogcoord rownumsel numcommits global have_tk85 use_ttk NS + global git_version + global worddiff # The "mc" arguments here are purely so that xgettext # sees the following string as needing to be translated @@ -2073,7 +2108,7 @@ proc makewindow {} { set sha1entry .tf.bar.sha1 set entries $sha1entry set sha1but .tf.bar.sha1label - button $sha1but -text [mc "SHA1 ID: "] -state disabled -relief flat \ + button $sha1but -text "[mc "SHA1 ID:"] " -state disabled -relief flat \ -command gotocommit -width 8 $sha1but conf -disabledforeground [$sha1but cget -foreground] pack .tf.bar.sha1label -side left @@ -2159,7 +2194,7 @@ proc makewindow {} { set findstring {} set fstring .tf.lbar.findstring lappend entries $fstring - ${NS}::entry $fstring -width 30 -font textfont -textvariable findstring + ${NS}::entry $fstring -width 30 -textvariable findstring trace add variable findstring write find_change set findtype [mc "Exact"] set findtypemenu [makedroplist .tf.lbar.findtype \ @@ -2202,7 +2237,7 @@ proc makewindow {} { pack .bleft.top.search -side left -padx 5 set sstring .bleft.top.sstring set searchstring "" - ${NS}::entry $sstring -width 20 -font textfont -textvariable searchstring + ${NS}::entry $sstring -width 20 -textvariable searchstring lappend entries $sstring trace add variable searchstring write incrsearch pack $sstring -side left -expand 1 -fill x @@ -2214,7 +2249,7 @@ proc makewindow {} { -command changediffdisp -variable diffelide -value {1 0} ${NS}::label .bleft.mid.labeldiffcontext -text " [mc "Lines of context"]: " pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left - spinbox .bleft.mid.diffcontext -width 5 -font textfont \ + spinbox .bleft.mid.diffcontext -width 5 \ -from 0 -increment 1 -to 10000000 \ -validate all -validatecommand "diffcontextvalidate %P" \ -textvariable diffcontextstring @@ -2225,6 +2260,15 @@ proc makewindow {} { ${NS}::checkbutton .bleft.mid.ignspace -text [mc "Ignore space change"] \ -command changeignorespace -variable ignorespace pack .bleft.mid.ignspace -side left -padx 5 + + set worddiff [mc "Line diff"] + if {[package vcompare $git_version "1.7.2"] >= 0} { + makedroplist .bleft.mid.worddiff worddiff [mc "Line diff"] \ + [mc "Markup words"] [mc "Color words"] + trace add variable worddiff write changeworddiff + pack .bleft.mid.worddiff -side left -padx 5 + } + set ctext .bleft.bottom.ctext text $ctext -background $bgcolor -foreground $fgcolor \ -state disabled -font textfont \ @@ -2368,6 +2412,8 @@ proc makewindow {} { } bindall <$::BM> "canvscan mark %W %x %y" bindall "canvscan dragto %W %x %y" + bind all <$M1B-Key-w> {destroy [winfo toplevel %W]} + bind . <$M1B-Key-w> doquit bindkey selfirstline bindkey sellastline bind . "selnextline -1" @@ -2431,6 +2477,7 @@ proc makewindow {} { global ctxbut bind $cflist $ctxbut {pop_flist_menu %W %X %Y %x %y} bind $ctext $ctxbut {pop_diff_menu %W %X %Y %x %y} + bind $ctext {focus %W} set maincursor [. cget -cursor] set textcursor [$ctext cget -cursor] @@ -2604,13 +2651,14 @@ proc savestuff {w} { global maxwidth showneartags showlocalchanges global viewname viewfiles viewargs viewargscmd viewperm nextviewnum global cmitmode wrapcomment datetimeformat limitdiffs - global colors bgcolor fgcolor diffcolors diffcontext selectbgcolor - global autoselect extdifftool perfile_attrs markbgcolor use_ttk + global colors uicolor bgcolor fgcolor diffcolors diffcontext selectbgcolor + global autoselect autosellen extdifftool perfile_attrs markbgcolor use_ttk global hideremotes want_ttk if {$stuffsaved} return if {![winfo viewable .]} return catch { + if {[file exists ~/.gitk-new]} {file delete -force ~/.gitk-new} set f [open "~/.gitk-new" w] if {$::tcl_platform(platform) eq {windows}} { file attributes "~/.gitk-new" -hidden true @@ -2625,11 +2673,13 @@ proc savestuff {w} { puts $f [list set cmitmode $cmitmode] puts $f [list set wrapcomment $wrapcomment] puts $f [list set autoselect $autoselect] + puts $f [list set autosellen $autosellen] puts $f [list set showneartags $showneartags] puts $f [list set hideremotes $hideremotes] puts $f [list set showlocalchanges $showlocalchanges] puts $f [list set datetimeformat $datetimeformat] puts $f [list set limitdiffs $limitdiffs] + puts $f [list set uicolor $uicolor] puts $f [list set want_ttk $want_ttk] puts $f [list set bgcolor $bgcolor] puts $f [list set fgcolor $fgcolor] @@ -2765,7 +2815,7 @@ proc about {} { message $w.m -text [mc " Gitk - a commit viewer for git -Copyright \u00a9 2005-2009 Paul Mackerras +Copyright \u00a9 2005-2010 Paul Mackerras Use and redistribute under the terms of the GNU General Public License"] \ -justify center -aspect 400 -border 2 -bg white -relief groove @@ -2797,6 +2847,7 @@ proc keys {} { [mc "Gitk key bindings:"] [mc "<%s-Q> Quit" $M1T] +[mc "<%s-W> Close window" $M1T] [mc " Move to first commit"] [mc " Move to last commit"] [mc ", p, i Move up one commit"] @@ -3278,6 +3329,28 @@ proc flist_hl {only} { set gdttype [mc "touching paths:"] } +proc gitknewtmpdir {} { + global diffnum gitktmpdir gitdir + + if {![info exists gitktmpdir]} { + set gitktmpdir [file join [file dirname $gitdir] \ + [format ".gitk-tmp.%s" [pid]]] + if {[catch {file mkdir $gitktmpdir} err]} { + error_popup "[mc "Error creating temporary directory %s:" $gitktmpdir] $err" + unset gitktmpdir + return {} + } + set diffnum 0 + } + incr diffnum + set diffdir [file join $gitktmpdir $diffnum] + if {[catch {file mkdir $diffdir} err]} { + error_popup "[mc "Error creating temporary directory %s:" $diffdir] $err" + return {} + } + return $diffdir +} + proc save_file_from_commit {filename output what} { global nullfile @@ -3312,11 +3385,10 @@ proc external_diff_get_one_file {diffid filename diffdir} { } proc external_diff {} { - global gitktmpdir nullid nullid2 + global nullid nullid2 global flist_menu_file global diffids - global diffnum - global gitdir extdifftool + global extdifftool if {[llength $diffids] == 1} { # no reference commit given @@ -3338,22 +3410,8 @@ proc external_diff {} { } # make sure that several diffs wont collide - if {![info exists gitktmpdir]} { - set gitktmpdir [file join [file dirname $gitdir] \ - [format ".gitk-tmp.%s" [pid]]] - if {[catch {file mkdir $gitktmpdir} err]} { - error_popup "[mc "Error creating temporary directory %s:" $gitktmpdir] $err" - unset gitktmpdir - return - } - set diffnum 0 - } - incr diffnum - set diffdir [file join $gitktmpdir $diffnum] - if {[catch {file mkdir $diffdir} err]} { - error_popup "[mc "Error creating temporary directory %s:" $diffdir] $err" - return - } + set diffdir [gitknewtmpdir] + if {$diffdir eq {}} return # gather files to diff set difffromfile [external_diff_get_one_file $diffidfrom $flist_menu_file $diffdir] @@ -3480,6 +3538,9 @@ proc index_sha1 {fname} { # Turn an absolute path into one relative to the current directory proc make_relative {f} { + if {[file pathtype $f] eq "relative"} { + return $f + } set elts [file split $f] set here [file split [pwd]] set ei 0 @@ -3778,10 +3839,10 @@ proc newview {ishighlight} { raise $top return } + decode_view_opts $nextviewnum $revtreeargs set newviewname($nextviewnum) "[mc "View"] $nextviewnum" set newviewopts($nextviewnum,perm) 0 set newviewopts($nextviewnum,cmd) $viewargscmd($curview) - decode_view_opts $nextviewnum $revtreeargs vieweditor $top $nextviewnum [mc "Gitk view definition"] } @@ -3818,6 +3879,7 @@ set known_view_options { {cmd t50= + {} {mc "Command to generate more commits to include:"}} } +# Convert $newviewopts($n, ...) into args for git log. proc encode_view_opts {n} { global known_view_options newviewopts @@ -3851,6 +3913,7 @@ proc encode_view_opts {n} { return [concat $rargs [shellsplit $newviewopts($n,args)]] } +# Fill $newviewopts($n, ...) based on args for git log. proc decode_view_opts {n view_args} { global known_view_options newviewopts @@ -3933,10 +3996,10 @@ proc editview {} { raise $top return } + decode_view_opts $curview $viewargs($curview) set newviewname($curview) $viewname($curview) set newviewopts($curview,perm) $viewperm($curview) set newviewopts($curview,cmd) $viewargscmd($curview) - decode_view_opts $curview $viewargs($curview) vieweditor $top $curview "[mc "Gitk: edit view"] $viewname($curview)" } @@ -4010,7 +4073,7 @@ proc vieweditor {top n title} { } elseif {$type eq "path"} { ${NS}::label $top.l -text $title pack $top.l -in $top -side top -pady [list 3 0] -anchor w -padx 3 - text $top.t -width 40 -height 5 -background $bgcolor -font uifont + text $top.t -width 40 -height 5 -background $bgcolor if {[info exists viewfiles($n)]} { foreach f $viewfiles($n) { $top.t insert end $f @@ -6834,7 +6897,7 @@ proc selectline {l isnew {desired_loc {}}} { global mergemax numcommits pending_select global cmitmode showneartags allcommits global targetrow targetid lastscrollrows - global autoselect jump_to_here + global autoselect autosellen jump_to_here catch {unset pending_select} $canv delete hover @@ -6896,7 +6959,7 @@ proc selectline {l isnew {desired_loc {}}} { $sha1entry delete 0 end $sha1entry insert 0 $id if {$autoselect} { - $sha1entry selection range 0 end + $sha1entry selection range 0 $autosellen } rhighlight_sel $id @@ -7266,6 +7329,7 @@ proc getblobline {bf id} { [lindex [split $commentend .] 0]}] mark_ctext_line $lnum } + $ctext config -state disabled return 0 } $ctext config -state disabled @@ -7361,7 +7425,7 @@ proc diffcmd {ids flags} { set cmd [concat | git diff-index --cached $flags] if {[llength $ids] > 1} { # comparing index with specific revision - if {$i == 0} { + if {$j == 0} { lappend cmd -R [lindex $ids 1] } else { lappend cmd [lindex $ids 0] @@ -7467,23 +7531,35 @@ proc changeignorespace {} { reselectline } +proc changeworddiff {name ix op} { + reselectline +} + proc getblobdiffs {ids} { global blobdifffd diffids env global diffinhdr treediffs global diffcontext global ignorespace + global worddiff global limitdiffs vfilelimit curview global diffencoding targetline diffnparents - global git_version + global git_version currdiffsubmod set textconv {} if {[package vcompare $git_version "1.6.1"] >= 0} { set textconv "--textconv" } - set cmd [diffcmd $ids "-p $textconv -C --cc --no-commit-id -U$diffcontext"] + set submodule {} + if {[package vcompare $git_version "1.6.6"] >= 0} { + set submodule "--submodule" + } + set cmd [diffcmd $ids "-p $textconv $submodule -C --cc --no-commit-id -U$diffcontext"] if {$ignorespace} { append cmd " -w" } + if {$worddiff ne [mc "Line diff"]} { + append cmd " --word-diff=porcelain" + } if {$limitdiffs && $vfilelimit($curview) ne {}} { set cmd [concat $cmd -- $vfilelimit($curview)] } @@ -7497,6 +7573,7 @@ proc getblobdiffs {ids} { set diffencoding [get_path_encoding {}] fconfigure $bdf -blocking 0 -encoding binary -eofchar {} set blobdifffd($ids) $bdf + set currdiffsubmod "" filerun $bdf [list getblobdiffline $bdf $diffids] } @@ -7567,13 +7644,14 @@ proc getblobdiffline {bdf ids} { global diffnexthead diffnextnote difffilestart global ctext_file_names ctext_file_lines global diffinhdr treediffs mergemax diffnparents - global diffencoding jump_to_here targetline diffline + global diffencoding jump_to_here targetline diffline currdiffsubmod + global worddiff set nr 0 $ctext conf -state normal while {[incr nr] <= 1000 && [gets $bdf line] >= 0} { if {$ids != $diffids || $bdf != $blobdifffd($ids)} { - close $bdf + catch {close $bdf} return 0 } if {![string compare -length 5 "diff " $line]} { @@ -7646,6 +7724,34 @@ proc getblobdiffline {bdf ids} { set diffnparents [expr {[string length $ats] - 1}] set diffinhdr 0 + } elseif {![string compare -length 10 "Submodule " $line]} { + # start of a new submodule + if {[regexp -indices "\[0-9a-f\]+\\.\\." $line nameend]} { + set fname [string range $line 10 [expr [lindex $nameend 0] - 2]] + } else { + set fname [string range $line 10 [expr [string first "contains " $line] - 2]] + } + if {$currdiffsubmod != $fname} { + $ctext insert end "\n"; # Add newline after commit message + } + set curdiffstart [$ctext index "end - 1c"] + lappend ctext_file_names "" + if {$currdiffsubmod != $fname} { + lappend ctext_file_lines $fname + makediffhdr $fname $ids + set currdiffsubmod $fname + $ctext insert end "\n$line\n" filesep + } else { + $ctext insert end "$line\n" filesep + } + } elseif {![string compare -length 3 " >" $line]} { + set $currdiffsubmod "" + set line [encoding convertfrom $diffencoding $line] + $ctext insert end "$line\n" dresult + } elseif {![string compare -length 3 " <" $line]} { + set $currdiffsubmod "" + set line [encoding convertfrom $diffencoding $line] + $ctext insert end "$line\n" d0 } elseif {$diffinhdr} { if {![string compare -length 12 "rename from " $line]} { set fname [string range $line [expr 6 + [string first " from " $line] ] end] @@ -7679,15 +7785,28 @@ proc getblobdiffline {bdf ids} { # parse the prefix - one ' ', '-' or '+' for each parent set prefix [string range $line 0 [expr {$diffnparents - 1}]] set tag [expr {$diffnparents > 1? "m": "d"}] + set dowords [expr {$worddiff ne [mc "Line diff"] && $diffnparents == 1}] + set words_pre_markup "" + set words_post_markup "" if {[string trim $prefix " -+"] eq {}} { # prefix only has " ", "-" and "+" in it: normal diff line set num [string first "-" $prefix] + if {$dowords} { + set line [string range $line 1 end] + } if {$num >= 0} { # removed line, first parent with line is $num if {$num >= $mergemax} { set num "max" } - $ctext insert end "$line\n" $tag$num + if {$dowords && $worddiff eq [mc "Markup words"]} { + $ctext insert end "\[-$line-\]" $tag$num + } else { + $ctext insert end "$line" $tag$num + } + if {!$dowords} { + $ctext insert end "\n" $tag$num + } } else { set tags {} if {[string first "+" $prefix] >= 0} { @@ -7702,6 +7821,8 @@ proc getblobdiffline {bdf ids} { lappend tags m$num } } + set words_pre_markup "{+" + set words_post_markup "+}" } if {$targetline ne {}} { if {$diffline == $targetline} { @@ -7711,8 +7832,17 @@ proc getblobdiffline {bdf ids} { incr diffline } } - $ctext insert end "$line\n" $tags + if {$dowords && $worddiff eq [mc "Markup words"]} { + $ctext insert end "$words_pre_markup$line$words_post_markup" $tags + } else { + $ctext insert end "$line" $tags + } + if {!$dowords} { + $ctext insert end "\n" $tags + } } + } elseif {$dowords && $prefix eq "~"} { + $ctext insert end "\n" {} } else { # "\ No newline at end of file", # or something else we don't recognize @@ -7726,7 +7856,7 @@ proc getblobdiffline {bdf ids} { maybe_scroll_ctext [eof $bdf] $ctext conf -state disabled if {[eof $bdf]} { - close $bdf + catch {close $bdf} return 0 } return [expr {$nr >= 1000? 2: 1}] @@ -8448,33 +8578,62 @@ proc do_cmp_commits {a b} { appendshortlink $a [mc "Commit "] " $heada\n" appendshortlink $b [mc " differs from\n "] \ " $headb\n" - $ctext insert end [mc "- stopping\n"] - break + $ctext insert end [mc "Diff of commits:\n\n"] + $ctext conf -state disabled + update + diffcommits $a $b + return } } if {$skipa} { - if {[llength $children($curview,$a)] != 1} { + set kids [real_children $curview,$a] + if {[llength $kids] != 1} { $ctext insert end "\n" appendshortlink $a [mc "Commit "] \ - [mc " has %s children - stopping\n" \ - [llength $children($curview,$a)]] + [mc " has %s children - stopping\n" [llength $kids]] break } - set a [lindex $children($curview,$a) 0] + set a [lindex $kids 0] } if {$skipb} { - if {[llength $children($curview,$b)] != 1} { + set kids [real_children $curview,$b] + if {[llength $kids] != 1} { appendshortlink $b [mc "Commit "] \ - [mc " has %s children - stopping\n" \ - [llength $children($curview,$b)]] + [mc " has %s children - stopping\n" [llength $kids]] break } - set b [lindex $children($curview,$b) 0] + set b [lindex $kids 0] } } $ctext conf -state disabled } +proc diffcommits {a b} { + global diffcontext diffids blobdifffd diffinhdr currdiffsubmod + + set tmpdir [gitknewtmpdir] + set fna [file join $tmpdir "commit-[string range $a 0 7]"] + set fnb [file join $tmpdir "commit-[string range $b 0 7]"] + if {[catch { + exec git diff-tree -p --pretty $a >$fna + exec git diff-tree -p --pretty $b >$fnb + } err]} { + error_popup [mc "Error writing commit to file: %s" $err] + return + } + if {[catch { + set fd [open "| diff -U$diffcontext $fna $fnb" r] + } err]} { + error_popup [mc "Error diffing commits: %s" $err] + return + } + set diffids [list commits $a $b] + set blobdifffd($diffids) $fd + set diffinhdr 0 + set currdiffsubmod "" + filerun $fd [list getblobdiffline $fd $diffids] +} + proc diffvssel {dirn} { global rowmenuid selectedline @@ -8627,6 +8786,11 @@ proc mktag {} { ${NS}::label $top.tlab -text [mc "Tag name:"] ${NS}::entry $top.tag -width 60 grid $top.tlab $top.tag -sticky w + ${NS}::label $top.op -text [mc "Tag message is optional"] + grid $top.op -columnspan 2 -sticky we + ${NS}::label $top.mlab -text [mc "Tag message:"] + ${NS}::entry $top.msg -width 60 + grid $top.mlab $top.msg -sticky w ${NS}::frame $top.buts ${NS}::button $top.buts.gen -text [mc "Create"] -command mktaggo ${NS}::button $top.buts.can -text [mc "Cancel"] -command mktagcan @@ -8644,6 +8808,7 @@ proc domktag {} { set id [$mktagtop.sha1 get] set tag [$mktagtop.tag get] + set msg [$mktagtop.msg get] if {$tag == {}} { error_popup [mc "No tag name specified"] $mktagtop return 0 @@ -8653,7 +8818,11 @@ proc domktag {} { return 0 } if {[catch { - exec git tag $tag $id + if {$msg != {}} { + exec git tag -a -m $msg $tag $id + } else { + exec git tag $tag $id + } } err]} { error_popup "[mc "Error creating tag:"] $err" $mktagtop return 0 @@ -9013,6 +9182,9 @@ proc headmenu {x y id head} { set headmenuid $id set headmenuhead $head set state normal + if {[string match "remotes/*" $head]} { + set state disabled + } if {$head eq $mainhead} { set state disabled } @@ -10406,7 +10578,7 @@ proc showtag {tag isnew} { set linknum 0 if {![info exists tagcontents($tag)]} { catch { - set tagcontents($tag) [exec git cat-file tag $tagobjid($tag)] + set tagcontents($tag) [exec git cat-file tag $tag] } } if {[info exists tagcontents($tag)]} { @@ -10415,7 +10587,7 @@ proc showtag {tag isnew} { set text "[mc "Tag"]: $tag\n[mc "Id"]: $tagids($tag)" } appendwithlinks $text {} - maybe_scroll_ctext + maybe_scroll_ctext 1 $ctext conf -state disabled init_flist {} } @@ -10439,7 +10611,6 @@ proc mkfontdisp {font top which} { set fontpref($font) [set $font] ${NS}::button $top.${font}but -text $which \ -command [list choosefont $font $which] - if {!$use_ttk} {$top.${font}but configure -font optionfont} ${NS}::label $top.$font -relief flat -font $font \ -text $fontattr($font,family) -justify left grid x $top.${font}but $top.$font -sticky w @@ -10585,8 +10756,8 @@ proc chg_fontparam {v sub op} { proc doprefs {} { global maxwidth maxgraphpct use_ttk NS global oldprefs prefstop showneartags showlocalchanges - global bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor - global tabstop limitdiffs autoselect extdifftool perfile_attrs + global uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor + global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs global hideremotes want_ttk have_ttk set top .gitkprefs @@ -10614,9 +10785,10 @@ proc doprefs {} { ${NS}::checkbutton $top.showlocal -text [mc "Show local changes"] \ -variable showlocalchanges grid x $top.showlocal -sticky w - ${NS}::checkbutton $top.autoselect -text [mc "Auto-select SHA1"] \ + ${NS}::checkbutton $top.autoselect -text [mc "Auto-select SHA1 (length)"] \ -variable autoselect - grid x $top.autoselect -sticky w + spinbox $top.autosellen -from 1 -to 40 -width 4 -textvariable autosellen + grid x $top.autoselect $top.autosellen -sticky w ${NS}::checkbutton $top.hideremotes -text [mc "Hide remote refs"] \ -variable hideremotes grid x $top.hideremotes -sticky w @@ -10657,6 +10829,10 @@ proc doprefs {} { ${NS}::label $top.cdisp -text [mc "Colors: press to choose"] grid $top.cdisp - -sticky w -pady 10 + label $top.ui -padx 40 -relief sunk -background $uicolor + ${NS}::button $top.uibut -text [mc "Interface"] \ + -command [list choosecolor uicolor {} $top.ui [mc "interface"] setui] + grid x $top.uibut $top.ui -sticky w label $top.bg -padx 40 -relief sunk -background $bgcolor ${NS}::button $top.bgbut -text [mc "Background"] \ -command [list choosecolor bgcolor {} $top.bg [mc "background"] setbg] @@ -10698,15 +10874,6 @@ proc doprefs {} { mkfontdisp textfont $top [mc "Diff display font"] mkfontdisp uifont $top [mc "User interface font"] - if {!$use_ttk} { - foreach w {maxpctl maxwidthl showlocal autoselect tabstopl ntag - ldiff lattr extdifff.l extdifff.b bgbut fgbut - diffoldbut diffnewbut hunksepbut markbgbut selbgbut - want_ttk ttk_note} { - $top.$w configure -font optionfont - } - } - ${NS}::frame $top.buts ${NS}::button $top.buts.ok -text [mc "OK"] -command prefsok -default active ${NS}::button $top.buts.can -text [mc "Cancel"] -command prefscan -default normal @@ -10750,6 +10917,21 @@ proc setselbg {c} { allcanvs itemconf secsel -fill $c } +# This sets the background color and the color scheme for the whole UI. +# For some reason, tk_setPalette chooses a nasty dark red for selectColor +# if we don't specify one ourselves, which makes the checkbuttons and +# radiobuttons look bad. This chooses white for selectColor if the +# background color is light, or black if it is dark. +proc setui {c} { + if {[tk windowingsystem] eq "win32"} { return } + set bg [winfo rgb . $c] + set selc black + if {[lindex $bg 0] + 1.5 * [lindex $bg 1] + 0.5 * [lindex $bg 2] > 100000} { + set selc white + } + tk_setPalette background $c selectColor $selc +} + proc setbg {c} { global bglist @@ -11184,8 +11366,8 @@ proc get_path_encoding {path} { # First check that Tcl/Tk is recent enough if {[catch {package require Tk 8.4} err]} { - show_error {} . [mc "Sorry, gitk cannot run with this version of Tcl/Tk.\n\ - Gitk requires at least Tcl/Tk 8.4."] + show_error {} . "Sorry, gitk cannot run with this version of Tcl/Tk.\n\ + Gitk requires at least Tcl/Tk 8.4." list exit 1 } @@ -11248,6 +11430,7 @@ set showlocalchanges 1 set limitdiffs 1 set datetimeformat "%Y-%m-%d %H:%M:%S" set autoselect 1 +set autosellen 40 set perfile_attrs 0 set want_ttk 1 @@ -11258,12 +11441,21 @@ if {[tk windowingsystem] eq "aqua"} { } set colors {green red blue magenta darkgrey brown orange} -set bgcolor white -set fgcolor black +if {[tk windowingsystem] eq "win32"} { + set uicolor SystemButtonFace + set bgcolor SystemWindow + set fgcolor SystemButtonText + set selectbgcolor SystemHighlight +} else { + set uicolor grey85 + set bgcolor white + set fgcolor black + set selectbgcolor gray85 +} set diffcolors {red "#00a000" blue} set diffcontext 3 set ignorespace 0 -set selectbgcolor gray85 +set worddiff "" set markbgcolor "#e0e0ff" set circlecolors {white blue gray blue blue} @@ -11296,8 +11488,6 @@ namespace import ::msgcat::mc catch {source ~/.gitk} -font create optionfont -family sans-serif -size -12 - parsefont mainfont $mainfont eval font create mainfont [fontflags mainfont] eval font create mainfontbold [fontflags mainfont 1] @@ -11309,6 +11499,8 @@ eval font create textfontbold [fontflags textfont 1] parsefont uifont $uifont eval font create uifont [fontflags uifont] +setui $uicolor + setoptions # check that we can find a .git directory somewhere... @@ -11392,7 +11584,12 @@ if {![info exists have_ttk]} { set use_ttk [expr {$have_ttk && $want_ttk}] set NS [expr {$use_ttk ? "ttk" : ""}] -set git_version [join [lrange [split [lindex [exec git version] end] .] 0 2] .] +regexp {^git version ([\d.]*\d)} [exec git version] _ git_version + +set show_notes {} +if {[package vcompare $git_version "1.6.6.2"] >= 0} { + set show_notes "--show-notes" +} set runq {} set history {} @@ -11496,3 +11693,9 @@ if {[tk windowingsystem] eq "win32"} { } getcommits {} + +# Local variables: +# mode: tcl +# indent-tabs-mode: t +# tab-width: 8 +# End: