Code

Merge branch 'master' into dev
authorPaul Mackerras <paulus@samba.org>
Sat, 5 Sep 2009 07:34:03 +0000 (17:34 +1000)
committerPaul Mackerras <paulus@samba.org>
Sat, 5 Sep 2009 07:34:03 +0000 (17:34 +1000)
1  2 
gitk

diff --combined gitk
index 082fa77513a7aaf41d8c45cf8cdeccd18d8cc882,8c08310e6dea4aa904b47cd335686deedb6fd5ed..9d8afd839cc54747b12cd367b4d02ef354cf5d6c
--- 1/gitk
--- 2/gitk
+++ b/gitk
@@@ -7,8 -7,6 +7,8 @@@ exec wish "$0" -- "$@
  # 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)]} {
@@@ -189,7 -187,8 +189,8 @@@ proc parseviewargs {n arglist} 
            "--until=*" - "--before=*" - "--max-age=*" - "--min-age=*" -
            "--author=*" - "--committer=*" - "--grep=*" - "-[iE]" -
            "--remove-empty" - "--first-parent" - "--cherry-pick" -
-           "-S*" - "--pickaxe-all" - "--pickaxe-regex" {
+           "-S*" - "--pickaxe-all" - "--pickaxe-regex" -
+           "--simplify-by-decoration" {
                # These mean that we get a subset of the commits
                set filtered 1
                lappend glflags $arg
@@@ -266,7 -265,7 +267,7 @@@ proc parseviewrevs {view revs} 
                }
                lappend badrev $line
            }
 -      }                   
 +      }
        error_popup "[mc "Error parsing revisions:"] $err"
        return {}
      }
            if {$sdm != 2} {
                lappend ret $id
            } else {
-               lset ret end [lindex $ret end]...$id
+               lset ret end $id...[lindex $ret end]
            }
            lappend pos $id
        }
@@@ -1678,6 -1677,7 +1679,7 @@@ proc readrefs {} 
      global tagids idtags headids idheads tagobjid
      global otherrefids idotherrefs mainhead mainheadid
      global selecthead selectheadid
