X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gitk;h=aa9b2e341debed2bf33b62c8d874c7128d25c7ce;hb=3878e636c640763ad12bff7f4dca967c34c530d6;hp=9da052623961c0e70c7b6bc96c1c2aa0b43ac16a;hpb=adab0dabcc95d02c3ab2076f0db5e5f94b30a96d;p=git.git diff --git a/gitk b/gitk index 9da052623..aa9b2e341 100755 --- a/gitk +++ b/gitk @@ -2,20 +2,25 @@ # Tcl ignores the next line -*- tcl -*- \ exec wish "$0" -- "$@" -# Copyright © 2005-2009 Paul Mackerras. All rights reserved. +# Copyright © 2005-2011 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. package require Tk -proc gitdir {} { - global env - if {[info exists env(GIT_DIR)]} { - return $env(GIT_DIR) - } else { - return [exec git rev-parse --git-dir] +proc hasworktree {} { + return [expr {[exec git rev-parse --is-bare-repository] == "false" && + [exec git rev-parse --is-inside-git-dir] == "false"}] +} + +proc reponame {} { + global gitdir + set n [file normalize $gitdir] + if {[string match "*/.git" $n]} { + set n [string range $n 0 end-5] } + return [file tail $n] } # A simple scheduler for compute-intensive stuff. @@ -131,6 +136,7 @@ proc unmerged_files {files} { proc parseviewargs {n arglist} { global vdatemode vmergeonly vflags vdflags vrevs vfiltered vorigargs env + global worddiff git_version set vdatemode($n) 0 set vmergeonly($n) 0 @@ -168,7 +174,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 +183,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" - @@ -313,6 +331,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 @@ -361,8 +380,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 @@ -454,10 +473,11 @@ proc updatecommits {} { global viewactive viewcomplete tclencoding global startmsecs showneartags showlocalchanges global mainheadid viewmainheadid viewmainheadid_orig pending_select - global isworktree + global hasworktree global varcid vposids vnegids vflags vrevs + global show_notes - set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == "true"}] + set hasworktree [hasworktree] rereadrefs set view $curview if {$mainheadid ne $viewmainheadid_orig($view)} { @@ -508,8 +528,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 @@ -644,7 +664,7 @@ proc newvarc {view id} { if {![info exists commitinfo($id)]} { parsecommit $id $commitdata($id) 1 } - set cdate [lindex $commitinfo($id) 4] + set cdate [lindex [lindex $commitinfo($id) 4] 0] if {![string is integer -strict $cdate]} { set cdate 0 } @@ -1606,7 +1626,7 @@ proc readcommit {id} { } proc parsecommit {id contents listed} { - global commitinfo cdate + global commitinfo set inhdr 1 set comment {} @@ -1626,10 +1646,10 @@ proc parsecommit {id contents listed} { set line [split $line " "] set tag [lindex $line 0] if {$tag == "author"} { - set audate [lindex $line end-1] + set audate [lrange $line end-1 end] set auname [join [lrange $line 1 end-2] " "] } elseif {$tag == "committer"} { - set comdate [lindex $line end-1] + set comdate [lrange $line end-1 end] set comname [join [lrange $line 1 end-2] " "] } } @@ -1656,11 +1676,9 @@ proc parsecommit {id contents listed} { } set comment $newcomment } - if {$comdate != {}} { - set cdate($id) $comdate - } + set hasnote [string first "\nNotes:\n" $contents] set commitinfo($id) [list $headline $auname $audate \ - $comname $comdate $comment] + $comname $comdate $comment $hasnote] } proc getcommit {id} { @@ -1970,6 +1988,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 @@ -2243,6 +2263,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 \ @@ -2411,9 +2440,9 @@ proc makewindow {} { bindkey n "selnextline 1" bindkey z "goback" bindkey x "goforw" - bindkey i "selnextline -1" - bindkey k "selnextline 1" - bindkey j "goback" + bindkey k "selnextline -1" + bindkey j "selnextline 1" + bindkey h "goback" bindkey l "goforw" bindkey b prevfile bindkey d "$ctext yview scroll 18 units" @@ -2451,6 +2480,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] @@ -2625,7 +2655,7 @@ proc savestuff {w} { global viewname viewfiles viewargs viewargscmd viewperm nextviewnum global cmitmode wrapcomment datetimeformat limitdiffs global colors uicolor bgcolor fgcolor diffcolors diffcontext selectbgcolor - global autoselect extdifftool perfile_attrs markbgcolor use_ttk + global autoselect autosellen extdifftool perfile_attrs markbgcolor use_ttk global hideremotes want_ttk if {$stuffsaved} return @@ -2646,6 +2676,7 @@ 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] @@ -2787,7 +2818,7 @@ proc about {} { message $w.m -text [mc " Gitk - a commit viewer for git -Copyright © 2005-2009 Paul Mackerras +Copyright \u00a9 2005-2011 Paul Mackerras Use and redistribute under the terms of the GNU General Public License"] \ -justify center -aspect 400 -border 2 -bg white -relief groove @@ -2822,9 +2853,9 @@ proc keys {} { [mc "<%s-W> Close window" $M1T] [mc " Move to first commit"] [mc " Move to last commit"] -[mc ", p, i Move up one commit"] -[mc ", n, k Move down one commit"] -[mc ", z, j Go back in history list"] +[mc ", p, k Move up one commit"] +[mc ", n, j Move down one commit"] +[mc ", z, h Go back in history list"] [mc ", x, l Go forward in history list"] [mc " Move up one page in commit list"] [mc " Move down one page in commit list"] @@ -3305,8 +3336,7 @@ proc gitknewtmpdir {} { global diffnum gitktmpdir gitdir if {![info exists gitktmpdir]} { - set gitktmpdir [file join [file dirname $gitdir] \ - [format ".gitk-tmp.%s" [pid]]] + 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 @@ -3338,10 +3368,10 @@ proc save_file_from_commit {filename output what} { proc external_diff_get_one_file {diffid filename diffdir} { global nullid nullid2 nullfile - global gitdir + global worktree if {$diffid == $nullid} { - set difffile [file join [file dirname $gitdir] $filename] + set difffile [file join $worktree $filename] if {[file exists $difffile]} { return $difffile } @@ -3531,7 +3561,7 @@ proc make_relative {f} { } proc external_blame {parent_idx {line {}}} { - global flist_menu_file gitdir + global flist_menu_file cdup global nullid nullid2 global parentlist selectedline currentid @@ -3550,7 +3580,7 @@ proc external_blame {parent_idx {line {}}} { if {$line ne {} && $line > 1} { lappend cmdline "--line=$line" } - set f [file join [file dirname $gitdir] $flist_menu_file] + set f [file join $cdup $flist_menu_file] # Unfortunately it seems git gui blame doesn't like # being given an absolute path... set f [make_relative $f] @@ -3563,7 +3593,7 @@ proc external_blame {parent_idx {line {}}} { proc show_line_source {} { global cmitmode currentid parents curview blamestuff blameinst global diff_menu_line diff_menu_filebase flist_menu_file - global nullid nullid2 gitdir + global nullid nullid2 gitdir cdup set from_index {} if {$cmitmode eq "tree"} { @@ -3616,7 +3646,7 @@ proc show_line_source {} { } else { lappend blameargs $id } - lappend blameargs -- [file join [file dirname $gitdir] $flist_menu_file] + lappend blameargs -- [file join $cdup $flist_menu_file] if {[catch { set f [open $blameargs r] } err]} { @@ -4501,12 +4531,22 @@ proc makepatterns {l} { proc do_file_hl {serial} { global highlight_files filehighlight highlight_paths gdttype fhl_list + global cdup findtype if {$gdttype eq [mc "touching paths:"]} { + # If "exact" match then convert backslashes to forward slashes. + # Most useful to support Windows-flavoured file paths. + if {$findtype eq [mc "Exact"]} { + set highlight_files [string map {"\\" "/"} $highlight_files] + } if {[catch {set paths [shellsplit $highlight_files]}]} return set highlight_paths [makepatterns $paths] highlight_filelist - set gdtargs [concat -- $paths] + set relative_paths {} + foreach path $paths { + lappend relative_paths [file join $cdup $path] + } + set gdtargs [concat -- $relative_paths] } elseif {$gdttype eq [mc "adding/removing string:"]} { set gdtargs [list "-S$highlight_files"] } else { @@ -5003,9 +5043,9 @@ proc dohidelocalchanges {} { # spawn off a process to do git diff-index --cached HEAD proc dodiffindex {} { global lserial showlocalchanges vfilelimit curview - global isworktree + global hasworktree - if {!$showlocalchanges || !$isworktree} return + if {!$showlocalchanges || !$hasworktree} return incr lserial set cmd "|git diff-index --cached HEAD" if {$vfilelimit($curview) ne {}} { @@ -5871,6 +5911,9 @@ proc drawcmittext {id row col} { || [info exists idotherrefs($id)]} { set xt [drawtags $id $x $xt $y] } + if {[lindex $commitinfo($id) 6] > 0} { + set xt [drawnotesign $xt $y] + } set headline [lindex $commitinfo($id) 0] set name [lindex $commitinfo($id) 1] set date [lindex $commitinfo($id) 2] @@ -6273,6 +6316,7 @@ proc drawtags {id x xt y1} { -width $lthickness -fill black -tags tag.$id] $canv lower $t foreach tag $marks x $xvals wid $wvals { + set tag_quoted [string map {% %%} $tag] set xl [expr {$x + $delta}] set xr [expr {$x + $delta + $wid + $lthickness}] set font mainfont @@ -6281,7 +6325,7 @@ proc drawtags {id x xt y1} { set t [$canv create polygon $x [expr {$yt + $delta}] $xl $yt \ $xr $yt $xr $yb $xl $yb $x [expr {$yb - $delta}] \ -width 1 -outline black -fill yellow -tags tag.$id] - $canv bind $t <1> [list showtag $tag 1] + $canv bind $t <1> [list showtag $tag_quoted 1] set rowtextx([rowofcommit $id]) [expr {$xr + $linespc}] } else { # draw a head or other ref @@ -6308,14 +6352,25 @@ proc drawtags {id x xt y1} { set t [$canv create text $xl $y1 -anchor w -text $tag -fill $fgcolor \ -font $font -tags [list tag.$id text]] if {$ntags >= 0} { - $canv bind $t <1> [list showtag $tag 1] + $canv bind $t <1> [list showtag $tag_quoted 1] } elseif {$nheads >= 0} { - $canv bind $t $ctxbut [list headmenu %X %Y $id $tag] + $canv bind $t $ctxbut [list headmenu %X %Y $id $tag_quoted] } } return $xt } +proc drawnotesign {xt y} { + global linespc canv fgcolor + + set orad [expr {$linespc / 3}] + set t [$canv create rectangle [expr {$xt - $orad}] [expr {$y - $orad}] \ + [expr {$xt + $orad - 1}] [expr {$y + $orad - 1}] \ + -fill yellow -outline $fgcolor -width 1 -tags circle] + set xt [expr {$xt + $orad * 3}] + return $xt +} + proc xcoord {i level ln} { global canvx0 xspc1 xspc2 @@ -6869,7 +6924,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 @@ -6931,7 +6986,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 @@ -7301,6 +7356,7 @@ proc getblobline {bf id} { [lindex [split $commentend .] 0]}] mark_ctext_line $lnum } + $ctext config -state disabled return 0 } $ctext config -state disabled @@ -7502,14 +7558,19 @@ 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} { @@ -7523,6 +7584,9 @@ proc getblobdiffs {ids} { 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)] } @@ -7536,6 +7600,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] } @@ -7606,7 +7671,8 @@ 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 @@ -7687,19 +7753,30 @@ proc getblobdiffline {bdf ids} { } elseif {![string compare -length 10 "Submodule " $line]} { # start of a new submodule - if {[string compare [$ctext get "end - 4c" end] "\n \n\n"]} { + 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 "" - set fname [string range $line 10 [expr [string last " " $line] - 1]] - lappend ctext_file_lines $fname - makediffhdr $fname $ids - $ctext insert end "\n$line\n" filesep + 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} { @@ -7735,15 +7812,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} { @@ -7758,6 +7848,8 @@ proc getblobdiffline {bdf ids} { lappend tags m$num } } + set words_pre_markup "{+" + set words_post_markup "+}" } if {$targetline ne {}} { if {$diffline == $targetline} { @@ -7767,8 +7859,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 @@ -8535,7 +8636,7 @@ proc do_cmp_commits {a b} { } proc diffcommits {a b} { - global diffcontext diffids blobdifffd diffinhdr + global diffcontext diffids blobdifffd diffinhdr currdiffsubmod set tmpdir [gitknewtmpdir] set fna [file join $tmpdir "commit-[string range $a 0 7]"] @@ -8556,6 +8657,7 @@ proc diffcommits {a b} { set diffids [list commits $a $b] set blobdifffd($diffids) $fd set diffinhdr 0 + set currdiffsubmod "" filerun $fd [list getblobdiffline $fd $diffids] } @@ -8967,6 +9069,7 @@ proc exec_citool {tool_args {baseid {}}} { proc cherrypick {} { global rowmenuid curview global mainhead mainheadid + global gitdir set oldhead [exec git rev-parse HEAD] set dheads [descheads $rowmenuid] @@ -8989,13 +9092,13 @@ proc cherrypick {} { to file '%s'.\nPlease commit, reset or stash\ your changes and try again." $fname] } elseif {[regexp -line \ - {^(CONFLICT \(.*\):|Automatic cherry-pick failed)} \ + {^(CONFLICT \(.*\):|Automatic cherry-pick failed|error: could not apply)} \ $err]} { if {[confirm_popup [mc "Cherry-pick failed because of merge\ conflict.\nDo you wish to run git citool to\ resolve it?"]]} { # Force citool to read MERGE_MSG - file delete [file join [gitdir] "GITGUI_MSG"] + file delete [file join $gitdir "GITGUI_MSG"] exec_citool {} $rowmenuid } } else { @@ -9361,6 +9464,7 @@ proc refill_reflist {} { proc getallcommits {} { global allcommits nextarc seeds allccache allcwait cachedarcs allcupdate global idheads idtags idotherrefs allparents tagobjid + global gitdir if {![info exists allcommits]} { set nextarc 0 @@ -9368,7 +9472,7 @@ proc getallcommits {} { set seeds {} set allcwait 0 set cachedarcs 0 - set allccache [file join [gitdir] "gitk.cache"] + set allccache [file join $gitdir "gitk.cache"] if {![catch { set f [open $allccache r] set allcwait 1 @@ -10682,7 +10786,7 @@ proc doprefs {} { global maxwidth maxgraphpct use_ttk NS global oldprefs prefstop showneartags showlocalchanges global uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor - global tabstop limitdiffs autoselect extdifftool perfile_attrs + global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs global hideremotes want_ttk have_ttk set top .gitkprefs @@ -10710,9 +10814,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 @@ -10947,7 +11052,7 @@ proc prefsok {} { proc formatdate {d} { global datetimeformat if {$d ne {}} { - set d [clock format $d -format $datetimeformat] + set d [clock format [lindex $d 0] -format $datetimeformat] } return $d } @@ -11354,6 +11459,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 @@ -11378,6 +11484,7 @@ if {[tk windowingsystem] eq "win32"} { set diffcolors {red "#00a000" blue} set diffcontext 3 set ignorespace 0 +set worddiff "" set markbgcolor "#e0e0ff" set circlecolors {white blue gray blue blue} @@ -11426,14 +11533,10 @@ setui $uicolor setoptions # check that we can find a .git directory somewhere... -if {[catch {set gitdir [gitdir]}]} { +if {[catch {set gitdir [exec git rev-parse --git-dir]}]} { show_error {} . [mc "Cannot find a git repository here."] exit 1 } -if {![file isdirectory $gitdir]} { - show_error {} . [mc "Cannot find the git directory \"%s\"." $gitdir] - exit 1 -} set selecthead {} set selectheadid {} @@ -11506,7 +11609,14 @@ 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 appname "gitk" set runq {} set history {} @@ -11544,7 +11654,12 @@ set stopped 0 set stuffsaved 0 set patchnum 0 set lserial 0 -set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == "true"}] +set hasworktree [hasworktree] +set cdup {} +if {[expr {[exec git rev-parse --is-inside-work-tree] == "true"}]} { + set cdup [exec git rev-parse --show-cdup] +} +set worktree [exec git rev-parse --show-toplevel] setcoords makewindow catch { @@ -11572,7 +11687,7 @@ catch { } # wait for the window to become visible tkwait visibility . -wm title . "[file tail $argv0]: [file tail [pwd]]" +wm title . "$appname: [reponame]" update readrefs