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@@
}
14 Copyright ©
2006, 2007 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 [mc
"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 dirname [file normalize
$argv0]]]
56 set oguilib
[file join $oguilib share git-gui lib
]
57 set oguimsg
[file join $oguilib msgs
]
58 } elseif
{[string match @@
* $oguirel]} {
59 set oguilib
[file join [file dirname [file normalize
$argv0]] lib
]
60 set oguimsg
[file join [file dirname [file normalize
$argv0]] po
]
62 set oguimsg
[file join $oguilib msgs
]
66 ######################################################################
68 ## enable verbose loading?
70 if {![catch
{set _verbose
$env(GITGUI_VERBOSE
)}]} {
72 rename auto_load real__auto_load
73 proc auto_load
{name args
} {
74 puts stderr
"auto_load $name"
75 return [uplevel
1 real__auto_load
$name $args]
77 rename
source real__source
79 puts stderr
"source $name"
80 uplevel
1 real__source
$name
84 ######################################################################
86 ## Internationalization (i18n) through msgcat and gettext. See
87 ## http://www.gnu.org/software/gettext/manual/html_node/Tcl.html
89 package require msgcat
92 set fmt [::msgcat
::mc
$fmt]
93 set cmk
[string first @@
$fmt]
95 set fmt [string range
$fmt 0 [expr {$cmk - 1}]]
97 return [eval [list format
$fmt] $args]
101 return [join $args {}]
104 ::msgcat
::mcload
$oguimsg
107 ######################################################################
111 set _appname
{Git Gui
}
128 return [eval [list
file join $_gitdir] $args]
131 proc gitexec
{args
} {
133 if {$_gitexec eq
{}} {
134 if {[catch
{set _gitexec
[git
--exec-path]} err
]} {
135 error
"Git not installed?\n\n$err"
138 set _gitexec
[exec cygpath \
143 set _gitexec
[file normalize
$_gitexec]
149 return [eval [list
file join $_gitexec] $args]
157 if {[tk windowingsystem
] eq
{aqua
}} {
164 if {$
::tcl_platform
(platform
) eq
{windows
}} {
172 if {$_iscygwin eq
{}} {
173 if {$
::tcl_platform
(platform
) eq
{windows
}} {
174 if {[catch
{set p
[exec cygpath
--windir]} err
]} {
186 proc is_enabled
{option
} {
187 global enabled_options
188 if {[catch
{set on
$enabled_options($option)}]} {return 0}
192 proc enable_option
{option
} {
193 global enabled_options
194 set enabled_options
($option) 1
197 proc disable_option
{option
} {
198 global enabled_options
199 set enabled_options
($option) 0
202 ######################################################################
206 proc is_many_config
{name
} {
207 switch
-glob -- $name {
216 proc is_config_true
{name
} {
218 if {[catch
{set v
$repo_config($name)}]} {
220 } elseif
{$v eq
{true
} ||
$v eq
{1} ||
$v eq
{yes}} {
227 proc get_config
{name
} {
229 if {[catch
{set v
$repo_config($name)}]} {
236 proc load_config
{include_global
} {
237 global repo_config global_config default_config
239 array
unset global_config
240 if {$include_global} {
242 set fd_rc
[git_read config
--global --list]
243 while {[gets
$fd_rc line
] >= 0} {
244 if {[regexp
{^
([^
=]+)=(.
*)$
} $line line name value
]} {
245 if {[is_many_config
$name]} {
246 lappend global_config
($name) $value
248 set global_config
($name) $value
256 array
unset repo_config
258 set fd_rc
[git_read config
--list]
259 while {[gets
$fd_rc line
] >= 0} {
260 if {[regexp
{^
([^
=]+)=(.
*)$
} $line line name value
]} {
261 if {[is_many_config
$name]} {
262 lappend repo_config
($name) $value
264 set repo_config
($name) $value
271 foreach name
[array names default_config
] {
272 if {[catch
{set v
$global_config($name)}]} {
273 set global_config
($name) $default_config($name)
275 if {[catch
{set v
$repo_config($name)}]} {
276 set repo_config
($name) $default_config($name)
281 ######################################################################
285 proc _git_cmd
{name
} {
288 if {[catch
{set v
$_git_cmd_path($name)}]} {
292 --exec-path { return [list $
::_git
$name] }
295 set p
[gitexec git-
$name$
::_search_exe
]
296 if {[file exists
$p]} {
298 } elseif
{[is_Windows
] && [file exists
[gitexec git-
$name]]} {
299 # Try to determine what sort of magic will make
300 # git-$name go and do its thing, because native
301 # Tcl on Windows doesn't know it.
303 set p
[gitexec git-
$name]
308 switch
-glob -- [lindex
$s 0] {
310 #!*perl { set i perl }
311 #!*python { set i python }
312 default
{ error
"git-$name is not supported: $s" }
316 if {![info exists interp
]} {
317 set interp
[_which
$i]
320 error
"git-$name requires $i (not in PATH)"
322 set v
[concat
[list
$interp] [lrange
$s 1 end
] [list
$p]]
324 # Assume it is builtin to git somehow and we
325 # aren't actually able to see a file for it.
327 set v
[list $
::_git
$name]
329 set _git_cmd_path
($name) $v
335 global env _search_exe _search_path
337 if {$_search_path eq
{}} {
338 if {[is_Cygwin
] && [regexp
{^
(/|\.
:)} $env(PATH
)]} {
339 set _search_path
[split [exec cygpath \
345 } elseif
{[is_Windows
]} {
346 set gitguidir
[file dirname [info
script]]
347 regsub
-all ";" $gitguidir "\\;" gitguidir
348 set env
(PATH
) "$gitguidir;$env(PATH)"
349 set _search_path
[split $env(PATH
) {;}]
352 set _search_path
[split $env(PATH
) :]
357 foreach p
$_search_path {
358 set p
[file join $p $what$_search_exe]
359 if {[file exists
$p]} {
360 return [file normalize
$p]
366 proc _lappend_nice
{cmd_var
} {
370 if {![info exists _nice
]} {
371 set _nice
[_which nice
]
382 switch
-- [lindex
$args 0] {
393 set args
[lrange
$args 1 end
]
396 set cmdp
[_git_cmd
[lindex
$args 0]]
397 set args
[lrange
$args 1 end
]
399 return [eval $opt $cmdp $args]
402 proc _open_stdout_stderr
{cmd
} {
406 if { [lindex
$cmd end
] eq
{2>@
1}
407 && $err eq
{can not
find channel named
"1"}
409 # Older versions of Tcl 8.4 don't have this 2>@1 IO
410 # redirect operator. Fallback to |& cat for those.
411 # The command was not actually started, so its safe
412 # to try to start it a second time.
414 set fd
[open
[concat \
415 [lrange
$cmd 0 end-1
] \
422 fconfigure
$fd -eofchar {}
426 proc git_read
{args
} {
430 switch
-- [lindex
$args 0] {
445 set args
[lrange
$args 1 end
]
448 set cmdp
[_git_cmd
[lindex
$args 0]]
449 set args
[lrange
$args 1 end
]
451 return [_open_stdout_stderr
[concat
$opt $cmdp $args]]
454 proc git_write
{args
} {
458 switch
-- [lindex
$args 0] {
469 set args
[lrange
$args 1 end
]
472 set cmdp
[_git_cmd
[lindex
$args 0]]
473 set args
[lrange
$args 1 end
]
475 return [open
[concat
$opt $cmdp $args] w
]
479 regsub
-all ' $value "'\\''" value
483 proc load_current_branch {} {
484 global current_branch is_detached
486 set fd [open [gitdir HEAD] r]
487 if {[gets $fd ref] < 1} {
492 set pfx {ref: refs/heads/}
493 set len [string length $pfx]
494 if {[string equal -length $len $pfx $ref]} {
495 # We're on a branch. It might not exist. But
496 # HEAD looks good enough to be a branch.
498 set current_branch [string range $ref $len end]
501 # Assume this is a detached head.
503 set current_branch HEAD
508 auto_load tk_optionMenu
509 rename tk_optionMenu real__tkOptionMenu
510 proc tk_optionMenu {w varName args} {
511 set m [eval real__tkOptionMenu $w $varName $args]
512 $m configure -font font_ui
513 $w configure -font font_ui
517 proc rmsel_tag {text} {
519 -background [$text cget -background] \
520 -foreground [$text cget -foreground] \
522 $text tag conf in_sel -background lightgray
523 bind $text <Motion> break
528 bind . <Visibility> {
529 bind . <Visibility> {}
534 wm iconbitmap . -default $oguilib/git-gui.ico
537 ######################################################################
542 font create font_diff -family Courier -size 10
546 eval font configure font_ui [font actual [.dummy cget -font]]
550 font create font_uiitalic
551 font create font_uibold
552 font create font_diffbold
553 font create font_diffitalic
555 foreach class {Button Checkbutton Entry Label
556 Labelframe Listbox Menu Message
557 Radiobutton Spinbox Text} {
558 option add *$class.font font_ui
562 if {[is_Windows] || [is_MacOSX]} {
563 option add *Menu.tearOff 0
574 proc bind_button3 {w cmd} {
575 bind $w <Any-Button-3> $cmd
577 # Mac OS X sends Button-2 on right click through three-button mouse,
578 # or through trackpad right-clicking (two-finger touch + click).
579 bind $w <Any-Button-2> $cmd
580 bind $w <Control-Button-1> $cmd
584 proc apply_config {} {
585 global repo_config font_descs
587 foreach option $font_descs {
588 set name [lindex $option 0]
589 set font [lindex $option 1]
591 foreach {cn cv} $repo_config(gui.$name) {
592 font configure $font $cn $cv -weight normal
595 error_popup [strcat [mc "Invalid font specified
in %s
:" "gui.
$name"] "\n\n$err"]
597 foreach {cn cv} [font configure $font] {
598 font configure ${font}bold $cn $cv
599 font configure ${font}italic $cn $cv
601 font configure ${font}bold -weight bold
602 font configure ${font}italic -slant italic
606 set default_config(merge.diffstat) true
607 set default_config(merge.summary) false
608 set default_config(merge.verbosity) 2
609 set default_config(user.name) {}
610 set default_config(user.email) {}
612 set default_config(gui.matchtrackingbranch) false
613 set default_config(gui.pruneduringfetch) false
614 set default_config(gui.trustmtime) false
615 set default_config(gui.diffcontext) 5
616 set default_config(gui.newbranchtemplate) {}
617 set default_config(gui.fontui) [font configure font_ui]
618 set default_config(gui.fontdiff) [font configure font_diff]
620 {fontui font_ui {mc "Main Font
"}}
621 {fontdiff font_diff {mc "Diff
/Console Font
"}}
624 ######################################################################
628 set _git [_which git]
630 catch {wm withdraw .}
634 -title [mc "git-gui
: fatal error
"] \
635 -message [mc "Cannot
find git
in PATH.
"]
639 ######################################################################
643 if {[catch {set _git_version [git --version]} err]} {
644 catch {wm withdraw .}
648 -title [mc "git-gui
: fatal error
"] \
649 -message "Cannot determine Git version
:
653 [appname
] requires Git
1.5.0 or later.
"
656 if {![regsub {^git version } $_git_version {} _git_version]} {
657 catch {wm withdraw .}
661 -title [mc "git-gui
: fatal error
"] \
662 -message [strcat [mc "Cannot parse Git version string
:"] "\n\n$_git_version"]
666 set _real_git_version $_git_version
667 regsub -- {-dirty$} $_git_version {} _git_version
668 regsub {\.[0-9]+\.g[0-9a-f]+$} $_git_version {} _git_version
669 regsub {\.rc[0-9]+$} $_git_version {} _git_version
670 regsub {\.GIT$} $_git_version {} _git_version
671 regsub {\.[a-zA-Z]+\.[0-9]+$} $_git_version {} _git_version
673 if {![regexp {^[1-9]+(\.[0-9]+)+$} $_git_version]} {
674 catch {wm withdraw .}
679 -title "[appname
]: warning
" \
680 -message [mc "Git version cannot be determined.
682 %s claims it is version
'%s'.
684 %s requires
at least Git
1.5.0 or later.
686 Assume
'%s' is version
1.5.0?
687 " $_git $_real_git_version [appname] $_real_git_version]] eq {yes}} {
688 set _git_version 1.5.0
693 unset _real_git_version
695 proc git-version {args} {
698 switch [llength $args] {
704 set op [lindex $args 0]
705 set vr [lindex $args 1]
706 set cm [package vcompare $_git_version $vr]
707 return [expr $cm $op 0]
711 set type [lindex $args 0]
712 set name [lindex $args 1]
713 set parm [lindex $args 2]
714 set body [lindex $args 3]
716 if {($type ne {proc} && $type ne {method})} {
717 error "Invalid arguments to git-version
"
719 if {[llength $body] < 2 || [lindex $body end-1] ne {default}} {
720 error "Last arm of
$type $name must be default
"
723 foreach {op vr cb} [lrange $body 0 end-2] {
724 if {[git-version $op $vr]} {
725 return [uplevel [list $type $name $parm $cb]]
729 return [uplevel [list $type $name $parm [lindex $body end]]]
733 error "git-version
>= x
"
739 if {[git-version < 1.5]} {
740 catch {wm withdraw .}
744 -title [mc "git-gui
: fatal error
"] \
745 -message "[appname
] requires Git
1.5.0 or later.
747 You are using
[git-version
]:
753 ######################################################################
755 ## configure our library
757 set idx [file join $oguilib tclIndex]
758 if {[catch {set fd [open $idx r]} err]} {
759 catch {wm withdraw .}
763 -title [mc "git-gui
: fatal error
"] \
767 if {[gets $fd] eq {# Autogenerated by git-gui Makefile}} {
769 while {[gets $fd n] >= 0} {
770 if {$n ne {} && ![string match #* $n]} {
782 if {[lsearch -exact $loaded $p] >= 0} continue
783 source [file join $oguilib $p]
788 set auto_path [concat [list $oguilib] $auto_path]
790 unset -nocomplain idx fd
792 ######################################################################
794 ## feature option selection
796 if {[regexp {^git-(.+)$} [file tail $argv0] _junk subcommand]} {
801 if {$subcommand eq {gui.sh}} {
804 if {$subcommand eq {gui} && [llength $argv] > 0} {
805 set subcommand [lindex $argv 0]
806 set argv [lrange $argv 1 end]
809 enable_option multicommit
811 enable_option transport
814 switch -- $subcommand {
819 disable_option multicommit
820 disable_option branch
821 disable_option transport
824 enable_option singlecommit
826 disable_option multicommit
827 disable_option branch
828 disable_option transport
832 ######################################################################
837 set _gitdir $env(GIT_DIR)
841 set _gitdir [git rev-parse --git-dir]
842 set _prefix [git rev-parse --show-prefix]
846 choose_repository::pick
848 if {![file isdirectory $_gitdir] && [is_Cygwin]} {
849 catch {set _gitdir [exec cygpath --windows $_gitdir]}
851 if {![file isdirectory $_gitdir]} {
852 catch {wm withdraw .}
853 error_popup [strcat [mc "Git directory not found
:"] "\n\n$_gitdir"]
856 if {$_prefix ne {}} {
857 regsub -all {[^/]+/} $_prefix ../ cdup
858 if {[catch {cd $cdup} err]} {
859 catch {wm withdraw .}
860 error_popup [strcat [mc "Cannot move to top of working directory
:"] "\n\n$err"]
864 } elseif {![is_enabled bare]} {
865 if {[lindex [file split $_gitdir] end] ne {.git}} {
866 catch {wm withdraw .}
867 error_popup [strcat [mc "Cannot use funny .git directory
:"] "\n\n$_gitdir"]
870 if {[catch {cd [file dirname $_gitdir]} err]} {
871 catch {wm withdraw .}
872 error_popup [strcat [mc "No working directory
"] " [file dirname $_gitdir]:\n\n$err"]
876 set _reponame [file split [file normalize $_gitdir]]
877 if {[lindex $_reponame end] eq {.git}} {
878 set _reponame [lindex $_reponame end-1]
880 set _reponame [lindex $_reponame end]
883 ######################################################################
887 set current_diff_path {}
888 set current_diff_side {}
889 set diff_actions [list]
893 set MERGE_HEAD [list]
896 set current_branch {}
898 set current_diff_path {}
900 set selected_commit_type new
902 ######################################################################
910 set disable_on_lock [list]
911 set index_lock_type none
913 proc lock_index {type} {
914 global index_lock_type disable_on_lock
916 if {$index_lock_type eq {none}} {
917 set index_lock_type $type
918 foreach w $disable_on_lock {
919 uplevel #0 $w disabled
922 } elseif {$index_lock_type eq "begin-
$type"} {
923 set index_lock_type $type
929 proc unlock_index {} {
930 global index_lock_type disable_on_lock
932 set index_lock_type none
933 foreach w $disable_on_lock {
938 ######################################################################
942 proc repository_state {ctvar hdvar mhvar} {
943 global current_branch
944 upvar $ctvar ct $hdvar hd $mhvar mh
949 if {[catch {set hd [git rev-parse --verify HEAD]}]} {
955 set merge_head [gitdir MERGE_HEAD]
956 if {[file exists $merge_head]} {
958 set fd_mh [open $merge_head r]
959 while {[gets $fd_mh line] >= 0} {
970 global PARENT empty_tree
972 set p [lindex $PARENT 0]
976 if {$empty_tree eq {}} {
977 set empty_tree [git mktree << {}]
982 proc rescan {after {honor_trustmtime 1}} {
983 global HEAD PARENT MERGE_HEAD commit_type
984 global ui_index ui_workdir ui_comm
985 global rescan_active file_states
988 if {$rescan_active > 0 || ![lock_index read]} return
990 repository_state newType newHEAD newMERGE_HEAD
991 if {[string match amend* $commit_type]
992 && $newType eq {normal}
993 && $newHEAD eq $HEAD} {
997 set MERGE_HEAD $newMERGE_HEAD
998 set commit_type $newType
1001 array unset file_states
1003 if {!$::GITGUI_BCK_exists &&
1004 (![$ui_comm edit modified]
1005 || [string trim [$ui_comm get 0.0 end]] eq {})} {
1006 if {[string match amend* $commit_type]} {
1007 } elseif {[load_message GITGUI_MSG]} {
1008 } elseif {[load_message MERGE_MSG]} {
1009 } elseif {[load_message SQUASH_MSG]} {
1012 $ui_comm edit modified false
1015 if {$honor_trustmtime && $repo_config(gui.trustmtime) eq {true}} {
1016 rescan_stage2 {} $after
1019 ui_status [mc "Refreshing
file status...
"]
1020 set fd_rf [git_read update-index \
1026 fconfigure $fd_rf -blocking 0 -translation binary
1027 fileevent $fd_rf readable \
1028 [list rescan_stage2 $fd_rf $after]
1033 set is_git_info_link {}
1034 set is_git_info_exclude {}
1035 proc have_info_exclude {} {
1036 global is_git_info_link is_git_info_exclude
1038 if {$is_git_info_link eq {}} {
1039 set is_git_info_link [file isfile [gitdir info.lnk]]
1042 if {$is_git_info_link} {
1043 if {$is_git_info_exclude eq {}} {
1044 if {[catch {exec test -f [gitdir info exclude]}]} {
1045 set is_git_info_exclude 0
1047 set is_git_info_exclude 1
1050 return $is_git_info_exclude
1052 return [file readable [gitdir info exclude]]
1056 proc have_info_exclude {} {
1057 return [file readable [gitdir info exclude]]
1061 proc rescan_stage2 {fd after} {
1062 global rescan_active buf_rdi buf_rdf buf_rlo
1066 if {![eof $fd]} return
1070 set ls_others [list --exclude-per-directory=.gitignore]
1071 if {[have_info_exclude]} {
1072 lappend ls_others "--exclude-from=[gitdir info exclude
]"
1074 set user_exclude [get_config core.excludesfile]
1075 if {$user_exclude ne {} && [file readable $user_exclude]} {
1076 lappend ls_others "--exclude-from=$user_exclude"
1084 ui_status [mc "Scanning
for modified files ...
"]
1085 set fd_di [git_read diff-index --cached -z [PARENT]]
1086 set fd_df [git_read diff-files -z]
1087 set fd_lo [eval git_read ls-files --others -z $ls_others]
1089 fconfigure $fd_di -blocking 0 -translation binary -encoding binary
1090 fconfigure $fd_df -blocking 0 -translation binary -encoding binary
1091 fconfigure $fd_lo -blocking 0 -translation binary -encoding binary
1092 fileevent $fd_di readable [list read_diff_index $fd_di $after]
1093 fileevent $fd_df readable [list read_diff_files $fd_df $after]
1094 fileevent $fd_lo readable [list read_ls_others $fd_lo $after]
1097 proc load_message {file} {
1100 set f [gitdir $file]
1101 if {[file isfile $f]} {
1102 if {[catch {set fd [open $f r]}]} {
1105 fconfigure $fd -eofchar {}
1106 set content [string trim [read $fd]]
1108 regsub -all -line {[ \r\t]+$} $content {} content
1109 $ui_comm delete 0.0 end
1110 $ui_comm insert end $content
1116 proc read_diff_index {fd after} {
1119 append buf_rdi [read $fd]
1121 set n [string length $buf_rdi]
1123 set z1 [string first "\
0" $buf_rdi $c]
1124 if {$z1 == -1} break
1126 set z2 [string first "\
0" $buf_rdi $z1]
1127 if {$z2 == -1} break
1130 set i [split [string range $buf_rdi $c [expr {$z1 - 2}]] { }]
1131 set p [string range $buf_rdi $z1 [expr {$z2 - 1}]]
1133 [encoding convertfrom $p] \
1135 [list [lindex $i 0] [lindex $i 2]] \
1141 set buf_rdi [string range $buf_rdi $c end]
1146 rescan_done $fd buf_rdi $after
1149 proc read_diff_files {fd after} {
1152 append buf_rdf [read $fd]
1154 set n [string length $buf_rdf]
1156 set z1 [string first "\
0" $buf_rdf $c]
1157 if {$z1 == -1} break
1159 set z2 [string first "\
0" $buf_rdf $z1]
1160 if {$z2 == -1} break
1163 set i [split [string range $buf_rdf $c [expr {$z1 - 2}]] { }]
1164 set p [string range $buf_rdf $z1 [expr {$z2 - 1}]]
1166 [encoding convertfrom $p] \
1169 [list [lindex $i 0] [lindex $i 2]]
1174 set buf_rdf [string range $buf_rdf $c end]
1179 rescan_done $fd buf_rdf $after
1182 proc read_ls_others {fd after} {
1185 append buf_rlo [read $fd]
1186 set pck [split $buf_rlo "\
0"]
1187 set buf_rlo [lindex $pck end]
1188 foreach p [lrange $pck 0 end-1] {
1189 set p [encoding convertfrom $p]
1190 if {[string index $p end] eq {/}} {
1191 set p [string range $p 0 end-1]
1195 rescan_done $fd buf_rlo $after
1198 proc rescan_done {fd buf after} {
1199 global rescan_active current_diff_path
1200 global file_states repo_config
1203 if {![eof $fd]} return
1206 if {[incr rescan_active -1] > 0} return
1211 if {$current_diff_path ne {}} reshow_diff
1215 proc prune_selection {} {
1216 global file_states selected_paths
1218 foreach path [array names selected_paths] {
1219 if {[catch {set still_here $file_states($path)}]} {
1220 unset selected_paths($path)
1225 ######################################################################
1229 proc mapicon {w state path} {
1232 if {[catch {set r $all_icons($state$w)}]} {
1233 puts "error
: no icon
for $w state
={$state} $path"
1239 proc mapdesc {state path} {
1242 if {[catch {set r $all_descs($state)}]} {
1243 puts "error
: no desc
for state
={$state} $path"
1249 proc ui_status {msg} {
1251 if {[info exists main_status]} {
1252 $main_status show $msg
1256 proc ui_ready {{test {}}} {
1258 if {[info exists main_status]} {
1259 $main_status show [mc "Ready.
"] $test
1263 proc escape_path {path} {
1264 regsub -all {\\} $path "\\\\" path
1265 regsub -all "\n" $path "\\n
" path
1269 proc short_path {path} {
1270 return [escape_path [lindex [file split $path] end]]
1274 set null_sha1 [string repeat 0 40]
1276 proc merge_state {path new_state {head_info {}} {index_info {}}} {
1277 global file_states next_icon_id null_sha1
1279 set s0 [string index $new_state 0]
1280 set s1 [string index $new_state 1]
1282 if {[catch {set info $file_states($path)}]} {
1284 set icon n[incr next_icon_id]
1286 set state [lindex $info 0]
1287 set icon [lindex $info 1]
1288 if {$head_info eq {}} {set head_info [lindex $info 2]}
1289 if {$index_info eq {}} {set index_info [lindex $info 3]}
1292 if {$s0 eq {?}} {set s0 [string index $state 0]} \
1293 elseif {$s0 eq {_}} {set s0 _}
1295 if {$s1 eq {?}} {set s1 [string index $state 1]} \
1296 elseif {$s1 eq {_}} {set s1 _}
1298 if {$s0 eq {A} && $s1 eq {_} && $head_info eq {}} {
1299 set head_info [list 0 $null_sha1]
1300 } elseif {$s0 ne {_} && [string index $state 0] eq {_}
1301 && $head_info eq {}} {
1302 set head_info $index_info
1305 set file_states($path) [list $s0$s1 $icon \
1306 $head_info $index_info \
1311 proc display_file_helper {w path icon_name old_m new_m} {
1314 if {$new_m eq {_}} {
1315 set lno [lsearch -sorted -exact $file_lists($w) $path]
1317 set file_lists($w) [lreplace $file_lists($w) $lno $lno]
1319 $w conf -state normal
1320 $w delete $lno.0 [expr {$lno + 1}].0
1321 $w conf -state disabled
1323 } elseif {$old_m eq {_} && $new_m ne {_}} {
1324 lappend file_lists($w) $path
1325 set file_lists($w) [lsort -unique $file_lists($w)]
1326 set lno [lsearch -sorted -exact $file_lists($w) $path]
1328 $w conf -state normal
1329 $w image create $lno.0 \
1330 -align center -padx 5 -pady 1 \
1332 -image [mapicon $w $new_m $path]
1333 $w insert $lno.1 "[escape_path
$path]\n"
1334 $w conf -state disabled
1335 } elseif {$old_m ne $new_m} {
1336 $w conf -state normal
1337 $w image conf $icon_name -image [mapicon $w $new_m $path]
1338 $w conf -state disabled
1342 proc display_file {path state} {
1343 global file_states selected_paths
1344 global ui_index ui_workdir
1346 set old_m [merge_state $path $state]
1347 set s $file_states($path)
1348 set new_m [lindex $s 0]
1349 set icon_name [lindex $s 1]
1351 set o [string index $old_m 0]
1352 set n [string index $new_m 0]
1359 display_file_helper $ui_index $path $icon_name $o $n
1361 if {[string index $old_m 0] eq {U}} {
1364 set o [string index $old_m 1]
1366 if {[string index $new_m 0] eq {U}} {
1369 set n [string index $new_m 1]
1371 display_file_helper $ui_workdir $path $icon_name $o $n
1373 if {$new_m eq {__}} {
1374 unset file_states($path)
1375 catch {unset selected_paths($path)}
1379 proc display_all_files_helper {w path icon_name m} {
1382 lappend file_lists($w) $path
1383 set lno [expr {[lindex [split [$w index end] .] 0] - 1}]
1384 $w image create end \
1385 -align center -padx 5 -pady 1 \
1387 -image [mapicon $w $m $path]
1388 $w insert end "[escape_path
$path]\n"
1391 proc display_all_files {} {
1392 global ui_index ui_workdir
1393 global file_states file_lists
1396 $ui_index conf -state normal
1397 $ui_workdir conf -state normal
1399 $ui_index delete 0.0 end
1400 $ui_workdir delete 0.0 end
1403 set file_lists($ui_index) [list]
1404 set file_lists($ui_workdir) [list]
1406 foreach path [lsort [array names file_states]] {
1407 set s $file_states($path)
1409 set icon_name [lindex $s 1]
1411 set s [string index $m 0]
1412 if {$s ne {U} && $s ne {_}} {
1413 display_all_files_helper $ui_index $path \
1417 if {[string index $m 0] eq {U}} {
1420 set s [string index $m 1]
1423 display_all_files_helper $ui_workdir $path \
1428 $ui_index conf -state disabled
1429 $ui_workdir conf -state disabled
1432 ######################################################################
1437 #define mask_width 14
1438 #define mask_height 15
1439 static unsigned char mask_bits[] = {
1440 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
1441 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
1442 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f};
1445 image create bitmap file_plain -background white -foreground black -data {
1446 #define plain_width 14
1447 #define plain_height 15
1448 static unsigned char plain_bits[] = {
1449 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
1450 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10,
1451 0x02, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1452 } -maskdata $filemask
1454 image create bitmap file_mod -background white -foreground blue -data {
1455 #define mod_width 14
1456 #define mod_height 15
1457 static unsigned char mod_bits[] = {
1458 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
1459 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
1460 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
1461 } -maskdata $filemask
1463 image create bitmap file_fulltick -background white -foreground "#007000" -data {
1464 #define file_fulltick_width 14
1465 #define file_fulltick_height 15
1466 static unsigned char file_fulltick_bits
[] = {
1467 0xfe, 0x01, 0x02, 0x1a, 0x02, 0x0c, 0x02, 0x0c, 0x02, 0x16, 0x02, 0x16,
1468 0x02, 0x13, 0x00, 0x13, 0x86, 0x11, 0x8c, 0x11, 0xd8, 0x10, 0xf2, 0x10,
1469 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1470 } -maskdata $filemask
1472 image create bitmap file_parttick
-background white
-foreground "#005050" -data {
1473 #define parttick_width 14
1474 #define parttick_height 15
1475 static unsigned char parttick_bits
[] = {
1476 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
1477 0x7a, 0x14, 0x02, 0x16, 0x02, 0x13, 0x8a, 0x11, 0xda, 0x10, 0x72, 0x10,
1478 0x22, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1479 } -maskdata $filemask
1481 image create bitmap file_question
-background white
-foreground black
-data {
1482 #define file_question_width 14
1483 #define file_question_height 15
1484 static unsigned char file_question_bits
[] = {
1485 0xfe, 0x01, 0x02, 0x02, 0xe2, 0x04, 0xf2, 0x09, 0x1a, 0x1b, 0x0a, 0x13,
1486 0x82, 0x11, 0xc2, 0x10, 0x62, 0x10, 0x62, 0x10, 0x02, 0x10, 0x62, 0x10,
1487 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1488 } -maskdata $filemask
1490 image create bitmap file_removed
-background white
-foreground red
-data {
1491 #define file_removed_width 14
1492 #define file_removed_height 15
1493 static unsigned char file_removed_bits
[] = {
1494 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
1495 0x1a, 0x16, 0x32, 0x13, 0xe2, 0x11, 0xc2, 0x10, 0xe2, 0x11, 0x32, 0x13,
1496 0x1a, 0x16, 0x02, 0x10, 0xfe, 0x1f};
1497 } -maskdata $filemask
1499 image create bitmap file_merge
-background white
-foreground blue
-data {
1500 #define file_merge_width 14
1501 #define file_merge_height 15
1502 static unsigned char file_merge_bits
[] = {
1503 0xfe, 0x01, 0x02, 0x03, 0x62, 0x05, 0x62, 0x09, 0x62, 0x1f, 0x62, 0x10,
1504 0xfa, 0x11, 0xf2, 0x10, 0x62, 0x10, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
1505 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
1506 } -maskdata $filemask
1508 set ui_index .vpane.files.index.list
1509 set ui_workdir .vpane.files.workdir.list
1511 set all_icons
(_
$ui_index) file_plain
1512 set all_icons
(A
$ui_index) file_fulltick
1513 set all_icons
(M
$ui_index) file_fulltick
1514 set all_icons
(D
$ui_index) file_removed
1515 set all_icons
(U
$ui_index) file_merge
1517 set all_icons
(_
$ui_workdir) file_plain
1518 set all_icons
(M
$ui_workdir) file_mod
1519 set all_icons
(D
$ui_workdir) file_question
1520 set all_icons
(U
$ui_workdir) file_merge
1521 set all_icons
(O
$ui_workdir) file_plain
1523 set max_status_desc
0
1525 {__
{mc
"Unmodified"}}
1527 {_M
{mc
"Modified, not staged"}}
1528 {M_
{mc
"Staged for commit"}}
1529 {MM
{mc
"Portions staged for commit"}}
1530 {MD
{mc
"Staged for commit, missing"}}
1532 {_O
{mc
"Untracked, not staged"}}
1533 {A_
{mc
"Staged for commit"}}
1534 {AM
{mc
"Portions staged for commit"}}
1535 {AD
{mc
"Staged for commit, missing"}}
1538 {D_
{mc
"Staged for removal"}}
1539 {DO
{mc
"Staged for removal, still present"}}
1541 {U_
{mc
"Requires merge resolution"}}
1542 {UU
{mc
"Requires merge resolution"}}
1543 {UM
{mc
"Requires merge resolution"}}
1544 {UD
{mc
"Requires merge resolution"}}
1546 set text
[eval [lindex
$i 1]]
1547 if {$max_status_desc < [string length
$text]} {
1548 set max_status_desc
[string length
$text]
1550 set all_descs
([lindex
$i 0]) $text
1554 ######################################################################
1558 proc scrollbar2many
{list mode args
} {
1559 foreach w
$list {eval $w $mode $args}
1562 proc many2scrollbar
{list mode sb top bottom
} {
1563 $sb set $top $bottom
1564 foreach w
$list {$w $mode moveto
$top}
1567 proc incr_font_size
{font
{amt
1}} {
1568 set sz
[font configure
$font -size]
1570 font configure
$font -size $sz
1571 font configure
${font}bold
-size $sz
1572 font configure
${font}italic
-size $sz
1575 ######################################################################
1579 set starting_gitk_msg
[mc
"Starting gitk... please wait..."]
1581 proc do_gitk
{revs
} {
1582 # -- Always start gitk through whatever we were loaded with. This
1583 # lets us bypass using shell process on Windows systems.
1585 set exe
[file join [file dirname $
::_git
] gitk
]
1586 set cmd
[list
[info nameofexecutable
] $exe]
1587 if {! [file exists
$exe]} {
1588 error_popup
[mc
"Unable to start gitk:\n\n%s does not exist" $exe]
1592 if {[info exists env
(GIT_DIR
)]} {
1593 set old_GIT_DIR
$env(GIT_DIR
)
1599 cd [file dirname [gitdir
]]
1600 set env
(GIT_DIR
) [file tail [gitdir
]]
1602 eval exec $cmd $revs &
1604 if {$old_GIT_DIR eq
{}} {
1607 set env
(GIT_DIR
) $old_GIT_DIR
1611 ui_status $
::starting_gitk_msg
1613 ui_ready
$starting_gitk_msg
1621 global ui_comm is_quitting repo_config commit_type
1622 global GITGUI_BCK_exists GITGUI_BCK_i
1624 if {$is_quitting} return
1627 if {[winfo exists
$ui_comm]} {
1628 # -- Stash our current commit buffer.
1630 set save
[gitdir GITGUI_MSG
]
1631 if {$GITGUI_BCK_exists && ![$ui_comm edit modified
]} {
1632 file rename
-force [gitdir GITGUI_BCK
] $save
1633 set GITGUI_BCK_exists
0
1635 set msg
[string trim
[$ui_comm get
0.0 end
]]
1636 regsub
-all -line {[ \r\t]+$
} $msg {} msg
1637 if {(![string match amend
* $commit_type]
1638 ||
[$ui_comm edit modified
])
1641 set fd
[open
$save w
]
1642 puts
-nonewline $fd $msg
1646 catch
{file delete
$save}
1650 # -- Remove our editor backup, its not needed.
1652 after cancel
$GITGUI_BCK_i
1653 if {$GITGUI_BCK_exists} {
1654 catch
{file delete
[gitdir GITGUI_BCK
]}
1657 # -- Stash our current window geometry into this repository.
1659 set cfg_geometry
[list
]
1660 lappend cfg_geometry
[wm geometry .
]
1661 lappend cfg_geometry
[lindex
[.vpane sash coord
0] 1]
1662 lappend cfg_geometry
[lindex
[.vpane.files sash coord
0] 0]
1663 if {[catch
{set rc_geometry
$repo_config(gui.geometry
)}]} {
1666 if {$cfg_geometry ne
$rc_geometry} {
1667 catch
{git config gui.geometry
$cfg_geometry}
1682 proc toggle_or_diff
{w x y
} {
1683 global file_states file_lists current_diff_path ui_index ui_workdir
1684 global last_clicked selected_paths
1686 set pos
[split [$w index @
$x,$y] .
]
1687 set lno
[lindex
$pos 0]
1688 set col [lindex
$pos 1]
1689 set path
[lindex
$file_lists($w) [expr {$lno - 1}]]
1695 set last_clicked
[list
$w $lno]
1696 array
unset selected_paths
1697 $ui_index tag remove in_sel
0.0 end
1698 $ui_workdir tag remove in_sel
0.0 end
1701 if {$current_diff_path eq
$path} {
1702 set after
{reshow_diff
;}
1706 if {$w eq
$ui_index} {
1708 "Unstaging [short_path $path] from commit" \
1710 [concat
$after [list ui_ready
]]
1711 } elseif
{$w eq
$ui_workdir} {
1713 "Adding [short_path $path]" \
1715 [concat
$after [list ui_ready
]]
1718 show_diff
$path $w $lno
1722 proc add_one_to_selection
{w x y
} {
1723 global file_lists last_clicked selected_paths
1725 set lno
[lindex
[split [$w index @
$x,$y] .
] 0]
1726 set path
[lindex
$file_lists($w) [expr {$lno - 1}]]
1732 if {$last_clicked ne
{}
1733 && [lindex
$last_clicked 0] ne
$w} {
1734 array
unset selected_paths
1735 [lindex
$last_clicked 0] tag remove in_sel
0.0 end
1738 set last_clicked
[list
$w $lno]
1739 if {[catch
{set in_sel
$selected_paths($path)}]} {
1743 unset selected_paths
($path)
1744 $w tag remove in_sel
$lno.0 [expr {$lno + 1}].0
1746 set selected_paths
($path) 1
1747 $w tag add in_sel
$lno.0 [expr {$lno + 1}].0
1751 proc add_range_to_selection
{w x y
} {
1752 global file_lists last_clicked selected_paths
1754 if {[lindex
$last_clicked 0] ne
$w} {
1755 toggle_or_diff
$w $x $y
1759 set lno
[lindex
[split [$w index @
$x,$y] .
] 0]
1760 set lc
[lindex
$last_clicked 1]
1769 foreach path
[lrange
$file_lists($w) \
1770 [expr {$begin - 1}] \
1771 [expr {$end - 1}]] {
1772 set selected_paths
($path) 1
1774 $w tag add in_sel
$begin.0 [expr {$end + 1}].0
1777 ######################################################################
1787 menu .mbar
-tearoff 0
1788 .mbar add cascade
-label [mc Repository
] -menu .mbar.repository
1789 .mbar add cascade
-label [mc Edit
] -menu .mbar.edit
1790 if {[is_enabled branch
]} {
1791 .mbar add cascade
-label [mc Branch
] -menu .mbar.branch
1793 if {[is_enabled multicommit
] ||
[is_enabled singlecommit
]} {
1794 .mbar add cascade
-label [mc Commit@@noun
] -menu .mbar.commit
1796 if {[is_enabled transport
]} {
1797 .mbar add cascade
-label [mc Merge
] -menu .mbar.merge
1798 .mbar add cascade
-label [mc Remote
] -menu .mbar.remote
1800 . configure
-menu .mbar
1802 # -- Repository Menu
1804 menu .mbar.repository
1806 .mbar.repository add
command \
1807 -label [mc
"Browse Current Branch's Files"] \
1808 -command {browser
::new
$current_branch}
1809 set ui_browse_current
[.mbar.repository index last
]
1810 .mbar.repository add
command \
1811 -label [mc
"Browse Branch Files..."] \
1812 -command browser_open
::dialog
1813 .mbar.repository add separator
1815 .mbar.repository add
command \
1816 -label [mc
"Visualize Current Branch's History"] \
1817 -command {do_gitk
$current_branch}
1818 set ui_visualize_current
[.mbar.repository index last
]
1819 .mbar.repository add
command \
1820 -label [mc
"Visualize All Branch History"] \
1821 -command {do_gitk
--all}
1822 .mbar.repository add separator
1824 proc current_branch_write
{args
} {
1825 global current_branch
1826 .mbar.repository entryconf $
::ui_browse_current \
1827 -label [mc
"Browse %s's Files" $current_branch]
1828 .mbar.repository entryconf $
::ui_visualize_current \
1829 -label [mc
"Visualize %s's History" $current_branch]
1831 trace add variable current_branch
write current_branch_write
1833 if {[is_enabled multicommit
]} {
1834 .mbar.repository add
command -label [mc
"Database Statistics"] \
1837 .mbar.repository add
command -label [mc
"Compress Database"] \
1840 .mbar.repository add
command -label [mc
"Verify Database"] \
1841 -command do_fsck_objects
1843 .mbar.repository add separator
1846 .mbar.repository add
command \
1847 -label [mc
"Create Desktop Icon"] \
1848 -command do_cygwin_shortcut
1849 } elseif
{[is_Windows
]} {
1850 .mbar.repository add
command \
1851 -label [mc
"Create Desktop Icon"] \
1852 -command do_windows_shortcut
1853 } elseif
{[is_MacOSX
]} {
1854 .mbar.repository add
command \
1855 -label [mc
"Create Desktop Icon"] \
1856 -command do_macosx_app
1860 .mbar.repository add
command -label [mc Quit
] \
1867 .mbar.edit add
command -label [mc Undo
] \
1868 -command {catch
{[focus
] edit undo
}} \
1870 .mbar.edit add
command -label [mc Redo
] \
1871 -command {catch
{[focus
] edit redo
}} \
1873 .mbar.edit add separator
1874 .mbar.edit add
command -label [mc Cut
] \
1875 -command {catch
{tk_textCut
[focus
]}} \
1877 .mbar.edit add
command -label [mc Copy
] \
1878 -command {catch
{tk_textCopy
[focus
]}} \
1880 .mbar.edit add
command -label [mc Paste
] \
1881 -command {catch
{tk_textPaste
[focus
]; [focus
] see insert
}} \
1883 .mbar.edit add
command -label [mc Delete
] \
1884 -command {catch
{[focus
] delete sel.first sel.last
}} \
1886 .mbar.edit add separator
1887 .mbar.edit add
command -label [mc
"Select All"] \
1888 -command {catch
{[focus
] tag add sel
0.0 end
}} \
1893 if {[is_enabled branch
]} {
1896 .mbar.branch add
command -label [mc
"Create..."] \
1897 -command branch_create
::dialog \
1899 lappend disable_on_lock
[list .mbar.branch entryconf \
1900 [.mbar.branch index last
] -state]
1902 .mbar.branch add
command -label [mc
"Checkout..."] \
1903 -command branch_checkout
::dialog \
1905 lappend disable_on_lock
[list .mbar.branch entryconf \
1906 [.mbar.branch index last
] -state]
1908 .mbar.branch add
command -label [mc
"Rename..."] \
1909 -command branch_rename
::dialog
1910 lappend disable_on_lock
[list .mbar.branch entryconf \
1911 [.mbar.branch index last
] -state]
1913 .mbar.branch add
command -label [mc
"Delete..."] \
1914 -command branch_delete
::dialog
1915 lappend disable_on_lock
[list .mbar.branch entryconf \
1916 [.mbar.branch index last
] -state]
1918 .mbar.branch add
command -label [mc
"Reset..."] \
1919 -command merge
::reset_hard
1920 lappend disable_on_lock
[list .mbar.branch entryconf \
1921 [.mbar.branch index last
] -state]
1926 if {[is_enabled multicommit
] ||
[is_enabled singlecommit
]} {
1929 .mbar.commit add radiobutton \
1930 -label [mc
"New Commit"] \
1931 -command do_select_commit_type \
1932 -variable selected_commit_type \
1934 lappend disable_on_lock \
1935 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1937 .mbar.commit add radiobutton \
1938 -label [mc
"Amend Last Commit"] \
1939 -command do_select_commit_type \
1940 -variable selected_commit_type \
1942 lappend disable_on_lock \
1943 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1945 .mbar.commit add separator
1947 .mbar.commit add
command -label [mc Rescan
] \
1948 -command do_rescan \
1950 lappend disable_on_lock \
1951 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1953 .mbar.commit add
command -label [mc
"Stage To Commit"] \
1954 -command do_add_selection
1955 lappend disable_on_lock \
1956 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1958 .mbar.commit add
command -label [mc
"Stage Changed Files To Commit"] \
1959 -command do_add_all \
1961 lappend disable_on_lock \
1962 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1964 .mbar.commit add
command -label [mc
"Unstage From Commit"] \
1965 -command do_unstage_selection
1966 lappend disable_on_lock \
1967 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1969 .mbar.commit add
command -label [mc
"Revert Changes"] \
1970 -command do_revert_selection
1971 lappend disable_on_lock \
1972 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1974 .mbar.commit add separator
1976 .mbar.commit add
command -label [mc
"Sign Off"] \
1977 -command do_signoff \
1980 .mbar.commit add
command -label [mc Commit@@verb
] \
1981 -command do_commit \
1982 -accelerator $M1T-Return
1983 lappend disable_on_lock \
1984 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1989 if {[is_enabled branch
]} {
1991 .mbar.merge add
command -label [mc
"Local Merge..."] \
1992 -command merge
::dialog \
1994 lappend disable_on_lock \
1995 [list .mbar.merge entryconf
[.mbar.merge index last
] -state]
1996 .mbar.merge add
command -label [mc
"Abort Merge..."] \
1997 -command merge
::reset_hard
1998 lappend disable_on_lock \
1999 [list .mbar.merge entryconf
[.mbar.merge index last
] -state]
2004 if {[is_enabled transport
]} {
2007 .mbar.remote add
command \
2008 -label [mc
"Push..."] \
2009 -command do_push_anywhere \
2011 .mbar.remote add
command \
2012 -label [mc
"Delete..."] \
2013 -command remote_branch_delete
::dialog
2017 # -- Apple Menu (Mac OS X only)
2019 .mbar add cascade
-label [mc Apple
] -menu .mbar.apple
2022 .mbar.apple add
command -label [mc
"About %s" [appname
]] \
2024 .mbar.apple add separator
2025 .mbar.apple add
command \
2026 -label [mc
"Preferences..."] \
2027 -command do_options \
2029 bind .
<$M1B-,> do_options
2033 .mbar.edit add separator
2034 .mbar.edit add
command -label [mc
"Options..."] \
2040 .mbar add cascade
-label [mc Help
] -menu .mbar.
help
2044 .mbar.
help add
command -label [mc
"About %s" [appname
]] \
2049 catch
{set browser
$repo_config(instaweb.browser
)}
2050 set doc_path
[file dirname [gitexec
]]
2051 set doc_path
[file join $doc_path Documentation index.html
]
2054 set doc_path
[exec cygpath
--mixed $doc_path]
2057 if {$browser eq
{}} {
2060 } elseif
{[is_Cygwin
]} {
2061 set program_files
[file dirname [exec cygpath
--windir]]
2062 set program_files
[file join $program_files {Program Files
}]
2063 set firefox
[file join $program_files {Mozilla Firefox
} firefox.exe
]
2064 set ie
[file join $program_files {Internet Explorer
} IEXPLORE.EXE
]
2065 if {[file exists
$firefox]} {
2066 set browser
$firefox
2067 } elseif
{[file exists
$ie]} {
2070 unset program_files firefox ie
2074 if {[file isfile
$doc_path]} {
2075 set doc_url
"file:$doc_path"
2077 set doc_url
{http
://www.kernel.org
/pub
/software
/scm
/git
/docs
/}
2080 if {$browser ne
{}} {
2081 .mbar.
help add
command -label [mc
"Online Documentation"] \
2082 -command [list
exec $browser $doc_url &]
2084 unset browser doc_path doc_url
2086 # -- Standard bindings
2088 wm protocol . WM_DELETE_WINDOW do_quit
2089 bind all
<$M1B-Key-q> do_quit
2090 bind all
<$M1B-Key-Q> do_quit
2091 bind all
<$M1B-Key-w> {destroy
[winfo toplevel
%W
]}
2092 bind all
<$M1B-Key-W> {destroy
[winfo toplevel
%W
]}
2094 set subcommand_args
{}
2096 puts stderr
"usage: $::argv0 $::subcommand $::subcommand_args"
2100 # -- Not a normal commit type invocation? Do that instead!
2102 switch
-- $subcommand {
2105 set subcommand_args
{rev? path
}
2106 if {$argv eq
{}} usage
2111 if {$is_path ||
[file exists
$_prefix$a]} {
2112 if {$path ne
{}} usage
2115 } elseif
{$a eq
{--}} {
2117 if {$head ne
{}} usage
2122 } elseif
{$head eq
{}} {
2123 if {$head ne
{}} usage
2132 if {$head ne
{} && $path eq
{}} {
2133 set path
$_prefix$head
2140 if {[regexp
{^
[0-9a-f]{1,39}$
} $head]} {
2142 set head [git rev-parse
--verify $head]
2148 set current_branch
$head
2151 switch
-- $subcommand {
2154 if {$path ne
{} && [file isdirectory
$path]} {
2155 set head $current_branch
2161 browser
::new
$head $path
2164 if {$head eq
{} && ![file exists
$path]} {
2165 puts stderr
[mc
"fatal: cannot stat path %s: No such file or directory" $path]
2168 blame
::new
$head $path
2175 if {[llength
$argv] != 0} {
2176 puts
-nonewline stderr
"usage: $argv0"
2177 if {$subcommand ne
{gui
}
2178 && [file tail $argv0] ne
"git-$subcommand"} {
2179 puts
-nonewline stderr
" $subcommand"
2184 # fall through to setup UI for commits
2187 puts stderr
"usage: $argv0 \[{blame|browser|citool}\]"
2198 -text [mc
"Current Branch:"] \
2202 -textvariable current_branch \
2205 pack .branch.l1
-side left
2206 pack .branch.cb
-side left
-fill x
2207 pack .branch
-side top
-fill x
2209 # -- Main Window Layout
2211 panedwindow .vpane
-orient vertical
2212 panedwindow .vpane.files
-orient horizontal
2213 .vpane add .vpane.files
-sticky nsew
-height 100 -width 200
2214 pack .vpane
-anchor n
-side top
-fill both
-expand 1
2216 # -- Index File List
2218 frame .vpane.files.index
-height 100 -width 200
2219 label .vpane.files.index.title
-text [mc
"Staged Changes (Will Commit)"] \
2220 -background lightgreen
2221 text
$ui_index -background white
-borderwidth 0 \
2222 -width 20 -height 10 \
2224 -cursor $cursor_ptr \
2225 -xscrollcommand {.vpane.files.index.sx
set} \
2226 -yscrollcommand {.vpane.files.index.sy
set} \
2228 scrollbar .vpane.files.index.sx
-orient h
-command [list
$ui_index xview
]
2229 scrollbar .vpane.files.index.sy
-orient v
-command [list
$ui_index yview
]
2230 pack .vpane.files.index.title
-side top
-fill x
2231 pack .vpane.files.index.sx
-side bottom
-fill x
2232 pack .vpane.files.index.sy
-side right
-fill y
2233 pack
$ui_index -side left
-fill both
-expand 1
2234 .vpane.files add .vpane.files.index
-sticky nsew
2236 # -- Working Directory File List
2238 frame .vpane.files.workdir
-height 100 -width 200
2239 label .vpane.files.workdir.title
-text [mc
"Unstaged Changes"] \
2240 -background lightsalmon
2241 text
$ui_workdir -background white
-borderwidth 0 \
2242 -width 20 -height 10 \
2244 -cursor $cursor_ptr \
2245 -xscrollcommand {.vpane.files.workdir.sx
set} \
2246 -yscrollcommand {.vpane.files.workdir.sy
set} \
2248 scrollbar .vpane.files.workdir.sx
-orient h
-command [list
$ui_workdir xview
]
2249 scrollbar .vpane.files.workdir.sy
-orient v
-command [list
$ui_workdir yview
]
2250 pack .vpane.files.workdir.title
-side top
-fill x
2251 pack .vpane.files.workdir.sx
-side bottom
-fill x
2252 pack .vpane.files.workdir.sy
-side right
-fill y
2253 pack
$ui_workdir -side left
-fill both
-expand 1
2254 .vpane.files add .vpane.files.workdir
-sticky nsew
2256 foreach i
[list
$ui_index $ui_workdir] {
2258 $i tag conf in_diff
-background [$i tag cget in_sel
-background]
2262 # -- Diff and Commit Area
2264 frame .vpane.lower
-height 300 -width 400
2265 frame .vpane.lower.commarea
2266 frame .vpane.lower.
diff -relief sunken
-borderwidth 1
2267 pack .vpane.lower.commarea
-side top
-fill x
2268 pack .vpane.lower.
diff -side bottom
-fill both
-expand 1
2269 .vpane add .vpane.lower
-sticky nsew
2271 # -- Commit Area Buttons
2273 frame .vpane.lower.commarea.buttons
2274 label .vpane.lower.commarea.buttons.l
-text {} \
2277 pack .vpane.lower.commarea.buttons.l
-side top
-fill x
2278 pack .vpane.lower.commarea.buttons
-side left
-fill y
2280 button .vpane.lower.commarea.buttons.rescan
-text [mc Rescan
] \
2282 pack .vpane.lower.commarea.buttons.rescan
-side top
-fill x
2283 lappend disable_on_lock \
2284 {.vpane.lower.commarea.buttons.rescan conf
-state}
2286 button .vpane.lower.commarea.buttons.incall
-text [mc
"Stage Changed"] \
2288 pack .vpane.lower.commarea.buttons.incall
-side top
-fill x
2289 lappend disable_on_lock \
2290 {.vpane.lower.commarea.buttons.incall conf
-state}
2292 button .vpane.lower.commarea.buttons.signoff
-text [mc
"Sign Off"] \
2294 pack .vpane.lower.commarea.buttons.signoff
-side top
-fill x
2296 button .vpane.lower.commarea.buttons.commit
-text [mc Commit@@verb
] \
2298 pack .vpane.lower.commarea.buttons.commit
-side top
-fill x
2299 lappend disable_on_lock \
2300 {.vpane.lower.commarea.buttons.commit conf
-state}
2302 button .vpane.lower.commarea.buttons.push
-text [mc Push
] \
2303 -command do_push_anywhere
2304 pack .vpane.lower.commarea.buttons.push
-side top
-fill x
2306 # -- Commit Message Buffer
2308 frame .vpane.lower.commarea.buffer
2309 frame .vpane.lower.commarea.buffer.header
2310 set ui_comm .vpane.lower.commarea.buffer.t
2311 set ui_coml .vpane.lower.commarea.buffer.header.l
2312 radiobutton .vpane.lower.commarea.buffer.header.new \
2313 -text [mc
"New Commit"] \
2314 -command do_select_commit_type \
2315 -variable selected_commit_type \
2317 lappend disable_on_lock \
2318 [list .vpane.lower.commarea.buffer.header.new conf
-state]
2319 radiobutton .vpane.lower.commarea.buffer.header.amend \
2320 -text [mc
"Amend Last Commit"] \
2321 -command do_select_commit_type \
2322 -variable selected_commit_type \
2324 lappend disable_on_lock \
2325 [list .vpane.lower.commarea.buffer.header.amend conf
-state]
2329 proc trace_commit_type
{varname args
} {
2330 global ui_coml commit_type
2331 switch
-glob -- $commit_type {
2332 initial
{set txt
[mc
"Initial Commit Message:"]}
2333 amend
{set txt
[mc
"Amended Commit Message:"]}
2334 amend-initial
{set txt
[mc
"Amended Initial Commit Message:"]}
2335 amend-merge
{set txt
[mc
"Amended Merge Commit Message:"]}
2336 merge
{set txt
[mc
"Merge Commit Message:"]}
2337 * {set txt
[mc
"Commit Message:"]}
2339 $ui_coml conf
-text $txt
2341 trace add variable commit_type
write trace_commit_type
2342 pack
$ui_coml -side left
-fill x
2343 pack .vpane.lower.commarea.buffer.header.amend
-side right
2344 pack .vpane.lower.commarea.buffer.header.new
-side right
2346 text
$ui_comm -background white
-borderwidth 1 \
2349 -autoseparators true \
2351 -width 75 -height 9 -wrap none \
2353 -yscrollcommand {.vpane.lower.commarea.buffer.sby
set}
2354 scrollbar .vpane.lower.commarea.buffer.sby \
2355 -command [list
$ui_comm yview
]
2356 pack .vpane.lower.commarea.buffer.header
-side top
-fill x
2357 pack .vpane.lower.commarea.buffer.sby
-side right
-fill y
2358 pack
$ui_comm -side left
-fill y
2359 pack .vpane.lower.commarea.buffer
-side left
-fill y
2361 # -- Commit Message Buffer Context Menu
2363 set ctxm .vpane.lower.commarea.buffer.ctxm
2364 menu
$ctxm -tearoff 0
2367 -command {tk_textCut
$ui_comm}
2370 -command {tk_textCopy
$ui_comm}
2373 -command {tk_textPaste
$ui_comm}
2375 -label [mc Delete
] \
2376 -command {$ui_comm delete sel.first sel.last
}
2379 -label [mc
"Select All"] \
2380 -command {focus
$ui_comm;$ui_comm tag add sel
0.0 end
}
2382 -label [mc
"Copy All"] \
2384 $ui_comm tag add sel
0.0 end
2385 tk_textCopy
$ui_comm
2386 $ui_comm tag remove sel
0.0 end
2390 -label [mc
"Sign Off"] \
2392 bind_button3
$ui_comm "tk_popup $ctxm %X %Y"
2396 proc trace_current_diff_path
{varname args
} {
2397 global current_diff_path diff_actions file_states
2398 if {$current_diff_path eq
{}} {
2404 set p
$current_diff_path
2405 set s
[mapdesc
[lindex
$file_states($p) 0] $p]
2407 set p
[escape_path
$p]
2411 .vpane.lower.
diff.header.status configure
-text $s
2412 .vpane.lower.
diff.header.
file configure
-text $f
2413 .vpane.lower.
diff.header.path configure
-text $p
2414 foreach w
$diff_actions {
2418 trace add variable current_diff_path
write trace_current_diff_path
2420 frame .vpane.lower.
diff.header
-background gold
2421 label .vpane.lower.
diff.header.status \
2423 -width $max_status_desc \
2426 label .vpane.lower.
diff.header.
file \
2430 label .vpane.lower.
diff.header.path \
2434 pack .vpane.lower.
diff.header.status
-side left
2435 pack .vpane.lower.
diff.header.
file -side left
2436 pack .vpane.lower.
diff.header.path
-fill x
2437 set ctxm .vpane.lower.
diff.header.ctxm
2438 menu
$ctxm -tearoff 0
2446 -- $current_diff_path
2448 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2449 bind_button3 .vpane.lower.
diff.header.path
"tk_popup $ctxm %X %Y"
2453 frame .vpane.lower.
diff.body
2454 set ui_diff .vpane.lower.
diff.body.t
2455 text
$ui_diff -background white
-borderwidth 0 \
2456 -width 80 -height 15 -wrap none \
2458 -xscrollcommand {.vpane.lower.
diff.body.sbx
set} \
2459 -yscrollcommand {.vpane.lower.
diff.body.sby
set} \
2461 scrollbar .vpane.lower.
diff.body.sbx
-orient horizontal \
2462 -command [list
$ui_diff xview
]
2463 scrollbar .vpane.lower.
diff.body.sby
-orient vertical \
2464 -command [list
$ui_diff yview
]
2465 pack .vpane.lower.
diff.body.sbx
-side bottom
-fill x
2466 pack .vpane.lower.
diff.body.sby
-side right
-fill y
2467 pack
$ui_diff -side left
-fill both
-expand 1
2468 pack .vpane.lower.
diff.header
-side top
-fill x
2469 pack .vpane.lower.
diff.body
-side bottom
-fill both
-expand 1
2471 $ui_diff tag conf d_cr
-elide true
2472 $ui_diff tag conf d_@
-foreground blue
-font font_diffbold
2473 $ui_diff tag conf d_
+ -foreground {#00a000}
2474 $ui_diff tag conf d_-
-foreground red
2476 $ui_diff tag conf d_
++ -foreground {#00a000}
2477 $ui_diff tag conf d_--
-foreground red
2478 $ui_diff tag conf d_
+s \
2479 -foreground {#00a000} \
2480 -background {#e2effa}
2481 $ui_diff tag conf d_-s \
2483 -background {#e2effa}
2484 $ui_diff tag conf d_s
+ \
2485 -foreground {#00a000} \
2487 $ui_diff tag conf d_s- \
2491 $ui_diff tag conf d
<<<<<<< \
2492 -foreground orange \
2494 $ui_diff tag conf d
======= \
2495 -foreground orange \
2497 $ui_diff tag conf d
>>>>>>> \
2498 -foreground orange \
2501 $ui_diff tag raise sel
2503 # -- Diff Body Context Menu
2505 set ctxm .vpane.lower.
diff.body.ctxm
2506 menu
$ctxm -tearoff 0
2508 -label [mc Refresh
] \
2509 -command reshow_diff
2510 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2513 -command {tk_textCopy
$ui_diff}
2514 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2516 -label [mc
"Select All"] \
2517 -command {focus
$ui_diff;$ui_diff tag add sel
0.0 end
}
2518 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2520 -label [mc
"Copy All"] \
2522 $ui_diff tag add sel
0.0 end
2523 tk_textCopy
$ui_diff
2524 $ui_diff tag remove sel
0.0 end
2526 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2529 -label [mc
"Apply/Reverse Hunk"] \
2530 -command {apply_hunk
$cursorX $cursorY}
2531 set ui_diff_applyhunk
[$ctxm index last
]
2532 lappend diff_actions
[list
$ctxm entryconf
$ui_diff_applyhunk -state]
2535 -label [mc
"Decrease Font Size"] \
2536 -command {incr_font_size font_diff
-1}
2537 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2539 -label [mc
"Increase Font Size"] \
2540 -command {incr_font_size font_diff
1}
2541 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2544 -label [mc
"Show Less Context"] \
2545 -command {if {$repo_config(gui.diffcontext
) >= 1} {
2546 incr repo_config
(gui.diffcontext
) -1
2549 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2551 -label [mc
"Show More Context"] \
2552 -command {if {$repo_config(gui.diffcontext
) < 99} {
2553 incr repo_config
(gui.diffcontext
)
2556 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2558 $ctxm add
command -label [mc
"Options..."] \
2560 proc popup_diff_menu
{ctxm x y X Y
} {
2561 global current_diff_path file_states
2564 if {$
::ui_index eq $
::current_diff_side
} {
2565 set l
[mc
"Unstage Hunk From Commit"]
2567 set l
[mc
"Stage Hunk For Commit"]
2570 ||
$current_diff_path eq
{}
2571 ||
![info exists file_states
($current_diff_path)]
2572 ||
{_O
} eq
[lindex
$file_states($current_diff_path) 0]} {
2577 $ctxm entryconf $
::ui_diff_applyhunk
-state $s -label $l
2578 tk_popup
$ctxm $X $Y
2580 bind_button3
$ui_diff [list popup_diff_menu
$ctxm %x
%y
%X
%Y
]
2584 set main_status
[::status_bar
::new .status
]
2585 pack .status
-anchor w
-side bottom
-fill x
2586 $main_status show
[mc
"Initializing..."]
2591 set gm
$repo_config(gui.geometry
)
2592 wm geometry .
[lindex
$gm 0]
2593 .vpane sash place
0 \
2594 [lindex
[.vpane sash coord
0] 0] \
2596 .vpane.files sash place
0 \
2598 [lindex
[.vpane.files sash coord
0] 1]
2604 bind $ui_comm <$M1B-Key-Return> {do_commit
;break}
2605 bind $ui_comm <$M1B-Key-i> {do_add_all
;break}
2606 bind $ui_comm <$M1B-Key-I> {do_add_all
;break}
2607 bind $ui_comm <$M1B-Key-x> {tk_textCut
%W
;break}
2608 bind $ui_comm <$M1B-Key-X> {tk_textCut
%W
;break}
2609 bind $ui_comm <$M1B-Key-c> {tk_textCopy
%W
;break}
2610 bind $ui_comm <$M1B-Key-C> {tk_textCopy
%W
;break}
2611 bind $ui_comm <$M1B-Key-v> {tk_textPaste
%W
; %W see insert
; break}
2612 bind $ui_comm <$M1B-Key-V> {tk_textPaste
%W
; %W see insert
; break}
2613 bind $ui_comm <$M1B-Key-a> {%W tag add sel
0.0 end
;break}
2614 bind $ui_comm <$M1B-Key-A> {%W tag add sel
0.0 end
;break}
2616 bind $ui_diff <$M1B-Key-x> {tk_textCopy
%W
;break}
2617 bind $ui_diff <$M1B-Key-X> {tk_textCopy
%W
;break}
2618 bind $ui_diff <$M1B-Key-c> {tk_textCopy
%W
;break}
2619 bind $ui_diff <$M1B-Key-C> {tk_textCopy
%W
;break}
2620 bind $ui_diff <$M1B-Key-v> {break}
2621 bind $ui_diff <$M1B-Key-V> {break}
2622 bind $ui_diff <$M1B-Key-a> {%W tag add sel
0.0 end
;break}
2623 bind $ui_diff <$M1B-Key-A> {%W tag add sel
0.0 end
;break}
2624 bind $ui_diff <Key-Up
> {catch
{%W yview scroll
-1 units
};break}
2625 bind $ui_diff <Key-Down
> {catch
{%W yview scroll
1 units
};break}
2626 bind $ui_diff <Key-Left
> {catch
{%W xview scroll
-1 units
};break}
2627 bind $ui_diff <Key-Right
> {catch
{%W xview scroll
1 units
};break}
2628 bind $ui_diff <Key-k
> {catch
{%W yview scroll
-1 units
};break}
2629 bind $ui_diff <Key-j
> {catch
{%W yview scroll
1 units
};break}
2630 bind $ui_diff <Key-h
> {catch
{%W xview scroll
-1 units
};break}
2631 bind $ui_diff <Key-l
> {catch
{%W xview scroll
1 units
};break}
2632 bind $ui_diff <Control-Key-b
> {catch
{%W yview scroll
-1 pages
};break}
2633 bind $ui_diff <Control-Key-f
> {catch
{%W yview scroll
1 pages
};break}
2634 bind $ui_diff <Button-1
> {focus
%W
}
2636 if {[is_enabled branch
]} {
2637 bind .
<$M1B-Key-n> branch_create
::dialog
2638 bind .
<$M1B-Key-N> branch_create
::dialog
2639 bind .
<$M1B-Key-o> branch_checkout
::dialog
2640 bind .
<$M1B-Key-O> branch_checkout
::dialog
2641 bind .
<$M1B-Key-m> merge
::dialog
2642 bind .
<$M1B-Key-M> merge
::dialog
2644 if {[is_enabled transport
]} {
2645 bind .
<$M1B-Key-p> do_push_anywhere
2646 bind .
<$M1B-Key-P> do_push_anywhere
2649 bind .
<Key-F5
> do_rescan
2650 bind .
<$M1B-Key-r> do_rescan
2651 bind .
<$M1B-Key-R> do_rescan
2652 bind .
<$M1B-Key-s> do_signoff
2653 bind .
<$M1B-Key-S> do_signoff
2654 bind .
<$M1B-Key-i> do_add_all
2655 bind .
<$M1B-Key-I> do_add_all
2656 bind .
<$M1B-Key-Return> do_commit
2657 foreach i
[list
$ui_index $ui_workdir] {
2658 bind $i <Button-1
> "toggle_or_diff $i %x %y; break"
2659 bind $i <$M1B-Button-1> "add_one_to_selection $i %x %y; break"
2660 bind $i <Shift-Button-1
> "add_range_to_selection $i %x %y; break"
2664 set file_lists
($ui_index) [list
]
2665 set file_lists
($ui_workdir) [list
]
2667 wm title .
"[appname] ([reponame]) [file normalize [file dirname [gitdir]]]"
2668 focus
-force $ui_comm
2670 # -- Warn the user about environmental problems. Cygwin's Tcl
2671 # does *not* pass its env array onto any processes it spawns.
2672 # This means that git processes get none of our environment.
2677 set msg
[mc
"Possible environment issues exist.
2679 The following environment variables are probably
2680 going to be ignored by any Git subprocess run
2684 foreach name
[array names env
] {
2685 switch
-regexp -- $name {
2686 {^GIT_INDEX_FILE$
} -
2687 {^GIT_OBJECT_DIRECTORY$
} -
2688 {^GIT_ALTERNATE_OBJECT_DIRECTORIES$
} -
2690 {^GIT_EXTERNAL_DIFF$
} -
2694 {^GIT_CONFIG_LOCAL$
} -
2695 {^GIT_
(AUTHOR|COMMITTER
)_DATE$
} {
2696 append msg
" - $name\n"
2699 {^GIT_
(AUTHOR|COMMITTER
)_
(NAME|EMAIL
)$
} {
2700 append msg
" - $name\n"
2702 set suggest_user
$name
2706 if {$ignored_env > 0} {
2708 This is due to a known issue with the
2709 Tcl binary distributed by Cygwin."]
2711 if {$suggest_user ne
{}} {
2714 A good replacement for %s
2715 is placing values for the user.name and
2716 user.email settings into your personal
2722 unset ignored_env msg suggest_user name
2725 # -- Only initialize complex UI if we are going to stay running.
2727 if {[is_enabled transport
]} {
2730 set n
[.mbar.remote index end
]
2733 set n
[expr {[.mbar.remote index end
] - $n}]
2735 .mbar.remote insert
$n separator
2740 if {[winfo exists
$ui_comm]} {
2741 set GITGUI_BCK_exists
[load_message GITGUI_BCK
]
2743 # -- If both our backup and message files exist use the
2744 # newer of the two files to initialize the buffer.
2746 if {$GITGUI_BCK_exists} {
2747 set m
[gitdir GITGUI_MSG
]
2748 if {[file isfile
$m]} {
2749 if {[file mtime
[gitdir GITGUI_BCK
]] > [file mtime
$m]} {
2750 catch
{file delete
[gitdir GITGUI_MSG
]}
2752 $ui_comm delete
0.0 end
2754 $ui_comm edit modified false
2755 catch
{file delete
[gitdir GITGUI_BCK
]}
2756 set GITGUI_BCK_exists
0
2762 proc backup_commit_buffer
{} {
2763 global ui_comm GITGUI_BCK_exists
2765 set m
[$ui_comm edit modified
]
2766 if {$m ||
$GITGUI_BCK_exists} {
2767 set msg
[string trim
[$ui_comm get
0.0 end
]]
2768 regsub
-all -line {[ \r\t]+$
} $msg {} msg
2771 if {$GITGUI_BCK_exists} {
2772 catch
{file delete
[gitdir GITGUI_BCK
]}
2773 set GITGUI_BCK_exists
0
2777 set fd
[open
[gitdir GITGUI_BCK
] w
]
2778 puts
-nonewline $fd $msg
2780 set GITGUI_BCK_exists
1
2784 $ui_comm edit modified false
2787 set ::GITGUI_BCK_i
[after
2000 backup_commit_buffer
]
2790 backup_commit_buffer
2793 lock_index begin-read
2794 if {![winfo ismapped .
]} {
2798 if {[is_enabled multicommit
]} {