+     global hideremotes
  
      foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
        catch {unset $v}
        if {![string match "refs/*" $ref]} continue
        set name [string range $ref 5 end]
        if {[string match "remotes/*" $name]} {
-           if {![string match "*/HEAD" $name]} {
+           if {![string match "*/HEAD" $name] && !$hideremotes} {
                set headids($name) $id
                lappend idheads($id) $name
            }
@@@ -1769,15 -1769,6 +1771,15 @@@ proc removehead {id name} 
      unset headids($name)
  }
  
 +proc ttk_toplevel {w args} {
 +    global use_ttk
 +    eval [linsert $args 0 ::toplevel $w]
 +    if {$use_ttk} {
 +        place [ttk::frame $w._toplevel_background] -x 0 -y 0 -relwidth 1 -relheight 1
 +    }
 +    return $w
 +}
 +
  proc make_transient {window origin} {
      global have_tk85
  
  }
  
  proc show_error {w top msg} {
 +    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
 -    button $w.ok -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 <Visibility> "grab $top; focus $top"
      bind $top <Key-Return> "destroy $top"
  }
  
  proc error_popup {msg {owner .}} {
 -    set w .error
 -    toplevel $w
 -    make_transient $w $owner
 -    show_error $w $w $msg
 +    if {[tk windowingsystem] eq "win32"} {
 +        tk_messageBox -icon error -type ok -title [wm title .] \
 +            -parent $owner -message $msg
 +    } else {
 +        set w .error
 +        ttk_toplevel $w
 +        make_transient $w $owner
 +        show_error $w $w $msg
 +    }
  }
  
  proc confirm_popup {msg {owner .}} {
 -    global confirm_ok
 +    global confirm_ok NS
      set confirm_ok 0
      set w .confirm
 -    toplevel $w
 +    ttk_toplevel $w
      make_transient $w $owner
      message $w.m -text $msg -justify center -aspect 400
      pack $w.m -side top -fill x -padx 20 -pady 20
 -    button $w.ok -text [mc OK] -command "set confirm_ok 1; destroy $w"
 +    ${NS}::button $w.ok -text [mc OK] -command "set confirm_ok 1; destroy $w"
      pack $w.ok -side left -fill x
 -    button $w.cancel -text [mc Cancel] -command "destroy $w"
 +    ${NS}::button $w.cancel -text [mc Cancel] -command "destroy $w"
      pack $w.cancel -side right -fill x
      bind $w <Visibility> "grab $w; focus $w"
      bind $w <Key-Return> "set confirm_ok 1; destroy $w"
      bind $w <Key-space>  "set confirm_ok 1; destroy $w"
      bind $w <Key-Escape> "destroy $w"
 +    tk::PlaceWindow $w widget $owner
      tkwait window $w
      return $confirm_ok
  }
  
  proc setoptions {} {
 -    option add *Panedwindow.showHandle 1 startupFile
 -    option add *Panedwindow.sashRelief raised startupFile
 +    if {[tk windowingsystem] ne "win32"} {
 +        option add *Panedwindow.showHandle 1 startupFile
 +        option add *Panedwindow.sashRelief raised startupFile
 +        if {[tk windowingsystem] ne "aqua"} {
 +            option add *Menu.font uifont startupFile
 +        }
 +    } else {
 +        option add *Menu.TearOff 0 startupFile
 +    }
      option add *Button.font uifont startupFile
      option add *Checkbutton.font uifont startupFile
      option add *Radiobutton.font uifont startupFile
 -    if {[tk windowingsystem] ne "aqua"} {
 -      option add *Menu.font uifont startupFile
 -    }
      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 *Labelframe.font uifont startupFile
  }
  
  # Make a menu and submenus.
@@@ -1918,22 -1895,6 +1920,22 @@@ proc mca {str} 
      return [string map {&& & & {}} [mc $str]]
  }
  
 +proc makedroplist {w varname args} {
 +    global use_ttk
 +    if {$use_ttk} {
 +        set width 0
 +        foreach label $args {
 +            set cx [string length $label]
 +            if {$cx > $width} {set width $cx}
 +        }
 +      set gm [ttk::combobox $w -width $width -state readonly\
 +                  -textvariable $varname -values $args]
 +    } else {
 +      set gm [eval [linsert $args 0 tk_optionMenu $w $varname]]
 +    }
 +    return $gm
 +}
 +
  proc makewindow {} {
      global canv canv2 canv3 linespc charspc ctext cflist cscroll
      global tabstop
      global headctxmenu progresscanv progressitem progresscoords statusw
      global fprogitem fprogcoord lastprogupdate progupdatepending
      global rprogitem rprogcoord rownumsel numcommits
 -    global have_tk85
 +    global have_tk85 use_ttk NS
  
      # The "mc" arguments here are purely so that xgettext
      # sees the following string as needing to be translated
      makemenu .bar $bar
      . configure -menu .bar
  
 +    if {$use_ttk} {
 +        # cover the non-themed toplevel with a themed frame.
 +        place [ttk::frame ._main_background] -x 0 -y 0 -relwidth 1 -relheight 1
 +    }
 +
      # the gui has upper and lower half, parts of a paned window.
 -    panedwindow .ctop -orient vertical
 +    ${NS}::panedwindow .ctop -orient vertical
  
      # possibly use assumed geometry
      if {![info exists geometry(pwsash0)]} {
          set geometry(topwidth) [expr {80 * $charspc}]
          set geometry(botheight) [expr {15 * $linespc}]
          set geometry(botwidth) [expr {50 * $charspc}]
 -        set geometry(pwsash0) "[expr {40 * $charspc}] 2"
 -        set geometry(pwsash1) "[expr {60 * $charspc}] 2"
 +        set geometry(pwsash0) [list [expr {40 * $charspc}] 2]
 +        set geometry(pwsash1) [list [expr {60 * $charspc}] 2]
      }
  
      # the upper half will have a paned window, a scroll bar to the right, and some stuff below
 -    frame .tf -height $geometry(topheight) -width $geometry(topwidth)
 -    frame .tf.histframe
 -    panedwindow .tf.histframe.pwclist -orient horizontal -sashpad 0 -handlesize 4
 +    ${NS}::frame .tf -height $geometry(topheight) -width $geometry(topwidth)
 +    ${NS}::frame .tf.histframe
 +    ${NS}::panedwindow .tf.histframe.pwclist -orient horizontal
 +    if {!$use_ttk} {
 +      .tf.histframe.pwclist configure -sashpad 0 -handlesize 4
 +    }
  
      # create three canvases
      set cscroll .tf.histframe.csb
        -selectbackground $selectbgcolor \
        -background $bgcolor -bd 0 -yscrollincr $linespc
      .tf.histframe.pwclist add $canv3
 -    eval .tf.histframe.pwclist sash place 0 $geometry(pwsash0)
 -    eval .tf.histframe.pwclist sash place 1 $geometry(pwsash1)
 +    if {$use_ttk} {
 +      bind .tf.histframe.pwclist <Map> {
 +          bind %W <Map> {}
 +          .tf.histframe.pwclist sashpos 1 [lindex $::geometry(pwsash1) 0]
 +          .tf.histframe.pwclist sashpos 0 [lindex $::geometry(pwsash0) 0]
 +      }
 +    } else {
 +      eval .tf.histframe.pwclist sash place 0 $geometry(pwsash0)
 +      eval .tf.histframe.pwclist sash place 1 $geometry(pwsash1)
 +    }
  
      # a scroll bar to rule them
 -    scrollbar $cscroll -command {allcanvs yview} -highlightthickness 0
 +    ${NS}::scrollbar $cscroll -command {allcanvs yview}
 +    if {!$use_ttk} {$cscroll configure -highlightthickness 0}
      pack $cscroll -side right -fill y
      bind .tf.histframe.pwclist <Configure> {resizeclistpanes %W %w}
      lappend bglist $canv $canv2 $canv3
      pack .tf.histframe.pwclist -fill both -expand 1 -side left
  
      # we have two button bars at bottom of top frame. Bar 1
 -    frame .tf.bar
 -    frame .tf.lbar -height 15
 +    ${NS}::frame .tf.bar
 +    ${NS}::frame .tf.lbar -height 15
  
      set sha1entry .tf.bar.sha1
      set entries $sha1entry
        -command gotocommit -width 8
      $sha1but conf -disabledforeground [$sha1but cget -foreground]
      pack .tf.bar.sha1label -side left
 -    entry $sha1entry -width 40 -font textfont -textvariable sha1string
 +    ${NS}::entry $sha1entry -width 40 -font textfont -textvariable sha1string
      trace add variable sha1string write sha1change
      pack $sha1entry -side left -pady 2
  
        0x00, 0x38, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0x00, 0x38, 0x00, 0x1c,
        0x00, 0x0e, 0x00, 0x07, 0x80, 0x03, 0xc0, 0x01};
      }
 -    button .tf.bar.leftbut -image bm-left -command goback \
 +    ${NS}::button .tf.bar.leftbut -image bm-left -command goback \
        -state disabled -width 26
      pack .tf.bar.leftbut -side left -fill y
 -    button .tf.bar.rightbut -image bm-right -command goforw \
 +    ${NS}::button .tf.bar.rightbut -image bm-right -command goforw \
        -state disabled -width 26
      pack .tf.bar.rightbut -side left -fill y
  
 -    label .tf.bar.rowlabel -text [mc "Row"]
 +    ${NS}::label .tf.bar.rowlabel -text [mc "Row"]
      set rownumsel {}
 -    label .tf.bar.rownum -width 7 -font textfont -textvariable rownumsel \
 +    ${NS}::label .tf.bar.rownum -width 7 -textvariable rownumsel \
        -relief sunken -anchor e
 -    label .tf.bar.rowlabel2 -text "/"
 -    label .tf.bar.numcommits -width 7 -font textfont -textvariable numcommits \
 +    ${NS}::label .tf.bar.rowlabel2 -text "/"
 +    ${NS}::label .tf.bar.numcommits -width 7 -textvariable numcommits \
        -relief sunken -anchor e
      pack .tf.bar.rowlabel .tf.bar.rownum .tf.bar.rowlabel2 .tf.bar.numcommits \
        -side left
 +    if {!$use_ttk} {
 +        foreach w {rownum numcommits} {.tf.bar.$w configure -font textfont}
 +    }
      global selectedline
      trace add variable selectedline write selectedline_change
  
      # Status label and progress bar
      set statusw .tf.bar.status
 -    label $statusw -width 15 -relief sunken
 +    ${NS}::label $statusw -width 15 -relief sunken
      pack $statusw -side left -padx 5
 -    set h [expr {[font metrics uifont -linespace] + 2}]
 -    set progresscanv .tf.bar.progress
 -    canvas $progresscanv -relief sunken -height $h -borderwidth 2
 -    set progressitem [$progresscanv create rect -1 0 0 $h -fill green]
 -    set fprogitem [$progresscanv create rect -1 0 0 $h -fill yellow]
 -    set rprogitem [$progresscanv create rect -1 0 0 $h -fill red]
 -    pack $progresscanv -side right -expand 1 -fill x
 +    if {$use_ttk} {
 +      set progresscanv [ttk::progressbar .tf.bar.progress]
 +    } else {
 +      set h [expr {[font metrics uifont -linespace] + 2}]
 +      set progresscanv .tf.bar.progress
 +      canvas $progresscanv -relief sunken -height $h -borderwidth 2
 +      set progressitem [$progresscanv create rect -1 0 0 $h -fill green]
 +      set fprogitem [$progresscanv create rect -1 0 0 $h -fill yellow]
 +      set rprogitem [$progresscanv create rect -1 0 0 $h -fill red]
 +    }
 +    pack $progresscanv -side right -expand 1 -fill x -padx {0 2}
      set progresscoords {0 0}
      set fprogcoord 0
      set rprogcoord 0
      set progupdatepending 0
  
      # build up the bottom bar of upper window
 -    label .tf.lbar.flabel -text "[mc "Find"] "
 -    button .tf.lbar.fnext -text [mc "next"] -command {dofind 1 1}
 -    button .tf.lbar.fprev -text [mc "prev"] -command {dofind -1 1}
 -    label .tf.lbar.flab2 -text " [mc "commit"] "
 +    ${NS}::label .tf.lbar.flabel -text "[mc "Find"] "
 +    ${NS}::button .tf.lbar.fnext -text [mc "next"] -command {dofind 1 1}
 +    ${NS}::button .tf.lbar.fprev -text [mc "prev"] -command {dofind -1 1}
 +    ${NS}::label .tf.lbar.flab2 -text " [mc "commit"] "
      pack .tf.lbar.flabel .tf.lbar.fnext .tf.lbar.fprev .tf.lbar.flab2 \
        -side left -fill y
      set gdttype [mc "containing:"]
 -    set gm [tk_optionMenu .tf.lbar.gdttype gdttype \
 +    set gm [makedroplist .tf.lbar.gdttype gdttype \
                [mc "containing:"] \
                [mc "touching paths:"] \
                [mc "adding/removing string:"]]
      set findstring {}
      set fstring .tf.lbar.findstring
      lappend entries $fstring
 -    entry $fstring -width 30 -font textfont -textvariable findstring
 +    ${NS}::entry $fstring -width 30 -font textfont -textvariable findstring
      trace add variable findstring write find_change
      set findtype [mc "Exact"]
 -    set findtypemenu [tk_optionMenu .tf.lbar.findtype \
 -                    findtype [mc "Exact"] [mc "IgnCase"] [mc "Regexp"]]
 +    set findtypemenu [makedroplist .tf.lbar.findtype \
 +                        findtype [mc "Exact"] [mc "IgnCase"] [mc "Regexp"]]
      trace add variable findtype write findcom_change
      set findloc [mc "All fields"]
 -    tk_optionMenu .tf.lbar.findloc findloc [mc "All fields"] [mc "Headline"] \
 +    makedroplist .tf.lbar.findloc findloc [mc "All fields"] [mc "Headline"] \
        [mc "Comments"] [mc "Author"] [mc "Committer"]
      trace add variable findloc write find_change
      pack .tf.lbar.findloc -side right
      pack .tf.bar -in .tf -side bottom -fill x
      pack .tf.histframe -fill both -side top -expand 1
      .ctop add .tf
 -    .ctop paneconfigure .tf -height $geometry(topheight)
 -    .ctop paneconfigure .tf -width $geometry(topwidth)
 +    if {!$use_ttk} {
 +      .ctop paneconfigure .tf -height $geometry(topheight)
 +      .ctop paneconfigure .tf -width $geometry(topwidth)
 +    }
  
      # now build up the bottom
 -    panedwindow .pwbottom -orient horizontal
 +    ${NS}::panedwindow .pwbottom -orient horizontal
  
      # lower left, a text box over search bar, scroll bar to the right
      # if we know window height, then that will set the lower text height, otherwise
      # we set lower text height which will drive window height
      if {[info exists geometry(main)]} {
 -        frame .bleft -width $geometry(botwidth)
 +      ${NS}::frame .bleft -width $geometry(botwidth)
      } else {
 -        frame .bleft -width $geometry(botwidth) -height $geometry(botheight)
 +      ${NS}::frame .bleft -width $geometry(botwidth) -height $geometry(botheight)
      }
 -    frame .bleft.top
 -    frame .bleft.mid
 -    frame .bleft.bottom
 +    ${NS}::frame .bleft.top
 +    ${NS}::frame .bleft.mid
 +    ${NS}::frame .bleft.bottom
  
 -    button .bleft.top.search -text [mc "Search"] -command dosearch
 +    ${NS}::button .bleft.top.search -text [mc "Search"] -command dosearch
      pack .bleft.top.search -side left -padx 5
      set sstring .bleft.top.sstring
 -    entry $sstring -width 20 -font textfont -textvariable searchstring
 +    set searchstring ""
 +    ${NS}::entry $sstring -width 20 -font textfont -textvariable searchstring
      lappend entries $sstring
      trace add variable searchstring write incrsearch
      pack $sstring -side left -expand 1 -fill x
 -    radiobutton .bleft.mid.diff -text [mc "Diff"] \
 +    ${NS}::radiobutton .bleft.mid.diff -text [mc "Diff"] \
        -command changediffdisp -variable diffelide -value {0 0}
 -    radiobutton .bleft.mid.old -text [mc "Old version"] \
 +    ${NS}::radiobutton .bleft.mid.old -text [mc "Old version"] \
        -command changediffdisp -variable diffelide -value {0 1}
 -    radiobutton .bleft.mid.new -text [mc "New version"] \
 +    ${NS}::radiobutton .bleft.mid.new -text [mc "New version"] \
        -command changediffdisp -variable diffelide -value {1 0}
 -    label .bleft.mid.labeldiffcontext -text "      [mc "Lines of context"]: "
 +    ${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 \
-       -from 1 -increment 1 -to 10000000 \
+       -from 0 -increment 1 -to 10000000 \
        -validate all -validatecommand "diffcontextvalidate %P" \
        -textvariable diffcontextstring
      .bleft.mid.diffcontext set $diffcontext
      trace add variable diffcontextstring write diffcontextchange
      lappend entries .bleft.mid.diffcontext
      pack .bleft.mid.labeldiffcontext .bleft.mid.diffcontext -side left
 -    checkbutton .bleft.mid.ignspace -text [mc "Ignore space change"] \
 +    ${NS}::checkbutton .bleft.mid.ignspace -text [mc "Ignore space change"] \
        -command changeignorespace -variable ignorespace
      pack .bleft.mid.ignspace -side left -padx 5
      set ctext .bleft.bottom.ctext
      if {$have_tk85} {
        $ctext conf -tabstyle wordprocessor
      }
 -    scrollbar .bleft.bottom.sb -command "$ctext yview"
 -    scrollbar .bleft.bottom.sbhorizontal -command "$ctext xview" -orient h \
 -      -width 10
 +    ${NS}::scrollbar .bleft.bottom.sb -command "$ctext yview"
 +    ${NS}::scrollbar .bleft.bottom.sbhorizontal -command "$ctext xview" -orient h
      pack .bleft.top -side top -fill x
      pack .bleft.mid -side top -fill x
      grid $ctext .bleft.bottom.sb -sticky nsew
      $ctext tag conf found -back yellow
  
      .pwbottom add .bleft
 -    .pwbottom paneconfigure .bleft -width $geometry(botwidth)
 +    if {!$use_ttk} {
 +      .pwbottom paneconfigure .bleft -width $geometry(botwidth)
 +    }
  
      # lower right
 -    frame .bright
 -    frame .bright.mode
 -    radiobutton .bright.mode.patch -text [mc "Patch"] \
 +    ${NS}::frame .bright
 +    ${NS}::frame .bright.mode
 +    ${NS}::radiobutton .bright.mode.patch -text [mc "Patch"] \
        -command reselectline -variable cmitmode -value "patch"
 -    radiobutton .bright.mode.tree -text [mc "Tree"] \
 +    ${NS}::radiobutton .bright.mode.tree -text [mc "Tree"] \
        -command reselectline -variable cmitmode -value "tree"
      grid .bright.mode.patch .bright.mode.tree -sticky ew
      pack .bright.mode -side top -fill x
        -spacing1 1 -spacing3 1
      lappend bglist $cflist
      lappend fglist $cflist
 -    scrollbar .bright.sb -command "$cflist yview"
 +    ${NS}::scrollbar .bright.sb -command "$cflist yview"
      pack .bright.sb -side right -fill y
      pack $cflist -side left -fill both -expand 1
      $cflist tag configure highlight \
          set ::BM "2"
      }
  
 +    if {$use_ttk} {
 +        bind .ctop <Map> {
 +            bind %W <Map> {}
 +            %W sashpos 0 $::geometry(topheight)
 +        }
 +        bind .pwbottom <Map> {
 +            bind %W <Map> {}
 +            %W sashpos 0 $::geometry(botwidth)
 +        }
 +    }
 +
      bind .pwbottom <Configure> {resizecdetpanes %W %w}
      pack .ctop -fill both -expand 1
      bindall <1> {selcanvline %W %x %y}
@@@ -2562,12 -2484,7 +2564,12 @@@ proc click {w} 
  proc adjustprogress {} {
      global progresscanv progressitem progresscoords
      global fprogitem fprogcoord lastprogupdate progupdatepending
 -    global rprogitem rprogcoord
 +    global rprogitem rprogcoord use_ttk
 +
 +    if {$use_ttk} {
 +      $progresscanv configure -value [expr {int($fprogcoord * 100)}]
 +      return
 +    }
  
      set w [expr {[winfo width $progresscanv] - 4}]
      set x0 [expr {$w * [lindex $progresscoords 0]}]
@@@ -2603,7 -2520,8 +2605,8 @@@ proc savestuff {w} 
      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
 +    global autoselect extdifftool perfile_attrs markbgcolor use_ttk
+     global hideremotes
  
      if {$stuffsaved} return
      if {![winfo viewable .]} return
        puts $f [list set wrapcomment $wrapcomment]
        puts $f [list set autoselect $autoselect]
        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 "set geometry(state) [wm state .]"
        puts $f "set geometry(topwidth) [winfo width .tf]"
        puts $f "set geometry(topheight) [winfo height .tf]"
 -        puts $f "set geometry(pwsash0) \"[.tf.histframe.pwclist sash coord 0]\""
 -        puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sash coord 1]\""
 +      if {$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 {
 +          puts $f "set geometry(pwsash0) \"[.tf.histframe.pwclist sash coord 0]\""
 +          puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sash coord 1]\""
 +      }
        puts $f "set geometry(botwidth) [winfo width .bleft]"
        puts $f "set geometry(botheight) [winfo height .bleft]"
  
  }
  
  proc resizeclistpanes {win w} {
 -    global oldwidth
 +    global oldwidth use_ttk
      if {[info exists oldwidth($win)]} {
 -      set s0 [$win sash coord 0]
 -      set s1 [$win sash coord 1]
 +      if {$use_ttk} {
 +          set s0 [$win sashpos 0]
 +          set s1 [$win sashpos 1]
 +      } else {
 +          set s0 [$win sash coord 0]
 +          set s1 [$win sash coord 1]
 +      }
        if {$w < 60} {
            set sash0 [expr {int($w/2 - 2)}]
            set sash1 [expr {int($w*5/6 - 2)}]
                }
            }
        }
 -      $win sash place 0 $sash0 [lindex $s0 1]
 -      $win sash place 1 $sash1 [lindex $s1 1]
 +      if {$use_ttk} {
 +          $win sashpos 0 $sash0
 +          $win sashpos 1 $sash1
 +      } else {
 +          $win sash place 0 $sash0 [lindex $s0 1]
 +          $win sash place 1 $sash1 [lindex $s1 1]
 +      }
      }
      set oldwidth($win) $w
  }
  
  proc resizecdetpanes {win w} {
 -    global oldwidth
 +    global oldwidth use_ttk
      if {[info exists oldwidth($win)]} {
 -      set s0 [$win sash coord 0]
 +      if {$use_ttk} {
 +          set s0 [$win sashpos 0]
 +      } else {
 +          set s0 [$win sash coord 0]
 +      }
        if {$w < 60} {
            set sash0 [expr {int($w*3/4 - 2)}]
        } else {
                set sash0 [expr {$w - 15}]
            }
        }
 -      $win sash place 0 $sash0 [lindex $s0 1]
 +      if {$use_ttk} {
 +          $win sashpos 0 $sash0
 +      } else {
 +          $win sash place 0 $sash0 [lindex $s0 1]
 +      }
      }
      set oldwidth($win) $w
  }
