2 # Tcl ignores the next line -*- tcl -*- \
3 if test "z$*" = zversion \
4 ||
test "z$*" = z--version
; \
6 echo 'git-gui version @@GITGUI_VERSION@@'; \
10 exec wish
"$argv0" -- "$@"
12 set appvers
{@@GITGUI_VERSION@@
}
13 set copyright
[string map
[list
(c
) \u00a9] {
14 Copyright
(c
) 2006-2010 Shawn Pearce
, et. al.
16 This program is free software
; you can redistribute it and
/or modify
17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation
; either version
2 of the License
, or
19 (at your option
) any later version.
21 This program is distributed
in the hope that it will be useful
,
22 but WITHOUT ANY WARRANTY
; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU General Public License
for more details.
26 You should have received a copy of the GNU General Public License
27 along with this program
; if not
, write to the Free Software
28 Foundation
, Inc.
, 59 Temple Place
, Suite
330, Boston
, MA
02111-1307 USA
}]
30 ######################################################################
32 ## Tcl/Tk sanity check
34 if {[catch
{package require Tcl
8.4} err
]
35 ||
[catch
{package require Tk
8.4} err
]
41 -title "git-gui: fatal error" \
46 catch
{rename send
{}} ; # What an evil concept...
48 ######################################################################
52 set oguilib
{@@GITGUI_LIBDIR@@
}
53 set oguirel
{@@GITGUI_RELATIVE@@
}
54 if {$oguirel eq
{1}} {
55 set oguilib
[file dirname [file normalize
$argv0]]
56 if {[file tail $oguilib] eq
{git-core
}} {
57 set oguilib
[file dirname $oguilib]
59 set oguilib
[file dirname $oguilib]
60 set oguilib
[file join $oguilib share git-gui lib
]
61 set oguimsg
[file join $oguilib msgs
]
62 } elseif
{[string match @@
* $oguirel]} {
63 set oguilib
[file join [file dirname [file normalize
$argv0]] lib
]
64 set oguimsg
[file join [file dirname [file normalize
$argv0]] po
]
66 set oguimsg
[file join $oguilib msgs
]
70 ######################################################################
72 ## enable verbose loading?
74 if {![catch
{set _verbose
$env(GITGUI_VERBOSE
)}]} {
76 rename auto_load real__auto_load
77 proc auto_load
{name args
} {
78 puts stderr
"auto_load $name"
79 return [uplevel
1 real__auto_load
$name $args]
81 rename
source real__source
83 puts stderr
"source $name"
84 uplevel
1 real__source
$name
86 if {[tk windowingsystem
] eq
"win32"} { console show
}
89 ######################################################################
91 ## Internationalization (i18n) through msgcat and gettext. See
92 ## http://www.gnu.org/software/gettext/manual/html_node/Tcl.html
94 package require msgcat
96 # Check for Windows 7 MUI language pack (missed by msgcat < 1.4.4)
97 if {[tk windowingsystem
] eq
"win32"
98 && [package vcompare
[package provide msgcat
] 1.4.4] < 0
100 proc _mc_update_locale
{} {
101 set key
{HKEY_CURRENT_USER\Control Panel\Desktop
}
103 package require registry
104 set uilocale
[registry get
$key "PreferredUILanguages"]
105 msgcat
::ConvertLocale
[string map
{- _
} [lindex
$uilocale 0]]
107 if {[string length
$uilocale] > 0} {
108 msgcat
::mclocale
$uilocale
115 proc _mc_trim
{fmt} {
116 set cmk
[string first @@
$fmt]
118 return [string range
$fmt 0 [expr {$cmk - 1}]]
123 proc mc
{en_fmt args
} {
124 set fmt [_mc_trim
[::msgcat
::mc
$en_fmt]]
125 if {[catch
{set msg
[eval [list format
$fmt] $args]} err
]} {
126 set msg
[eval [list format
[_mc_trim
$en_fmt]] $args]
132 return [join $args {}]
135 ::msgcat
::mcload
$oguimsg
138 ######################################################################
140 ## On Mac, bring the current Wish process window to front
142 if {[tk windowingsystem
] eq
"aqua"} {
144 exec osascript
-e [format
{
145 tell application
"System Events"
146 set frontmost of processes whose unix id is
%d to true
152 ######################################################################
156 set _appname
{Git Gui
}
165 set _shellpath
{@@SHELL_PATH@@
}
167 set _trace
[lsearch
-exact $argv --trace]
169 set argv
[lreplace
$argv $_trace $_trace]
171 if {[tk windowingsystem
] eq
"win32"} { console show
}
176 # variable for the last merged branch (useful for a default when deleting
178 set _last_merged_branch
{}
181 global _shellpath env
182 if {[string match @@
* $_shellpath]} {
183 if {[info exists env
(SHELL
)]} {
202 return [eval [list
file join $_gitdir] $args]
205 proc gitexec
{args
} {
207 if {$_gitexec eq
{}} {
208 if {[catch
{set _gitexec
[git
--exec-path]} err
]} {
209 error
"Git not installed?\n\n$err"
212 set _gitexec
[exec cygpath \
217 set _gitexec
[file normalize
$_gitexec]
223 return [eval [list
file join $_gitexec] $args]
226 proc githtmldir
{args
} {
228 if {$_githtmldir eq
{}} {
229 if {[catch
{set _githtmldir
[git
--html-path]}]} {
230 # Git not installed or option not yet supported
234 set _githtmldir
[exec cygpath \
239 set _githtmldir
[file normalize
$_githtmldir]
245 return [eval [list
file join $_githtmldir] $args]
253 if {[tk windowingsystem
] eq
{aqua
}} {
260 if {$
::tcl_platform
(platform
) eq
{windows
}} {
268 if {$_iscygwin eq
{}} {
269 if {$
::tcl_platform
(platform
) eq
{windows
}} {
270 if {[catch
{set p
[exec cygpath
--windir]} err
]} {
282 proc is_enabled
{option
} {
283 global enabled_options
284 if {[catch
{set on
$enabled_options($option)}]} {return 0}
288 proc enable_option
{option
} {
289 global enabled_options
290 set enabled_options
($option) 1
293 proc disable_option
{option
} {
294 global enabled_options
295 set enabled_options
($option) 0
298 ######################################################################
302 proc is_many_config
{name
} {
303 switch
-glob -- $name {
313 proc is_config_true
{name
} {
315 if {[catch
{set v
$repo_config($name)}]} {
318 set v
[string tolower
$v]
319 if {$v eq
{} ||
$v eq
{true
} ||
$v eq
{1} ||
$v eq
{yes} ||
$v eq
{on
}} {
326 proc is_config_false
{name
} {
328 if {[catch
{set v
$repo_config($name)}]} {
331 set v
[string tolower
$v]
332 if {$v eq
{false
} ||
$v eq
{0} ||
$v eq
{no
} ||
$v eq
{off
}} {
339 proc get_config
{name
} {
341 if {[catch
{set v
$repo_config($name)}]} {
353 if {$_isbare eq
{}} {
355 set _bare
[git rev-parse
--is-bare-repository]
357 true
{ set _isbare
1 }
358 false
{ set _isbare
0}
362 if {[is_config_true core.bare
]
363 ||
($_gitworktree eq
{}
364 && [lindex
[file split $_gitdir] end
] ne
{.git
})} {
374 ######################################################################
378 proc _trace_exec
{cmd
} {
379 if {!$
::_trace
} return
385 if {[regexp
{[ \t\r\n'"$?*]} $v]} {
393 #'" fix poor old emacs font-lock mode
395 proc _git_cmd {name} {
398 if {[catch {set v $_git_cmd_path($name)}]} {
402 --exec-path { return [list $::_git $name] }
405 set p [gitexec git-$name$::_search_exe]
406 if {[file exists $p]} {
408 } elseif {[is_Windows] && [file exists [gitexec git-$name]]} {
409 # Try to determine what sort of magic will make
410 # git-$name go and do its thing, because native
411 # Tcl on Windows doesn't know it.
413 set p [gitexec git-$name]
418 switch -glob -- [lindex $s 0] {
420 #!*perl { set i perl }
421 #!*python { set i python }
422 default { error "git-
$name is not supported
: $s" }
426 if {![info exists interp]} {
427 set interp [_which $i]
430 error "git-
$name requires
$i (not
in PATH
)"
432 set v [concat [list $interp] [lrange $s 1 end] [list $p]]
434 # Assume it is builtin to git somehow and we
435 # aren't actually able to see a file for it.
437 set v [list $::_git $name]
439 set _git_cmd_path($name) $v
444 proc _which {what args} {
445 global env _search_exe _search_path
447 if {$_search_path eq {}} {
448 if {[is_Cygwin] && [regexp {^(/|\.:)} $env(PATH)]} {
449 set _search_path [split [exec cygpath \
455 } elseif {[is_Windows]} {
456 set gitguidir [file dirname [info script]]
457 regsub -all ";" $gitguidir "\\;" gitguidir
458 set env(PATH) "$gitguidir;$env(PATH
)"
459 set _search_path [split $env(PATH) {;}]
462 set _search_path [split $env(PATH) :]
467 if {[is_Windows] && [lsearch -exact $args -script] >= 0} {
470 set suffix $_search_exe
473 foreach p $_search_path {
474 set p [file join $p $what$suffix]
475 if {[file exists $p]} {
476 return [file normalize $p]
482 # Test a file for a hashbang to identify executable scripts on Windows.
483 proc is_shellscript {filename} {
484 if {![file exists $filename]} {return 0}
485 set f [open $filename r]
486 fconfigure $f -encoding binary
487 set magic [read $f 2]
489 return [expr {$magic eq "#!"}]
492 # Run a command connected via pipes on stdout.
493 # This is for use with textconv filters and uses sh -c "..." to allow it to
494 # contain a command with arguments. On windows we must check for shell
495 # scripts specifically otherwise just call the filter command.
496 proc open_cmd_pipe
{cmd path
} {
498 if {![file executable
[shellpath
]]} {
499 set exe
[auto_execok
[lindex
$cmd 0]]
500 if {[is_shellscript
[lindex
$exe 0]]} {
501 set run
[linsert
[auto_execok sh
] end
-c "$cmd \"\$0\"" $path]
503 set run
[concat
$exe [lrange
$cmd 1 end
] $path]
506 set run
[list
[shellpath
] -c "$cmd \"\$0\"" $path]
508 return [open |
$run r
]
511 proc _lappend_nice
{cmd_var
} {
515 if {![info exists _nice
]} {
516 set _nice
[_which nice
]
517 if {[catch
{exec $_nice git version
}]} {
519 } elseif
{[is_Windows
] && [file dirname $_nice] ne
[file dirname $
::_git
]} {
532 switch
-- [lindex
$args 0] {
543 set args
[lrange
$args 1 end
]
546 set cmdp
[_git_cmd
[lindex
$args 0]]
547 set args
[lrange
$args 1 end
]
549 _trace_exec
[concat
$opt $cmdp $args]
550 set result
[eval exec $opt $cmdp $args]
552 puts stderr
"< $result"
557 proc _open_stdout_stderr
{cmd
} {
560 set fd
[open
[concat
[list |
] $cmd] r
]
562 if { [lindex
$cmd end
] eq
{2>@
1}
563 && $err eq
{can not
find channel named
"1"}
565 # Older versions of Tcl 8.4 don't have this 2>@1 IO
566 # redirect operator. Fallback to |& cat for those.
567 # The command was not actually started, so its safe
568 # to try to start it a second time.
570 set fd
[open
[concat \
572 [lrange
$cmd 0 end-1
] \
579 fconfigure
$fd -eofchar {}
583 proc git_read
{args
} {
587 switch
-- [lindex
$args 0] {
602 set args
[lrange
$args 1 end
]
605 set cmdp
[_git_cmd
[lindex
$args 0]]
606 set args
[lrange
$args 1 end
]
608 return [_open_stdout_stderr
[concat
$opt $cmdp $args]]
611 proc git_write
{args
} {
615 switch
-- [lindex
$args 0] {
626 set args
[lrange
$args 1 end
]
629 set cmdp
[_git_cmd
[lindex
$args 0]]
630 set args
[lrange
$args 1 end
]
632 _trace_exec
[concat
$opt $cmdp $args]
633 return [open
[concat
[list |
] $opt $cmdp $args] w
]
636 proc githook_read
{hook_name args
} {
637 set pchook
[gitdir hooks
$hook_name]
640 # On Windows [file executable] might lie so we need to ask
641 # the shell if the hook is executable. Yes that's annoying.
645 if {![info exists interp
]} {
646 set interp
[_which sh
]
649 error
"hook execution requires sh (not in PATH)"
652 set scr
{if test -x "$1";then exec "$@";fi}
653 set sh_c
[list
$interp -c $scr $interp $pchook]
654 return [_open_stdout_stderr
[concat
$sh_c $args]]
657 if {[file executable
$pchook]} {
658 return [_open_stdout_stderr
[concat
[list
$pchook] $args]]
664 proc kill_file_process
{fd
} {
665 set process
[pid
$fd]
669 # Use a Cygwin-specific flag to allow killing
670 # native Windows processes
671 exec kill -f $process
678 proc gitattr
{path attr default
} {
679 if {[catch
{set r
[git check-attr
$attr -- $path]}]} {
682 set r
[join [lrange
[split $r :] 2 end
] :]
685 if {$r eq
{unspecified
}} {
692 regsub
-all ' $value "'\\''" value
696 proc load_current_branch {} {
697 global current_branch is_detached
699 set fd [open [gitdir HEAD] r]
700 if {[gets $fd ref] < 1} {
705 set pfx {ref: refs/heads/}
706 set len [string length $pfx]
707 if {[string equal -length $len $pfx $ref]} {
708 # We're on a branch. It might not exist. But
709 # HEAD looks good enough to be a branch.
711 set current_branch [string range $ref $len end]
714 # Assume this is a detached head.
716 set current_branch HEAD
721 auto_load tk_optionMenu
722 rename tk_optionMenu real__tkOptionMenu
723 proc tk_optionMenu {w varName args} {
724 set m [eval real__tkOptionMenu $w $varName $args]
725 $m configure -font font_ui
726 $w configure -font font_ui
730 proc rmsel_tag {text} {
732 -background [$text cget -background] \
733 -foreground [$text cget -foreground] \
735 $text tag conf in_sel -background lightgray
736 bind $text <Motion> break
742 bind . <Visibility> {
743 bind . <Visibility> {}
748 wm iconbitmap . -default $oguilib/git-gui.ico
749 set ::tk::AlwaysShowSelection 1
750 bind . <Control-F2> {console show}
752 # Spoof an X11 display for SSH
753 if {![info exists env(DISPLAY)]} {
754 set env(DISPLAY) :9999
758 image create photo gitlogo -width 16 -height 16
760 gitlogo put #33CC33 -to 7 0 9 2
761 gitlogo put #33CC33 -to 4 2 12 4
762 gitlogo put #33CC33 -to 7 4 9 6
763 gitlogo put #CC3333 -to 4 6 12 8
764 gitlogo put gray26 -to 4 9 6 10
765 gitlogo put gray26 -to 3 10 6 12
766 gitlogo put gray26 -to 8 9 13 11
767 gitlogo put gray26 -to 8 11 10 12
768 gitlogo put gray26 -to 11 11 13 14
769 gitlogo put gray26 -to 3 12 5 14
770 gitlogo put gray26 -to 5 13
771 gitlogo put gray26 -to 10 13
772 gitlogo put gray26 -to 4 14 12 15
773 gitlogo put gray26 -to 5 15 11 16
776 image create photo gitlogo32 -width 32 -height 32
777 gitlogo32 copy gitlogo -zoom 2 2
779 wm iconphoto . -default gitlogo gitlogo32
783 ######################################################################
789 if {[lsearch -exact [font names] TkDefaultFont] != -1} {
790 eval [linsert [font actual TkDefaultFont] 0 font configure font_ui]
791 eval [linsert [font actual TkFixedFont] 0 font create font_diff]
793 font create font_diff -family Courier -size 10
796 eval font configure font_ui [font actual [.dummy cget -font]]
801 font create font_uiitalic
802 font create font_uibold
803 font create font_diffbold
804 font create font_diffitalic
806 foreach class {Button Checkbutton Entry Label
807 Labelframe Listbox Message
808 Radiobutton Spinbox Text} {
809 option add *$class.font font_ui
812 option add *Menu.font font_ui
813 option add *Entry.borderWidth 1 startupFile
814 option add *Entry.relief sunken startupFile
815 option add *RadioButton.anchor w startupFile
819 if {[is_Windows] || [is_MacOSX]} {
820 option add *Menu.tearOff 0
831 proc bind_button3 {w cmd} {
832 bind $w <Any-Button-3> $cmd
834 # Mac OS X sends Button-2 on right click through three-button mouse,
835 # or through trackpad right-clicking (two-finger touch + click).
836 bind $w <Any-Button-2> $cmd
837 bind $w <Control-Button-1> $cmd
841 proc apply_config {} {
842 global repo_config font_descs
844 foreach option $font_descs {
845 set name [lindex $option 0]
846 set font [lindex $option 1]
849 foreach {cn cv} $repo_config(gui.$name) {
850 if {$cn eq {-weight}} {
853 font configure $font $cn $cv
856 font configure $font -weight normal
859 error_popup [strcat [mc "Invalid font specified
in %s
:" "gui.
$name"] "\n\n$err"]
861 foreach {cn cv} [font configure $font] {
862 font configure ${font}bold $cn $cv
863 font configure ${font}italic $cn $cv
865 font configure ${font}bold -weight bold
866 font configure ${font}italic -slant italic
872 if {$repo_config(gui.usettk)} {
873 set use_ttk [package vsatisfies [package provide Tk] 8.5]
876 bind [winfo class .] <<ThemeChanged>> [list InitTheme]
882 set default_config(branch.autosetupmerge) true
883 set default_config(merge.tool) {}
884 set default_config(mergetool.keepbackup) true
885 set default_config(merge.diffstat) true
886 set default_config(merge.summary) false
887 set default_config(merge.verbosity) 2
888 set default_config(user.name) {}
889 set default_config(user.email) {}
891 set default_config(gui.encoding) [encoding system]
892 set default_config(gui.matchtrackingbranch) false
893 set default_config(gui.textconv) true
894 set default_config(gui.pruneduringfetch) false
895 set default_config(gui.trustmtime) false
896 set default_config(gui.fastcopyblame) false
897 set default_config(gui.maxrecentrepo) 10
898 set default_config(gui.copyblamethreshold) 40
899 set default_config(gui.blamehistoryctx) 7
900 set default_config(gui.diffcontext) 5
901 set default_config(gui.diffopts) {}
902 set default_config(gui.commitmsgwidth) 75
903 set default_config(gui.newbranchtemplate) {}
904 set default_config(gui.spellingdictionary) {}
905 set default_config(gui.fontui) [font configure font_ui]
906 set default_config(gui.fontdiff) [font configure font_diff]
907 # TODO: this option should be added to the git-config documentation
908 set default_config(gui.maxfilesdisplayed) 5000
909 set default_config(gui.usettk) 1
910 set default_config(gui.warndetachedcommit) 1
912 {fontui font_ui {mc "Main Font
"}}
913 {fontdiff font_diff {mc "Diff
/Console Font
"}}
915 set default_config(gui.stageuntracked) ask
916 set default_config(gui.displayuntracked) true
918 ######################################################################
922 set _git [_which git]
924 catch {wm withdraw .}
928 -title [mc "git-gui
: fatal error
"] \
929 -message [mc "Cannot
find git
in PATH.
"]
933 ######################################################################
937 if {[catch {set _git_version [git --version]} err]} {
938 catch {wm withdraw .}
942 -title [mc "git-gui
: fatal error
"] \
943 -message "Cannot determine Git version
:
947 [appname
] requires Git
1.5.0 or later.
"
950 if {![regsub {^git version } $_git_version {} _git_version]} {
951 catch {wm withdraw .}
955 -title [mc "git-gui
: fatal error
"] \
956 -message [strcat [mc "Cannot parse Git version string
:"] "\n\n$_git_version"]
960 proc get_trimmed_version {s} {
962 foreach x [split $s -._] {
963 if {[string is integer -strict $x]} {
971 set _real_git_version $_git_version
972 set _git_version [get_trimmed_version $_git_version]
974 if {![regexp {^[1-9]+(\.[0-9]+)+$} $_git_version]} {
975 catch {wm withdraw .}
980 -title "[appname
]: warning
" \
981 -message [mc "Git version cannot be determined.
983 %s claims it is version
'%s'.
985 %s requires
at least Git
1.5.0 or later.
987 Assume
'%s' is version
1.5.0?
988 " $_git $_real_git_version [appname] $_real_git_version]] eq {yes}} {
989 set _git_version 1.5.0
994 unset _real_git_version
996 proc git-version {args} {
999 switch [llength $args] {
1001 return $_git_version
1005 set op [lindex $args 0]
1006 set vr [lindex $args 1]
1007 set cm [package vcompare $_git_version $vr]
1008 return [expr $cm $op 0]
1012 set type [lindex $args 0]
1013 set name [lindex $args 1]
1014 set parm [lindex $args 2]
1015 set body [lindex $args 3]
1017 if {($type ne {proc} && $type ne {method})} {
1018 error "Invalid arguments to git-version
"
1020 if {[llength $body] < 2 || [lindex $body end-1] ne {default}} {
1021 error "Last arm of
$type $name must be default
"
1024 foreach {op vr cb} [lrange $body 0 end-2] {
1025 if {[git-version $op $vr]} {
1026 return [uplevel [list $type $name $parm $cb]]
1030 return [uplevel [list $type $name $parm [lindex $body end]]]
1034 error "git-version
>= x
"
1040 if {[git-version < 1.5]} {
1041 catch {wm withdraw .}
1045 -title [mc "git-gui
: fatal error
"] \
1046 -message "[appname
] requires Git
1.5.0 or later.
1048 You are using
[git-version
]:
1054 ######################################################################
1056 ## configure our library
1058 set idx [file join $oguilib tclIndex]
1059 if {[catch {set fd [open $idx r]} err]} {
1060 catch {wm withdraw .}
1064 -title [mc "git-gui
: fatal error
"] \
1068 if {[gets $fd] eq {# Autogenerated by git-gui Makefile}} {
1070 while {[gets $fd n] >= 0} {
1071 if {$n ne {} && ![string match #* $n]} {
1083 if {[lsearch -exact $loaded $p] >= 0} continue
1084 source [file join $oguilib $p]
1089 set auto_path [concat [list $oguilib] $auto_path]
1091 unset -nocomplain idx fd
1093 ######################################################################
1095 ## config file parsing
1097 git-version proc _parse_config {arr_name args} {
1104 [list git_read config] \
1106 [list --null --list]]
1107 fconfigure $fd_rc -translation binary
1108 set buf [read $fd_rc]
1111 foreach line [split $buf "\
0"] {
1112 if {[regexp {^([^\n]+)\n(.*)$} $line line name value]} {
1113 if {[is_many_config $name]} {
1114 lappend arr($name) $value
1116 set arr($name) $value
1118 } elseif {[regexp {^([^\n]+)$} $line line name]} {
1119 # no value given, but interpreting them as
1120 # boolean will be handled as true
1129 set fd_rc [eval [list git_read config --list] $args]
1130 while {[gets $fd_rc line] >= 0} {
1131 if {[regexp {^([^=]+)=(.*)$} $line line name value]} {
1132 if {[is_many_config $name]} {
1133 lappend arr($name) $value
1135 set arr($name) $value
1137 } elseif {[regexp {^([^=]+)$} $line line name]} {
1138 # no value given, but interpreting them as
1139 # boolean will be handled as true
1148 proc load_config {include_global} {
1149 global repo_config global_config system_config default_config
1151 if {$include_global} {
1152 _parse_config system_config --system
1153 _parse_config global_config --global
1155 _parse_config repo_config
1157 foreach name [array names default_config] {
1158 if {[catch {set v $system_config($name)}]} {
1159 set system_config($name) $default_config($name)
1162 foreach name [array names system_config] {
1163 if {[catch {set v $global_config($name)}]} {
1164 set global_config($name) $system_config($name)
1166 if {[catch {set v $repo_config($name)}]} {
1167 set repo_config($name) $system_config($name)
1172 ######################################################################
1174 ## feature option selection
1176 if {[regexp {^git-(.+)$} [file tail $argv0] _junk subcommand]} {
1181 if {$subcommand eq {gui.sh}} {
1184 if {$subcommand eq {gui} && [llength $argv] > 0} {
1185 set subcommand [lindex $argv 0]
1186 set argv [lrange $argv 1 end]
1189 enable_option multicommit
1190 enable_option branch
1191 enable_option transport
1194 switch -- $subcommand {
1199 disable_option multicommit
1200 disable_option branch
1201 disable_option transport
1204 enable_option singlecommit
1205 enable_option retcode
1207 disable_option multicommit
1208 disable_option branch
1209 disable_option transport
1211 while {[llength $argv] > 0} {
1212 set a [lindex $argv 0]
1215 enable_option initialamend
1218 enable_option nocommit
1219 enable_option nocommitmsg
1222 disable_option nocommitmsg
1229 set argv [lrange $argv 1 end]
1234 ######################################################################
1236 ## execution environment
1238 set have_tk85 [expr {[package vcompare $tk_version "8.5"] >= 0}]
1240 # Suggest our implementation of askpass, if none is set
1241 if {![info exists env(SSH_ASKPASS)]} {
1242 set env(SSH_ASKPASS) [gitexec git-gui--askpass]
1245 ######################################################################
1251 set _gitdir $env(GIT_DIR)
1255 # beware that from the .git dir this sets _gitdir to .
1256 # and _prefix to the empty string
1257 set _gitdir [git rev-parse --git-dir]
1258 set _prefix [git rev-parse --show-prefix]
1262 choose_repository::pick
1266 # we expand the _gitdir when it's just a single dot (i.e. when we're being
1267 # run from the .git dir itself) lest the routines to find the worktree
1269 if {$_gitdir eq ".
"} {
1273 if {![file isdirectory $_gitdir] && [is_Cygwin]} {
1274 catch {set _gitdir [exec cygpath --windows $_gitdir]}
1276 if {![file isdirectory $_gitdir]} {
1277 catch {wm withdraw .}
1278 error_popup [strcat [mc "Git directory not found
:"] "\n\n$_gitdir"]
1281 # _gitdir exists, so try loading the config
1285 # v1.7.0 introduced --show-toplevel to return the canonical work-tree
1286 if {[package vsatisfies $_git_version 1.7.0]} {
1287 if { [is_Cygwin] } {
1288 catch {set _gitworktree [exec cygpath --windows [git rev-parse --show-toplevel]]}
1290 set _gitworktree [git rev-parse --show-toplevel]
1293 # try to set work tree from environment, core.worktree or use
1294 # cdup to obtain a relative path to the top of the worktree. If
1295 # run from the top, the ./ prefix ensures normalize expands pwd.
1296 if {[catch { set _gitworktree $env(GIT_WORK_TREE) }]} {
1297 set _gitworktree [get_config core.worktree]
1298 if {$_gitworktree eq ""} {
1299 set _gitworktree [file normalize ./[git rev-parse --show-cdup]]
1304 if {$_prefix ne {}} {
1305 if {$_gitworktree eq {}} {
1306 regsub -all {[^/]+/} $_prefix ../ cdup
1308 set cdup $_gitworktree
1310 if {[catch {cd $cdup} err]} {
1311 catch {wm withdraw .}
1312 error_popup [strcat [mc "Cannot move to top of working directory
:"] "\n\n$err"]
1315 set _gitworktree [pwd]
1317 } elseif {![is_enabled bare]} {
1319 catch {wm withdraw .}
1320 error_popup [strcat [mc "Cannot use bare repository
:"] "\n\n$_gitdir"]
1323 if {$_gitworktree eq {}} {
1324 set _gitworktree [file dirname $_gitdir]
1326 if {[catch {cd $_gitworktree} err]} {
1327 catch {wm withdraw .}
1328 error_popup [strcat [mc "No working directory
"] " $_gitworktree:\n\n$err"]
1331 set _gitworktree [pwd]
1333 set _reponame [file split [file normalize $_gitdir]]
1334 if {[lindex $_reponame end] eq {.git}} {
1335 set _reponame [lindex $_reponame end-1]
1337 set _reponame [lindex $_reponame end]
1340 set env(GIT_DIR) $_gitdir
1341 set env(GIT_WORK_TREE) $_gitworktree
1343 catch { unset env(GIT_EDITOR_F_NBLOCK) }
1344 catch { unset env(GIT_EDITOR_F_POSITION) }
1346 ######################################################################
1350 set current_diff_path {}
1351 set current_diff_side {}
1352 set diff_actions [list]
1356 set MERGE_HEAD [list]
1359 set current_branch {}
1361 set current_diff_path {}
1363 set is_submodule_diff 0
1364 set is_conflict_diff 0
1365 set selected_commit_type new
1366 set diff_empty_count 0
1367 set diff_show_line_numbers 1
1368 set diff_lno_column_width 0
1371 set nullid "0000000000000000000000000000000000000000"
1372 set nullid2 "0000000000000000000000000000000000000001"
1375 ######################################################################
1383 set disable_on_lock [list]
1384 set index_lock_type none
1386 proc lock_index {type} {
1387 global index_lock_type disable_on_lock
1389 if {$index_lock_type eq {none}} {
1390 set index_lock_type $type
1391 foreach w $disable_on_lock {
1392 uplevel #0 $w disabled
1395 } elseif {$index_lock_type eq "begin-
$type"} {
1396 set index_lock_type $type
1402 proc unlock_index {} {
1403 global index_lock_type disable_on_lock
1405 set index_lock_type none
1406 foreach w $disable_on_lock {
1407 uplevel #0 $w normal
1411 ######################################################################
1415 proc repository_state {ctvar hdvar mhvar} {
1416 global current_branch
1417 upvar $ctvar ct $hdvar hd $mhvar mh
1422 if {[catch {set hd [git rev-parse --verify HEAD]}]} {
1428 set merge_head [gitdir MERGE_HEAD]
1429 if {[file exists $merge_head]} {
1431 set fd_mh [open $merge_head r]
1432 while {[gets $fd_mh line] >= 0} {
1443 global PARENT empty_tree
1445 set p [lindex $PARENT 0]
1449 if {$empty_tree eq {}} {
1450 set empty_tree [git mktree << {}]
1455 proc force_amend {} {
1456 global selected_commit_type
1457 global HEAD PARENT MERGE_HEAD commit_type
1459 repository_state newType newHEAD newMERGE_HEAD
1462 set MERGE_HEAD $newMERGE_HEAD
1463 set commit_type $newType
1465 set selected_commit_type amend
1466 do_select_commit_type
1469 proc rescan {after {honor_trustmtime 1}} {
1470 global HEAD PARENT MERGE_HEAD commit_type
1471 global ui_index ui_workdir ui_comm
1472 global rescan_active file_states
1475 if {$rescan_active > 0 || ![lock_index read]} return
1477 repository_state newType newHEAD newMERGE_HEAD
1478 if {[string match amend* $commit_type]
1479 && $newType eq {normal}
1480 && $newHEAD eq $HEAD} {
1484 set MERGE_HEAD $newMERGE_HEAD
1485 set commit_type $newType
1488 array unset file_states
1490 if {!$::GITGUI_BCK_exists &&
1491 (![$ui_comm edit modified]
1492 || [string trim [$ui_comm get 0.0 end]] eq {})} {
1493 if {[string match amend* $commit_type]} {
1494 } elseif {[load_message GITGUI_MSG utf-8]} {
1495 } elseif {[run_prepare_commit_msg_hook]} {
1496 } elseif {[load_message MERGE_MSG]} {
1497 } elseif {[load_message SQUASH_MSG]} {
1500 $ui_comm edit modified false
1503 if {$honor_trustmtime && $repo_config(gui.trustmtime) eq {true}} {
1504 rescan_stage2 {} $after
1507 ui_status [mc "Refreshing
file status...
"]
1508 set fd_rf [git_read update-index \
1514 fconfigure $fd_rf -blocking 0 -translation binary
1515 fileevent $fd_rf readable \
1516 [list rescan_stage2 $fd_rf $after]
1521 set is_git_info_exclude {}
1522 proc have_info_exclude {} {
1523 global is_git_info_exclude
1525 if {$is_git_info_exclude eq {}} {
1526 if {[catch {exec test -f [gitdir info exclude]}]} {
1527 set is_git_info_exclude 0
1529 set is_git_info_exclude 1
1532 return $is_git_info_exclude
1535 proc have_info_exclude {} {
1536 return [file readable [gitdir info exclude]]
1540 proc rescan_stage2 {fd after} {
1541 global rescan_active buf_rdi buf_rdf buf_rlo
1545 if {![eof $fd]} return
1549 if {[package vsatisfies $::_git_version 1.6.3]} {
1550 set ls_others [list --exclude-standard]
1552 set ls_others [list --exclude-per-directory=.gitignore]
1553 if {[have_info_exclude]} {
1554 lappend ls_others "--exclude-from=[gitdir info exclude
]"
1556 set user_exclude [get_config core.excludesfile]
1557 if {$user_exclude ne {} && [file readable $user_exclude]} {
1558 lappend ls_others "--exclude-from=[file normalize
$user_exclude]"
1567 ui_status [mc "Scanning
for modified files ...
"]
1568 set fd_di [git_read diff-index --cached -z [PARENT]]
1569 set fd_df [git_read diff-files -z]
1571 fconfigure $fd_di -blocking 0 -translation binary -encoding binary
1572 fconfigure $fd_df -blocking 0 -translation binary -encoding binary
1574 fileevent $fd_di readable [list read_diff_index $fd_di $after]
1575 fileevent $fd_df readable [list read_diff_files $fd_df $after]
1577 if {[is_config_true gui.displayuntracked]} {
1578 set fd_lo [eval git_read ls-files --others -z $ls_others]
1579 fconfigure $fd_lo -blocking 0 -translation binary -encoding binary
1580 fileevent $fd_lo readable [list read_ls_others $fd_lo $after]
1585 proc load_message {file {encoding {}}} {
1588 set f [gitdir $file]
1589 if {[file isfile $f]} {
1590 if {[catch {set fd [open $f r]}]} {
1593 fconfigure $fd -eofchar {}
1594 if {$encoding ne {}} {
1595 fconfigure $fd -encoding $encoding
1597 set content [string trim [read $fd]]
1599 regsub -all -line {[ \r\t]+$} $content {} content
1600 $ui_comm delete 0.0 end
1601 $ui_comm insert end $content
1607 proc run_prepare_commit_msg_hook {} {
1610 # prepare-commit-msg requires PREPARE_COMMIT_MSG exist. From git-gui
1611 # it will be .git/MERGE_MSG (merge), .git/SQUASH_MSG (squash), or an
1612 # empty file but existent file.
1614 set fd_pcm [open [gitdir PREPARE_COMMIT_MSG] a]
1616 if {[file isfile [gitdir MERGE_MSG]]} {
1617 set pcm_source "merge
"
1618 set fd_mm [open [gitdir MERGE_MSG] r]
1619 puts -nonewline $fd_pcm [read $fd_mm]
1621 } elseif {[file isfile [gitdir SQUASH_MSG]]} {
1622 set pcm_source "squash
"
1623 set fd_sm [open [gitdir SQUASH_MSG] r]
1624 puts -nonewline $fd_pcm [read $fd_sm]
1632 set fd_ph [githook_read prepare-commit-msg \
1633 [gitdir PREPARE_COMMIT_MSG] $pcm_source]
1635 catch {file delete [gitdir PREPARE_COMMIT_MSG]}
1639 ui_status [mc "Calling prepare-commit-msg hook...
"]
1642 fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
1643 fileevent $fd_ph readable \
1644 [list prepare_commit_msg_hook_wait $fd_ph]
1649 proc prepare_commit_msg_hook_wait {fd_ph} {
1652 append pch_error [read $fd_ph]
1653 fconfigure $fd_ph -blocking 1
1655 if {[catch {close $fd_ph}]} {
1656 ui_status [mc "Commit declined by prepare-commit-msg hook.
"]
1657 hook_failed_popup prepare-commit-msg $pch_error
1658 catch {file delete [gitdir PREPARE_COMMIT_MSG]}
1661 load_message PREPARE_COMMIT_MSG
1664 catch {file delete [gitdir PREPARE_COMMIT_MSG]}
1667 fconfigure $fd_ph -blocking 0
1668 catch {file delete [gitdir PREPARE_COMMIT_MSG]}
1671 proc read_diff_index {fd after} {
1674 append buf_rdi [read $fd]
1676 set n [string length $buf_rdi]
1678 set z1 [string first "\
0" $buf_rdi $c]
1679 if {$z1 == -1} break
1681 set z2 [string first "\
0" $buf_rdi $z1]
1682 if {$z2 == -1} break
1685 set i [split [string range $buf_rdi $c [expr {$z1 - 2}]] { }]
1686 set p [string range $buf_rdi $z1 [expr {$z2 - 1}]]
1688 [encoding convertfrom $p] \
1690 [list [lindex $i 0] [lindex $i 2]] \
1696 set buf_rdi [string range $buf_rdi $c end]
1701 rescan_done $fd buf_rdi $after
1704 proc read_diff_files {fd after} {
1707 append buf_rdf [read $fd]
1709 set n [string length $buf_rdf]
1711 set z1 [string first "\
0" $buf_rdf $c]
1712 if {$z1 == -1} break
1714 set z2 [string first "\
0" $buf_rdf $z1]
1715 if {$z2 == -1} break
1718 set i [split [string range $buf_rdf $c [expr {$z1 - 2}]] { }]
1719 set p [string range $buf_rdf $z1 [expr {$z2 - 1}]]
1721 [encoding convertfrom $p] \
1724 [list [lindex $i 0] [lindex $i 2]]
1729 set buf_rdf [string range $buf_rdf $c end]
1734 rescan_done $fd buf_rdf $after
1737 proc read_ls_others {fd after} {
1740 append buf_rlo [read $fd]
1741 set pck [split $buf_rlo "\
0"]
1742 set buf_rlo [lindex $pck end]
1743 foreach p [lrange $pck 0 end-1] {
1744 set p [encoding convertfrom $p]
1745 if {[string index $p end] eq {/}} {
1746 set p [string range $p 0 end-1]
1750 rescan_done $fd buf_rlo $after
1753 proc rescan_done {fd buf after} {
1754 global rescan_active current_diff_path
1755 global file_states repo_config
1758 if {![eof $fd]} return
1761 if {[incr rescan_active -1] > 0} return
1766 if {$current_diff_path ne {}} { reshow_diff $after }
1767 if {$current_diff_path eq {}} { select_first_diff $after }
1770 proc prune_selection {} {
1771 global file_states selected_paths
1773 foreach path [array names selected_paths] {
1774 if {[catch {set still_here $file_states($path)}]} {
1775 unset selected_paths($path)
1780 ######################################################################
1784 proc mapicon {w state path} {
1787 if {[catch {set r $all_icons($state$w)}]} {
1788 puts "error
: no icon
for $w state
={$state} $path"
1794 proc mapdesc {state path} {
1797 if {[catch {set r $all_descs($state)}]} {
1798 puts "error
: no desc
for state
={$state} $path"
1804 proc ui_status {msg} {
1806 if {[info exists main_status]} {
1807 $main_status show $msg
1811 proc ui_ready {{test {}}} {
1813 if {[info exists main_status]} {
1814 $main_status show [mc "Ready.
"] $test
1818 proc escape_path {path} {
1819 regsub -all {\\} $path "\\\\" path
1820 regsub -all "\n" $path "\\n
" path
1824 proc short_path {path} {
1825 return [escape_path [lindex [file split $path] end]]
1829 set null_sha1 [string repeat 0 40]
1831 proc merge_state {path new_state {head_info {}} {index_info {}}} {
1832 global file_states next_icon_id null_sha1
1834 set s0 [string index $new_state 0]
1835 set s1 [string index $new_state 1]
1837 if {[catch {set info $file_states($path)}]} {
1839 set icon n[incr next_icon_id]
1841 set state [lindex $info 0]
1842 set icon [lindex $info 1]
1843 if {$head_info eq {}} {set head_info [lindex $info 2]}
1844 if {$index_info eq {}} {set index_info [lindex $info 3]}
1847 if {$s0 eq {?}} {set s0 [string index $state 0]} \
1848 elseif {$s0 eq {_}} {set s0 _}
1850 if {$s1 eq {?}} {set s1 [string index $state 1]} \
1851 elseif {$s1 eq {_}} {set s1 _}
1853 if {$s0 eq {A} && $s1 eq {_} && $head_info eq {}} {
1854 set head_info [list 0 $null_sha1]
1855 } elseif {$s0 ne {_} && [string index $state 0] eq {_}
1856 && $head_info eq {}} {
1857 set head_info $index_info
1858 } elseif {$s0 eq {_} && [string index $state 0] ne {_}} {
1859 set index_info $head_info
1863 set file_states($path) [list $s0$s1 $icon \
1864 $head_info $index_info \
1869 proc display_file_helper {w path icon_name old_m new_m} {
1872 if {$new_m eq {_}} {
1873 set lno [lsearch -sorted -exact $file_lists($w) $path]
1875 set file_lists($w) [lreplace $file_lists($w) $lno $lno]
1877 $w conf -state normal
1878 $w delete $lno.0 [expr {$lno + 1}].0
1879 $w conf -state disabled
1881 } elseif {$old_m eq {_} && $new_m ne {_}} {
1882 lappend file_lists($w) $path
1883 set file_lists($w) [lsort -unique $file_lists($w)]
1884 set lno [lsearch -sorted -exact $file_lists($w) $path]
1886 $w conf -state normal
1887 $w image create $lno.0 \
1888 -align center -padx 5 -pady 1 \
1890 -image [mapicon $w $new_m $path]
1891 $w insert $lno.1 "[escape_path
$path]\n"
1892 $w conf -state disabled
1893 } elseif {$old_m ne $new_m} {
1894 $w conf -state normal
1895 $w image conf $icon_name -image [mapicon $w $new_m $path]
1896 $w conf -state disabled
1900 proc display_file {path state} {
1901 global file_states selected_paths
1902 global ui_index ui_workdir
1904 set old_m [merge_state $path $state]
1905 set s $file_states($path)
1906 set new_m [lindex $s 0]
1907 set icon_name [lindex $s 1]
1909 set o [string index $old_m 0]
1910 set n [string index $new_m 0]
1917 display_file_helper $ui_index $path $icon_name $o $n
1919 if {[string index $old_m 0] eq {U}} {
1922 set o [string index $old_m 1]
1924 if {[string index $new_m 0] eq {U}} {
1927 set n [string index $new_m 1]
1929 display_file_helper $ui_workdir $path $icon_name $o $n
1931 if {$new_m eq {__}} {
1932 unset file_states($path)
1933 catch {unset selected_paths($path)}
1937 proc display_all_files_helper {w path icon_name m} {
1940 lappend file_lists($w) $path
1941 set lno [expr {[lindex [split [$w index end] .] 0] - 1}]
1942 $w image create end \
1943 -align center -padx 5 -pady 1 \
1945 -image [mapicon $w $m $path]
1946 $w insert end "[escape_path
$path]\n"
1950 proc display_all_files {} {
1951 global ui_index ui_workdir
1952 global file_states file_lists
1954 global files_warning
1956 $ui_index conf -state normal
1957 $ui_workdir conf -state normal
1959 $ui_index delete 0.0 end
1960 $ui_workdir delete 0.0 end
1963 set file_lists($ui_index) [list]
1964 set file_lists($ui_workdir) [list]
1966 set to_display [lsort [array names file_states]]
1967 set display_limit [get_config gui.maxfilesdisplayed]
1968 if {[llength $to_display] > $display_limit} {
1969 if {!$files_warning} {
1970 # do not repeatedly warn:
1972 info_popup [mc "Displaying only
%s of
%s files.
" \
1973 $display_limit [llength $to_display]]
1975 set to_display [lrange $to_display 0 [expr {$display_limit-1}]]
1977 foreach path $to_display {
1978 set s $file_states($path)
1980 set icon_name [lindex $s 1]
1982 set s [string index $m 0]
1983 if {$s ne {U} && $s ne {_}} {
1984 display_all_files_helper $ui_index $path \
1988 if {[string index $m 0] eq {U}} {
1991 set s [string index $m 1]
1994 display_all_files_helper $ui_workdir $path \
1999 $ui_index conf -state disabled
2000 $ui_workdir conf -state disabled
2003 ######################################################################
2008 #define mask_width 14
2009 #define mask_height 15
2010 static unsigned char mask_bits[] = {
2011 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
2012 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
2013 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f};
2016 image create bitmap file_plain -background white -foreground black -data {
2017 #define plain_width 14
2018 #define plain_height 15
2019 static unsigned char plain_bits[] = {
2020 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
2021 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10,
2022 0x02, 0x10, 0x02, 0x10, 0xfe, 0x1f};
2023 } -maskdata $filemask
2025 image create bitmap file_mod -background white -foreground blue -data {
2026 #define mod_width 14
2027 #define mod_height 15
2028 static unsigned char mod_bits[] = {
2029 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
2030 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
2031 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
2032 } -maskdata $filemask
2034 image create bitmap file_fulltick -background white -foreground "#007000" -data {
2035 #define file_fulltick_width 14
2036 #define file_fulltick_height 15
2037 static unsigned char file_fulltick_bits
[] = {
2038 0xfe, 0x01, 0x02, 0x1a, 0x02, 0x0c, 0x02, 0x0c, 0x02, 0x16, 0x02, 0x16,
2039 0x02, 0x13, 0x00, 0x13, 0x86, 0x11, 0x8c, 0x11, 0xd8, 0x10, 0xf2, 0x10,
2040 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
2041 } -maskdata $filemask
2043 image create bitmap file_question
-background white
-foreground black
-data {
2044 #define file_question_width 14
2045 #define file_question_height 15
2046 static unsigned char file_question_bits
[] = {
2047 0xfe, 0x01, 0x02, 0x02, 0xe2, 0x04, 0xf2, 0x09, 0x1a, 0x1b, 0x0a, 0x13,
2048 0x82, 0x11, 0xc2, 0x10, 0x62, 0x10, 0x62, 0x10, 0x02, 0x10, 0x62, 0x10,
2049 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
2050 } -maskdata $filemask
2052 image create bitmap file_removed
-background white
-foreground red
-data {
2053 #define file_removed_width 14
2054 #define file_removed_height 15
2055 static unsigned char file_removed_bits
[] = {
2056 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
2057 0x1a, 0x16, 0x32, 0x13, 0xe2, 0x11, 0xc2, 0x10, 0xe2, 0x11, 0x32, 0x13,
2058 0x1a, 0x16, 0x02, 0x10, 0xfe, 0x1f};
2059 } -maskdata $filemask
2061 image create bitmap file_merge
-background white
-foreground blue
-data {
2062 #define file_merge_width 14
2063 #define file_merge_height 15
2064 static unsigned char file_merge_bits
[] = {
2065 0xfe, 0x01, 0x02, 0x03, 0x62, 0x05, 0x62, 0x09, 0x62, 0x1f, 0x62, 0x10,
2066 0xfa, 0x11, 0xf2, 0x10, 0x62, 0x10, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
2067 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
2068 } -maskdata $filemask
2070 image create bitmap file_statechange
-background white
-foreground green
-data {
2071 #define file_statechange_width 14
2072 #define file_statechange_height 15
2073 static unsigned char file_statechange_bits
[] = {
2074 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x62, 0x10,
2075 0x62, 0x10, 0xba, 0x11, 0xba, 0x11, 0x62, 0x10, 0x62, 0x10, 0x02, 0x10,
2076 0x02, 0x10, 0x02, 0x10, 0xfe, 0x1f};
2077 } -maskdata $filemask
2079 set ui_index .vpane.files.index.list
2080 set ui_workdir .vpane.files.workdir.list
2082 set all_icons
(_
$ui_index) file_plain
2083 set all_icons
(A
$ui_index) file_plain
2084 set all_icons
(M
$ui_index) file_fulltick
2085 set all_icons
(D
$ui_index) file_removed
2086 set all_icons
(U
$ui_index) file_merge
2087 set all_icons
(T
$ui_index) file_statechange
2089 set all_icons
(_
$ui_workdir) file_plain
2090 set all_icons
(M
$ui_workdir) file_mod
2091 set all_icons
(D
$ui_workdir) file_question
2092 set all_icons
(U
$ui_workdir) file_merge
2093 set all_icons
(O
$ui_workdir) file_plain
2094 set all_icons
(T
$ui_workdir) file_statechange
2097 {__
{mc
"Unmodified"}}
2099 {_M
{mc
"Modified, not staged"}}
2100 {M_
{mc
"Staged for commit"}}
2101 {MM
{mc
"Portions staged for commit"}}
2102 {MD
{mc
"Staged for commit, missing"}}
2104 {_T
{mc
"File type changed, not staged"}}
2105 {MT
{mc
"File type changed, old type staged for commit"}}
2106 {AT
{mc
"File type changed, old type staged for commit"}}
2107 {T_
{mc
"File type changed, staged"}}
2108 {TM
{mc
"File type change staged, modification not staged"}}
2109 {TD
{mc
"File type change staged, file missing"}}
2111 {_O
{mc
"Untracked, not staged"}}
2112 {A_
{mc
"Staged for commit"}}
2113 {AM
{mc
"Portions staged for commit"}}
2114 {AD
{mc
"Staged for commit, missing"}}
2117 {D_
{mc
"Staged for removal"}}
2118 {DO
{mc
"Staged for removal, still present"}}
2120 {_U
{mc
"Requires merge resolution"}}
2121 {U_
{mc
"Requires merge resolution"}}
2122 {UU
{mc
"Requires merge resolution"}}
2123 {UM
{mc
"Requires merge resolution"}}
2124 {UD
{mc
"Requires merge resolution"}}
2125 {UT
{mc
"Requires merge resolution"}}
2127 set all_descs
([lindex
$i 0]) [eval [lindex
$i 1]]
2131 ######################################################################
2135 proc scrollbar2many
{list mode args
} {
2136 foreach w
$list {eval $w $mode $args}
2139 proc many2scrollbar
{list mode sb top bottom
} {
2140 $sb set $top $bottom
2141 foreach w
$list {$w $mode moveto
$top}
2144 # delegates mouse selection actions from gutter columns to the main text
2146 # use delegator_bind, if you need to bind more actions
2147 proc delegate_sel_to
{w from
} {
2148 set bind_list
[list \
2154 <Double-Shift-Button-1
> \
2155 <Triple-Shift-Button-1
> \
2158 foreach
seq $bind_list {
2159 set script [bind Text
$seq]
2160 set new_script
[string map
[list
%W
$w %x
0 word line
] $script]
2162 bind $f $seq "$new_script; focus $w; break"
2167 # use this for binding any of the mouse actions from a delegator
2168 # see bind_list in delegate_sel_to
2169 proc delegator_bind
{tag
seq script} {
2170 bind $tag $seq "$script; [bind $tag $seq]"
2173 proc incr_font_size
{font
{amt
1}} {
2174 set sz
[font configure
$font -size]
2176 font configure
$font -size $sz
2177 font configure
${font}bold
-size $sz
2178 font configure
${font}italic
-size $sz
2181 ######################################################################
2185 set starting_gitk_msg
[mc
"Starting gitk... please wait..."]
2187 proc do_gitk
{revs
{is_submodule false
}} {
2188 global current_diff_path file_states current_diff_side ui_index
2189 global _gitdir _gitworktree
2191 # -- Always start gitk through whatever we were loaded with. This
2192 # lets us bypass using shell process on Windows systems.
2194 set exe
[_which gitk
-script]
2195 set cmd
[list
[info nameofexecutable
] $exe]
2197 error_popup
[mc
"Couldn't find gitk in PATH"]
2203 if {!$is_submodule} {
2208 cd $current_diff_path
2209 if {$revs eq
{--}} {
2210 set s
$file_states($current_diff_path)
2213 switch
-glob -- [lindex
$s 0] {
2214 M_
{ set old_sha1
[lindex
[lindex
$s 2] 1] }
2215 _M
{ set old_sha1
[lindex
[lindex
$s 3] 1] }
2217 if {$current_diff_side eq
$ui_index} {
2218 set old_sha1
[lindex
[lindex
$s 2] 1]
2219 set new_sha1
[lindex
[lindex
$s 3] 1]
2221 set old_sha1
[lindex
[lindex
$s 3] 1]
2225 set revs
$old_sha1...
$new_sha1
2227 # GIT_DIR and GIT_WORK_TREE for the submodule are not the ones
2228 # we've been using for the main repository, so unset them.
2229 # TODO we could make life easier (start up faster?) for gitk
2230 # by setting these to the appropriate values to allow gitk
2231 # to skip the heuristics to find their proper value
2233 unset env
(GIT_WORK_TREE
)
2235 eval exec $cmd $revs "--" "--" &
2237 set env
(GIT_DIR
) $_gitdir
2238 set env
(GIT_WORK_TREE
) $_gitworktree
2241 ui_status $
::starting_gitk_msg
2243 ui_ready
$starting_gitk_msg
2248 proc do_git_gui
{} {
2249 global current_diff_path
2251 # -- Always start git gui through whatever we were loaded with. This
2252 # lets us bypass using shell process on Windows systems.
2254 set exe
[list
[_which git
]]
2256 error_popup
[mc
"Couldn't find git gui in PATH"]
2259 global _gitdir _gitworktree
2261 # see note in do_gitk about unsetting these vars when
2262 # running tools in a submodule
2264 unset env
(GIT_WORK_TREE
)
2267 cd $current_diff_path
2269 eval exec $exe gui
&
2271 set env
(GIT_DIR
) $_gitdir
2272 set env
(GIT_WORK_TREE
) $_gitworktree
2275 ui_status $
::starting_gitk_msg
2277 ui_ready
$starting_gitk_msg
2282 proc do_explore
{} {
2285 if {[is_Cygwin
] ||
[is_Windows
]} {
2286 set explorer
"explorer.exe"
2287 } elseif
{[is_MacOSX
]} {
2290 # freedesktop.org-conforming system is our best shot
2291 set explorer
"xdg-open"
2293 eval exec $explorer [list
[file nativename
$_gitworktree]] &
2299 proc terminate_me
{win
} {
2301 if {$win ne
{.
}} return
2305 proc do_quit
{{rc
{1}}} {
2306 global ui_comm is_quitting repo_config commit_type
2307 global GITGUI_BCK_exists GITGUI_BCK_i
2308 global ui_comm_spell
2309 global ret_code use_ttk
2311 if {$is_quitting} return
2314 if {[winfo exists
$ui_comm]} {
2315 # -- Stash our current commit buffer.
2317 set save
[gitdir GITGUI_MSG
]
2318 if {$GITGUI_BCK_exists && ![$ui_comm edit modified
]} {
2319 file rename
-force [gitdir GITGUI_BCK
] $save
2320 set GITGUI_BCK_exists
0
2322 set msg
[string trim
[$ui_comm get
0.0 end
]]
2323 regsub
-all -line {[ \r\t]+$
} $msg {} msg
2324 if {(![string match amend
* $commit_type]
2325 ||
[$ui_comm edit modified
])
2328 set fd
[open
$save w
]
2329 fconfigure
$fd -encoding utf-8
2330 puts
-nonewline $fd $msg
2334 catch
{file delete
$save}
2338 # -- Cancel our spellchecker if its running.
2340 if {[info exists ui_comm_spell
]} {
2344 # -- Remove our editor backup, its not needed.
2346 after cancel
$GITGUI_BCK_i
2347 if {$GITGUI_BCK_exists} {
2348 catch
{file delete
[gitdir GITGUI_BCK
]}
2351 # -- Stash our current window geometry into this repository.
2353 set cfg_wmstate
[wm state .
]
2354 if {[catch
{set rc_wmstate
$repo_config(gui.wmstate
)}]} {
2357 if {$cfg_wmstate ne
$rc_wmstate} {
2358 catch
{git config gui.wmstate
$cfg_wmstate}
2360 if {$cfg_wmstate eq
{zoomed
}} {
2361 # on Windows wm geometry will lie about window
2362 # position (but not size) when window is zoomed
2363 # restore the window before querying wm geometry
2366 set cfg_geometry
[list
]
2367 lappend cfg_geometry
[wm geometry .
]
2369 lappend cfg_geometry
[.vpane sashpos
0]
2370 lappend cfg_geometry
[.vpane.files sashpos
0]
2372 lappend cfg_geometry
[lindex
[.vpane sash coord
0] 0]
2373 lappend cfg_geometry
[lindex
[.vpane.files sash coord
0] 1]
2375 if {[catch
{set rc_geometry
$repo_config(gui.geometry
)}]} {
2378 if {$cfg_geometry ne
$rc_geometry} {
2379 catch
{git config gui.geometry
$cfg_geometry}
2385 # Briefly enable send again, working around Tk bug
2386 # http://sourceforge.net/tracker/?func=detail&atid=112997&aid=1821174&group_id=12997
2387 tk appname
[appname
]
2396 proc ui_do_rescan
{} {
2397 rescan
{force_first_diff ui_ready
}
2404 proc next_diff
{{after
{}}} {
2405 global next_diff_p next_diff_w next_diff_i
2406 show_diff
$next_diff_p $next_diff_w {} {} $after
2409 proc find_anchor_pos
{lst name
} {
2410 set lid
[lsearch
-sorted -exact $lst $name]
2414 foreach lname
$lst {
2415 if {$lname >= $name} break
2423 proc find_file_from
{flist idx delta path mmask
} {
2426 set len
[llength
$flist]
2427 while {$idx >= 0 && $idx < $len} {
2428 set name
[lindex
$flist $idx]
2430 if {$name ne
$path && [info exists file_states
($name)]} {
2431 set state
[lindex
$file_states($name) 0]
2433 if {$mmask eq
{} ||
[regexp
$mmask $state]} {
2444 proc find_next_diff
{w path
{lno
{}} {mmask
{}}} {
2445 global next_diff_p next_diff_w next_diff_i
2446 global file_lists ui_index ui_workdir
2448 set flist
$file_lists($w)
2450 set lno
[find_anchor_pos
$flist $path]
2455 if {$mmask ne
{} && ![regexp
{(^\^
)|
(\$$
)} $mmask]} {
2456 if {$w eq
$ui_index} {
2459 set mmask
"$mmask\$"
2463 set idx
[find_file_from
$flist $lno 1 $path $mmask]
2466 set idx
[find_file_from
$flist $lno -1 $path $mmask]
2471 set next_diff_p
[lindex
$flist $idx]
2472 set next_diff_i
[expr {$idx+1}]
2479 proc next_diff_after_action
{w path
{lno
{}} {mmask
{}}} {
2480 global current_diff_path
2482 if {$path ne
$current_diff_path} {
2484 } elseif
{[find_next_diff
$w $path $lno $mmask]} {
2487 return {reshow_diff
;}
2491 proc select_first_diff
{after
} {
2494 if {[find_next_diff
$ui_workdir {} 1 {^_?U
}] ||
2495 [find_next_diff
$ui_workdir {} 1 {[^O
]$
}]} {
2502 proc force_first_diff
{after
} {
2503 global ui_workdir current_diff_path file_states
2505 if {[info exists file_states
($current_diff_path)]} {
2506 set state
[lindex
$file_states($current_diff_path) 0]
2512 if {[string first
{U
} $state] >= 0} {
2513 # Already a conflict, do nothing
2514 } elseif
{[find_next_diff
$ui_workdir $current_diff_path {} {^_?U
}]} {
2516 } elseif
{[string index
$state 1] ne
{O
}} {
2517 # Already a diff & no conflicts, do nothing
2518 } elseif
{[find_next_diff
$ui_workdir $current_diff_path {} {[^O
]$
}]} {
2529 # opens file in editor
2530 proc open_in_git_editor
{path
{lno
0} {edit_index
0}} {
2535 set fd
[git_read ls-files
-s --error-unmatch -- $path]
2536 fconfigure
$fd -translation binary
-encoding binary
2537 set info
[split [gets
$fd] " \t"]
2539 set mode
[lindex
$info 0]
2540 set sha1
[lindex
$info 1]
2541 set stage
[lindex
$info 2]
2542 if {$mode != 100644 && $mode != 100755} {
2543 return -code error
"Path is not a regular file: $mode"
2546 return -code error
"Path is in unmerged state."
2548 set tmp_path
"[file rootname $path].[string range $sha1 0 11][file extension $path]"
2549 if {[file exists
$tmp_path]} {
2550 return -code error
"Path is currently edited."
2552 set fd
[git_read checkout-index
--temp -- $path]
2553 fconfigure
$fd -translation binary
-encoding binary
2554 set info
[split [gets
$fd] " \t"]
2556 set git_tmp_path
[lindex
$info 0]
2557 file rename
$git_tmp_path $tmp_path
2559 if {$mode == 100644} {
2560 file attributes
$tmp_path -permissions 0600
2562 file attributes
$tmp_path -permissions 0700
2568 if {[info exists tmp_path
]} {
2569 file delete
$tmp_path
2571 if {[info exists git_tmp_path
]} {
2572 file delete
$git_tmp_path
2577 -title {git-gui
: Can
't edit path from index} \
2583 catch { unset env(ARGS) }
2584 catch { unset env(REVISION) }
2587 set env(GIT_EDITOR_F_NBLOCK) 1
2590 set env(GIT_EDITOR_F_POSITION) $lno
2593 if {[catch {exec [shellpath] -c "[git var GIT_EDITOR] [sq $path]"} err]} {
2597 -title {git-gui: Can't start GIT_EDITOR
} \
2601 catch
{ unset env
(GIT_EDITOR_F_NBLOCK
) }
2602 catch
{ unset env
(GIT_EDITOR_F_POSITION
) }
2606 set new_mode
[file attributes
$path -permissions]
2607 switch
-glob $new_mode {
2615 return -code error
"Invalid mode of edited file."
2618 set fd
[git_read hash-object
-w --path=[encoding convertto
$orig_path] -- [encoding convertto
$path]]
2619 fconfigure
$fd -translation binary
-encoding binary
2620 set new_sha1
[gets
$fd]
2623 set fd
[git_write update-index
-z --index-info]
2624 puts
-nonewline $fd "$new_mode $new_sha1\t[encoding convertto $orig_path]\0"
2631 -title {git-gui
: Can
't edit path from index} \
2639 proc get_best_diff_lno {w lno} {
2640 set fwi [$w search -elide -regexp {^\d+$} $lno.0 end]
2644 set bwi [$w search -elide -backwards -regexp {^\d+$} $lno.0 1.0]
2648 set fwl [$w count -lines $lno.0 $fwi]
2649 set bwl [$w count -lines $bwi $lno.0]
2651 set lno [$w get "$fwi linestart" "$fwi lineend"]
2653 set lno [$w get "$bwi linestart" "$bwi lineend"]
2663 proc open_from_file_list {w x y {edit_index 0}} {
2664 global ui_diff ui_diff_blnos
2665 global file_lists current_diff_path
2667 set pos [split [$w index @$x,$y] .]
2668 set lno [lindex $pos 0]
2669 set col [lindex $pos 1]
2670 set path [lindex $file_lists($w) [expr {$lno - 1}]]
2676 if {$path eq $current_diff_path} {
2677 # calculate the line number which is visible in the middle
2678 set height [$ui_diff count -ypixels 1.0 end]
2679 set ypos [$ui_diff yview]
2680 set yposm [expr {([lindex $ypos 1] + [lindex $ypos 0]) / 2}]
2681 set mpixel [expr {$height * $yposm}]
2682 set ytop [expr {[lindex $ypos 0] * $height}]
2683 set rmpixel [expr {round($mpixel - $ytop)}]
2684 set lno [$ui_diff index "@0,$rmpixel linestart"]
2685 set lno [lindex [split $lno .] 0]
2687 set lno [get_best_diff_lno $ui_diff_blnos $lno]
2690 open_in_git_editor $path $lno $edit_index
2693 proc open_from_diff_view {x y {edit_index 0}} {
2694 global ui_diff ui_diff_blnos
2695 global file_lists current_diff_path
2697 if {$current_diff_path eq {}} {
2701 set lno [$ui_diff index "@0,$y linestart"]
2702 set lno [lindex [split $lno .] 0]
2703 set lno [get_best_diff_lno $ui_diff_blnos $lno]
2705 open_in_git_editor $current_diff_path $lno $edit_index
2708 proc popup_files_ctxm {m w x y X Y} {
2709 global file_lists popup_path
2714 set pos [split [$w index @$x,$y] .]
2715 set lno [lindex $pos 0]
2716 set col [lindex $pos 1]
2717 set popup_path [lindex $file_lists($w) [expr {$lno - 1}]]
2718 if {$popup_path eq {}} {
2724 proc toggle_or_diff {w x y} {
2725 global file_states file_lists current_diff_path ui_index ui_workdir
2726 global last_clicked selected_paths
2728 set pos [split [$w index @$x,$y] .]
2729 set lno [lindex $pos 0]
2730 set col [lindex $pos 1]
2731 set path [lindex $file_lists($w) [expr {$lno - 1}]]
2737 set last_clicked [list $w $lno]
2738 array unset selected_paths
2739 $ui_index tag remove in_sel 0.0 end
2740 $ui_workdir tag remove in_sel 0.0 end
2742 # Determine the state of the file
2743 if {[info exists file_states($path)]} {
2744 set state [lindex $file_states($path) 0]
2749 # Restage the file, or simply show the diff
2750 if {$col == 0 && $y > 1} {
2751 # Conflicts need special handling
2752 if {[string first {U} $state] >= 0} {
2753 # $w must always be $ui_workdir, but...
2754 if {$w ne $ui_workdir} { set lno {} }
2755 merge_stage_workdir $path $lno
2759 if {[string index $state 1] eq {O}} {
2765 set after [next_diff_after_action $w $path $lno $mmask]
2767 if {$w eq $ui_index} {
2769 "Unstaging [short_path $path] from commit" \
2771 [concat $after [list ui_ready]]
2772 } elseif {$w eq $ui_workdir} {
2774 "Adding [short_path $path]" \
2776 [concat $after [list ui_ready]]
2779 show_diff $path $w $lno
2783 proc add_one_to_selection {w x y} {
2784 global file_lists last_clicked selected_paths
2786 set lno [lindex [split [$w index @$x,$y] .] 0]
2787 set path [lindex $file_lists($w) [expr {$lno - 1}]]
2793 if {$last_clicked ne {}
2794 && [lindex $last_clicked 0] ne $w} {
2795 array unset selected_paths
2796 [lindex $last_clicked 0] tag remove in_sel 0.0 end
2799 set last_clicked [list $w $lno]
2800 if {[catch {set in_sel $selected_paths($path)}]} {
2804 unset selected_paths($path)
2805 $w tag remove in_sel $lno.0 [expr {$lno + 1}].0
2807 set selected_paths($path) 1
2808 $w tag add in_sel $lno.0 [expr {$lno + 1}].0
2812 proc add_range_to_selection {w x y} {
2813 global file_lists last_clicked selected_paths
2815 if {[lindex $last_clicked 0] ne $w} {
2816 toggle_or_diff $w $x $y
2820 set lno [lindex [split [$w index @$x,$y] .] 0]
2821 set lc [lindex $last_clicked 1]
2830 foreach path [lrange $file_lists($w) \
2831 [expr {$begin - 1}] \
2832 [expr {$end - 1}]] {
2833 set selected_paths($path) 1
2835 $w tag add in_sel $begin.0 [expr {$end + 1}].0
2838 proc show_more_context {} {
2840 if {$repo_config(gui.diffcontext) < 99} {
2841 incr repo_config(gui.diffcontext)
2846 proc show_less_context {} {
2848 if {$repo_config(gui.diffcontext) > 1} {
2849 incr repo_config(gui.diffcontext) -1
2854 ######################################################################
2862 menu .mbar -tearoff 0
2864 # -- Apple Menu (Mac OS X only)
2866 .mbar add cascade -label Apple -menu .mbar.apple
2869 .mbar add cascade -label [mc Repository] -menu .mbar.repository
2870 .mbar add cascade -label [mc Edit] -menu .mbar.edit
2871 if {[is_enabled branch]} {
2872 .mbar add cascade -label [mc Branch] -menu .mbar.branch
2874 if {[is_enabled multicommit] || [is_enabled singlecommit]} {
2875 .mbar add cascade -label [mc Commit@@noun] -menu .mbar.commit
2877 if {[is_enabled transport]} {
2878 .mbar add cascade -label [mc Merge] -menu .mbar.merge
2879 .mbar add cascade -label [mc Remote] -menu .mbar.remote
2881 if {[is_enabled multicommit] || [is_enabled singlecommit]} {
2882 .mbar add cascade -label [mc Tools] -menu .mbar.tools
2885 # -- Repository Menu
2887 menu .mbar.repository
2890 .mbar.repository add command \
2891 -label [mc "Explore Working Copy"] \
2892 -command {do_explore}
2896 .mbar.repository add command \
2897 -label [mc "Git Bash"] \
2898 -command {eval exec [auto_execok start] \
2899 [list "Git Bash" bash --login -l &]}
2902 if {[is_Windows] || ![is_bare]} {
2903 .mbar.repository add separator
2906 .mbar.repository add command \
2907 -label [mc "Browse Current Branch's Files
"] \
2908 -command {browser::new $current_branch}
2909 set ui_browse_current [.mbar.repository index last]
2910 .mbar.repository add command \
2911 -label [mc "Browse Branch Files...
"] \
2912 -command browser_open::dialog
2913 .mbar.repository add separator
2915 .mbar.repository add command \
2916 -label [mc "Visualize Current Branch
's History"] \
2917 -command {do_gitk $current_branch}
2918 set ui_visualize_current [.mbar.repository index last]
2919 .mbar.repository add command \
2920 -label [mc "Visualize All Branch History"] \
2921 -command {do_gitk --all}
2922 .mbar.repository add separator
2924 proc current_branch_write {args} {
2925 global current_branch
2926 .mbar.repository entryconf $::ui_browse_current \
2927 -label [mc "Browse %s's Files
" $current_branch]
2928 .mbar.repository entryconf $::ui_visualize_current \
2929 -label [mc "Visualize
%s
's History" $current_branch]
2931 trace add variable current_branch write current_branch_write
2933 if {[is_enabled multicommit]} {
2934 .mbar.repository add command -label [mc "Database Statistics"] \
2937 .mbar.repository add command -label [mc "Compress Database"] \
2940 .mbar.repository add command -label [mc "Verify Database"] \
2941 -command do_fsck_objects
2943 .mbar.repository add separator
2946 .mbar.repository add command \
2947 -label [mc "Create Desktop Icon"] \
2948 -command do_cygwin_shortcut
2949 } elseif {[is_Windows]} {
2950 .mbar.repository add command \
2951 -label [mc "Create Desktop Icon"] \
2952 -command do_windows_shortcut
2953 } elseif {[is_MacOSX]} {
2954 .mbar.repository add command \
2955 -label [mc "Create Desktop Icon"] \
2956 -command do_macosx_app
2961 proc ::tk::mac::Quit {args} { do_quit }
2963 .mbar.repository add command -label [mc Quit] \
2971 .mbar.edit add command -label [mc Undo] \
2972 -command {catch {[focus] edit undo}} \
2974 .mbar.edit add command -label [mc Redo] \
2975 -command {catch {[focus] edit redo}} \
2977 .mbar.edit add separator
2978 .mbar.edit add command -label [mc Cut] \
2979 -command {catch {tk_textCut [focus]}} \
2981 .mbar.edit add command -label [mc Copy] \
2982 -command {catch {tk_textCopy [focus]}} \
2984 .mbar.edit add command -label [mc Paste] \
2985 -command {catch {tk_textPaste [focus]; [focus] see insert}} \
2987 .mbar.edit add command -label [mc Delete] \
2988 -command {catch {[focus] delete sel.first sel.last}} \
2990 .mbar.edit add separator
2991 .mbar.edit add command -label [mc "Select All"] \
2992 -command {catch {[focus] tag add sel 0.0 end}} \
2997 if {[is_enabled branch]} {
3000 .mbar.branch add command -label [mc "Create..."] \
3001 -command branch_create::dialog \
3003 lappend disable_on_lock [list .mbar.branch entryconf \
3004 [.mbar.branch index last] -state]
3006 .mbar.branch add command -label [mc "Checkout..."] \
3007 -command branch_checkout::dialog \
3009 lappend disable_on_lock [list .mbar.branch entryconf \
3010 [.mbar.branch index last] -state]
3012 .mbar.branch add command -label [mc "Rename..."] \
3013 -command branch_rename::dialog
3014 lappend disable_on_lock [list .mbar.branch entryconf \
3015 [.mbar.branch index last] -state]
3017 .mbar.branch add command -label [mc "Delete..."] \
3018 -command branch_delete::dialog
3019 lappend disable_on_lock [list .mbar.branch entryconf \
3020 [.mbar.branch index last] -state]
3022 .mbar.branch add command -label [mc "Reset..."] \
3023 -command merge::reset_hard
3024 lappend disable_on_lock [list .mbar.branch entryconf \
3025 [.mbar.branch index last] -state]
3030 proc commit_btn_caption {} {
3031 if {[is_enabled nocommit]} {
3034 return [mc Commit@@verb]
3038 if {[is_enabled multicommit] || [is_enabled singlecommit]} {
3041 if {![is_enabled nocommit]} {
3042 .mbar.commit add radiobutton \
3043 -label [mc "New Commit"] \
3044 -command do_select_commit_type \
3045 -variable selected_commit_type \
3047 lappend disable_on_lock \
3048 [list .mbar.commit entryconf [.mbar.commit index last] -state]
3050 .mbar.commit add radiobutton \
3051 -label [mc "Amend Last Commit"] \
3052 -command do_select_commit_type \
3053 -variable selected_commit_type \
3055 lappend disable_on_lock \
3056 [list .mbar.commit entryconf [.mbar.commit index last] -state]
3058 .mbar.commit add separator
3061 .mbar.commit add command -label [mc Rescan] \
3062 -command ui_do_rescan \
3064 lappend disable_on_lock \
3065 [list .mbar.commit entryconf [.mbar.commit index last] -state]
3067 .mbar.commit add command -label [mc "Stage To Commit"] \
3068 -command do_add_selection \
3070 lappend disable_on_lock \
3071 [list .mbar.commit entryconf [.mbar.commit index last] -state]
3073 .mbar.commit add command -label [mc "Stage Changed Files To Commit"] \
3074 -command do_add_all \
3076 lappend disable_on_lock \
3077 [list .mbar.commit entryconf [.mbar.commit index last] -state]
3079 .mbar.commit add command -label [mc "Unstage From Commit"] \
3080 -command do_unstage_selection \
3082 lappend disable_on_lock \
3083 [list .mbar.commit entryconf [.mbar.commit index last] -state]
3085 .mbar.commit add command -label [mc "Revert Changes"] \
3086 -command do_revert_selection \
3088 lappend disable_on_lock \
3089 [list .mbar.commit entryconf [.mbar.commit index last] -state]
3091 .mbar.commit add separator
3093 .mbar.commit add command -label [mc "Show Less Context"] \
3094 -command show_less_context \
3095 -accelerator $M1T-\-
3097 .mbar.commit add command -label [mc "Show More Context"] \
3098 -command show_more_context \
3101 .mbar.commit add checkbutton -label [mc "Show Line Numbers"] \
3102 -command update_show_line_numbers \
3103 -variable diff_show_line_numbers
3105 .mbar.commit add separator
3107 if {![is_enabled nocommitmsg]} {
3108 .mbar.commit add command -label [mc "Sign Off"] \
3109 -command do_signoff \
3113 .mbar.commit add command -label [commit_btn_caption] \
3114 -command do_commit \
3115 -accelerator $M1T-Return
3116 lappend disable_on_lock \
3117 [list .mbar.commit entryconf [.mbar.commit index last] -state]
3122 if {[is_enabled branch]} {
3124 .mbar.merge add command -label [mc "Local Merge..."] \
3125 -command merge::dialog \
3127 lappend disable_on_lock \
3128 [list .mbar.merge entryconf [.mbar.merge index last] -state]
3129 .mbar.merge add command -label [mc "Abort Merge..."] \
3130 -command merge::reset_hard
3131 lappend disable_on_lock \
3132 [list .mbar.merge entryconf [.mbar.merge index last] -state]
3137 if {[is_enabled transport]} {
3140 .mbar.remote add command \
3141 -label [mc "Add..."] \
3142 -command remote_add::dialog \
3144 .mbar.remote add command \
3145 -label [mc "Push..."] \
3146 -command do_push_anywhere \
3148 .mbar.remote add command \
3149 -label [mc "Delete Branch..."] \
3150 -command remote_branch_delete::dialog
3154 proc ::tk::mac::ShowPreferences {} {do_options}
3158 .mbar.edit add separator
3159 .mbar.edit add command -label [mc "Options..."] \
3165 if {[is_enabled multicommit] || [is_enabled singlecommit]} {
3166 set tools_menubar .mbar.tools
3168 $tools_menubar add separator
3169 $tools_menubar add command -label [mc "Add..."] -command tools_add::dialog
3170 $tools_menubar add command -label [mc "Remove..."] -command tools_remove::dialog
3171 if {[array names repo_config guitool.*.cmd] ne {}} {
3172 tools_populate_all 3
3178 .mbar add cascade -label [mc Help] -menu .mbar.help
3182 .mbar.apple add command -label [mc "About %s" [appname]] \
3184 .mbar.apple add separator
3186 .mbar.help add command -label [mc "About %s" [appname]] \
3189 . configure -menu .mbar
3191 set doc_path [githtmldir]
3192 if {$doc_path ne {}} {
3193 set doc_path [file join $doc_path index.html]
3196 set doc_path [exec cygpath --mixed $doc_path]
3200 if {[file isfile $doc_path]} {
3201 set doc_url "file:$doc_path"
3203 set doc_url {http://www.kernel.org/pub/software/scm/git/docs/}
3206 proc start_browser {url} {
3207 git "web--browse" $url
3210 .mbar.help add command -label [mc "Online Documentation"] \
3211 -command [list start_browser $doc_url]
3213 .mbar.help add command -label [mc "Show SSH Key"] \
3216 unset doc_path doc_url
3218 # -- Standard bindings
3220 wm protocol . WM_DELETE_WINDOW do_quit
3221 bind all <$M1B-Key-q> do_quit
3222 bind all <$M1B-Key-Q> do_quit
3223 bind all <$M1B-Key-w> {destroy [winfo toplevel %W]}
3224 bind all <$M1B-Key-W> {destroy [winfo toplevel %W]}
3226 set subcommand_args {}
3228 set s "usage: $::argv0 $::subcommand $::subcommand_args"
3229 if {[tk windowingsystem] eq "win32"} {
3231 tk_messageBox -icon info -message $s \
3239 proc normalize_relpath {path} {
3241 foreach item [file split $path] {
3242 if {$item eq {.}} continue
3243 if {$item eq {..} && [llength $elements] > 0
3244 && [lindex $elements end] ne {..}} {
3245 set elements [lrange $elements 0 end-1]
3248 lappend elements $item
3250 return [eval file join $elements]
3253 # -- Not a normal commit type invocation? Do that instead!
3255 switch -- $subcommand {
3258 if {$subcommand eq "blame"} {
3259 set subcommand_args {[--line=<num>] rev? path}
3261 set subcommand_args {rev? path}
3263 if {$argv eq {}} usage
3269 set p [file join $_prefix $a]
3271 if {$is_path || [file exists $p]} {
3272 if {$path ne {}} usage
3273 set path [normalize_relpath $p]
3275 } elseif {$a eq {--}} {
3277 if {$head ne {}} usage
3282 } elseif {[regexp {^--line=(\d+)$} $a a lnum]} {
3283 if {$jump_spec ne {} || $head ne {}} usage
3284 set jump_spec [list $lnum]
3285 } elseif {$head eq {}} {
3286 if {$head ne {}} usage
3295 if {$head ne {} && $path eq {}} {
3296 if {[string index $head 0] eq {/}} {
3297 set path [normalize_relpath $head]
3300 set path [normalize_relpath $_prefix$head]
3308 if {[regexp {^[0-9a-f]{1,39}$} $head]} {
3310 set head [git rev-parse --verify $head]
3312 if {[tk windowingsystem] eq "win32"} {
3313 tk_messageBox -icon error -title [mc Error] -message $err
3320 set current_branch $head
3324 switch -- $subcommand {
3326 if {$jump_spec ne {}} usage
3328 if {$path ne {} && [file isdirectory $path]} {
3329 set head $current_branch
3335 browser::new $head $path
3338 if {$head eq {} && ![file exists $path]} {
3339 catch {wm withdraw .}
3343 -title [mc "git-gui: fatal error"] \
3344 -message [mc "fatal: cannot stat path %s: No such file or directory" $path]
3347 blame::new $head $path $jump_spec
3354 if {[llength $argv] != 0} {
3357 # fall through to setup UI for commits
3360 set err "usage: $argv0 \[{blame|browser|citool}\]"
3361 if {[tk windowingsystem] eq "win32"} {
3363 tk_messageBox -icon error -message $err \
3374 ${NS}::frame .branch
3375 if {!$use_ttk} {.branch configure -borderwidth 1 -relief sunken}
3376 ${NS}::label .branch.l1 \
3377 -text [mc "Current Branch:"] \
3380 ${NS}::label .branch.cb \
3381 -textvariable current_branch \
3384 pack .branch.l1 -side left
3385 pack .branch.cb -side left -fill x
3386 pack .branch -side top -fill x
3388 # -- Main Window Layout
3390 ${NS}::panedwindow .vpane -orient horizontal
3391 ${NS}::panedwindow .vpane.files -orient vertical
3393 .vpane add .vpane.files -weight 0
3395 .vpane add .vpane.files -sticky nsew -height 100 -width 200
3397 pack .vpane -anchor n -side top -fill both -expand 1
3399 # -- Index File List
3401 ${NS}::frame .vpane.files.index -height 100 -width 200
3402 tlabel .vpane.files.index.title \
3403 -text [mc "Staged Changes (Will Commit)"] \
3404 -background lightgreen -foreground black
3405 text $ui_index -background white -foreground black \
3407 -width 20 -height 10 \
3409 -cursor $cursor_ptr \
3410 -xscrollcommand {.vpane.files.index.sx set} \
3411 -yscrollcommand {.vpane.files.index.sy set} \
3413 ${NS}::scrollbar .vpane.files.index.sx -orient h -command [list $ui_index xview]
3414 ${NS}::scrollbar .vpane.files.index.sy -orient v -command [list $ui_index yview]
3415 pack .vpane.files.index.title -side top -fill x
3416 pack .vpane.files.index.sx -side bottom -fill x
3417 pack .vpane.files.index.sy -side right -fill y
3418 pack $ui_index -side left -fill both -expand 1
3420 # -- Working Directory File List
3422 ${NS}::frame .vpane.files.workdir -height 100 -width 200
3423 tlabel .vpane.files.workdir.title -text [mc "Unstaged Changes"] \
3424 -background lightsalmon -foreground black
3425 text $ui_workdir -background white -foreground black \
3427 -width 20 -height 10 \
3429 -cursor $cursor_ptr \
3430 -xscrollcommand {.vpane.files.workdir.sx set} \
3431 -yscrollcommand {.vpane.files.workdir.sy set} \
3433 ${NS}::scrollbar .vpane.files.workdir.sx -orient h -command [list $ui_workdir xview]
3434 ${NS}::scrollbar .vpane.files.workdir.sy -orient v -command [list $ui_workdir yview]
3435 pack .vpane.files.workdir.title -side top -fill x
3436 pack .vpane.files.workdir.sx -side bottom -fill x
3437 pack .vpane.files.workdir.sy -side right -fill y
3438 pack $ui_workdir -side left -fill both -expand 1
3441 .vpane.files add .vpane.files.workdir -weight 1
3442 .vpane.files add .vpane.files.index -weight 1
3444 .vpane.files add .vpane.files.workdir -sticky news
3445 .vpane.files add .vpane.files.index -sticky news
3448 foreach i [list $ui_index $ui_workdir] {
3450 $i tag conf in_diff -background [$i tag cget in_sel -background]
3451 #$i tag conf in_diff -underline 1
3452 #$i tag conf in_sel -background {#c6e2ff} -font font_diffitalic
3453 $i tag conf in_sel -background [$i cget -background] -underline 1
3457 set files_ctxm .vpane.files.ctxm
3458 menu $files_ctxm -tearoff 0
3459 $files_ctxm add separator
3460 $files_ctxm add command -label [mc "Open in Editor"] -command {open_from_file_list $current_diff_side $cursorX $cursorY}
3461 $files_ctxm add command -label [mc "Stage All Changed"] -command do_add_all
3462 $files_ctxm add command -label [mc "Stage Selected"] -command do_add_selection
3463 if {[array names repo_config guitool.*.cmd] ne {}} {
3464 files_tools_populate_all 4 popup_path
3468 # -- Diff and Commit Area
3471 ${NS}::panedwindow .vpane.lower -orient vertical
3472 ${NS}::frame .vpane.lower.commarea
3473 ${NS}::frame .vpane.lower.diff -relief sunken -borderwidth 1 -height 500
3474 .vpane.lower add .vpane.lower.diff
3475 .vpane.lower add .vpane.lower.commarea
3476 .vpane add .vpane.lower
3478 .vpane.lower pane .vpane.lower.diff -weight 1
3479 .vpane.lower pane .vpane.lower.commarea -weight 0
3481 .vpane.lower paneconfigure .vpane.lower.diff -stretch always
3482 .vpane.lower paneconfigure .vpane.lower.commarea -stretch never
3485 frame .vpane.lower -height 300 -width 400
3486 frame .vpane.lower.commarea
3487 frame .vpane.lower.diff -relief sunken -borderwidth 1
3488 pack .vpane.lower.diff -fill both -expand 1
3489 pack .vpane.lower.commarea -side bottom -fill x
3490 .vpane add .vpane.lower
3491 .vpane paneconfigure .vpane.lower -sticky nsew
3494 # -- Commit Area Buttons
3496 ${NS}::frame .vpane.lower.commarea.buttons
3497 ${NS}::label .vpane.lower.commarea.buttons.l -text {} \
3500 pack .vpane.lower.commarea.buttons.l -side top -fill x
3501 pack .vpane.lower.commarea.buttons -side left -fill y
3503 ${NS}::button .vpane.lower.commarea.buttons.rescan -text [mc Rescan] \
3504 -command ui_do_rescan
3505 pack .vpane.lower.commarea.buttons.rescan -side top -fill x
3506 lappend disable_on_lock \
3507 {.vpane.lower.commarea.buttons.rescan conf -state}
3509 ${NS}::button .vpane.lower.commarea.buttons.incall -text [mc "Stage Changed"] \
3511 pack .vpane.lower.commarea.buttons.incall -side top -fill x
3512 lappend disable_on_lock \
3513 {.vpane.lower.commarea.buttons.incall conf -state}
3515 if {![is_enabled nocommitmsg]} {
3516 ${NS}::button .vpane.lower.commarea.buttons.signoff -text [mc "Sign Off"] \
3518 pack .vpane.lower.commarea.buttons.signoff -side top -fill x
3521 ${NS}::button .vpane.lower.commarea.buttons.commit -text [commit_btn_caption] \
3523 pack .vpane.lower.commarea.buttons.commit -side top -fill x
3524 lappend disable_on_lock \
3525 {.vpane.lower.commarea.buttons.commit conf -state}
3527 if {![is_enabled nocommit]} {
3528 ${NS}::button .vpane.lower.commarea.buttons.push -text [mc Push] \
3529 -command do_push_anywhere
3530 pack .vpane.lower.commarea.buttons.push -side top -fill x
3533 # -- Commit Message Buffer
3535 ${NS}::frame .vpane.lower.commarea.buffer
3536 ${NS}::frame .vpane.lower.commarea.buffer.header
3537 set ui_comm .vpane.lower.commarea.buffer.t
3538 set ui_coml .vpane.lower.commarea.buffer.header.l
3540 proc ignore_yscrollcommand {top bottom} {}
3542 proc update_show_line_numbers {} {
3543 global ui_diff_alnos ui_diff_blnos ui_diff_clnos
3544 global diff_show_line_numbers is_3way_diff is_other_diff
3545 global ui_diff ui_diff_columns ui_diff_columns_to_scroll
3547 # remember current sscroll position
3548 set current_pos [.vpane.lower.diff.body.sby get]
3550 # remove all line number columns
3551 grid remove $ui_diff_alnos $ui_diff_blnos $ui_diff_clnos
3552 set ui_diff_columns_to_scroll [list $ui_diff]
3553 foreach i $ui_diff_columns {
3554 $i conf -yscrollcommand {}
3557 if {$diff_show_line_numbers} {
3558 if {!$is_other_diff} {
3559 grid configure $ui_diff_alnos
3560 lappend ui_diff_columns_to_scroll $ui_diff_alnos
3562 grid configure $ui_diff_blnos
3563 lappend ui_diff_columns_to_scroll $ui_diff_blnos
3564 if {$is_3way_diff} {
3565 grid configure $ui_diff_clnos
3566 lappend ui_diff_columns_to_scroll $ui_diff_clnos
3570 foreach i $ui_diff_columns_to_scroll {
3571 $i conf -yscrollcommand \
3572 "[list many2scrollbar $ui_diff_columns_to_scroll yview .vpane.lower.diff.body.sby]"
3574 .vpane.lower.diff.body.sby conf \
3575 -command [list scrollbar2many $ui_diff_columns_to_scroll yview]
3577 # restore current scroll position
3578 many2scrollbar $ui_diff_columns_to_scroll yview .vpane.lower.diff.body.sby [lindex $current_pos 0] [lindex $current_pos 1]
3581 if {![is_enabled nocommit]} {
3582 ${NS}::radiobutton .vpane.lower.commarea.buffer.header.new \
3583 -text [mc "New Commit"] \
3584 -command do_select_commit_type \
3585 -variable selected_commit_type \
3587 lappend disable_on_lock \
3588 [list .vpane.lower.commarea.buffer.header.new conf -state]
3589 ${NS}::radiobutton .vpane.lower.commarea.buffer.header.amend \
3590 -text [mc "Amend Last Commit"] \
3591 -command do_select_commit_type \
3592 -variable selected_commit_type \
3594 lappend disable_on_lock \
3595 [list .vpane.lower.commarea.buffer.header.amend conf -state]
3598 ${NS}::label $ui_coml \
3601 proc trace_commit_type {varname args} {
3602 global ui_coml commit_type
3603 switch -glob -- $commit_type {
3604 initial {set txt [mc "Initial Commit Message:"]}
3605 amend {set txt [mc "Amended Commit Message:"]}
3606 amend-initial {set txt [mc "Amended Initial Commit Message:"]}
3607 amend-merge {set txt [mc "Amended Merge Commit Message:"]}
3608 merge {set txt [mc "Merge Commit Message:"]}
3609 * {set txt [mc "Commit Message:"]}
3611 $ui_coml conf -text $txt
3613 trace add variable commit_type write trace_commit_type
3614 pack $ui_coml -side left -fill x
3616 if {![is_enabled nocommit]} {
3617 pack .vpane.lower.commarea.buffer.header.amend -side right
3618 pack .vpane.lower.commarea.buffer.header.new -side right
3621 text $ui_comm -background white -foreground black \
3625 -autoseparators true \
3627 -width $repo_config(gui.commitmsgwidth) -height 9 -wrap none \
3629 -yscrollcommand {.vpane.lower.commarea.buffer.sby set}
3630 ${NS}::scrollbar .vpane.lower.commarea.buffer.sby \
3631 -command [list $ui_comm yview]
3632 pack .vpane.lower.commarea.buffer.header -side top -fill x
3633 pack .vpane.lower.commarea.buffer.sby -side right -fill y
3634 pack $ui_comm -side left -fill y
3635 pack .vpane.lower.commarea.buffer -side left -fill y
3637 # -- Commit Message Buffer Context Menu
3639 set ui_comm_ctxm .vpane.lower.commarea.buffer.ctxm
3640 menu $ui_comm_ctxm -tearoff 0
3641 $ui_comm_ctxm add command \
3643 -command {tk_textCut $ui_comm}
3644 $ui_comm_ctxm add command \
3646 -command {tk_textCopy $ui_comm}
3647 $ui_comm_ctxm add command \
3649 -command {tk_textPaste $ui_comm}
3650 $ui_comm_ctxm add command \
3651 -label [mc Delete] \
3652 -command {catch {$ui_comm delete sel.first sel.last}}
3653 $ui_comm_ctxm add separator
3654 $ui_comm_ctxm add command \
3655 -label [mc "Select All"] \
3656 -command {focus $ui_comm;$ui_comm tag add sel 0.0 end}
3657 $ui_comm_ctxm add command \
3658 -label [mc "Copy All"] \
3660 $ui_comm tag add sel 0.0 end
3661 tk_textCopy $ui_comm
3662 $ui_comm tag remove sel 0.0 end
3664 $ui_comm_ctxm add separator
3665 $ui_comm_ctxm add command \
3666 -label [mc "Sign Off"] \
3671 proc trace_current_diff_path {varname args} {
3672 global current_diff_path diff_actions file_states
3673 if {$current_diff_path eq {}} {
3679 set p $current_diff_path
3680 set s [mapdesc [lindex $file_states($p) 0] $p]
3682 set p [escape_path $p]
3686 .vpane.lower.diff.header.status configure -text $s
3687 .vpane.lower.diff.header.file configure -text $f
3688 .vpane.lower.diff.header.path configure -text $p
3689 foreach w $diff_actions {
3693 trace add variable current_diff_path write trace_current_diff_path
3695 gold_frame .vpane.lower.diff.header
3696 tlabel .vpane.lower.diff.header.status \
3701 tlabel .vpane.lower.diff.header.file \
3706 tlabel .vpane.lower.diff.header.path \
3711 pack .vpane.lower.diff.header.status -side left
3712 pack .vpane.lower.diff.header.path -side right -fill x
3713 pack .vpane.lower.diff.header.file -side right
3714 set hctxm .vpane.lower.diff.header.ctxm
3715 menu $hctxm -tearoff 0
3716 $hctxm add command \
3723 -- $current_diff_path
3725 lappend diff_actions [list $hctxm entryconf [$hctxm index last] -state]
3726 bind_button3 .vpane.lower.diff.header.path "tk_popup $hctxm %X %Y"
3730 ${NS}::frame .vpane.lower.diff.body
3731 set ui_diff .vpane.lower.diff.body.t
3733 set ui_diff_clnos .vpane.lower.diff.body.c
3735 set ui_diff_alnos .vpane.lower.diff.body.a
3737 set ui_diff_blnos .vpane.lower.diff.body.b
3739 set ui_diff_lno_col_width 2
3741 text $ui_diff_alnos \
3743 -highlightthickness 0 \
3745 -background grey90 \
3748 -width [expr $ui_diff_lno_col_width + 2] \
3753 $ui_diff_alnos tag conf linenumber -justify right -rmargin 5
3754 $ui_diff_alnos tag conf red -foreground red
3755 $ui_diff_alnos tag conf green -foreground green4
3757 text $ui_diff_blnos \
3759 -highlightthickness 0 \
3761 -background grey95 \
3764 -width [expr $ui_diff_lno_col_width + 2] \
3769 $ui_diff_blnos tag conf linenumber -justify right -rmargin 5
3770 $ui_diff_blnos tag conf red -foreground red
3771 $ui_diff_blnos tag conf green -foreground green4
3772 $ui_diff_blnos tag conf hide -elide 1
3774 text $ui_diff_clnos \
3776 -highlightthickness 0 \
3778 -background grey90 \
3781 -width [expr $ui_diff_lno_col_width + 2] \
3786 $ui_diff_clnos tag conf linenumber -justify right -rmargin 5
3787 $ui_diff_clnos tag conf red -foreground red
3788 $ui_diff_clnos tag conf green -foreground green4
3790 delegate_sel_to $ui_diff [list $ui_diff_alnos $ui_diff_blnos $ui_diff_clnos]
3793 -highlightthickness 0 \
3798 -width 80 -height 5 \
3801 -xscrollcommand {.vpane.lower.diff.body.sbx set} \
3803 catch {$ui_diff configure -tabstyle wordprocessor}
3805 set ui_diff_columns [list $ui_diff_alnos $ui_diff_blnos $ui_diff $ui_diff_clnos]
3806 set ui_diff_line_columns [list $ui_diff_alnos $ui_diff_blnos $ui_diff_clnos]
3807 set ui_diff_columns_to_scroll $ui_diff_columns
3809 ${NS}::scrollbar .vpane.lower.diff.body.sbx -orient horizontal \
3810 -command [list $ui_diff xview]
3811 ${NS}::scrollbar .vpane.lower.diff.body.sby -orient vertical \
3812 -command [list scrollbar2many $ui_diff_columns_to_scroll yview]
3814 grid $ui_diff_alnos $ui_diff_blnos $ui_diff_clnos $ui_diff .vpane.lower.diff.body.sby -sticky nsew
3815 grid conf .vpane.lower.diff.body.sbx \
3819 grid columnconfigure .vpane.lower.diff.body \
3822 grid rowconfigure .vpane.lower.diff.body \
3826 update_show_line_numbers
3828 pack .vpane.lower.diff.header -side top -fill x
3829 pack .vpane.lower.diff.body -side bottom -fill both -expand 1
3832 foreach {n c} {0 black 1 red 2 green4 3 yellow4 4 blue4 5 magenta4 6 cyan4 7 grey60} {
3833 $ui_diff tag configure clr4$n -background $c
3834 $ui_diff tag configure clri4$n -foreground $c
3835 $ui_diff tag configure clr3$n -foreground $c
3836 $ui_diff tag configure clri3$n -background $c
3838 $ui_diff tag configure clr1 -font font_diffbold
3839 $ui_diff tag configure clr4 -underline 1
3841 $ui_diff tag conf d_info -foreground blue -font font_diffbold
3843 $ui_diff tag conf d_cr -elide true
3844 $ui_diff tag conf d_@ -font font_diffbold
3845 $ui_diff tag conf d_+ -foreground green4
3846 $ui_diff tag conf d_- -foreground red
3848 $ui_diff tag conf d_++ -foreground green4
3849 $ui_diff tag conf d_-- -foreground red
3850 $ui_diff tag conf d_+s \
3851 -foreground green4 \
3852 -background {#e2effa}
3853 $ui_diff tag conf d_-s \
3855 -background {#e2effa}
3856 $ui_diff tag conf d_s+ \
3857 -foreground green4 \
3859 $ui_diff tag conf d_s- \
3863 $ui_diff tag conf d< \
3864 -foreground orange \
3866 $ui_diff tag conf d| \
3867 -foreground orange \
3869 $ui_diff tag conf d= \
3870 -foreground orange \
3872 $ui_diff tag conf d> \
3873 -foreground orange \
3876 foreach i $ui_diff_columns {
3880 # -- Diff Body Context Menu
3883 proc create_common_diff_popup {ctxm} {
3885 -label [mc Refresh] \
3886 -command reshow_diff
3887 lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
3890 -command {tk_textCopy $ui_diff}
3891 lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
3893 -label [mc "Select All"] \
3894 -command {focus $ui_diff;$ui_diff tag add sel 0.0 end}
3895 lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
3897 -label [mc "Copy All"] \
3899 $ui_diff tag add sel 0.0 end
3900 tk_textCopy $ui_diff
3901 $ui_diff tag remove sel 0.0 end
3903 lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
3906 -label [mc "Decrease Font Size"] \
3907 -command {incr_font_size font_diff -1}
3908 lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
3910 -label [mc "Increase Font Size"] \
3911 -command {incr_font_size font_diff 1}
3912 lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
3916 build_encoding_menu $emenu [list force_diff_encoding]
3918 -label [mc "Encoding"] \
3920 lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
3922 $ctxm add command -label [mc "Options..."] \
3926 set ctxmw .vpane.lower.diff.body.ctxmw
3927 menu $ctxmw -tearoff 0
3928 $ctxmw add command \
3929 -label [mc "Apply/Reverse Hunk"] \
3930 -command {apply_hunk $cursorX $cursorY}
3931 set ui_diff_applyhunk [$ctxmw index last]
3932 lappend diff_actions [list $ctxmw entryconf $ui_diff_applyhunk -state]
3933 $ctxmw add command \
3934 -label [mc "Apply/Reverse Line"] \
3935 -command {apply_range_or_line $cursorX $cursorY; do_rescan}
3936 set ui_diff_applyline [$ctxmw index last]
3937 lappend diff_actions [list $ctxmw entryconf $ui_diff_applyline -state]
3938 $ctxmw add separator
3939 $ctxmw add command \
3940 -label [mc "Revert Hunk"] \
3941 -command {apply_hunk $cursorX $cursorY 1}
3942 lappend diff_actions [list $ctxmw entryconf $ui_diff_applyhunk -state]
3943 $ctxmw add command \
3944 -label [mc "Revert Line"] \
3945 -command {apply_range_or_line $cursorX $cursorY 1; do_rescan}
3946 set ui_diff_revertline [$ctxmw index last]
3947 lappend diff_actions [list $ctxmw entryconf $ui_diff_applyline -state]
3948 $ctxmw add separator
3949 $ctxmw add command \
3950 -label [mc "Open in Editor"] \
3951 -command {open_from_diff_view $cursorX $cursorY}
3952 lappend diff_actions [list $ctxmw entryconf [$ctxmw index last] -state]
3953 $ctxmw add command \
3954 -label [mc "Show Less Context"] \
3955 -command show_less_context
3956 lappend diff_actions [list $ctxmw entryconf [$ctxmw index last] -state]
3957 $ctxmw add command \
3958 -label [mc "Show More Context"] \
3959 -command show_more_context
3960 lappend diff_actions [list $ctxmw entryconf [$ctxmw index last] -state]
3961 $ctxmw add checkbutton \
3962 -label [mc "Show Line Numbers"] \
3963 -command update_show_line_numbers \
3964 -variable diff_show_line_numbers
3965 $ctxmw add separator
3966 create_common_diff_popup $ctxmw
3968 set ctxmi .vpane.lower.diff.body.ctxmi
3969 menu $ctxmi -tearoff 0
3970 $ctxmi add command \
3971 -label [mc "Apply/Reverse Hunk"] \
3972 -command {apply_hunk $cursorX $cursorY}
3973 lappend diff_actions [list $ctxmi entryconf $ui_diff_applyhunk -state]
3974 $ctxmi add command \
3975 -label [mc "Apply/Reverse Line"] \
3976 -command {apply_range_or_line $cursorX $cursorY; do_rescan}
3977 lappend diff_actions [list $ctxmi entryconf $ui_diff_applyline -state]
3978 $ctxmi add separator
3979 $ctxmi add command \
3980 -label [mc "Open in Editor"] \
3981 -command {open_from_diff_view $cursorX $cursorY}
3982 lappend diff_actions [list $ctxmi entryconf [$ctxmi index last] -state]
3983 $ctxmi add command \
3984 -label [mc "Open Staged Content in Editor"] \
3985 -command {open_from_diff_view $cursorX $cursorY 1}
3986 lappend diff_actions [list $ctxmi entryconf [$ctxmi index last] -state]
3987 $ctxmi add command \
3988 -label [mc "Show Less Context"] \
3989 -command show_less_context
3990 lappend diff_actions [list $ctxmi entryconf [$ctxmi index last] -state]
3991 $ctxmi add command \
3992 -label [mc "Show More Context"] \
3993 -command show_more_context
3994 lappend diff_actions [list $ctxmi entryconf [$ctxmi index last] -state]
3995 $ctxmi add checkbutton \
3996 -label [mc "Show Line Numbers"] \
3997 -command update_show_line_numbers \
3998 -variable diff_show_line_numbers
3999 $ctxmi add separator
4000 create_common_diff_popup $ctxmi
4002 set ctxmmg .vpane.lower.diff.body.ctxmmg
4003 menu $ctxmmg -tearoff 0
4004 $ctxmmg add command \
4005 -label [mc "Run Merge Tool"] \
4006 -command {merge_resolve_tool}
4007 lappend diff_actions [list $ctxmmg entryconf [$ctxmmg index last] -state]
4008 $ctxmmg add separator
4009 $ctxmmg add command \
4010 -label [mc "Use Remote Version"] \
4011 -command {merge_resolve_one 3}
4012 lappend diff_actions [list $ctxmmg entryconf [$ctxmmg index last] -state]
4013 $ctxmmg add command \
4014 -label [mc "Use Local Version"] \
4015 -command {merge_resolve_one 2}
4016 lappend diff_actions [list $ctxmmg entryconf [$ctxmmg index last] -state]
4017 $ctxmmg add command \
4018 -label [mc "Revert To Base"] \
4019 -command {merge_resolve_one 1}
4020 lappend diff_actions [list $ctxmmg entryconf [$ctxmmg index last] -state]
4021 $ctxmmg add separator
4022 $ctxmmg add command \
4023 -label [mc "Open in Editor"] \
4024 -command {open_from_diff_view $cursorX $cursorY}
4025 lappend diff_actions [list $ctxmmg entryconf [$ctxmmg index last] -state]
4026 $ctxmmg add command \
4027 -label [mc "Show Less Context"] \
4028 -command show_less_context
4029 lappend diff_actions [list $ctxmmg entryconf [$ctxmmg index last] -state]
4030 $ctxmmg add command \
4031 -label [mc "Show More Context"] \
4032 -command show_more_context
4033 lappend diff_actions [list $ctxmmg entryconf [$ctxmmg index last] -state]
4034 $ctxmmg add checkbutton \
4035 -label [mc "Show Line Numbers"] \
4036 -command update_show_line_numbers \
4037 -variable diff_show_line_numbers
4038 $ctxmmg add separator
4039 create_common_diff_popup $ctxmmg
4041 set ctxmsm .vpane.lower.diff.body.ctxmsm
4042 menu $ctxmsm -tearoff 0
4043 $ctxmsm add command \
4044 -label [mc "Visualize These Changes In The Submodule"] \
4045 -command {do_gitk -- true}
4046 lappend diff_actions [list $ctxmsm entryconf [$ctxmsm index last] -state]
4047 $ctxmsm add command \
4048 -label [mc "Visualize Current Branch History In The Submodule"] \
4049 -command {do_gitk {} true}
4050 lappend diff_actions [list $ctxmsm entryconf [$ctxmsm index last] -state]
4051 $ctxmsm add command \
4052 -label [mc "Visualize All Branch History In The Submodule"] \
4053 -command {do_gitk --all true}
4054 lappend diff_actions [list $ctxmsm entryconf [$ctxmsm index last] -state]
4055 $ctxmsm add separator
4056 $ctxmsm add command \
4057 -label [mc "Start git gui In The Submodule"] \
4058 -command {do_git_gui}
4059 lappend diff_actions [list $ctxmsm entryconf [$ctxmsm index last] -state]
4060 $ctxmsm add separator
4061 create_common_diff_popup $ctxmsm
4063 proc has_textconv {path} {
4064 if {[is_config_false gui.textconv]} {
4067 set filter [gitattr $path diff set]
4068 set textconv [get_config [join [list diff $filter textconv] .]]
4069 if {$filter ne {set} && $textconv ne {}} {
4076 proc popup_diff_menu {ctxmw ctxmi ctxmmg ctxmsm x y X Y} {
4077 global current_diff_path file_states
4080 if {[info exists file_states($current_diff_path)]} {
4081 set state [lindex $file_states($current_diff_path) 0]
4085 if {[string first {U} $state] >= 0} {
4086 tk_popup $ctxmmg $X $Y
4087 } elseif {$::is_submodule_diff} {
4088 tk_popup $ctxmsm $X $Y
4090 set has_range [expr {[$::ui_diff tag nextrange sel 0.0] != {}}]
4091 if {$::ui_index eq $::current_diff_side} {
4093 set l [mc "Unstage Hunk From Commit"]
4095 set t [mc "Unstage Lines From Commit"]
4097 set t [mc "Unstage Line From Commit"]
4101 set l [mc "Stage Hunk For Commit"]
4103 set t [mc "Stage Lines For Commit"]
4104 set r [mc "Revert Lines"]
4106 set t [mc "Stage Line For Commit"]
4107 set r [mc "Revert Line"]
4111 || $current_diff_path eq {}
4114 || [string match {?T} $state]
4115 || [string match {T?} $state]
4116 || [has_textconv $current_diff_path]} {
4121 $ctxm entryconf $::ui_diff_applyhunk -state $s -label $l
4122 $ctxm entryconf $::ui_diff_applyline -state $s -label $t
4123 if {$::ui_workdir eq $::current_diff_side} {
4124 $ctxm entryconf $::ui_diff_revertline -state $s -label $r
4126 tk_popup $ctxm $X $Y
4129 bind_button3 $ui_diff [list popup_diff_menu $ctxmw $ctxmi $ctxmmg $ctxmsm %x %y %X %Y]
4131 foreach i $ui_diff_columns {
4132 bind $i <ButtonRelease-2> {open_from_diff_view %x %y}
4133 bind $i <Shift-ButtonRelease-2> {open_from_diff_view %x %y 1}
4138 set main_status [::status_bar::new .status]
4139 pack .status -anchor w -side bottom -fill x
4140 $main_status show [mc "Initializing..."]
4144 proc on_ttk_pane_mapped {w pane pos} {
4146 after 0 [list after idle [list $w sashpos $pane $pos]]
4148 proc on_tk_pane_mapped {w pane x y} {
4150 after 0 [list after idle [list $w sash place $pane $x $y]]
4152 proc on_application_mapped {} {
4153 global repo_config use_ttk
4155 set gm $repo_config(gui.geometry)
4158 [list on_ttk_pane_mapped %W 0 [lindex $gm 1]]
4159 bind .vpane.files <Map> \
4160 [list on_ttk_pane_mapped %W 0 [lindex $gm 2]]
4163 [list on_tk_pane_mapped %W 0 \
4165 [lindex [.vpane sash coord 0] 1]]
4166 bind .vpane.files <Map> \
4167 [list on_tk_pane_mapped %W 0 \
4168 [lindex [.vpane.files sash coord 0] 0] \
4171 wm geometry . [lindex $gm 0]
4173 if {[info exists repo_config(gui.geometry)]} {
4174 bind . <Map> [list on_application_mapped]
4175 wm geometry . [lindex $repo_config(gui.geometry) 0]
4178 # -- Load window state
4180 if {[info exists repo_config(gui.wmstate)]} {
4181 catch {wm state . $repo_config(gui.wmstate)}
4186 bind $ui_comm <$M1B-Key-Return> {do_commit;break}
4187 bind $ui_comm <$M1B-Key-t> {do_add_selection;break}
4188 bind $ui_comm <$M1B-Key-T> {do_add_selection;break}
4189 bind $ui_comm <$M1B-Key-u> {do_unstage_selection;break}
4190 bind $ui_comm <$M1B-Key-U> {do_unstage_selection;break}
4191 bind $ui_comm <$M1B-Key-j> {do_revert_selection;break}
4192 bind $ui_comm <$M1B-Key-J> {do_revert_selection;break}
4193 bind $ui_comm <$M1B-Key-i> {do_add_all;break}
4194 bind $ui_comm <$M1B-Key-I> {do_add_all;break}
4195 bind $ui_comm <$M1B-Key-x> {tk_textCut %W;break}
4196 bind $ui_comm <$M1B-Key-X> {tk_textCut %W;break}
4197 bind $ui_comm <$M1B-Key-c> {tk_textCopy %W;break}
4198 bind $ui_comm <$M1B-Key-C> {tk_textCopy %W;break}
4199 bind $ui_comm <$M1B-Key-v> {tk_textPaste %W; %W see insert; break}
4200 bind $ui_comm <$M1B-Key-V> {tk_textPaste %W; %W see insert; break}
4201 bind $ui_comm <$M1B-Key-a> {%W tag add sel 0.0 end;break}
4202 bind $ui_comm <$M1B-Key-A> {%W tag add sel 0.0 end;break}
4203 bind $ui_comm <$M1B-Key-minus> {show_less_context;break}
4204 bind $ui_comm <$M1B-Key-KP_Subtract> {show_less_context;break}
4205 bind $ui_comm <$M1B-Key-equal> {show_more_context;break}
4206 bind $ui_comm <$M1B-Key-plus> {show_more_context;break}
4207 bind $ui_comm <$M1B-Key-KP_Add> {show_more_context;break}
4209 bind $ui_diff <$M1B-Key-x> {tk_textCopy %W;break}
4210 bind $ui_diff <$M1B-Key-X> {tk_textCopy %W;break}
4211 bind $ui_diff <$M1B-Key-c> {tk_textCopy %W;break}
4212 bind $ui_diff <$M1B-Key-C> {tk_textCopy %W;break}
4213 bind $ui_diff <$M1B-Key-v> {break}
4214 bind $ui_diff <$M1B-Key-V> {break}
4215 bind $ui_diff <$M1B-Key-a> {%W tag add sel 0.0 end;break}
4216 bind $ui_diff <$M1B-Key-A> {%W tag add sel 0.0 end;break}
4217 bind $ui_diff <$M1B-Key-j> {do_revert_selection;break}
4218 bind $ui_diff <$M1B-Key-J> {do_revert_selection;break}
4219 bind $ui_diff <Key-Up> {catch {%W yview scroll -1 units};break}
4220 bind $ui_diff <Key-Down> {catch {%W yview scroll 1 units};break}
4221 bind $ui_diff <Key-Left> {catch {%W xview scroll -1 units};break}
4222 bind $ui_diff <Key-Right> {catch {%W xview scroll 1 units};break}
4223 bind $ui_diff <Key-k> {catch {%W yview scroll -1 units};break}
4224 bind $ui_diff <Key-j> {catch {%W yview scroll 1 units};break}
4225 bind $ui_diff <Key-h> {catch {%W xview scroll -1 units};break}
4226 bind $ui_diff <Key-l> {catch {%W xview scroll 1 units};break}
4227 bind $ui_diff <Control-Key-b> {catch {%W yview scroll -1 pages};break}
4228 bind $ui_diff <Control-Key-f> {catch {%W yview scroll 1 pages};break}
4229 bind $ui_diff <Button-1> {focus %W}
4231 if {[is_enabled branch]} {
4232 bind . <$M1B-Key-n> branch_create::dialog
4233 bind . <$M1B-Key-N> branch_create::dialog
4234 bind . <$M1B-Key-o> branch_checkout::dialog
4235 bind . <$M1B-Key-O> branch_checkout::dialog
4236 bind . <$M1B-Key-m> merge::dialog
4237 bind . <$M1B-Key-M> merge::dialog
4239 if {[is_enabled transport]} {
4240 bind . <$M1B-Key-p> do_push_anywhere
4241 bind . <$M1B-Key-P> do_push_anywhere
4244 bind . <Key-F5> ui_do_rescan
4245 bind . <$M1B-Key-r> ui_do_rescan
4246 bind . <$M1B-Key-R> ui_do_rescan
4247 bind . <$M1B-Key-s> do_signoff
4248 bind . <$M1B-Key-S> do_signoff
4249 bind . <$M1B-Key-t> do_add_selection
4250 bind . <$M1B-Key-T> do_add_selection
4251 bind . <$M1B-Key-u> do_unstage_selection
4252 bind . <$M1B-Key-U> do_unstage_selection
4253 bind . <$M1B-Key-j> do_revert_selection
4254 bind . <$M1B-Key-J> do_revert_selection
4255 bind . <$M1B-Key-i> do_add_all
4256 bind . <$M1B-Key-I> do_add_all
4257 bind . <$M1B-Key-minus> {show_less_context;break}
4258 bind . <$M1B-Key-KP_Subtract> {show_less_context;break}
4259 bind . <$M1B-Key-equal> {show_more_context;break}
4260 bind . <$M1B-Key-plus> {show_more_context;break}
4261 bind . <$M1B-Key-KP_Add> {show_more_context;break}
4262 bind . <$M1B-Key-Return> do_commit
4263 foreach i [list $ui_index $ui_workdir] {
4264 bind $i <Button-1> "toggle_or_diff $i %x %y; break"
4265 bind $i <$M1B-Button-1> "add_one_to_selection $i %x %y; break"
4266 bind $i <Shift-Button-1> "add_range_to_selection $i %x %y; break"
4268 bind $i <ButtonRelease-2> "open_from_file_list $i %x %y; break"
4269 bind $i <Shift-ButtonRelease-2> "open_from_file_list $i %x %y 1; break"
4272 if {[$files_ctxm index end] == 1} {
4273 # remove the separator, when we don't have user specified
file tools
4274 $files_ctxm delete
0
4276 bind_button3
$ui_index "popup_files_ctxm $files_ctxm $ui_index %x %y %X %Y; break"
4277 bind_button3
$ui_workdir "popup_files_ctxm $files_ctxm $ui_workdir %x %y %X %Y; break"
4281 set file_lists
($ui_index) [list
]
4282 set file_lists
($ui_workdir) [list
]
4284 wm title .
"[appname] ([reponame]) [file normalize $_gitworktree]"
4285 focus
-force $ui_comm
4287 # -- Warn the user about environmental problems. Cygwin's Tcl
4288 # does *not* pass its env array onto any processes it spawns.
4289 # This means that git processes get none of our environment.
4294 set msg
[mc
"Possible environment issues exist.
4296 The following environment variables are probably
4297 going to be ignored by any Git subprocess run
4301 foreach name
[array names env
] {
4302 switch
-regexp -- $name {
4303 {^GIT_INDEX_FILE$
} -
4304 {^GIT_OBJECT_DIRECTORY$
} -
4305 {^GIT_ALTERNATE_OBJECT_DIRECTORIES$
} -
4307 {^GIT_EXTERNAL_DIFF$
} -
4311 {^GIT_
(AUTHOR|COMMITTER
)_DATE$
} {
4312 append msg
" - $name\n"
4315 {^GIT_
(AUTHOR|COMMITTER
)_
(NAME|EMAIL
)$
} {
4316 append msg
" - $name\n"
4318 set suggest_user
$name
4322 if {$ignored_env > 0} {
4324 This is due to a known issue with the
4325 Tcl binary distributed by Cygwin."]
4327 if {$suggest_user ne
{}} {
4330 A good replacement for %s
4331 is placing values for the user.name and
4332 user.email settings into your personal
4338 unset ignored_env msg suggest_user name
4341 # -- Only initialize complex UI if we are going to stay running.
4343 if {[is_enabled transport
]} {
4346 set n
[.mbar.remote index end
]
4347 populate_remotes_menu
4348 set n
[expr {[.mbar.remote index end
] - $n}]
4350 if {[.mbar.remote
type 0] eq
"tearoff"} { incr n
}
4351 .mbar.remote insert
$n separator
4356 if {[winfo exists
$ui_comm]} {
4357 set GITGUI_BCK_exists
[load_message GITGUI_BCK utf-8
]
4359 # -- If both our backup and message files exist use the
4360 # newer of the two files to initialize the buffer.
4362 if {$GITGUI_BCK_exists} {
4363 set m
[gitdir GITGUI_MSG
]
4364 if {[file isfile
$m]} {
4365 if {[file mtime
[gitdir GITGUI_BCK
]] > [file mtime
$m]} {
4366 catch
{file delete
[gitdir GITGUI_MSG
]}
4368 $ui_comm delete
0.0 end
4370 $ui_comm edit modified false
4371 catch
{file delete
[gitdir GITGUI_BCK
]}
4372 set GITGUI_BCK_exists
0
4378 proc backup_commit_buffer
{} {
4379 global ui_comm GITGUI_BCK_exists
4381 set m
[$ui_comm edit modified
]
4382 if {$m ||
$GITGUI_BCK_exists} {
4383 set msg
[string trim
[$ui_comm get
0.0 end
]]
4384 regsub
-all -line {[ \r\t]+$
} $msg {} msg
4387 if {$GITGUI_BCK_exists} {
4388 catch
{file delete
[gitdir GITGUI_BCK
]}
4389 set GITGUI_BCK_exists
0
4393 set fd
[open
[gitdir GITGUI_BCK
] w
]
4394 fconfigure
$fd -encoding utf-8
4395 puts
-nonewline $fd $msg
4397 set GITGUI_BCK_exists
1
4401 $ui_comm edit modified false
4404 set ::GITGUI_BCK_i
[after
2000 backup_commit_buffer
]
4407 backup_commit_buffer
4409 # -- If the user has aspell available we can drive it
4410 # in pipe mode to spellcheck the commit message.
4412 set spell_cmd
[list |
]
4413 set spell_dict
[get_config gui.spellingdictionary
]
4414 lappend spell_cmd aspell
4415 if {$spell_dict ne
{}} {
4416 lappend spell_cmd
--master=$spell_dict
4418 lappend spell_cmd
--mode=none
4419 lappend spell_cmd
--encoding=utf-8
4420 lappend spell_cmd pipe
4421 if {$spell_dict eq
{none
}
4422 ||
[catch
{set spell_fd
[open
$spell_cmd r
+]} spell_err
]} {
4423 bind_button3
$ui_comm [list tk_popup
$ui_comm_ctxm %X
%Y
]
4425 set ui_comm_spell
[spellcheck
::init \
4431 unset -nocomplain spell_cmd spell_fd spell_err spell_dict
4434 lock_index begin-read
4435 if {![winfo ismapped .
]} {
4439 if {[is_enabled initialamend
]} {
4445 if {[is_enabled nocommitmsg
]} {
4446 $ui_comm configure
-state disabled
-background gray
4449 if {[is_enabled multicommit
] && ![is_config_false gui.gcwarning
]} {
4452 if {[is_enabled retcode
]} {
4453 bind .
<Destroy
> {+terminate_me
%W
}
4455 if {$picked && [is_config_true gui.autoexplore
]} {
4461 # indent-tabs-mode: t