summaryrefslogtreecommitdiff
path: root/gitk-git/gitk
diff options
context:
space:
mode:
Diffstat (limited to 'gitk-git/gitk')
-rwxr-xr-xgitk-git/gitk296
1 files changed, 205 insertions, 91 deletions
diff --git a/gitk-git/gitk b/gitk-git/gitk
index 90764e8..9a2daf3 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)}]
@@ -2585,6 +2594,7 @@ proc makewindow {} {
bind $fstring <Key-Return> {dofind 1 1}
bind $sha1entry <Key-Return> {gotocommit; break}
bind $sha1entry <<PasteSelection>> clearsha1
+ bind $sha1entry <<Paste>> clearsha1
bind $cflist <1> {sel_flist %W %x %y; break}
bind $cflist <B1-Motion> {sel_flist %W %x %y; break}
bind $cflist <ButtonRelease-1> {treeclick %W %x %y}
@@ -2593,6 +2603,9 @@ proc makewindow {} {
bind $ctext $ctxbut {pop_diff_menu %W %X %Y %x %y}
bind $ctext <Button-1> {focus %W}
bind $ctext <<Selection>> rehighlight_search_results
+ for {set i 1} {$i < 10} {incr i} {
+ bind . <$M1B-Key-$i> [list go_to_parent $i]
+ }
set maincursor [. cget -cursor]
set textcursor [$ctext cget -cursor]
@@ -2770,93 +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
+ 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 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 {
@@ -2866,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
}
@@ -3015,6 +3050,7 @@ proc keys {} {
[mc "<Down>, n, j Move down one commit"]
[mc "<Left>, z, h Go back in history list"]
[mc "<Right>, x, l Go forward in history list"]
+[mc "<%s-n> Go to n-th parent of current commit in history list" $M1T]
[mc "<PageUp> Move up one page in commit list"]
[mc "<PageDown> Move down one page in commit list"]
[mc "<%s-Home> Scroll to top of commit list" $M1T]
@@ -3492,10 +3528,20 @@ proc flist_hl {only} {
}
proc gitknewtmpdir {} {
- global diffnum gitktmpdir gitdir
+ global diffnum gitktmpdir gitdir env
if {![info exists gitktmpdir]} {
- set gitktmpdir [file join $gitdir [format ".gitk-tmp.%s" [pid]]]
+ if {[info exists env(GITK_TMPDIR)]} {
+ set tmpdir $env(GITK_TMPDIR)
+ } elseif {[info exists env(TMPDIR)]} {
+ set tmpdir $env(TMPDIR)
+ } else {
+ set tmpdir $gitdir
+ }
+ set gitktmpformat [file join $tmpdir ".gitk-tmp.XXXXXX"]
+ if {[catch {set gitktmpdir [exec mktemp -d $gitktmpformat]}]} {
+ set gitktmpdir [file join $gitdir [format ".gitk-tmp.%s" [pid]]]
+ }
if {[catch {file mkdir $gitktmpdir} err]} {
error_popup "[mc "Error creating temporary directory %s:" $gitktmpdir] $err"
unset gitktmpdir
@@ -3870,7 +3916,7 @@ proc read_line_source {fd inst} {
set id $nullid2
}
if {[commitinview $id $curview]} {
- selectline [rowofcommit $id] 1 [list $fname $lnum]
+ selectline [rowofcommit $id] 1 [list $fname $lnum] 1
} else {
error_popup [mc "That line comes from commit %s, \
which is not in this view" [shortids $id]]
@@ -4020,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"}}
@@ -4281,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 {
@@ -4302,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)
@@ -4314,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] \
@@ -4336,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} {
@@ -4345,6 +4394,7 @@ proc delview {} {
}
allviewmenus $curview delete
set viewperm($curview) 0
+ set viewchanged($curview) 1
showview 0
}
@@ -5205,11 +5255,15 @@ proc dohidelocalchanges {} {
# spawn off a process to do git diff-index --cached HEAD
proc dodiffindex {} {
global lserial showlocalchanges vfilelimit curview
- global hasworktree
+ global hasworktree git_version
if {!$showlocalchanges || !$hasworktree} return
incr lserial
- set cmd "|git diff-index --cached HEAD"
+ if {[package vcompare $git_version "1.7.2"] >= 0} {
+ set cmd "|git diff-index --cached --ignore-submodules=dirty HEAD"
+ } else {
+ set cmd "|git diff-index --cached HEAD"
+ }
if {$vfilelimit($curview) ne {}} {
set cmd [concat $cmd -- $vfilelimit($curview)]
}
@@ -7020,7 +7074,7 @@ proc viewnextline {dir} {
# add a list of tag or branch names at position pos
# returns the number of names inserted
proc appendrefs {pos ids var} {
- global ctext linknum curview $var maxrefs mainheadid
+ global ctext linknum curview $var maxrefs visiblerefs mainheadid
if {[catch {$ctext index $pos}]} {
return 0
@@ -7041,14 +7095,14 @@ proc appendrefs {pos ids var} {
if {[llength $tags] > $maxrefs} {
# If we are displaying heads, and there are too many,
# see if there are some important heads to display.
- # Currently this means "master" and the current head.
+ # Currently that are the current head and heads listed in $visiblerefs option
set itags {}
if {$var eq "idheads"} {
set utags {}
foreach ti $tags {
set hname [lindex $ti 0]
set id [lindex $ti 1]
- if {($hname eq "master" || $id eq $mainheadid) &&
+ if {([lsearch -exact $visiblerefs $hname] != -1 || $id eq $mainheadid) &&
[llength $itags] < $maxrefs} {
lappend itags $ti
} else {
@@ -7161,7 +7215,7 @@ proc make_idmark {id} {
$canv raise $t
}
-proc selectline {l isnew {desired_loc {}}} {
+proc selectline {l isnew {desired_loc {}} {switch_to_patch 0}} {
global canv ctext commitinfo selectedline
global canvy0 linespc parents children curview
global currentid sha1entry
@@ -7187,6 +7241,10 @@ proc selectline {l isnew {desired_loc {}}} {
setcanvscroll
}
+ if {$cmitmode ne "patch" && $switch_to_patch} {
+ set cmitmode "patch"
+ }
+
set y [expr {$canvy0 + $l * $linespc}]
set ymax [lindex [$canv cget -scrollregion] 3]
set ytop [expr {$y - $linespc - 1}]
@@ -7477,6 +7535,14 @@ proc goforw {} {
}
}
+proc go_to_parent {i} {
+ global parents curview targetid
+ set ps $parents($curview,$targetid)
+ if {[llength $ps] >= $i} {
+ selbyid [lindex $ps [expr $i - 1]]
+ }
+}
+
proc gettree {id} {
global treefilelist treeidlist diffids diffmergeid treepending
global nullid nullid2
@@ -7705,7 +7771,7 @@ proc addtocflist {ids} {
}
proc diffcmd {ids flags} {
- global log_showroot nullid nullid2
+ global log_showroot nullid nullid2 git_version
set i [lsearch -exact $ids $nullid]
set j [lsearch -exact $ids $nullid2]
@@ -7726,6 +7792,9 @@ proc diffcmd {ids flags} {
}
}
} elseif {$j >= 0} {
+ if {[package vcompare $git_version "1.7.2"] >= 0} {
+ set flags "$flags --ignore-submodules=dirty"
+ }
set cmd [concat | git diff-index --cached $flags]
if {[llength $ids] > 1} {
# comparing index with specific revision
@@ -11261,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
@@ -11575,7 +11645,29 @@ proc prefsok {} {
proc formatdate {d} {
global datetimeformat
if {$d ne {}} {
- set d [clock format [lindex $d 0] -format $datetimeformat]
+ # If $datetimeformat includes a timezone, display in the
+ # timezone of the argument. Otherwise, display in local time.
+ if {[string match {*%[zZ]*} $datetimeformat]} {
+ if {[catch {set d [clock format [lindex $d 0] -timezone [lindex $d 1] -format $datetimeformat]}]} {
+ # Tcl < 8.5 does not support -timezone. Emulate it by
+ # setting TZ (e.g. TZ=<-0430>+04:30).
+ global env
+ if {[info exists env(TZ)]} {
+ set savedTZ $env(TZ)
+ }
+ set zone [lindex $d 1]
+ set sign [string map {+ - - +} [string index $zone 0]]
+ set env(TZ) <$zone>$sign[string range $zone 1 2]:[string range $zone 3 4]
+ set d [clock format [lindex $d 0] -format $datetimeformat]
+ if {[info exists savedTZ]} {
+ set env(TZ) $savedTZ
+ } else {
+ unset env(TZ)
+ }
+ }
+ } else {
+ set d [clock format [lindex $d 0] -format $datetimeformat]
+ }
}
return $d
}
@@ -11938,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 {
@@ -12001,6 +12093,7 @@ set wrapcomment "none"
set showneartags 1
set hideremotes 0
set maxrefs 20
+set visiblerefs {"master"}
set maxlinelen 200
set showlocalchanges 1
set limitdiffs 1
@@ -12110,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]
@@ -12237,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) {}
@@ -12295,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
@@ -12310,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
}
}