@@@ -2748,33 -2644,31 +2752,33 @@@ proc bindall {event action} 
  }
  
  proc about {} {
 -    global uifont
 +    global uifont NS
      set w .about
      if {[winfo exists $w]} {
        raise $w
        return
      }
 -    toplevel $w
 +    ttk_toplevel $w
      wm title $w [mc "About gitk"]
      make_transient $w .
      message $w.m -text [mc "
  Gitk - a commit viewer for git
  
 -Copyright Â© 2005-2008 Paul Mackerras
 +Copyright \u00a9 2005-2009 Paul Mackerras
  
  Use and redistribute under the terms of the GNU General Public License"] \
            -justify center -aspect 400 -border 2 -bg white -relief groove
      pack $w.m -side top -fill x -padx 2 -pady 2
 -    button $w.ok -text [mc "Close"] -command "destroy $w" -default active
 +    ${NS}::button $w.ok -text [mc "Close"] -command "destroy $w" -default active
      pack $w.ok -side bottom
      bind $w <Visibility> "focus $w.ok"
      bind $w <Key-Escape> "destroy $w"
      bind $w <Key-Return> "destroy $w"
 +    tk::PlaceWindow $w widget .
  }
  
  proc keys {} {
 +    global NS
      set w .keys
      if {[winfo exists $w]} {
        raise $w
      } else {
        set M1T Ctrl
      }
 -    toplevel $w
 +    ttk_toplevel $w
      wm title $w [mc "Gitk key bindings"]
      make_transient $w .
      message $w.m -text "
  " \
            -justify left -bg white -border 2 -relief groove
      pack $w.m -side top -fill both -padx 2 -pady 2
 -    button $w.ok -text [mc "Close"] -command "destroy $w" -default active
 +    ${NS}::button $w.ok -text [mc "Close"] -command "destroy $w" -default active
      bind $w <Key-Escape> [list destroy $w]
      pack $w.ok -side bottom
      bind $w <Visibility> "focus $w.ok"
@@@ -3781,17 -3675,36 +3785,36 @@@ proc newview {ishighlight} 
  }
  
  set known_view_options {
-     {perm    b    . {}               {mc "Remember this view"}}
-     {args    t50= + {}               {mc "Commits to include (arguments to git log):"}}
-     {all     b    * "--all"          {mc "Use all refs"}}
-     {dorder  b    . {"--date-order" "-d"}      {mc "Strictly sort by date"}}
-     {lright  b    . "--left-right"   {mc "Mark branch sides"}}
-     {since   t15  + {"--since=*" "--after=*"}  {mc "Since date:"}}
-     {until   t15  . {"--until=*" "--before=*"} {mc "Until date:"}}
-     {limit   t10  + "--max-count=*"  {mc "Max count:"}}
-     {skip    t10  . "--skip=*"       {mc "Skip:"}}
-     {first   b    . "--first-parent" {mc "Limit to first parent"}}
-     {cmd     t50= + {}               {mc "Command to generate more commits to include:"}}
+     {perm      b    .  {}               {mc "Remember this view"}}
+     {reflabel  l    +  {}               {mc "References (space separated list):"}}
+     {refs      t15  .. {}               {mc "Branches & tags:"}}
+     {allrefs   b    *. "--all"          {mc "All refs"}}
+     {branches  b    .  "--branches"     {mc "All (local) branches"}}
+     {tags      b    .  "--tags"         {mc "All tags"}}
+     {remotes   b    .  "--remotes"      {mc "All remote-tracking branches"}}
+     {commitlbl l    +  {}               {mc "Commit Info (regular expressions):"}}
+     {author    t15  .. "--author=*"     {mc "Author:"}}
+     {committer t15  .  "--committer=*"  {mc "Committer:"}}
+     {loginfo   t15  .. "--grep=*"       {mc "Commit Message:"}}
+     {allmatch  b    .. "--all-match"    {mc "Matches all Commit Info criteria"}}
+     {changes_l l    +  {}               {mc "Changes to Files:"}}
+     {pickaxe_s r0   .  {}               {mc "Fixed String"}}
+     {pickaxe_t r1   .  "--pickaxe-regex"  {mc "Regular Expression"}}
+     {pickaxe   t15  .. "-S*"            {mc "Search string:"}}
+     {datelabel l    +  {}               {mc "Commit Dates (\"2 weeks ago\", \"2009-03-17 15:27:38\", \"March 17, 2009 15:27:38\"):"}}
+     {since     t15  ..  {"--since=*" "--after=*"}  {mc "Since:"}}
+     {until     t15  .   {"--until=*" "--before=*"} {mc "Until:"}}
+     {limit_lbl l    +  {}               {mc "Limit and/or skip a number of revisions (positive integer):"}}
+     {limit     t10  *. "--max-count=*"  {mc "Number to show:"}}
+     {skip      t10  .  "--skip=*"       {mc "Number to skip:"}}
+     {misc_lbl  l    +  {}               {mc "Miscellaneous options:"}}
+     {dorder    b    *. {"--date-order" "-d"}      {mc "Strictly sort by date"}}
+     {lright    b    .  "--left-right"   {mc "Mark branch sides"}}
+     {first     b    .  "--first-parent" {mc "Limit to first parent"}}
+     {smplhst   b    .  "--simplify-by-decoration"   {mc "Simple history"}}
+     {args      t50  *. {}               {mc "Additional arguments to git log:"}}
+     {allpaths  path +  {}               {mc "Enter files and directories to include, one per line:"}}
+     {cmd       t50= +  {}               {mc "Command to generate more commits to include:"}}
      }
  
  proc encode_view_opts {n} {
        if {$patterns eq {}} continue
        set pattern [lindex $patterns 0]
  
-       set val $newviewopts($n,[lindex $opt 0])
        if {[lindex $opt 1] eq "b"} {
+           set val $newviewopts($n,[lindex $opt 0])
            if {$val} {
                lappend rargs $pattern
            }
+       } elseif {[regexp {^r(\d+)$} [lindex $opt 1] type value]} {
+           regexp {^(.*_)} [lindex $opt 0] uselessvar button_id
+           set val $newviewopts($n,$button_id)
+           if {$val eq $value} {
+               lappend rargs $pattern
+           }
        } else {
+           set val $newviewopts($n,[lindex $opt 0])
            set val [string trim $val]
            if {$val ne {}} {
                set pfix [string range $pattern 0 end-1]
            }
        }
      }
+     set rargs [concat $rargs [shellsplit $newviewopts($n,refs)]]
      return [concat $rargs [shellsplit $newviewopts($n,args)]]
  }
  
