diff options
Diffstat (limited to 'gitk-git/gitk')
-rwxr-xr-x | gitk-git/gitk | 218 |
1 files changed, 137 insertions, 81 deletions
diff --git a/gitk-git/gitk b/gitk-git/gitk index 3520bdaebc..9a2daf3c55 100755 --- a/gitk-git/gitk +++ b/gitk-git/gitk @@ -294,6 +294,8 @@ proc parseviewrevs {view revs} { if {$revs eq {}} { set revs HEAD + } elseif {[lsearch -exact $revs --all] >= 0} { + lappend revs HEAD } if {[catch {set ids [eval exec git rev-parse $revs]} err]} { # we get stdout followed by stderr in $err @@ -445,7 +447,7 @@ proc stop_instance {inst} { set pid [pid $fd] if {$::tcl_platform(platform) eq {windows}} { - exec kill -f $pid + exec taskkill /pid $pid } else { exec kill $pid } @@ -2514,6 +2516,13 @@ proc makewindow {} { } else { bindall <ButtonRelease-4> "allcanvs yview scroll -5 units" bindall <ButtonRelease-5> "allcanvs yview scroll 5 units" + bind $ctext <Button> { + if {"%b" eq 6} { + $ctext xview scroll -5 units + } elseif {"%b" eq 7} { + $ctext xview scroll 5 units + } + } if {[tk windowingsystem] eq "aqua"} { bindall <MouseWheel> { set delta [expr {- (%D)}] @@ -2774,94 +2783,87 @@ proc doprogupdate {} { } } +proc config_check_tmp_exists {tries_left} { + global config_file_tmp + + if {[file exists $config_file_tmp]} { + incr tries_left -1 + if {$tries_left > 0} { + after 100 [list config_check_tmp_exists $tries_left] + } else { + error_popup "There appears to be a stale $config_file_tmp\ + file, which will prevent gitk from saving its configuration on exit.\ + Please remove it if it is not being used by any existing gitk process." + } + } +} + +proc config_init_trace {name} { + global config_variable_changed config_variable_original + + upvar #0 $name var + set config_variable_changed($name) 0 + set config_variable_original($name) $var +} + +proc config_variable_change_cb {name name2 op} { + global config_variable_changed config_variable_original + + upvar #0 $name var + if {$op eq "write" && + (![info exists config_variable_original($name)] || + $config_variable_original($name) ne $var)} { + set config_variable_changed($name) 1 + } +} + proc savestuff {w} { - global canv canv2 canv3 mainfont textfont uifont tabstop - global stuffsaved findmergefiles maxgraphpct - global maxwidth showneartags showlocalchanges - global viewname viewfiles viewargs viewargscmd viewperm nextviewnum - global cmitmode wrapcomment datetimeformat limitdiffs - global colors uicolor bgcolor fgcolor diffcolors diffcontext selectbgcolor - global uifgcolor uifgdisabledcolor - global headbgcolor headfgcolor headoutlinecolor remotebgcolor - global tagbgcolor tagfgcolor tagoutlinecolor - global reflinecolor filesepbgcolor filesepfgcolor - global mergecolors foundbgcolor currentsearchhitbgcolor - global linehoverbgcolor linehoverfgcolor linehoveroutlinecolor circlecolors - global mainheadcirclecolor workingfilescirclecolor indexcirclecolor - global linkfgcolor circleoutlinecolor - global autoselect autosellen extdifftool perfile_attrs markbgcolor use_ttk - global hideremotes want_ttk maxrefs visiblerefs + global stuffsaved global config_file config_file_tmp + global config_variables config_variable_changed + global viewchanged + + upvar #0 viewname current_viewname + upvar #0 viewfiles current_viewfiles + upvar #0 viewargs current_viewargs + upvar #0 viewargscmd current_viewargscmd + upvar #0 viewperm current_viewperm + upvar #0 nextviewnum current_nextviewnum + upvar #0 use_ttk current_use_ttk if {$stuffsaved} return if {![winfo viewable .]} return - catch { - if {[file exists $config_file_tmp]} { - file delete -force $config_file_tmp + set remove_tmp 0 + if {[catch { + set try_count 0 + while {[catch {set f [open $config_file_tmp {WRONLY CREAT EXCL}]}]} { + if {[incr try_count] > 50} { + error "Unable to write config file: $config_file_tmp exists" + } + after 100 } - set f [open $config_file_tmp w] + set remove_tmp 1 if {$::tcl_platform(platform) eq {windows}} { file attributes $config_file_tmp -hidden true } - puts $f [list set mainfont $mainfont] - puts $f [list set textfont $textfont] - puts $f [list set uifont $uifont] - puts $f [list set tabstop $tabstop] - puts $f [list set findmergefiles $findmergefiles] - puts $f [list set maxgraphpct $maxgraphpct] - puts $f [list set maxwidth $maxwidth] - 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 maxrefs $maxrefs] - puts $f [list set visiblerefs $visiblerefs] - 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] - puts $f [list set uifgcolor $uifgcolor] - puts $f [list set uifgdisabledcolor $uifgdisabledcolor] - puts $f [list set colors $colors] - puts $f [list set diffcolors $diffcolors] - puts $f [list set mergecolors $mergecolors] - puts $f [list set markbgcolor $markbgcolor] - puts $f [list set diffcontext $diffcontext] - puts $f [list set selectbgcolor $selectbgcolor] - puts $f [list set foundbgcolor $foundbgcolor] - puts $f [list set currentsearchhitbgcolor $currentsearchhitbgcolor] - puts $f [list set extdifftool $extdifftool] - puts $f [list set perfile_attrs $perfile_attrs] - puts $f [list set headbgcolor $headbgcolor] - puts $f [list set headfgcolor $headfgcolor] - puts $f [list set headoutlinecolor $headoutlinecolor] - puts $f [list set remotebgcolor $remotebgcolor] - puts $f [list set tagbgcolor $tagbgcolor] - puts $f [list set tagfgcolor $tagfgcolor] - puts $f [list set tagoutlinecolor $tagoutlinecolor] - puts $f [list set reflinecolor $reflinecolor] - puts $f [list set filesepbgcolor $filesepbgcolor] - puts $f [list set filesepfgcolor $filesepfgcolor] - puts $f [list set linehoverbgcolor $linehoverbgcolor] - puts $f [list set linehoverfgcolor $linehoverfgcolor] - puts $f [list set linehoveroutlinecolor $linehoveroutlinecolor] - puts $f [list set mainheadcirclecolor $mainheadcirclecolor] - puts $f [list set workingfilescirclecolor $workingfilescirclecolor] - puts $f [list set indexcirclecolor $indexcirclecolor] - puts $f [list set circlecolors $circlecolors] - puts $f [list set linkfgcolor $linkfgcolor] - puts $f [list set circleoutlinecolor $circleoutlinecolor] + if {[file exists $config_file]} { + source $config_file + } + foreach var_name $config_variables { + upvar #0 $var_name var + upvar 0 $var_name old_var + if {!$config_variable_changed($var_name) && [info exists old_var]} { + puts $f [list set $var_name $old_var] + } else { + puts $f [list set $var_name $var] + } + } puts $f "set geometry(main) [wm geometry .]" puts $f "set geometry(state) [wm state .]" puts $f "set geometry(topwidth) [winfo width .tf]" puts $f "set geometry(topheight) [winfo height .tf]" - if {$use_ttk} { + if {$current_use_ttk} { puts $f "set geometry(pwsash0) \"[.tf.histframe.pwclist sashpos 0] 1\"" puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sashpos 1] 1\"" } else { @@ -2871,15 +2873,43 @@ proc savestuff {w} { puts $f "set geometry(botwidth) [winfo width .bleft]" puts $f "set geometry(botheight) [winfo height .bleft]" + array set view_save {} + array set views {} + if {![info exists permviews]} { set permviews {} } + foreach view $permviews { + set view_save([lindex $view 0]) 1 + set views([lindex $view 0]) $view + } puts -nonewline $f "set permviews {" - for {set v 0} {$v < $nextviewnum} {incr v} { - if {$viewperm($v)} { - puts $f "{[list $viewname($v) $viewfiles($v) $viewargs($v) $viewargscmd($v)]}" + for {set v 1} {$v < $current_nextviewnum} {incr v} { + if {$viewchanged($v)} { + if {$current_viewperm($v)} { + set views($current_viewname($v)) [list $current_viewname($v) $current_viewfiles($v) $current_viewargs($v) $current_viewargscmd($v)] + } else { + set view_save($current_viewname($v)) 0 + } } } + # write old and updated view to their places and append remaining to the end + foreach view $permviews { + set view_name [lindex $view 0] + if {$view_save($view_name)} { + puts $f "{$views($view_name)}" + } + unset views($view_name) + } + foreach view_name [array names views] { + puts $f "{$views($view_name)}" + } puts $f "}" close $f file rename -force $config_file_tmp $config_file + set remove_tmp 0 + } err]} { + puts "Error saving config: $err" + } + if {$remove_tmp} { + file delete -force $config_file_tmp } set stuffsaved 1 } @@ -4036,6 +4066,7 @@ set known_view_options { {committer t15 . "--committer=*" {mc "Committer:"}} {loginfo t15 .. "--grep=*" {mc "Commit Message:"}} {allmatch b .. "--all-match" {mc "Matches all Commit Info criteria"}} + {igrep b .. "--invert-grep" {mc "Matches none Commit Info criteria"}} {changes_l l + {} {mc "Changes to Files:"}} {pickaxe_s r0 . {} {mc "Fixed String"}} {pickaxe_t r1 . "--pickaxe-regex" {mc "Regular Expression"}} @@ -4297,7 +4328,7 @@ proc allviewmenus {n op args} { proc newviewok {top n {apply 0}} { global nextviewnum newviewperm newviewname newishighlight - global viewname viewfiles viewperm selectedview curview + global viewname viewfiles viewperm viewchanged selectedview curview global viewargs viewargscmd newviewopts viewhlmenu if {[catch { @@ -4318,6 +4349,7 @@ proc newviewok {top n {apply 0}} { incr nextviewnum set viewname($n) $newviewname($n) set viewperm($n) $newviewopts($n,perm) + set viewchanged($n) 1 set viewfiles($n) $files set viewargs($n) $newargs set viewargscmd($n) $newviewopts($n,cmd) @@ -4330,6 +4362,7 @@ proc newviewok {top n {apply 0}} { } else { # editing an existing view set viewperm($n) $newviewopts($n,perm) + set viewchanged($n) 1 if {$newviewname($n) ne $viewname($n)} { set viewname($n) $newviewname($n) doviewmenu .bar.view 5 [list showview $n] \ @@ -4352,7 +4385,7 @@ proc newviewok {top n {apply 0}} { } proc delview {} { - global curview viewperm hlview selectedhlview + global curview viewperm hlview selectedhlview viewchanged if {$curview == 0} return if {[info exists hlview] && $hlview == $curview} { @@ -4361,6 +4394,7 @@ proc delview {} { } allviewmenus $curview delete set viewperm($curview) 0 + set viewchanged($curview) 1 showview 0 } @@ -11296,6 +11330,7 @@ proc prefspage_general {notebook} { ${NS}::label $page.maxwidthl -text [mc "Maximum graph width (lines)"] spinbox $page.maxwidth -from 0 -to 100 -width 4 -textvariable maxwidth grid $page.spacer $page.maxwidthl $page.maxwidth -sticky w + #xgettext:no-tcl-format ${NS}::label $page.maxpctl -text [mc "Maximum graph width (% of pane)"] spinbox $page.maxpct -from 1 -to 100 -width 4 -textvariable maxgraphpct grid x $page.maxpctl $page.maxpct -sticky w @@ -11995,7 +12030,7 @@ if { [info exists ::env(GIT_TRACE)] } { } # defaults... -set wrcomcmd "git diff-tree --stdin -p --pretty" +set wrcomcmd "git diff-tree --stdin -p --pretty=email" set gitencoding {} catch { @@ -12168,6 +12203,24 @@ catch { } source $config_file } +config_check_tmp_exists 50 + +set config_variables { + mainfont textfont uifont tabstop findmergefiles maxgraphpct maxwidth + cmitmode wrapcomment autoselect autosellen showneartags maxrefs visiblerefs + hideremotes showlocalchanges datetimeformat limitdiffs uicolor want_ttk + bgcolor fgcolor uifgcolor uifgdisabledcolor colors diffcolors mergecolors + markbgcolor diffcontext selectbgcolor foundbgcolor currentsearchhitbgcolor + extdifftool perfile_attrs headbgcolor headfgcolor headoutlinecolor + remotebgcolor tagbgcolor tagfgcolor tagoutlinecolor reflinecolor + filesepbgcolor filesepfgcolor linehoverbgcolor linehoverfgcolor + linehoveroutlinecolor mainheadcirclecolor workingfilescirclecolor + indexcirclecolor circlecolors linkfgcolor circleoutlinecolor +} +foreach var $config_variables { + config_init_trace $var + trace add variable $var write config_variable_change_cb +} parsefont mainfont $mainfont eval font create mainfont [fontflags mainfont] @@ -12295,6 +12348,7 @@ set highlight_related [mc "None"] set highlight_files {} set viewfiles(0) {} set viewperm(0) 0 +set viewchanged(0) 0 set viewargs(0) {} set viewargscmd(0) {} @@ -12353,6 +12407,7 @@ if {$cmdline_files ne {} || $revtreeargs ne {} || $revtreeargscmd ne {}} { set viewargs(1) $revtreeargs set viewargscmd(1) $revtreeargscmd set viewperm(1) 0 + set viewchanged(1) 0 set vdatemode(1) 0 addviewmenu 1 .bar.view entryconf [mca "Edit view..."] -state normal @@ -12368,6 +12423,7 @@ if {[info exists permviews]} { set viewargs($n) [lindex $v 2] set viewargscmd($n) [lindex $v 3] set viewperm($n) 1 + set viewchanged($n) 0 addviewmenu $n } } |