@@@ -3824,14 -3744,22 +3854,22 @@@ proc decode_view_opts {n view_args} 
      global known_view_options newviewopts
  
      foreach opt $known_view_options {
+       set id [lindex $opt 0]
        if {[lindex $opt 1] eq "b"} {
+           # Checkboxes
+           set val 0
+         } elseif {[regexp {^r(\d+)$} [lindex $opt 1]]} {
+           # Radiobuttons
+           regexp {^(.*_)} $id uselessvar id
            set val 0
        } else {
+           # Text fields
            set val {}
        }
-       set newviewopts($n,[lindex $opt 0]) $val
+       set newviewopts($n,$id) $val
      }
      set oargs [list]
+     set refargs [list]
      foreach arg $view_args {
        if {[regexp -- {^-([0-9]+)$} $arg arg cnt]
            && ![info exists found(limit)]} {
            if {[info exists found($id)]} continue
            foreach pattern [lindex $opt 3] {
                if {![string match $pattern $arg]} continue
-               if {[lindex $opt 1] ne "b"} {
+               if {[lindex $opt 1] eq "b"} {
+                   # Check buttons
+                   set val 1
+               } elseif {[regexp {^r(\d+)$} [lindex $opt 1] match num]} {
+                   # Radio buttons
+                   regexp {^(.*_)} $id uselessvar id
+                   set val $num
+               } else {
+                   # Text input fields
                    set size [string length $pattern]
                    set val [string range $arg [expr {$size-1}] end]
-               } else {
-                   set val 1
                }
                set newviewopts($n,$id) $val
                set found($id) 1
            if {[info exists val]} break
        }
        if {[info exists val]} continue
-       lappend oargs $arg
+       if {[regexp {^-} $arg]} {
+           lappend oargs $arg
+       } else {
+           lappend refargs $arg
+       }
      }
+     set newviewopts($n,refs) [shellarglist $refargs]
      set newviewopts($n,args) [shellarglist $oargs]
  }
  
@@@ -3892,19 -3831,19 +3941,19 @@@ proc editview {} 
  
  proc vieweditor {top n title} {
      global newviewname newviewopts viewfiles bgcolor
 -    global known_view_options
 +    global known_view_options NS
  
 -    toplevel $top
 +    ttk_toplevel $top
-     wm title $top $title
+     wm title $top [concat $title [mc "-- criteria for selecting revisions"]]
      make_transient $top .
  
      # View name
 -    frame $top.nfr
 -    label $top.nl -text [mc "View Name:"]
 -    entry $top.name -width 20 -textvariable newviewname($n)
 +    ${NS}::frame $top.nfr
-     ${NS}::label $top.nl -text [mc "Name"]
++    ${NS}::label $top.nl -text [mc "View Name"]
 +    ${NS}::entry $top.name -width 20 -textvariable newviewname($n)
      pack $top.nfr -in $top -fill x -pady 5 -padx 3
-     pack $top.nl -in $top.nfr -side left -padx {0 30}
-     pack $top.name -in $top.nfr -side left
+     pack $top.nl -in $top.nfr -side left -padx {0 5}
+     pack $top.name -in $top.nfr -side left -padx {0 25}
  
      # View options
      set cframe $top.nfr
        if {$flags eq "+" || $flags eq "*"} {
            set cframe $top.fr$cnt
            incr cnt
 -          frame $cframe
 +          ${NS}::frame $cframe
            pack $cframe -in $top -fill x -pady 3 -padx 3
            set cexpand [expr {$flags eq "*"}]
 -          frame $cframe
+         } elseif {$flags eq ".." || $flags eq "*."} {
+           set cframe $top.fr$cnt
+           incr cnt
++          ${NS}::frame $cframe
+           pack $cframe -in $top -fill x -pady 3 -padx [list 15 3]
+           set cexpand [expr {$flags eq "*."}]
        } else {
            set lxpad 5
        }
  
-       if {$type eq "b"} {
+       if {$type eq "l"} {
 -            label $cframe.l_$id -text $title
++            ${NS}::label $cframe.l_$id -text $title
+             pack $cframe.l_$id -in $cframe -side left -pady [list 3 0] -anchor w
+       } elseif {$type eq "b"} {
 -          checkbutton $cframe.c_$id -text $title -variable newviewopts($n,$id)
 +          ${NS}::checkbutton $cframe.c_$id -text $title -variable newviewopts($n,$id)
            pack $cframe.c_$id -in $cframe -side left \
                -padx [list $lxpad 0] -expand $cexpand -anchor w
 -          radiobutton $cframe.c_$id -text $title -variable newviewopts($n,$button_id) -value $sz
+       } elseif {[regexp {^r(\d+)$} $type type sz]} {
+           regexp {^(.*_)} $id uselessvar button_id
++          ${NS}::radiobutton $cframe.c_$id -text $title -variable newviewopts($n,$button_id) -value $sz
+           pack $cframe.c_$id -in $cframe -side left \
+               -padx [list $lxpad 0] -expand $cexpand -anchor w
        } elseif {[regexp {^t(\d+)$} $type type sz]} {
 -          message $cframe.l_$id -aspect 1500 -text $title
 -          entry $cframe.e_$id -width $sz -background $bgcolor \
 +          ${NS}::label $cframe.l_$id -text $title
 +          ${NS}::entry $cframe.e_$id -width $sz -background $bgcolor \
                -textvariable newviewopts($n,$id)
            pack $cframe.l_$id -in $cframe -side left -padx [list $lxpad 0]
            pack $cframe.e_$id -in $cframe -side left -expand 1 -fill x
        } elseif {[regexp {^t(\d+)=$} $type type sz]} {
 -          message $cframe.l_$id -aspect 1500 -text $title
 -          entry $cframe.e_$id -width $sz -background $bgcolor \
 +          ${NS}::label $cframe.l_$id -text $title
 +          ${NS}::entry $cframe.e_$id -width $sz -background $bgcolor \
                -textvariable newviewopts($n,$id)
            pack $cframe.l_$id -in $cframe -side top -pady [list 3 0] -anchor w
            pack $cframe.e_$id -in $cframe -side top -fill x
 -          message $top.l -aspect 1500 -text $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
+           if {[info exists viewfiles($n)]} {
+               foreach f $viewfiles($n) {
+                   $top.t insert end $f
+                   $top.t insert end "\n"
+               }
+               $top.t delete {end - 1c} end
+               $top.t mark set insert 0.0
+           }
+           pack $top.t -in $top -side top -pady [list 0 5] -fill both -expand 1 -padx 3
        }
      }
  
-     # Path list
-     ${NS}::label $top.l \
-       -text [mc "Enter files and directories to include, one per line:"]
-     pack $top.l -in $top -side top -pady [list 7 0] -anchor w -padx 3
-     text $top.t -width 40 -height 5 -background $bgcolor -font uifont
-     if {[info exists viewfiles($n)]} {
-       foreach f $viewfiles($n) {
-           $top.t insert end $f
-           $top.t insert end "\n"
-       }
-       $top.t delete {end - 1c} end
-       $top.t mark set insert 0.0
-     }
-     pack $top.t -in $top -side top -pady [list 0 5] -fill both -expand 1 -padx 3
 -    frame $top.buts
 -    button $top.buts.ok -text [mc "OK"] -command [list newviewok $top $n]
 -    button $top.buts.apply -text [mc "Apply (F5)"] -command [list newviewok $top $n 1]
 -    button $top.buts.can -text [mc "Cancel"] -command [list destroy $top]
 +    ${NS}::frame $top.buts
 +    ${NS}::button $top.buts.ok -text [mc "OK"] -command [list newviewok $top $n]
 +    ${NS}::button $top.buts.apply -text [mc "Apply (F5)"] -command [list newviewok $top $n 1]
 +    ${NS}::button $top.buts.can -text [mc "Cancel"] -command [list destroy $top]
      bind $top <Control-Return> [list newviewok $top $n]
      bind $top <F5> [list newviewok $top $n 1]
      bind $top <Escape> [list destroy $top]
@@@ -6827,13 -6779,14 +6889,13 @@@ proc selectline {l isnew {desired_loc {
      make_secsel $id
  
      if {$isnew} {
 -      addtohistory [list selbyid $id]
 +      addtohistory [list selbyid $id 0] savecmitpos
      }
  
      $sha1entry delete 0 end
      $sha1entry insert 0 $id
      if {$autoselect} {
 -      $sha1entry selection from 0
 -      $sha1entry selection to end
 +      $sha1entry selection range 0 end
      }
      rhighlight_sel $id
  
@@@ -6978,12 -6931,10 +7040,12 @@@ proc reselectline {} 
      }
  }
  
 -proc addtohistory {cmd} {
 +proc addtohistory {cmd {saveproc {}}} {
      global history historyindex curview
  
 -    set elt [list $curview $cmd]
 +    unset_posvars
 +    save_position
 +    set elt [list $curview $cmd $saveproc {}]
      if {$historyindex > 0
        && [lindex $history [expr {$historyindex - 1}]] == $elt} {
        return
      .tf.bar.rightbut conf -state disabled
  }
  
 +# save the scrolling position of the diff display pane
 +proc save_position {} {
 +    global historyindex history
 +
 +    if {$historyindex < 1} return
 +    set hi [expr {$historyindex - 1}]
 +    set fn [lindex $history $hi 2]
 +    if {$fn ne {}} {
 +      lset history $hi 3 [eval $fn]
 +    }
 +}
 +
 +proc unset_posvars {} {
 +    global last_posvars
 +
 +    if {[info exists last_posvars]} {
 +      foreach {var val} $last_posvars {
 +          global $var
 +          catch {unset $var}
 +      }
 +      unset last_posvars
 +    }
 +}
 +
  proc godo {elt} {
 -    global curview
 +    global curview last_posvars
  
      set view [lindex $elt 0]
      set cmd [lindex $elt 1]
 +    set pv [lindex $elt 3]
      if {$curview != $view} {
        showview $view
      }
 +    unset_posvars
 +    foreach {var val} $pv {
 +      global $var
 +      set $var $val
 +    }
 +    set last_posvars $pv
      eval $cmd
  }
  
@@@ -7050,7 -6970,6 +7112,7 @@@ proc goback {} 
      focus .
  
      if {$historyindex > 1} {
 +      save_position
        incr historyindex -1
        godo [lindex $history [expr {$historyindex - 1}]]
        .tf.bar.rightbut conf -state normal
@@@ -7065,7 -6984,6 +7127,7 @@@ proc goforw {} 
      focus .
  
      if {$historyindex < [llength $history]} {
 +      save_position
        set cmd [lindex $history $historyindex]
        incr historyindex
        godo $cmd
@@@ -7393,7 -7311,7 +7455,7 @@@ proc diffcontextchange {n1 n2 op} 
      global diffcontextstring diffcontext
  
      if {[string is integer -strict $diffcontextstring]} {
-       if {$diffcontextstring > 0} {
+       if {$diffcontextstring >= 0} {
            set diffcontext $diffcontextstring
            reselectline
        }
@@@ -7411,8 -7329,13 +7473,13 @@@ proc getblobdiffs {ids} 
      global ignorespace
      global limitdiffs vfilelimit curview
      global diffencoding targetline diffnparents
+     global git_version
  
-     set cmd [diffcmd $ids "-p -C --cc --no-commit-id -U$diffcontext"]
+     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"]
      if {$ignorespace} {
        append cmd " -w"
      }
      filerun $bdf [list getblobdiffline $bdf $diffids]
  }
  
 +proc savecmitpos {} {
 +    global ctext cmitmode
 +
 +    if {$cmitmode eq "tree"} {
 +      return {}
 +    }
 +    return [list target_scrollpos [$ctext index @0,0]]
 +}
 +
 +proc savectextpos {} {
 +    global ctext
 +
 +    return [list target_scrollpos [$ctext index @0,0]]
 +}
 +
 +proc maybe_scroll_ctext {ateof} {
 +    global ctext target_scrollpos
 +
 +    if {![info exists target_scrollpos]} return
 +    if {!$ateof} {
 +      set nlines [expr {[winfo height $ctext]
 +                        / [font metrics textfont -linespace]}]
 +      if {[$ctext compare "$target_scrollpos + $nlines lines" <= end]} return
 +    }
 +    $ctext yview $target_scrollpos
 +    unset target_scrollpos
 +}
 +
  proc setinlist {var i val} {
      global $var
  
@@@ -7655,7 -7550,6 +7722,7 @@@ proc getblobdiffline {bdf ids} 
      if {[info exists seehere]} {
        mark_ctext_line [lindex [split $seehere .] 0]
      }
 +    maybe_scroll_ctext [eof $bdf]
      $ctext conf -state disabled
      if {[eof $bdf]} {
        close $bdf
@@@ -8015,6 -7909,11 +8082,11 @@@ proc gotocommit {} 
                }
                set id [lindex $matches 0]
            }
+       } else {
+           if {[catch {set id [exec git rev-parse --verify $sha1string]}]} {
+               error_popup [mc "Revision %s is not known" $sha1string]
+               return
+           }
        }
      }
      if {[commitinview $id $curview]} {
      if {[regexp {^[0-9a-fA-F]{4,}$} $sha1string]} {
        set msg [mc "SHA1 id %s is not known" $sha1string]
      } else {
-       set msg [mc "Tag/Head %s is not known" $sha1string]
+       set msg [mc "Revision %s is not in the current view" $sha1string]
      }
      error_popup $msg
  }
@@@ -8150,7 -8049,7 +8222,7 @@@ proc lineclick {x y id isnew} 
      }
  
      if {$isnew} {
 -      addtohistory [list lineclick $x $y $id 0]
 +      addtohistory [list lineclick $x $y $id 0] savectextpos
      }
      # fill the details pane with info about this line
      $ctext conf -state normal
            $ctext insert end "\n\t[mc "Date"]:\t$date\n"
        }
      }
 +    maybe_scroll_ctext 1
      $ctext conf -state disabled
      init_flist {}
  }
@@@ -8195,10 -8093,10 +8267,10 @@@ proc normalline {} 
      }
  }
  
 -proc selbyid {id} {
 +proc selbyid {id {isnew 1}} {
      global curview
      if {[commitinview $id $curview]} {
 -      selectline [rowofcommit $id] 1
 +      selectline [rowofcommit $id] $isnew
      }
  }
  
@@@ -8413,7 -8311,7 +8485,7 @@@ proc diffvssel {dirn} 
        set oldid $rowmenuid
        set newid [commitonrow $selectedline]
      }
 -    addtohistory [list doseldiff $oldid $newid]
 +    addtohistory [list doseldiff $oldid $newid] savectextpos
      doseldiff $oldid $newid
  }
  
@@@ -8441,7 -8339,7 +8513,7 @@@ proc doseldiff {oldid newid} 
  }
  
  proc mkpatch {} {
 -    global rowmenuid currentid commitinfo patchtop patchnum
 +    global rowmenuid currentid commitinfo patchtop patchnum NS
  
      if {![info exists currentid]} return
      set oldid $currentid
      set top .patch
      set patchtop $top
      catch {destroy $top}
 -    toplevel $top
 +    ttk_toplevel $top
      make_transient $top .
 -    label $top.title -text [mc "Generate patch"]
 +    ${NS}::label $top.title -text [mc "Generate patch"]
      grid $top.title - -pady 10
 -    label $top.from -text [mc "From:"]
 -    entry $top.fromsha1 -width 40 -relief flat
 +    ${NS}::label $top.from -text [mc "From:"]
 +    ${NS}::entry $top.fromsha1 -width 40
      $top.fromsha1 insert 0 $oldid
      $top.fromsha1 conf -state readonly
      grid $top.from $top.fromsha1 -sticky w
 -    entry $top.fromhead -width 60 -relief flat
 +    ${NS}::entry $top.fromhead -width 60
      $top.fromhead insert 0 $oldhead
      $top.fromhead conf -state readonly
      grid x $top.fromhead -sticky w
 -    label $top.to -text [mc "To:"]
 -    entry $top.tosha1 -width 40 -relief flat
 +    ${NS}::label $top.to -text [mc "To:"]
 +    ${NS}::entry $top.tosha1 -width 40
      $top.tosha1 insert 0 $newid
      $top.tosha1 conf -state readonly
      grid $top.to $top.tosha1 -sticky w
 -    entry $top.tohead -width 60 -relief flat
 +    ${NS}::entry $top.tohead -width 60
      $top.tohead insert 0 $newhead
      $top.tohead conf -state readonly
      grid x $top.tohead -sticky w
 -    button $top.rev -text [mc "Reverse"] -command mkpatchrev -padx 5
 -    grid $top.rev x -pady 10
 -    label $top.flab -text [mc "Output file:"]
 -    entry $top.fname -width 60
 +    ${NS}::button $top.rev -text [mc "Reverse"] -command mkpatchrev
 +    grid $top.rev x -pady 10 -padx 5
 +    ${NS}::label $top.flab -text [mc "Output file:"]
 +    ${NS}::entry $top.fname -width 60
      $top.fname insert 0 [file normalize "patch$patchnum.patch"]
      incr patchnum
      grid $top.flab $top.fname -sticky w
 -    frame $top.buts
 -    button $top.buts.gen -text [mc "Generate"] -command mkpatchgo
 -    button $top.buts.can -text [mc "Cancel"] -command mkpatchcan
 +    ${NS}::frame $top.buts
 +    ${NS}::button $top.buts.gen -text [mc "Generate"] -command mkpatchgo
 +    ${NS}::button $top.buts.can -text [mc "Cancel"] -command mkpatchcan
      bind $top <Key-Return> mkpatchgo
      bind $top <Key-Escape> mkpatchcan
      grid $top.buts.gen $top.buts.can
@@@ -8533,30 -8431,30 +8605,30 @@@ proc mkpatchcan {} 
  }
  
  proc mktag {} {
 -    global rowmenuid mktagtop commitinfo
 +    global rowmenuid mktagtop commitinfo NS
  
      set top .maketag
      set mktagtop $top
      catch {destroy $top}
 -    toplevel $top
 +    ttk_toplevel $top
      make_transient $top .
 -    label $top.title -text [mc "Create tag"]
 +    ${NS}::label $top.title -text [mc "Create tag"]
      grid $top.title - -pady 10
 -    label $top.id -text [mc "ID:"]
 -    entry $top.sha1 -width 40 -relief flat
 +    ${NS}::label $top.id -text [mc "ID:"]
 +    ${NS}::entry $top.sha1 -width 40
      $top.sha1 insert 0 $rowmenuid
      $top.sha1 conf -state readonly
      grid $top.id $top.sha1 -sticky w
 -    entry $top.head -width 60 -relief flat
 +    ${NS}::entry $top.head -width 60
      $top.head insert 0 [lindex $commitinfo($rowmenuid) 0]
      $top.head conf -state readonly
      grid x $top.head -sticky w
 -    label $top.tlab -text [mc "Tag name:"]
 -    entry $top.tag -width 60
 +    ${NS}::label $top.tlab -text [mc "Tag name:"]
 +    ${NS}::entry $top.tag -width 60
      grid $top.tlab $top.tag -sticky w
 -    frame $top.buts
 -    button $top.buts.gen -text [mc "Create"] -command mktaggo
 -    button $top.buts.can -text [mc "Cancel"] -command mktagcan
 +    ${NS}::frame $top.buts
 +    ${NS}::button $top.buts.gen -text [mc "Create"] -command mktaggo
 +    ${NS}::button $top.buts.can -text [mc "Cancel"] -command mktagcan
      bind $top <Key-Return> mktaggo
      bind $top <Key-Escape> mktagcan
      grid $top.buts.gen $top.buts.can
@@@ -8639,34 -8537,34 +8711,34 @@@ proc mktaggo {} 
  }
  
  proc writecommit {} {
 -    global rowmenuid wrcomtop commitinfo wrcomcmd
 +    global rowmenuid wrcomtop commitinfo wrcomcmd NS
  
      set top .writecommit
      set wrcomtop $top
      catch {destroy $top}
 -    toplevel $top
 +    ttk_toplevel $top
      make_transient $top .
 -    label $top.title -text [mc "Write commit to file"]
 +    ${NS}::label $top.title -text [mc "Write commit to file"]
      grid $top.title - -pady 10
 -    label $top.id -text [mc "ID:"]
 -    entry $top.sha1 -width 40 -relief flat
 +    ${NS}::label $top.id -text [mc "ID:"]
 +    ${NS}::entry $top.sha1 -width 40
      $top.sha1 insert 0 $rowmenuid
      $top.sha1 conf -state readonly
      grid $top.id $top.sha1 -sticky w
 -    entry $top.head -width 60 -relief flat
 +    ${NS}::entry $top.head -width 60
      $top.head insert 0 [lindex $commitinfo($rowmenuid) 0]
      $top.head conf -state readonly
      grid x $top.head -sticky w
 -    label $top.clab -text [mc "Command:"]
 -    entry $top.cmd -width 60 -textvariable wrcomcmd
 +    ${NS}::label $top.clab -text [mc "Command:"]
 +    ${NS}::entry $top.cmd -width 60 -textvariable wrcomcmd
      grid $top.clab $top.cmd -sticky w -pady 10
 -    label $top.flab -text [mc "Output file:"]
 -    entry $top.fname -width 60
 +    ${NS}::label $top.flab -text [mc "Output file:"]
 +    ${NS}::entry $top.fname -width 60
      $top.fname insert 0 [file normalize "commit-[string range $rowmenuid 0 6]"]
      grid $top.flab $top.fname -sticky w
 -    frame $top.buts
 -    button $top.buts.gen -text [mc "Write"] -command wrcomgo
 -    button $top.buts.can -text [mc "Cancel"] -command wrcomcan
 +    ${NS}::frame $top.buts
 +    ${NS}::button $top.buts.gen -text [mc "Write"] -command wrcomgo
 +    ${NS}::button $top.buts.can -text [mc "Cancel"] -command wrcomcan
      bind $top <Key-Return> wrcomgo
      bind $top <Key-Escape> wrcomcan
      grid $top.buts.gen $top.buts.can
@@@ -8697,25 -8595,25 +8769,25 @@@ proc wrcomcan {} 
  }
  
  proc mkbranch {} {
 -    global rowmenuid mkbrtop
 +    global rowmenuid mkbrtop NS
  
      set top .makebranch
      catch {destroy $top}
 -    toplevel $top
 +    ttk_toplevel $top
      make_transient $top .
 -    label $top.title -text [mc "Create new branch"]
 +    ${NS}::label $top.title -text [mc "Create new branch"]
      grid $top.title - -pady 10
 -    label $top.id -text [mc "ID:"]
 -    entry $top.sha1 -width 40 -relief flat
 +    ${NS}::label $top.id -text [mc "ID:"]
 +    ${NS}::entry $top.sha1 -width 40
      $top.sha1 insert 0 $rowmenuid
      $top.sha1 conf -state readonly
      grid $top.id $top.sha1 -sticky w
 -    label $top.nlab -text [mc "Name:"]
 -    entry $top.name -width 40
 +    ${NS}::label $top.nlab -text [mc "Name:"]
 +    ${NS}::entry $top.name -width 40
      grid $top.nlab $top.name -sticky w
 -    frame $top.buts
 -    button $top.buts.go -text [mc "Create"] -command [list mkbrgo $top]
 -    button $top.buts.can -text [mc "Cancel"] -command "catch {destroy $top}"
 +    ${NS}::frame $top.buts
 +    ${NS}::button $top.buts.go -text [mc "Create"] -command [list mkbrgo $top]
 +    ${NS}::button $top.buts.can -text [mc "Cancel"] -command "catch {destroy $top}"
      bind $top <Key-Return> [list mkbrgo $top]
      bind $top <Key-Escape> "catch {destroy $top}"
      grid $top.buts.go $top.buts.can
@@@ -8860,31 -8758,34 +8932,31 @@@ proc cherrypick {} 
  }
  
  proc resethead {} {
 -    global mainhead rowmenuid confirm_ok resettype
 +    global mainhead rowmenuid confirm_ok resettype NS
  
      set confirm_ok 0
      set w ".confirmreset"
 -    toplevel $w
 +    ttk_toplevel $w
      make_transient $w .
      wm title $w [mc "Confirm reset"]
 -    message $w.m -text \
 -      [mc "Reset branch %s to %s?" $mainhead [string range $rowmenuid 0 7]] \
 -      -justify center -aspect 1000
 +    ${NS}::label $w.m -text \
 +      [mc "Reset branch %s to %s?" $mainhead [string range $rowmenuid 0 7]]
      pack $w.m -side top -fill x -padx 20 -pady 20
 -    frame $w.f -relief sunken -border 2
 -    message $w.f.rt -text [mc "Reset type:"] -aspect 1000
 -    grid $w.f.rt -sticky w
 +    ${NS}::labelframe $w.f -text [mc "Reset type:"]
      set resettype mixed
 -    radiobutton $w.f.soft -value soft -variable resettype -justify left \
 +    ${NS}::radiobutton $w.f.soft -value soft -variable resettype \
        -text [mc "Soft: Leave working tree and index untouched"]
      grid $w.f.soft -sticky w
 -    radiobutton $w.f.mixed -value mixed -variable resettype -justify left \
 +    ${NS}::radiobutton $w.f.mixed -value mixed -variable resettype \
        -text [mc "Mixed: Leave working tree untouched, reset index"]
      grid $w.f.mixed -sticky w
 -    radiobutton $w.f.hard -value hard -variable resettype -justify left \
 +    ${NS}::radiobutton $w.f.hard -value hard -variable resettype \
        -text [mc "Hard: Reset working tree and index\n(discard ALL local changes)"]
      grid $w.f.hard -sticky w
 -    pack $w.f -side top -fill x
 -    button $w.ok -text [mc OK] -command "set confirm_ok 1; destroy $w"
 +    pack $w.f -side top -fill x -padx 4
 +    ${NS}::button $w.ok -text [mc OK] -command "set confirm_ok 1; destroy $w"
      pack $w.ok -side left -fill x -padx 20 -pady 20
 -    button $w.cancel -text [mc Cancel] -command "destroy $w"
 +    ${NS}::button $w.cancel -text [mc Cancel] -command "destroy $w"
      bind $w <Key-Escape> [list destroy $w]
      pack $w.cancel -side right -fill x -padx 20 -pady 20
      bind $w <Visibility> "grab $w; focus $w"
@@@ -9032,7 -8933,7 +9104,7 @@@ proc rmbranch {} 
  
  # Display a list of tags and heads
  proc showrefs {} {
 -    global showrefstop bgcolor fgcolor selectbgcolor
 +    global showrefstop bgcolor fgcolor selectbgcolor NS
      global bglist fglist reflistfilter reflist maincursor
  
      set top .showrefs
        refill_reflist
        return
      }
 -    toplevel $top
 +    ttk_toplevel $top
      wm title $top [mc "Tags and heads: %s" [file tail [pwd]]]
      make_transient $top .
      text $top.list -background $bgcolor -foreground $fgcolor \
      $top.list tag configure highlight -background $selectbgcolor
      lappend bglist $top.list
      lappend fglist $top.list
 -    scrollbar $top.ysb -command "$top.list yview" -orient vertical
 -    scrollbar $top.xsb -command "$top.list xview" -orient horizontal
 +    ${NS}::scrollbar $top.ysb -command "$top.list yview" -orient vertical
 +    ${NS}::scrollbar $top.xsb -command "$top.list xview" -orient horizontal
      grid $top.list $top.ysb -sticky nsew
      grid $top.xsb x -sticky ew
 -    frame $top.f
 -    label $top.f.l -text "[mc "Filter"]: "
 -    entry $top.f.e -width 20 -textvariable reflistfilter
 +    ${NS}::frame $top.f
 +    ${NS}::label $top.f.l -text "[mc "Filter"]: "
 +    ${NS}::entry $top.f.e -width 20 -textvariable reflistfilter
      set reflistfilter "*"
      trace add variable reflistfilter write reflistfilter_change
      pack $top.f.e -side right -fill x -expand 1
      pack $top.f.l -side left
      grid $top.f - -sticky ew -pady 2
 -    button $top.close -command [list destroy $top] -text [mc "Close"]
 +    ${NS}::button $top.close -command [list destroy $top] -text [mc "Close"]
      bind $top <Key-Escape> [list destroy $top]
      grid $top.close -
      grid columnconfigure $top 0 -weight 1
@@@ -9263,7 -9164,7 +9335,7 @@@ proc getallclines {fd} 
      global allparents allchildren idtags idheads nextarc
      global arcnos arcids arctags arcout arcend arcstart archeads growing
      global seeds allcommits cachedarcs allcupdate
 -    
 +
      set nid 0
      while {[incr nid] <= 1000 && [gets $fd line] >= 0} {
        set id [lindex $line 0]
@@@ -10325,7 -10226,7 +10397,7 @@@ proc showtag {tag isnew} 
      global ctext tagcontents tagids linknum tagobjid
  
      if {$isnew} {
 -      addtohistory [list showtag $tag 0]
 +      addtohistory [list showtag $tag 0] savectextpos
      }
      $ctext conf -state normal
      clear_ctext
        set text "[mc "Tag"]: $tag\n[mc "Id"]:  $tagids($tag)"
      }
      appendwithlinks $text {}
 +    maybe_scroll_ctext
      $ctext conf -state disabled
      init_flist {}
  }
@@@ -10361,20 -10261,19 +10433,20 @@@ proc doquit {} 
  }
  
  proc mkfontdisp {font top which} {
 -    global fontattr fontpref $font
 +    global fontattr fontpref $font NS use_ttk
  
      set fontpref($font) [set $font]
 -    button $top.${font}but -text $which -font optionfont \
 +    ${NS}::button $top.${font}but -text $which \
        -command [list choosefont $font $which]
 -    label $top.$font -relief flat -font $font \
 +    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
  }
  
  proc choosefont {font which} {
      global fontparam fontlist fonttop fontattr
 -    global prefstop
 +    global prefstop NS
  
      set fontparam(which) $which
      set fontparam(font) $font
      if {![winfo exists $top]} {
        font create sample
        eval font config sample [font actual $font]
 -      toplevel $top
 +      ttk_toplevel $top
        make_transient $top $prefstop
        wm title $top [mc "Gitk font chooser"]
 -      label $top.l -textvariable fontparam(which)
 +      ${NS}::label $top.l -textvariable fontparam(which)
        pack $top.l -side top
        set fontlist [lsort [font families]]
 -      frame $top.f
 +      ${NS}::frame $top.f
        listbox $top.f.fam -listvariable fontlist \
            -yscrollcommand [list $top.f.sb set]
        bind $top.f.fam <<ListboxSelect>> selfontfam
 -      scrollbar $top.f.sb -command [list $top.f.fam yview]
 +      ${NS}::scrollbar $top.f.sb -command [list $top.f.fam yview]
        pack $top.f.sb -side right -fill y
        pack $top.f.fam -side left -fill both -expand 1
        pack $top.f -side top -fill both -expand 1
 -      frame $top.g
 +      ${NS}::frame $top.g
        spinbox $top.g.size -from 4 -to 40 -width 4 \
            -textvariable fontparam(size) \
            -validatecommand {string is integer -strict %s}
            -fill black -tags text
        bind $top.c <Configure> [list centertext $top.c]
        pack $top.c -side top -fill x
 -      frame $top.buts
 -      button $top.buts.ok -text [mc "OK"] -command fontok -default active
 -      button $top.buts.can -text [mc "Cancel"] -command fontcan -default normal
 +      ${NS}::frame $top.buts
 +      ${NS}::button $top.buts.ok -text [mc "OK"] -command fontok -default active
 +      ${NS}::button $top.buts.can -text [mc "Cancel"] -command fontcan -default normal
        bind $top <Key-Return> fontok
        bind $top <Key-Escape> fontcan
        grid $top.buts.ok $top.buts.can
@@@ -10457,7 -10356,7 +10529,7 @@@ proc fontok {} 
      }
      set w $prefstop.$f
      $w conf -text $fontparam(family) -font $fontpref($f)
 -      
 +
      fontcan
  }
  
@@@ -10472,28 -10371,6 +10544,28 @@@ proc fontcan {} 
      }
  }
  
 +if {[package vsatisfies [package provide Tk] 8.6]} {
 +    # In Tk 8.6 we have a native font chooser dialog. Overwrite the above
 +    # function to make use of it.
 +    proc choosefont {font which} {
 +      tk fontchooser configure -title $which -font $font \
 +          -command [list on_choosefont $font $which]
 +      tk fontchooser show
 +    }
 +    proc on_choosefont {font which newfont} {
 +      global fontparam
 +      puts stderr "$font $newfont"
 +      array set f [font actual $newfont]
 +      set fontparam(which) $which
 +      set fontparam(font) $font
 +      set fontparam(family) $f(-family)
 +      set fontparam(size) $f(-size)
 +      set fontparam(weight) $f(-weight)
 +      set fontparam(slant) $f(-slant)
 +      fontok
 +    }
 +}
 +
  proc selfontfam {} {
      global fonttop fontparam
  
@@@ -10510,10 -10387,11 +10582,11 @@@ proc chg_fontparam {v sub op} 
  }
  
  proc doprefs {} {
 -    global maxwidth maxgraphpct
 +    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 hideremotes
  
      set top .gitkprefs
      set prefstop $top
        return
      }
      foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
-                  limitdiffs tabstop perfile_attrs} {
+                  limitdiffs tabstop perfile_attrs hideremotes} {
        set oldprefs($v) [set $v]
      }
 -    toplevel $top
 +    ttk_toplevel $top
      wm title $top [mc "Gitk preferences"]
      make_transient $top .
 -    label $top.ldisp -text [mc "Commit list display options"]
 +    ${NS}::label $top.ldisp -text [mc "Commit list display options"]
      grid $top.ldisp - -sticky w -pady 10
 -    label $top.spacer -text " "
 -    label $top.maxwidthl -text [mc "Maximum graph width (lines)"] \
 -      -font optionfont
 +    ${NS}::label $top.spacer -text " "
 +    ${NS}::label $top.maxwidthl -text [mc "Maximum graph width (lines)"]
      spinbox $top.maxwidth -from 0 -to 100 -width 4 -textvariable maxwidth
      grid $top.spacer $top.maxwidthl $top.maxwidth -sticky w
 -    label $top.maxpctl -text [mc "Maximum graph width (% of pane)"] \
 -      -font optionfont
 +    ${NS}::label $top.maxpctl -text [mc "Maximum graph width (% of pane)"]
      spinbox $top.maxpct -from 1 -to 100 -width 4 -textvariable maxgraphpct
      grid x $top.maxpctl $top.maxpct -sticky w
 -    checkbutton $top.showlocal -text [mc "Show local changes"] \
 -      -font optionfont -variable showlocalchanges
 +    ${NS}::checkbutton $top.showlocal -text [mc "Show local changes"] \
 +      -variable showlocalchanges
      grid x $top.showlocal -sticky w
 -    checkbutton $top.autoselect -text [mc "Auto-select SHA1"] \
 -      -font optionfont -variable autoselect
 +    ${NS}::checkbutton $top.autoselect -text [mc "Auto-select SHA1"] \
 +      -variable autoselect
      grid x $top.autoselect -sticky w
  
 -    label $top.ddisp -text [mc "Diff display options"]
 +    ${NS}::label $top.ddisp -text [mc "Diff display options"]
      grid $top.ddisp - -sticky w -pady 10
 -    label $top.tabstopl -text [mc "Tab spacing"] -font optionfont
 +    ${NS}::label $top.tabstopl -text [mc "Tab spacing"]
      spinbox $top.tabstop -from 1 -to 20 -width 4 -textvariable tabstop
      grid x $top.tabstopl $top.tabstop -sticky w
 -    checkbutton $top.ntag -text [mc "Display nearby tags"] \
 -      -font optionfont -variable showneartags
 +    ${NS}::checkbutton $top.ntag -text [mc "Display nearby tags"] \
 +      -variable showneartags
      grid x $top.ntag -sticky w
 -    checkbutton $top.hideremotes -text [mc "Hide remote refs"] \
 -      -font optionfont -variable hideremotes
++    ${NS}::checkbutton $top.hideremotes -text [mc "Hide remote refs"] \
++      -variable hideremotes
+     grid x $top.hideremotes -sticky w
 -    checkbutton $top.ldiff -text [mc "Limit diffs to listed paths"] \
 -      -font optionfont -variable limitdiffs
 +    ${NS}::checkbutton $top.ldiff -text [mc "Limit diffs to listed paths"] \
 +      -variable limitdiffs
      grid x $top.ldiff -sticky w
 -    checkbutton $top.lattr -text [mc "Support per-file encodings"] \
 -      -font optionfont -variable perfile_attrs
 +    ${NS}::checkbutton $top.lattr -text [mc "Support per-file encodings"] \
 +      -variable perfile_attrs
      grid x $top.lattr -sticky w
  
 -    entry $top.extdifft -textvariable extdifftool
 -    frame $top.extdifff
 -    label $top.extdifff.l -text [mc "External diff tool" ] -font optionfont \
 -      -padx 10
 -    button $top.extdifff.b -text [mc "Choose..."] -font optionfont \
 -      -command choose_extdiff
 +    ${NS}::entry $top.extdifft -textvariable extdifftool
 +    ${NS}::frame $top.extdifff
 +    ${NS}::label $top.extdifff.l -text [mc "External diff tool" ]
 +    ${NS}::button $top.extdifff.b -text [mc "Choose..."] -command choose_extdiff
      pack $top.extdifff.l $top.extdifff.b -side left
 -    grid x $top.extdifff $top.extdifft -sticky w
 +    pack configure $top.extdifff.l -padx 10
 +    grid x $top.extdifff $top.extdifft -sticky ew
  
 -    label $top.cdisp -text [mc "Colors: press to choose"]
 +    ${NS}::label $top.cdisp -text [mc "Colors: press to choose"]
      grid $top.cdisp - -sticky w -pady 10
      label $top.bg -padx 40 -relief sunk -background $bgcolor
 -    button $top.bgbut -text [mc "Background"] -font optionfont \
 +    ${NS}::button $top.bgbut -text [mc "Background"] \
        -command [list choosecolor bgcolor {} $top.bg [mc "background"] setbg]
      grid x $top.bgbut $top.bg -sticky w
      label $top.fg -padx 40 -relief sunk -background $fgcolor
 -    button $top.fgbut -text [mc "Foreground"] -font optionfont \
 +    ${NS}::button $top.fgbut -text [mc "Foreground"] \
        -command [list choosecolor fgcolor {} $top.fg [mc "foreground"] setfg]
      grid x $top.fgbut $top.fg -sticky w
      label $top.diffold -padx 40 -relief sunk -background [lindex $diffcolors 0]
 -    button $top.diffoldbut -text [mc "Diff: old lines"] -font optionfont \
 +    ${NS}::button $top.diffoldbut -text [mc "Diff: old lines"] \
        -command [list choosecolor diffcolors 0 $top.diffold [mc "diff old lines"] \
                      [list $ctext tag conf d0 -foreground]]
      grid x $top.diffoldbut $top.diffold -sticky w
      label $top.diffnew -padx 40 -relief sunk -background [lindex $diffcolors 1]
 -    button $top.diffnewbut -text [mc "Diff: new lines"] -font optionfont \
 +    ${NS}::button $top.diffnewbut -text [mc "Diff: new lines"] \
        -command [list choosecolor diffcolors 1 $top.diffnew [mc "diff new lines"] \
                      [list $ctext tag conf dresult -foreground]]
      grid x $top.diffnewbut $top.diffnew -sticky w
      label $top.hunksep -padx 40 -relief sunk -background [lindex $diffcolors 2]
 -    button $top.hunksepbut -text [mc "Diff: hunk header"] -font optionfont \
 +    ${NS}::button $top.hunksepbut -text [mc "Diff: hunk header"] \
        -command [list choosecolor diffcolors 2 $top.hunksep \
                      [mc "diff hunk header"] \
                      [list $ctext tag conf hunksep -foreground]]
      grid x $top.hunksepbut $top.hunksep -sticky w
      label $top.markbgsep -padx 40 -relief sunk -background $markbgcolor
 -    button $top.markbgbut -text [mc "Marked line bg"] -font optionfont \
 +    ${NS}::button $top.markbgbut -text [mc "Marked line bg"] \
        -command [list choosecolor markbgcolor {} $top.markbgsep \
                      [mc "marked line background"] \
                      [list $ctext tag conf omark -background]]
      grid x $top.markbgbut $top.markbgsep -sticky w
      label $top.selbgsep -padx 40 -relief sunk -background $selectbgcolor
 -    button $top.selbgbut -text [mc "Select bg"] -font optionfont \
 +    ${NS}::button $top.selbgbut -text [mc "Select bg"] \
        -command [list choosecolor selectbgcolor {} $top.selbgsep [mc "background"] setselbg]
      grid x $top.selbgbut $top.selbgsep -sticky w
  
 -    label $top.cfont -text [mc "Fonts: press to choose"]
 +    ${NS}::label $top.cfont -text [mc "Fonts: press to choose"]
      grid $top.cfont - -sticky w -pady 10
      mkfontdisp mainfont $top [mc "Main font"]
      mkfontdisp textfont $top [mc "Diff display font"]
      mkfontdisp uifont $top [mc "User interface font"]
  
 -    frame $top.buts
 -    button $top.buts.ok -text [mc "OK"] -command prefsok -default active
 -    button $top.buts.can -text [mc "Cancel"] -command prefscan -default normal
 +    if {!$use_ttk} {
 +      foreach w {maxpctl maxwidthl showlocal autoselect tabstopl ntag
 +          ldiff lattr extdifff.l extdifff.b bgbut fgbut
 +          diffoldbut diffnewbut hunksepbut markbgbut selbgbut} {
 +          $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
      bind $top <Key-Return> prefsok
      bind $top <Key-Escape> prefscan
      grid $top.buts.ok $top.buts.can
      grid columnconfigure $top.buts 0 -weight 1 -uniform a
      grid columnconfigure $top.buts 1 -weight 1 -uniform a
      grid $top.buts - - -pady 10 -sticky ew
 +    grid columnconfigure $top 2 -weight 1
      bind $top <Visibility> "focus $top.buts.ok"
  }
  
@@@ -10684,7 -10559,7 +10760,7 @@@ proc prefscan {} 
      global oldprefs prefstop
  
      foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
-                  limitdiffs tabstop perfile_attrs} {
+                  limitdiffs tabstop perfile_attrs hideremotes} {
        global $v
        set $v $oldprefs($v)
      }
@@@ -10698,6 -10573,7 +10774,7 @@@ proc prefsok {} 
      global oldprefs prefstop showneartags showlocalchanges
      global fontpref mainfont textfont uifont
      global limitdiffs treediffs perfile_attrs
+     global hideremotes
  
      catch {destroy $prefstop}
      unset prefstop
          $limitdiffs != $oldprefs(limitdiffs)} {
        reselectline
      }
+     if {$hideremotes != $oldprefs(hideremotes)} {
+       rereadrefs
+     }
  }
  
  proc formatdate {d} {
@@@ -11038,7 -10917,7 +11118,7 @@@ proc gitattr {path attr default} 
      } else {
        set r "unspecified"
        if {![catch {set line [exec git check-attr $attr -- $path]}]} {
-           regexp "(.*): encoding: (.*)" $line m f r
+           regexp "(.*): $attr: (.*)" $line m f r
        }
        set path_attr_cache($attr,$path) $r
      }
@@@ -11066,7 -10945,7 +11146,7 @@@ proc cache_gitattr {attr pathlist} 
        set newlist [lrange $newlist $lim end]
        if {![catch {set rlist [eval exec git check-attr $attr -- $head]}]} {
            foreach row [split $rlist "\n"] {
-               if {[regexp "(.*): encoding: (.*)" $row m path value]} {
+               if {[regexp "(.*): $attr: (.*)" $row m path value]} {
                    if {[string index $path 0] eq "\""} {
                        set path [encoding convertfrom [lindex $path 0]]
                    }
@@@ -11148,6 -11027,7 +11228,7 @@@ set mingaplen 10
  set cmitmode "patch"
  set wrapcomment "none"
  set showneartags 1
+ set hideremotes 0
  set maxrefs 20
  set maxlinelen 200
  set showlocalchanges 1
@@@ -11291,10 -11171,7 +11372,11 @@@ set nullid2 "00000000000000000000000000
  set nullfile "/dev/null"
  
  set have_tk85 [expr {[package vcompare $tk_version "8.5"] >= 0}]
 +if {![info exists use_ttk]} {
 +    set use_ttk [llength [info commands ::ttk::style]]
 +}
 +set NS [expr {$use_ttk ? "ttk" : ""}]
+ set git_version [join [lrange [split [lindex [exec git version] end] .] 0 2] .]
  
  set runq {}
  set history {}