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 _search_path
[split $env(PATH
) {;}]
349 set _search_path
[split $env(PATH
) :]
354 foreach p
$_search_path {
355 set p
[file join $p $what$_search_exe]
356 if {[file exists
$p]} {
357 return [file normalize
$p]
363 proc _lappend_nice
{cmd_var
} {
367 if {![info exists _nice
]} {
368 set _nice
[_which nice
]
379 switch
-- [lindex
$args 0] {
390 set args
[lrange
$args 1 end
]
393 set cmdp
[_git_cmd
[lindex
$args 0]]
394 set args
[lrange
$args 1 end
]
396 return [eval $opt $cmdp $args]
399 proc _open_stdout_stderr
{cmd
} {
403 if { [lindex
$cmd end
] eq
{2>@
1}
404 && $err eq
{can not
find channel named
"1"}
406 # Older versions of Tcl 8.4 don't have this 2>@1 IO
407 # redirect operator. Fallback to |& cat for those.
408 # The command was not actually started, so its safe
409 # to try to start it a second time.
411 set fd
[open
[concat \
412 [lrange
$cmd 0 end-1
] \
419 fconfigure
$fd -eofchar {}
423 proc git_read
{args
} {
427 switch
-- [lindex
$args 0] {
442 set args
[lrange
$args 1 end
]
445 set cmdp
[_git_cmd
[lindex
$args 0]]
446 set args
[lrange
$args 1 end
]
448 return [_open_stdout_stderr
[concat
$opt $cmdp $args]]
451 proc git_write
{args
} {
455 switch
-- [lindex
$args 0] {
466 set args
[lrange
$args 1 end
]
469 set cmdp
[_git_cmd
[lindex
$args 0]]
470 set args
[lrange
$args 1 end
]
472 return [open
[concat
$opt $cmdp $args] w
]
476 regsub
-all ' $value "'\\''" value
480 proc load_current_branch {} {
481 global current_branch is_detached
483 set fd [open [gitdir HEAD] r]
484 if {[gets $fd ref] < 1} {
489 set pfx {ref: refs/heads/}
490 set len [string length $pfx]
491 if {[string equal -length $len $pfx $ref]} {
492 # We're on a branch. It might not exist. But
493 # HEAD looks good enough to be a branch.
495 set current_branch [string range $ref $len end]
498 # Assume this is a detached head.
500 set current_branch HEAD
505 auto_load tk_optionMenu
506 rename tk_optionMenu real__tkOptionMenu
507 proc tk_optionMenu {w varName args} {
508 set m [eval real__tkOptionMenu $w $varName $args]
509 $m configure -font font_ui
510 $w configure -font font_ui
514 proc rmsel_tag {text} {
516 -background [$text cget -background] \
517 -foreground [$text cget -foreground] \
519 $text tag conf in_sel -background lightgray
520 bind $text <Motion> break
525 bind . <Visibility> {
526 bind . <Visibility> {}
531 wm iconbitmap . -default $oguilib/git-gui.ico
534 ######################################################################
539 font create font_diff -family Courier -size 10
543 eval font configure font_ui [font actual [.dummy cget -font]]
547 font create font_uiitalic
548 font create font_uibold
549 font create font_diffbold
550 font create font_diffitalic
552 foreach class {Button Checkbutton Entry Label
553 Labelframe Listbox Menu Message
554 Radiobutton Spinbox Text} {
555 option add *$class.font font_ui
559 if {[is_Windows] || [is_MacOSX]} {
560 option add *Menu.tearOff 0
571 proc bind_button3 {w cmd} {
572 bind $w <Any-Button-3> $cmd
574 # Mac OS X sends Button-2 on right click through three-button mouse,
575 # or through trackpad right-clicking (two-finger touch + click).
576 bind $w <Any-Button-2> $cmd
577 bind $w <Control-Button-1> $cmd
581 proc apply_config {} {
582 global repo_config font_descs
584 foreach option $font_descs {
585 set name [lindex $option 0]
586 set font [lindex $option 1]
588 foreach {cn cv} $repo_config(gui.$name) {
589 font configure $font $cn $cv -weight normal
592 error_popup [strcat [mc "Invalid font specified
in %s
:" "gui.
$name"] "\n\n$err"]
594 foreach {cn cv} [font configure $font] {
595 font configure ${font}bold $cn $cv
596 font configure ${font}italic $cn $cv
598 font configure ${font}bold -weight bold
599 font configure ${font}italic -slant italic
603 set default_config(merge.diffstat) true
604 set default_config(merge.summary) false
605 set default_config(merge.verbosity) 2
606 set default_config(user.name) {}
607 set default_config(user.email) {}
609 set default_config(gui.matchtrackingbranch) false
610 set default_config(gui.pruneduringfetch) false
611 set default_config(gui.trustmtime) false
612 set default_config(gui.diffcontext) 5
613 set default_config(gui.newbranchtemplate) {}
614 set default_config(gui.fontui) [font configure font_ui]
615 set default_config(gui.fontdiff) [font configure font_diff]
617 {fontui font_ui {mc "Main Font
"}}
618 {fontdiff font_diff {mc "Diff
/Console Font
"}}
621 ######################################################################
625 set _git [_which git]
627 catch {wm withdraw .}
631 -title [mc "git-gui
: fatal error
"] \
632 -message [mc "Cannot
find git
in PATH.
"]
636 ######################################################################
640 if {[catch {set _git_version [git --version]} err]} {
641 catch {wm withdraw .}
645 -title [mc "git-gui
: fatal error
"] \
646 -message "Cannot determine Git version
:
650 [appname
] requires Git
1.5.0 or later.
"
653 if {![regsub {^git version } $_git_version {} _git_version]} {
654 catch {wm withdraw .}
658 -title [mc "git-gui
: fatal error
"] \
659 -message [strcat [mc "Cannot parse Git version string
:"] "\n\n$_git_version"]
663 set _real_git_version $_git_version
664 regsub -- {-dirty$} $_git_version {} _git_version
665 regsub {\.[0-9]+\.g[0-9a-f]+$} $_git_version {} _git_version
666 regsub {\.rc[0-9]+$} $_git_version {} _git_version
667 regsub {\.GIT$} $_git_version {} _git_version
669 if {![regexp {^[1-9]+(\.[0-9]+)+$} $_git_version]} {
670 catch {wm withdraw .}
675 -title "[appname
]: warning
" \
676 -message [mc "Git version cannot be determined.
678 %s claims it is version
'%s'.
680 %s requires
at least Git
1.5.0 or later.
682 Assume
'%s' is version
1.5.0?
683 " $_git $_real_git_version [appname] $_real_git_version]] eq {yes}} {
684 set _git_version 1.5.0
689 unset _real_git_version
691 proc git-version {args} {
694 switch [llength $args] {
700 set op [lindex $args 0]
701 set vr [lindex $args 1]
702 set cm [package vcompare $_git_version $vr]
703 return [expr $cm $op 0]
707 set type [lindex $args 0]
708 set name [lindex $args 1]
709 set parm [lindex $args 2]
710 set body [lindex $args 3]
712 if {($type ne {proc} && $type ne {method})} {
713 error "Invalid arguments to git-version
"
715 if {[llength $body] < 2 || [lindex $body end-1] ne {default}} {
716 error "Last arm of
$type $name must be default
"
719 foreach {op vr cb} [lrange $body 0 end-2] {
720 if {[git-version $op $vr]} {
721 return [uplevel [list $type $name $parm $cb]]
725 return [uplevel [list $type $name $parm [lindex $body end]]]
729 error "git-version
>= x
"
735 if {[git-version < 1.5]} {
736 catch {wm withdraw .}
740 -title [mc "git-gui
: fatal error
"] \
741 -message "[appname
] requires Git
1.5.0 or later.
743 You are using
[git-version
]:
749 ######################################################################
751 ## configure our library
753 set idx [file join $oguilib tclIndex]
754 if {[catch {set fd [open $idx r]} err]} {
755 catch {wm withdraw .}
759 -title [mc "git-gui
: fatal error
"] \
763 if {[gets $fd] eq {# Autogenerated by git-gui Makefile}} {
765 while {[gets $fd n] >= 0} {
766 if {$n ne {} && ![string match #* $n]} {
778 if {[lsearch -exact $loaded $p] >= 0} continue
779 source [file join $oguilib $p]
784 set auto_path [concat [list $oguilib] $auto_path]
786 unset -nocomplain idx fd
788 ######################################################################
790 ## feature option selection
792 if {[regexp {^git-(.+)$} [file tail $argv0] _junk subcommand]} {
797 if {$subcommand eq {gui.sh}} {
800 if {$subcommand eq {gui} && [llength $argv] > 0} {
801 set subcommand [lindex $argv 0]
802 set argv [lrange $argv 1 end]
805 enable_option multicommit
807 enable_option transport
810 switch -- $subcommand {
815 disable_option multicommit
816 disable_option branch
817 disable_option transport
820 enable_option singlecommit
822 disable_option multicommit
823 disable_option branch
824 disable_option transport
828 ######################################################################
833 set _gitdir $env(GIT_DIR)
837 set _gitdir [git rev-parse --git-dir]
838 set _prefix [git rev-parse --show-prefix]
842 choose_repository::pick
844 if {![file isdirectory $_gitdir] && [is_Cygwin]} {
845 catch {set _gitdir [exec cygpath --windows $_gitdir]}
847 if {![file isdirectory $_gitdir]} {
848 catch {wm withdraw .}
849 error_popup [strcat [mc "Git directory not found
:"] "\n\n$_gitdir"]
852 if {$_prefix ne {}} {
853 regsub -all {[^/]+/} $_prefix ../ cdup
854 if {[catch {cd $cdup} err]} {
855 catch {wm withdraw .}
856 error_popup [strcat [mc "Cannot move to top of working directory
:"] "\n\n$err"]
860 } elseif {![is_enabled bare]} {
861 if {[lindex [file split $_gitdir] end] ne {.git}} {
862 catch {wm withdraw .}
863 error_popup [strcat [mc "Cannot use funny .git directory
:"] "\n\n$_gitdir"]
866 if {[catch {cd [file dirname $_gitdir]} err]} {
867 catch {wm withdraw .}
868 error_popup [strcat [mc "No working directory
"] " [file dirname $_gitdir]:\n\n$err"]
872 set _reponame [file split [file normalize $_gitdir]]
873 if {[lindex $_reponame end] eq {.git}} {
874 set _reponame [lindex $_reponame end-1]
876 set _reponame [lindex $_reponame end]
879 ######################################################################
883 set current_diff_path {}
884 set current_diff_side {}
885 set diff_actions [list]
889 set MERGE_HEAD [list]
892 set current_branch {}
894 set current_diff_path {}
896 set selected_commit_type new
898 ######################################################################
906 set disable_on_lock [list]
907 set index_lock_type none
909 proc lock_index {type} {
910 global index_lock_type disable_on_lock
912 if {$index_lock_type eq {none}} {
913 set index_lock_type $type
914 foreach w $disable_on_lock {
915 uplevel #0 $w disabled
918 } elseif {$index_lock_type eq "begin-
$type"} {
919 set index_lock_type $type
925 proc unlock_index {} {
926 global index_lock_type disable_on_lock
928 set index_lock_type none
929 foreach w $disable_on_lock {
934 ######################################################################
938 proc repository_state {ctvar hdvar mhvar} {
939 global current_branch
940 upvar $ctvar ct $hdvar hd $mhvar mh
945 if {[catch {set hd [git rev-parse --verify HEAD]}]} {
951 set merge_head [gitdir MERGE_HEAD]
952 if {[file exists $merge_head]} {
954 set fd_mh [open $merge_head r]
955 while {[gets $fd_mh line] >= 0} {
966 global PARENT empty_tree
968 set p [lindex $PARENT 0]
972 if {$empty_tree eq {}} {
973 set empty_tree [git mktree << {}]
978 proc rescan {after {honor_trustmtime 1}} {
979 global HEAD PARENT MERGE_HEAD commit_type
980 global ui_index ui_workdir ui_comm
981 global rescan_active file_states
984 if {$rescan_active > 0 || ![lock_index read]} return
986 repository_state newType newHEAD newMERGE_HEAD
987 if {[string match amend* $commit_type]
988 && $newType eq {normal}
989 && $newHEAD eq $HEAD} {
993 set MERGE_HEAD $newMERGE_HEAD
994 set commit_type $newType
997 array unset file_states
999 if {!$::GITGUI_BCK_exists &&
1000 (![$ui_comm edit modified]
1001 || [string trim [$ui_comm get 0.0 end]] eq {})} {
1002 if {[string match amend* $commit_type]} {
1003 } elseif {[load_message GITGUI_MSG]} {
1004 } elseif {[load_message MERGE_MSG]} {
1005 } elseif {[load_message SQUASH_MSG]} {
1008 $ui_comm edit modified false
1011 if {$honor_trustmtime && $repo_config(gui.trustmtime) eq {true}} {
1012 rescan_stage2 {} $after
1015 ui_status [mc "Refreshing
file status...
"]
1016 set fd_rf [git_read update-index \
1022 fconfigure $fd_rf -blocking 0 -translation binary
1023 fileevent $fd_rf readable \
1024 [list rescan_stage2 $fd_rf $after]
1029 set is_git_info_link {}
1030 set is_git_info_exclude {}
1031 proc have_info_exclude {} {
1032 global is_git_info_link is_git_info_exclude
1034 if {$is_git_info_link eq {}} {
1035 set is_git_info_link [file isfile [gitdir info.lnk]]
1038 if {$is_git_info_link} {
1039 if {$is_git_info_exclude eq {}} {
1040 if {[catch {exec test -f [gitdir info exclude]}]} {
1041 set is_git_info_exclude 0
1043 set is_git_info_exclude 1
1046 return $is_git_info_exclude
1048 return [file readable [gitdir info exclude]]
1052 proc have_info_exclude {} {
1053 return [file readable [gitdir info exclude]]
1057 proc rescan_stage2 {fd after} {
1058 global rescan_active buf_rdi buf_rdf buf_rlo
1062 if {![eof $fd]} return
1066 set ls_others [list --exclude-per-directory=.gitignore]
1067 if {[have_info_exclude]} {
1068 lappend ls_others "--exclude-from=[gitdir info exclude
]"
1070 set user_exclude [get_config core.excludesfile]
1071 if {$user_exclude ne {} && [file readable $user_exclude]} {
1072 lappend ls_others "--exclude-from=$user_exclude"
1080 ui_status [mc "Scanning
for modified files ...
"]
1081 set fd_di [git_read diff-index --cached -z [PARENT]]
1082 set fd_df [git_read diff-files -z]
1083 set fd_lo [eval git_read ls-files --others -z $ls_others]
1085 fconfigure $fd_di -blocking 0 -translation binary -encoding binary
1086 fconfigure $fd_df -blocking 0 -translation binary -encoding binary
1087 fconfigure $fd_lo -blocking 0 -translation binary -encoding binary
1088 fileevent $fd_di readable [list read_diff_index $fd_di $after]
1089 fileevent $fd_df readable [list read_diff_files $fd_df $after]
1090 fileevent $fd_lo readable [list read_ls_others $fd_lo $after]
1093 proc load_message {file} {
1096 set f [gitdir $file]
1097 if {[file isfile $f]} {
1098 if {[catch {set fd [open $f r]}]} {
1101 fconfigure $fd -eofchar {}
1102 set content [string trim [read $fd]]
1104 regsub -all -line {[ \r\t]+$} $content {} content
1105 $ui_comm delete 0.0 end
1106 $ui_comm insert end $content
1112 proc read_diff_index {fd after} {
1115 append buf_rdi [read $fd]
1117 set n [string length $buf_rdi]
1119 set z1 [string first "\
0" $buf_rdi $c]
1120 if {$z1 == -1} break
1122 set z2 [string first "\
0" $buf_rdi $z1]
1123 if {$z2 == -1} break
1126 set i [split [string range $buf_rdi $c [expr {$z1 - 2}]] { }]
1127 set p [string range $buf_rdi $z1 [expr {$z2 - 1}]]
1129 [encoding convertfrom $p] \
1131 [list [lindex $i 0] [lindex $i 2]] \
1137 set buf_rdi [string range $buf_rdi $c end]
1142 rescan_done $fd buf_rdi $after
1145 proc read_diff_files {fd after} {
1148 append buf_rdf [read $fd]
1150 set n [string length $buf_rdf]
1152 set z1 [string first "\
0" $buf_rdf $c]
1153 if {$z1 == -1} break
1155 set z2 [string first "\
0" $buf_rdf $z1]
1156 if {$z2 == -1} break
1159 set i [split [string range $buf_rdf $c [expr {$z1 - 2}]] { }]
1160 set p [string range $buf_rdf $z1 [expr {$z2 - 1}]]
1162 [encoding convertfrom $p] \
1165 [list [lindex $i 0] [lindex $i 2]]
1170 set buf_rdf [string range $buf_rdf $c end]
1175 rescan_done $fd buf_rdf $after
1178 proc read_ls_others {fd after} {
1181 append buf_rlo [read $fd]
1182 set pck [split $buf_rlo "\
0"]
1183 set buf_rlo [lindex $pck end]
1184 foreach p [lrange $pck 0 end-1] {
1185 set p [encoding convertfrom $p]
1186 if {[string index $p end] eq {/}} {
1187 set p [string range $p 0 end-1]
1191 rescan_done $fd buf_rlo $after
1194 proc rescan_done {fd buf after} {
1195 global rescan_active current_diff_path
1196 global file_states repo_config
1199 if {![eof $fd]} return
1202 if {[incr rescan_active -1] > 0} return
1207 if {$current_diff_path ne {}} reshow_diff
1211 proc prune_selection {} {
1212 global file_states selected_paths
1214 foreach path [array names selected_paths] {
1215 if {[catch {set still_here $file_states($path)}]} {
1216 unset selected_paths($path)
1221 ######################################################################
1225 proc mapicon {w state path} {
1228 if {[catch {set r $all_icons($state$w)}]} {
1229 puts "error
: no icon
for $w state
={$state} $path"
1235 proc mapdesc {state path} {
1238 if {[catch {set r $all_descs($state)}]} {
1239 puts "error
: no desc
for state
={$state} $path"
1245 proc ui_status {msg} {
1246 $::main_status show $msg
1249 proc ui_ready {{test {}}} {
1250 $::main_status show [mc "Ready.
"] $test
1253 proc escape_path {path} {
1254 regsub -all {\\} $path "\\\\" path
1255 regsub -all "\n" $path "\\n
" path
1259 proc short_path {path} {
1260 return [escape_path [lindex [file split $path] end]]
1264 set null_sha1 [string repeat 0 40]
1266 proc merge_state {path new_state {head_info {}} {index_info {}}} {
1267 global file_states next_icon_id null_sha1
1269 set s0 [string index $new_state 0]
1270 set s1 [string index $new_state 1]
1272 if {[catch {set info $file_states($path)}]} {
1274 set icon n[incr next_icon_id]
1276 set state [lindex $info 0]
1277 set icon [lindex $info 1]
1278 if {$head_info eq {}} {set head_info [lindex $info 2]}
1279 if {$index_info eq {}} {set index_info [lindex $info 3]}
1282 if {$s0 eq {?}} {set s0 [string index $state 0]} \
1283 elseif {$s0 eq {_}} {set s0 _}
1285 if {$s1 eq {?}} {set s1 [string index $state 1]} \
1286 elseif {$s1 eq {_}} {set s1 _}
1288 if {$s0 eq {A} && $s1 eq {_} && $head_info eq {}} {
1289 set head_info [list 0 $null_sha1]
1290 } elseif {$s0 ne {_} && [string index $state 0] eq {_}
1291 && $head_info eq {}} {
1292 set head_info $index_info
1295 set file_states($path) [list $s0$s1 $icon \
1296 $head_info $index_info \
1301 proc display_file_helper {w path icon_name old_m new_m} {
1304 if {$new_m eq {_}} {
1305 set lno [lsearch -sorted -exact $file_lists($w) $path]
1307 set file_lists($w) [lreplace $file_lists($w) $lno $lno]
1309 $w conf -state normal
1310 $w delete $lno.0 [expr {$lno + 1}].0
1311 $w conf -state disabled
1313 } elseif {$old_m eq {_} && $new_m ne {_}} {
1314 lappend file_lists($w) $path
1315 set file_lists($w) [lsort -unique $file_lists($w)]
1316 set lno [lsearch -sorted -exact $file_lists($w) $path]
1318 $w conf -state normal
1319 $w image create $lno.0 \
1320 -align center -padx 5 -pady 1 \
1322 -image [mapicon $w $new_m $path]
1323 $w insert $lno.1 "[escape_path
$path]\n"
1324 $w conf -state disabled
1325 } elseif {$old_m ne $new_m} {
1326 $w conf -state normal
1327 $w image conf $icon_name -image [mapicon $w $new_m $path]
1328 $w conf -state disabled
1332 proc display_file {path state} {
1333 global file_states selected_paths
1334 global ui_index ui_workdir
1336 set old_m [merge_state $path $state]
1337 set s $file_states($path)
1338 set new_m [lindex $s 0]
1339 set icon_name [lindex $s 1]
1341 set o [string index $old_m 0]
1342 set n [string index $new_m 0]
1349 display_file_helper $ui_index $path $icon_name $o $n
1351 if {[string index $old_m 0] eq {U}} {
1354 set o [string index $old_m 1]
1356 if {[string index $new_m 0] eq {U}} {
1359 set n [string index $new_m 1]
1361 display_file_helper $ui_workdir $path $icon_name $o $n
1363 if {$new_m eq {__}} {
1364 unset file_states($path)
1365 catch {unset selected_paths($path)}
1369 proc display_all_files_helper {w path icon_name m} {
1372 lappend file_lists($w) $path
1373 set lno [expr {[lindex [split [$w index end] .] 0] - 1}]
1374 $w image create end \
1375 -align center -padx 5 -pady 1 \
1377 -image [mapicon $w $m $path]
1378 $w insert end "[escape_path
$path]\n"
1381 proc display_all_files {} {
1382 global ui_index ui_workdir
1383 global file_states file_lists
1386 $ui_index conf -state normal
1387 $ui_workdir conf -state normal
1389 $ui_index delete 0.0 end
1390 $ui_workdir delete 0.0 end
1393 set file_lists($ui_index) [list]
1394 set file_lists($ui_workdir) [list]
1396 foreach path [lsort [array names file_states]] {
1397 set s $file_states($path)
1399 set icon_name [lindex $s 1]
1401 set s [string index $m 0]
1402 if {$s ne {U} && $s ne {_}} {
1403 display_all_files_helper $ui_index $path \
1407 if {[string index $m 0] eq {U}} {
1410 set s [string index $m 1]
1413 display_all_files_helper $ui_workdir $path \
1418 $ui_index conf -state disabled
1419 $ui_workdir conf -state disabled
1422 ######################################################################
1427 #define mask_width 14
1428 #define mask_height 15
1429 static unsigned char mask_bits[] = {
1430 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
1431 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
1432 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f};
1435 image create bitmap file_plain -background white -foreground black -data {
1436 #define plain_width 14
1437 #define plain_height 15
1438 static unsigned char plain_bits[] = {
1439 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
1440 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10,
1441 0x02, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1442 } -maskdata $filemask
1444 image create bitmap file_mod -background white -foreground blue -data {
1445 #define mod_width 14
1446 #define mod_height 15
1447 static unsigned char mod_bits[] = {
1448 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
1449 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
1450 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
1451 } -maskdata $filemask
1453 image create bitmap file_fulltick -background white -foreground "#007000" -data {
1454 #define file_fulltick_width 14
1455 #define file_fulltick_height 15
1456 static unsigned char file_fulltick_bits
[] = {
1457 0xfe, 0x01, 0x02, 0x1a, 0x02, 0x0c, 0x02, 0x0c, 0x02, 0x16, 0x02, 0x16,
1458 0x02, 0x13, 0x00, 0x13, 0x86, 0x11, 0x8c, 0x11, 0xd8, 0x10, 0xf2, 0x10,
1459 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1460 } -maskdata $filemask
1462 image create bitmap file_parttick
-background white
-foreground "#005050" -data {
1463 #define parttick_width 14
1464 #define parttick_height 15
1465 static unsigned char parttick_bits
[] = {
1466 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
1467 0x7a, 0x14, 0x02, 0x16, 0x02, 0x13, 0x8a, 0x11, 0xda, 0x10, 0x72, 0x10,
1468 0x22, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1469 } -maskdata $filemask
1471 image create bitmap file_question
-background white
-foreground black
-data {
1472 #define file_question_width 14
1473 #define file_question_height 15
1474 static unsigned char file_question_bits
[] = {
1475 0xfe, 0x01, 0x02, 0x02, 0xe2, 0x04, 0xf2, 0x09, 0x1a, 0x1b, 0x0a, 0x13,
1476 0x82, 0x11, 0xc2, 0x10, 0x62, 0x10, 0x62, 0x10, 0x02, 0x10, 0x62, 0x10,
1477 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1478 } -maskdata $filemask
1480 image create bitmap file_removed
-background white
-foreground red
-data {
1481 #define file_removed_width 14
1482 #define file_removed_height 15
1483 static unsigned char file_removed_bits
[] = {
1484 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
1485 0x1a, 0x16, 0x32, 0x13, 0xe2, 0x11, 0xc2, 0x10, 0xe2, 0x11, 0x32, 0x13,
1486 0x1a, 0x16, 0x02, 0x10, 0xfe, 0x1f};
1487 } -maskdata $filemask
1489 image create bitmap file_merge
-background white
-foreground blue
-data {
1490 #define file_merge_width 14
1491 #define file_merge_height 15
1492 static unsigned char file_merge_bits
[] = {
1493 0xfe, 0x01, 0x02, 0x03, 0x62, 0x05, 0x62, 0x09, 0x62, 0x1f, 0x62, 0x10,
1494 0xfa, 0x11, 0xf2, 0x10, 0x62, 0x10, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
1495 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
1496 } -maskdata $filemask
1498 set ui_index .vpane.files.index.list
1499 set ui_workdir .vpane.files.workdir.list
1501 set all_icons
(_
$ui_index) file_plain
1502 set all_icons
(A
$ui_index) file_fulltick
1503 set all_icons
(M
$ui_index) file_fulltick
1504 set all_icons
(D
$ui_index) file_removed
1505 set all_icons
(U
$ui_index) file_merge
1507 set all_icons
(_
$ui_workdir) file_plain
1508 set all_icons
(M
$ui_workdir) file_mod
1509 set all_icons
(D
$ui_workdir) file_question
1510 set all_icons
(U
$ui_workdir) file_merge
1511 set all_icons
(O
$ui_workdir) file_plain
1513 set max_status_desc
0
1515 {__
{mc
"Unmodified"}}
1517 {_M
{mc
"Modified, not staged"}}
1518 {M_
{mc
"Staged for commit"}}
1519 {MM
{mc
"Portions staged for commit"}}
1520 {MD
{mc
"Staged for commit, missing"}}
1522 {_O
{mc
"Untracked, not staged"}}
1523 {A_
{mc
"Staged for commit"}}
1524 {AM
{mc
"Portions staged for commit"}}
1525 {AD
{mc
"Staged for commit, missing"}}
1528 {D_
{mc
"Staged for removal"}}
1529 {DO
{mc
"Staged for removal, still present"}}
1531 {U_
{mc
"Requires merge resolution"}}
1532 {UU
{mc
"Requires merge resolution"}}
1533 {UM
{mc
"Requires merge resolution"}}
1534 {UD
{mc
"Requires merge resolution"}}
1536 set text
[eval [lindex
$i 1]]
1537 if {$max_status_desc < [string length
$text]} {
1538 set max_status_desc
[string length
$text]
1540 set all_descs
([lindex
$i 0]) $text
1544 ######################################################################
1548 proc scrollbar2many
{list mode args
} {
1549 foreach w
$list {eval $w $mode $args}
1552 proc many2scrollbar
{list mode sb top bottom
} {
1553 $sb set $top $bottom
1554 foreach w
$list {$w $mode moveto
$top}
1557 proc incr_font_size
{font
{amt
1}} {
1558 set sz
[font configure
$font -size]
1560 font configure
$font -size $sz
1561 font configure
${font}bold
-size $sz
1562 font configure
${font}italic
-size $sz
1565 ######################################################################
1569 set starting_gitk_msg
[mc
"Starting gitk... please wait..."]
1571 proc do_gitk
{revs
} {
1572 # -- Always start gitk through whatever we were loaded with. This
1573 # lets us bypass using shell process on Windows systems.
1575 set exe
[file join [file dirname $
::_git
] gitk
]
1576 set cmd
[list
[info nameofexecutable
] $exe]
1577 if {! [file exists
$exe]} {
1578 error_popup
[mc
"Unable to start gitk:\n\n%s does not exist" $exe]
1580 eval exec $cmd $revs &
1581 ui_status $
::starting_gitk_msg
1583 ui_ready
$starting_gitk_msg
1591 global ui_comm is_quitting repo_config commit_type
1592 global GITGUI_BCK_exists GITGUI_BCK_i
1594 if {$is_quitting} return
1597 if {[winfo exists
$ui_comm]} {
1598 # -- Stash our current commit buffer.
1600 set save
[gitdir GITGUI_MSG
]
1601 if {$GITGUI_BCK_exists && ![$ui_comm edit modified
]} {
1602 file rename
-force [gitdir GITGUI_BCK
] $save
1603 set GITGUI_BCK_exists
0
1605 set msg
[string trim
[$ui_comm get
0.0 end
]]
1606 regsub
-all -line {[ \r\t]+$
} $msg {} msg
1607 if {(![string match amend
* $commit_type]
1608 ||
[$ui_comm edit modified
])
1611 set fd
[open
$save w
]
1612 puts
-nonewline $fd $msg
1616 catch
{file delete
$save}
1620 # -- Remove our editor backup, its not needed.
1622 after cancel
$GITGUI_BCK_i
1623 if {$GITGUI_BCK_exists} {
1624 catch
{file delete
[gitdir GITGUI_BCK
]}
1627 # -- Stash our current window geometry into this repository.
1629 set cfg_geometry
[list
]
1630 lappend cfg_geometry
[wm geometry .
]
1631 lappend cfg_geometry
[lindex
[.vpane sash coord
0] 1]
1632 lappend cfg_geometry
[lindex
[.vpane.files sash coord
0] 0]
1633 if {[catch
{set rc_geometry
$repo_config(gui.geometry
)}]} {
1636 if {$cfg_geometry ne
$rc_geometry} {
1637 catch
{git config gui.geometry
$cfg_geometry}
1652 proc toggle_or_diff
{w x y
} {
1653 global file_states file_lists current_diff_path ui_index ui_workdir
1654 global last_clicked selected_paths
1656 set pos
[split [$w index @
$x,$y] .
]
1657 set lno
[lindex
$pos 0]
1658 set col [lindex
$pos 1]
1659 set path
[lindex
$file_lists($w) [expr {$lno - 1}]]
1665 set last_clicked
[list
$w $lno]
1666 array
unset selected_paths
1667 $ui_index tag remove in_sel
0.0 end
1668 $ui_workdir tag remove in_sel
0.0 end
1671 if {$current_diff_path eq
$path} {
1672 set after
{reshow_diff
;}
1676 if {$w eq
$ui_index} {
1678 "Unstaging [short_path $path] from commit" \
1680 [concat
$after [list ui_ready
]]
1681 } elseif
{$w eq
$ui_workdir} {
1683 "Adding [short_path $path]" \
1685 [concat
$after [list ui_ready
]]
1688 show_diff
$path $w $lno
1692 proc add_one_to_selection
{w x y
} {
1693 global file_lists last_clicked selected_paths
1695 set lno
[lindex
[split [$w index @
$x,$y] .
] 0]
1696 set path
[lindex
$file_lists($w) [expr {$lno - 1}]]
1702 if {$last_clicked ne
{}
1703 && [lindex
$last_clicked 0] ne
$w} {
1704 array
unset selected_paths
1705 [lindex
$last_clicked 0] tag remove in_sel
0.0 end
1708 set last_clicked
[list
$w $lno]
1709 if {[catch
{set in_sel
$selected_paths($path)}]} {
1713 unset selected_paths
($path)
1714 $w tag remove in_sel
$lno.0 [expr {$lno + 1}].0
1716 set selected_paths
($path) 1
1717 $w tag add in_sel
$lno.0 [expr {$lno + 1}].0
1721 proc add_range_to_selection
{w x y
} {
1722 global file_lists last_clicked selected_paths
1724 if {[lindex
$last_clicked 0] ne
$w} {
1725 toggle_or_diff
$w $x $y
1729 set lno
[lindex
[split [$w index @
$x,$y] .
] 0]
1730 set lc
[lindex
$last_clicked 1]
1739 foreach path
[lrange
$file_lists($w) \
1740 [expr {$begin - 1}] \
1741 [expr {$end - 1}]] {
1742 set selected_paths
($path) 1
1744 $w tag add in_sel
$begin.0 [expr {$end + 1}].0
1747 ######################################################################
1757 menu .mbar
-tearoff 0
1758 .mbar add cascade
-label [mc Repository
] -menu .mbar.repository
1759 .mbar add cascade
-label [mc Edit
] -menu .mbar.edit
1760 if {[is_enabled branch
]} {
1761 .mbar add cascade
-label [mc Branch
] -menu .mbar.branch
1763 if {[is_enabled multicommit
] ||
[is_enabled singlecommit
]} {
1764 .mbar add cascade
-label [mc Commit@@noun
] -menu .mbar.commit
1766 if {[is_enabled transport
]} {
1767 .mbar add cascade
-label [mc Merge
] -menu .mbar.merge
1768 .mbar add cascade
-label [mc Fetch
] -menu .mbar.fetch
1769 .mbar add cascade
-label [mc Push
] -menu .mbar.push
1771 . configure
-menu .mbar
1773 # -- Repository Menu
1775 menu .mbar.repository
1777 .mbar.repository add
command \
1778 -label [mc
"Browse Current Branch's Files"] \
1779 -command {browser
::new
$current_branch}
1780 set ui_browse_current
[.mbar.repository index last
]
1781 .mbar.repository add
command \
1782 -label [mc
"Browse Branch Files..."] \
1783 -command browser_open
::dialog
1784 .mbar.repository add separator
1786 .mbar.repository add
command \
1787 -label [mc
"Visualize Current Branch's History"] \
1788 -command {do_gitk
$current_branch}
1789 set ui_visualize_current
[.mbar.repository index last
]
1790 .mbar.repository add
command \
1791 -label [mc
"Visualize All Branch History"] \
1792 -command {do_gitk
--all}
1793 .mbar.repository add separator
1795 proc current_branch_write
{args
} {
1796 global current_branch
1797 .mbar.repository entryconf $
::ui_browse_current \
1798 -label [mc
"Browse %s's Files" $current_branch]
1799 .mbar.repository entryconf $
::ui_visualize_current \
1800 -label [mc
"Visualize %s's History" $current_branch]
1802 trace add variable current_branch
write current_branch_write
1804 if {[is_enabled multicommit
]} {
1805 .mbar.repository add
command -label [mc
"Database Statistics"] \
1808 .mbar.repository add
command -label [mc
"Compress Database"] \
1811 .mbar.repository add
command -label [mc
"Verify Database"] \
1812 -command do_fsck_objects
1814 .mbar.repository add separator
1817 .mbar.repository add
command \
1818 -label [mc
"Create Desktop Icon"] \
1819 -command do_cygwin_shortcut
1820 } elseif
{[is_Windows
]} {
1821 .mbar.repository add
command \
1822 -label [mc
"Create Desktop Icon"] \
1823 -command do_windows_shortcut
1824 } elseif
{[is_MacOSX
]} {
1825 .mbar.repository add
command \
1826 -label [mc
"Create Desktop Icon"] \
1827 -command do_macosx_app
1831 .mbar.repository add
command -label [mc Quit
] \
1838 .mbar.edit add
command -label [mc Undo
] \
1839 -command {catch
{[focus
] edit undo
}} \
1841 .mbar.edit add
command -label [mc Redo
] \
1842 -command {catch
{[focus
] edit redo
}} \
1844 .mbar.edit add separator
1845 .mbar.edit add
command -label [mc Cut
] \
1846 -command {catch
{tk_textCut
[focus
]}} \
1848 .mbar.edit add
command -label [mc Copy
] \
1849 -command {catch
{tk_textCopy
[focus
]}} \
1851 .mbar.edit add
command -label [mc Paste
] \
1852 -command {catch
{tk_textPaste
[focus
]; [focus
] see insert
}} \
1854 .mbar.edit add
command -label [mc Delete
] \
1855 -command {catch
{[focus
] delete sel.first sel.last
}} \
1857 .mbar.edit add separator
1858 .mbar.edit add
command -label [mc
"Select All"] \
1859 -command {catch
{[focus
] tag add sel
0.0 end
}} \
1864 if {[is_enabled branch
]} {
1867 .mbar.branch add
command -label [mc
"Create..."] \
1868 -command branch_create
::dialog \
1870 lappend disable_on_lock
[list .mbar.branch entryconf \
1871 [.mbar.branch index last
] -state]
1873 .mbar.branch add
command -label [mc
"Checkout..."] \
1874 -command branch_checkout
::dialog \
1876 lappend disable_on_lock
[list .mbar.branch entryconf \
1877 [.mbar.branch index last
] -state]
1879 .mbar.branch add
command -label [mc
"Rename..."] \
1880 -command branch_rename
::dialog
1881 lappend disable_on_lock
[list .mbar.branch entryconf \
1882 [.mbar.branch index last
] -state]
1884 .mbar.branch add
command -label [mc
"Delete..."] \
1885 -command branch_delete
::dialog
1886 lappend disable_on_lock
[list .mbar.branch entryconf \
1887 [.mbar.branch index last
] -state]
1889 .mbar.branch add
command -label [mc
"Reset..."] \
1890 -command merge
::reset_hard
1891 lappend disable_on_lock
[list .mbar.branch entryconf \
1892 [.mbar.branch index last
] -state]
1897 if {[is_enabled multicommit
] ||
[is_enabled singlecommit
]} {
1900 .mbar.commit add radiobutton \
1901 -label [mc
"New Commit"] \
1902 -command do_select_commit_type \
1903 -variable selected_commit_type \
1905 lappend disable_on_lock \
1906 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1908 .mbar.commit add radiobutton \
1909 -label [mc
"Amend Last Commit"] \
1910 -command do_select_commit_type \
1911 -variable selected_commit_type \
1913 lappend disable_on_lock \
1914 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1916 .mbar.commit add separator
1918 .mbar.commit add
command -label [mc Rescan
] \
1919 -command do_rescan \
1921 lappend disable_on_lock \
1922 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1924 .mbar.commit add
command -label [mc
"Stage To Commit"] \
1925 -command do_add_selection
1926 lappend disable_on_lock \
1927 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1929 .mbar.commit add
command -label [mc
"Stage Changed Files To Commit"] \
1930 -command do_add_all \
1932 lappend disable_on_lock \
1933 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1935 .mbar.commit add
command -label [mc
"Unstage From Commit"] \
1936 -command do_unstage_selection
1937 lappend disable_on_lock \
1938 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1940 .mbar.commit add
command -label [mc
"Revert Changes"] \
1941 -command do_revert_selection
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
"Sign Off"] \
1948 -command do_signoff \
1951 .mbar.commit add
command -label [mc Commit@@verb
] \
1952 -command do_commit \
1953 -accelerator $M1T-Return
1954 lappend disable_on_lock \
1955 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1960 if {[is_enabled branch
]} {
1962 .mbar.merge add
command -label [mc
"Local Merge..."] \
1963 -command merge
::dialog \
1965 lappend disable_on_lock \
1966 [list .mbar.merge entryconf
[.mbar.merge index last
] -state]
1967 .mbar.merge add
command -label [mc
"Abort Merge..."] \
1968 -command merge
::reset_hard
1969 lappend disable_on_lock \
1970 [list .mbar.merge entryconf
[.mbar.merge index last
] -state]
1975 if {[is_enabled transport
]} {
1979 .mbar.push add
command -label [mc
"Push..."] \
1980 -command do_push_anywhere \
1982 .mbar.push add
command -label [mc
"Delete..."] \
1983 -command remote_branch_delete
::dialog
1987 # -- Apple Menu (Mac OS X only)
1989 .mbar add cascade
-label [mc Apple
] -menu .mbar.apple
1992 .mbar.apple add
command -label [mc
"About %s" [appname
]] \
1994 .mbar.apple add
command -label [mc
"Options..."] \
1999 .mbar.edit add separator
2000 .mbar.edit add
command -label [mc
"Options..."] \
2006 .mbar add cascade
-label [mc Help
] -menu .mbar.
help
2010 .mbar.
help add
command -label [mc
"About %s" [appname
]] \
2015 catch
{set browser
$repo_config(instaweb.browser
)}
2016 set doc_path
[file dirname [gitexec
]]
2017 set doc_path
[file join $doc_path Documentation index.html
]
2020 set doc_path
[exec cygpath
--mixed $doc_path]
2023 if {$browser eq
{}} {
2026 } elseif
{[is_Cygwin
]} {
2027 set program_files
[file dirname [exec cygpath
--windir]]
2028 set program_files
[file join $program_files {Program Files
}]
2029 set firefox
[file join $program_files {Mozilla Firefox
} firefox.exe
]
2030 set ie
[file join $program_files {Internet Explorer
} IEXPLORE.EXE
]
2031 if {[file exists
$firefox]} {
2032 set browser
$firefox
2033 } elseif
{[file exists
$ie]} {
2036 unset program_files firefox ie
2040 if {[file isfile
$doc_path]} {
2041 set doc_url
"file:$doc_path"
2043 set doc_url
{http
://www.kernel.org
/pub
/software
/scm
/git
/docs
/}
2046 if {$browser ne
{}} {
2047 .mbar.
help add
command -label [mc
"Online Documentation"] \
2048 -command [list
exec $browser $doc_url &]
2050 unset browser doc_path doc_url
2052 # -- Standard bindings
2054 wm protocol . WM_DELETE_WINDOW do_quit
2055 bind all
<$M1B-Key-q> do_quit
2056 bind all
<$M1B-Key-Q> do_quit
2057 bind all
<$M1B-Key-w> {destroy
[winfo toplevel
%W
]}
2058 bind all
<$M1B-Key-W> {destroy
[winfo toplevel
%W
]}
2060 set subcommand_args
{}
2062 puts stderr
"usage: $::argv0 $::subcommand $::subcommand_args"
2066 # -- Not a normal commit type invocation? Do that instead!
2068 switch
-- $subcommand {
2071 set subcommand_args
{rev? path
}
2072 if {$argv eq
{}} usage
2077 if {$is_path ||
[file exists
$_prefix$a]} {
2078 if {$path ne
{}} usage
2081 } elseif
{$a eq
{--}} {
2083 if {$head ne
{}} usage
2088 } elseif
{$head eq
{}} {
2089 if {$head ne
{}} usage
2098 if {$head ne
{} && $path eq
{}} {
2099 set path
$_prefix$head
2106 if {[regexp
{^
[0-9a-f]{1,39}$
} $head]} {
2108 set head [git rev-parse
--verify $head]
2114 set current_branch
$head
2117 switch
-- $subcommand {
2120 if {$path ne
{} && [file isdirectory
$path]} {
2121 set head $current_branch
2127 browser
::new
$head $path
2130 if {$head eq
{} && ![file exists
$path]} {
2131 puts stderr
[mc
"fatal: cannot stat path %s: No such file or directory" $path]
2134 blame
::new
$head $path
2141 if {[llength
$argv] != 0} {
2142 puts
-nonewline stderr
"usage: $argv0"
2143 if {$subcommand ne
{gui
}
2144 && [file tail $argv0] ne
"git-$subcommand"} {
2145 puts
-nonewline stderr
" $subcommand"
2150 # fall through to setup UI for commits
2153 puts stderr
"usage: $argv0 \[{blame|browser|citool}\]"
2164 -text [mc
"Current Branch:"] \
2168 -textvariable current_branch \
2171 pack .branch.l1
-side left
2172 pack .branch.cb
-side left
-fill x
2173 pack .branch
-side top
-fill x
2175 # -- Main Window Layout
2177 panedwindow .vpane
-orient vertical
2178 panedwindow .vpane.files
-orient horizontal
2179 .vpane add .vpane.files
-sticky nsew
-height 100 -width 200
2180 pack .vpane
-anchor n
-side top
-fill both
-expand 1
2182 # -- Index File List
2184 frame .vpane.files.index
-height 100 -width 200
2185 label .vpane.files.index.title
-text [mc
"Staged Changes (Will Be Committed)"] \
2186 -background lightgreen
2187 text
$ui_index -background white
-borderwidth 0 \
2188 -width 20 -height 10 \
2190 -cursor $cursor_ptr \
2191 -xscrollcommand {.vpane.files.index.sx
set} \
2192 -yscrollcommand {.vpane.files.index.sy
set} \
2194 scrollbar .vpane.files.index.sx
-orient h
-command [list
$ui_index xview
]
2195 scrollbar .vpane.files.index.sy
-orient v
-command [list
$ui_index yview
]
2196 pack .vpane.files.index.title
-side top
-fill x
2197 pack .vpane.files.index.sx
-side bottom
-fill x
2198 pack .vpane.files.index.sy
-side right
-fill y
2199 pack
$ui_index -side left
-fill both
-expand 1
2200 .vpane.files add .vpane.files.index
-sticky nsew
2202 # -- Working Directory File List
2204 frame .vpane.files.workdir
-height 100 -width 200
2205 label .vpane.files.workdir.title
-text [mc
"Unstaged Changes (Will Not Be Committed)"] \
2206 -background lightsalmon
2207 text
$ui_workdir -background white
-borderwidth 0 \
2208 -width 20 -height 10 \
2210 -cursor $cursor_ptr \
2211 -xscrollcommand {.vpane.files.workdir.sx
set} \
2212 -yscrollcommand {.vpane.files.workdir.sy
set} \
2214 scrollbar .vpane.files.workdir.sx
-orient h
-command [list
$ui_workdir xview
]
2215 scrollbar .vpane.files.workdir.sy
-orient v
-command [list
$ui_workdir yview
]
2216 pack .vpane.files.workdir.title
-side top
-fill x
2217 pack .vpane.files.workdir.sx
-side bottom
-fill x
2218 pack .vpane.files.workdir.sy
-side right
-fill y
2219 pack
$ui_workdir -side left
-fill both
-expand 1
2220 .vpane.files add .vpane.files.workdir
-sticky nsew
2222 foreach i
[list
$ui_index $ui_workdir] {
2224 $i tag conf in_diff
-background [$i tag cget in_sel
-background]
2228 # -- Diff and Commit Area
2230 frame .vpane.lower
-height 300 -width 400
2231 frame .vpane.lower.commarea
2232 frame .vpane.lower.
diff -relief sunken
-borderwidth 1
2233 pack .vpane.lower.commarea
-side top
-fill x
2234 pack .vpane.lower.
diff -side bottom
-fill both
-expand 1
2235 .vpane add .vpane.lower
-sticky nsew
2237 # -- Commit Area Buttons
2239 frame .vpane.lower.commarea.buttons
2240 label .vpane.lower.commarea.buttons.l
-text {} \
2243 pack .vpane.lower.commarea.buttons.l
-side top
-fill x
2244 pack .vpane.lower.commarea.buttons
-side left
-fill y
2246 button .vpane.lower.commarea.buttons.rescan
-text [mc Rescan
] \
2248 pack .vpane.lower.commarea.buttons.rescan
-side top
-fill x
2249 lappend disable_on_lock \
2250 {.vpane.lower.commarea.buttons.rescan conf
-state}
2252 button .vpane.lower.commarea.buttons.incall
-text [mc
"Stage Changed"] \
2254 pack .vpane.lower.commarea.buttons.incall
-side top
-fill x
2255 lappend disable_on_lock \
2256 {.vpane.lower.commarea.buttons.incall conf
-state}
2258 button .vpane.lower.commarea.buttons.signoff
-text [mc
"Sign Off"] \
2260 pack .vpane.lower.commarea.buttons.signoff
-side top
-fill x
2262 button .vpane.lower.commarea.buttons.commit
-text [mc Commit@@verb
] \
2264 pack .vpane.lower.commarea.buttons.commit
-side top
-fill x
2265 lappend disable_on_lock \
2266 {.vpane.lower.commarea.buttons.commit conf
-state}
2268 button .vpane.lower.commarea.buttons.push
-text [mc Push
] \
2269 -command do_push_anywhere
2270 pack .vpane.lower.commarea.buttons.push
-side top
-fill x
2272 # -- Commit Message Buffer
2274 frame .vpane.lower.commarea.buffer
2275 frame .vpane.lower.commarea.buffer.header
2276 set ui_comm .vpane.lower.commarea.buffer.t
2277 set ui_coml .vpane.lower.commarea.buffer.header.l
2278 radiobutton .vpane.lower.commarea.buffer.header.new \
2279 -text [mc
"New Commit"] \
2280 -command do_select_commit_type \
2281 -variable selected_commit_type \
2283 lappend disable_on_lock \
2284 [list .vpane.lower.commarea.buffer.header.new conf
-state]
2285 radiobutton .vpane.lower.commarea.buffer.header.amend \
2286 -text [mc
"Amend Last Commit"] \
2287 -command do_select_commit_type \
2288 -variable selected_commit_type \
2290 lappend disable_on_lock \
2291 [list .vpane.lower.commarea.buffer.header.amend conf
-state]
2295 proc trace_commit_type
{varname args
} {
2296 global ui_coml commit_type
2297 switch
-glob -- $commit_type {
2298 initial
{set txt
[mc
"Initial Commit Message:"]}
2299 amend
{set txt
[mc
"Amended Commit Message:"]}
2300 amend-initial
{set txt
[mc
"Amended Initial Commit Message:"]}
2301 amend-merge
{set txt
[mc
"Amended Merge Commit Message:"]}
2302 merge
{set txt
[mc
"Merge Commit Message:"]}
2303 * {set txt
[mc
"Commit Message:"]}
2305 $ui_coml conf
-text $txt
2307 trace add variable commit_type
write trace_commit_type
2308 pack
$ui_coml -side left
-fill x
2309 pack .vpane.lower.commarea.buffer.header.amend
-side right
2310 pack .vpane.lower.commarea.buffer.header.new
-side right
2312 text
$ui_comm -background white
-borderwidth 1 \
2315 -autoseparators true \
2317 -width 75 -height 9 -wrap none \
2319 -yscrollcommand {.vpane.lower.commarea.buffer.sby
set}
2320 scrollbar .vpane.lower.commarea.buffer.sby \
2321 -command [list
$ui_comm yview
]
2322 pack .vpane.lower.commarea.buffer.header
-side top
-fill x
2323 pack .vpane.lower.commarea.buffer.sby
-side right
-fill y
2324 pack
$ui_comm -side left
-fill y
2325 pack .vpane.lower.commarea.buffer
-side left
-fill y
2327 # -- Commit Message Buffer Context Menu
2329 set ctxm .vpane.lower.commarea.buffer.ctxm
2330 menu
$ctxm -tearoff 0
2333 -command {tk_textCut
$ui_comm}
2336 -command {tk_textCopy
$ui_comm}
2339 -command {tk_textPaste
$ui_comm}
2341 -label [mc Delete
] \
2342 -command {$ui_comm delete sel.first sel.last
}
2345 -label [mc
"Select All"] \
2346 -command {focus
$ui_comm;$ui_comm tag add sel
0.0 end
}
2348 -label [mc
"Copy All"] \
2350 $ui_comm tag add sel
0.0 end
2351 tk_textCopy
$ui_comm
2352 $ui_comm tag remove sel
0.0 end
2356 -label [mc
"Sign Off"] \
2358 bind_button3
$ui_comm "tk_popup $ctxm %X %Y"
2362 proc trace_current_diff_path
{varname args
} {
2363 global current_diff_path diff_actions file_states
2364 if {$current_diff_path eq
{}} {
2370 set p
$current_diff_path
2371 set s
[mapdesc
[lindex
$file_states($p) 0] $p]
2373 set p
[escape_path
$p]
2377 .vpane.lower.
diff.header.status configure
-text $s
2378 .vpane.lower.
diff.header.
file configure
-text $f
2379 .vpane.lower.
diff.header.path configure
-text $p
2380 foreach w
$diff_actions {
2384 trace add variable current_diff_path
write trace_current_diff_path
2386 frame .vpane.lower.
diff.header
-background gold
2387 label .vpane.lower.
diff.header.status \
2389 -width $max_status_desc \
2392 label .vpane.lower.
diff.header.
file \
2396 label .vpane.lower.
diff.header.path \
2400 pack .vpane.lower.
diff.header.status
-side left
2401 pack .vpane.lower.
diff.header.
file -side left
2402 pack .vpane.lower.
diff.header.path
-fill x
2403 set ctxm .vpane.lower.
diff.header.ctxm
2404 menu
$ctxm -tearoff 0
2412 -- $current_diff_path
2414 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2415 bind_button3 .vpane.lower.
diff.header.path
"tk_popup $ctxm %X %Y"
2419 frame .vpane.lower.
diff.body
2420 set ui_diff .vpane.lower.
diff.body.t
2421 text
$ui_diff -background white
-borderwidth 0 \
2422 -width 80 -height 15 -wrap none \
2424 -xscrollcommand {.vpane.lower.
diff.body.sbx
set} \
2425 -yscrollcommand {.vpane.lower.
diff.body.sby
set} \
2427 scrollbar .vpane.lower.
diff.body.sbx
-orient horizontal \
2428 -command [list
$ui_diff xview
]
2429 scrollbar .vpane.lower.
diff.body.sby
-orient vertical \
2430 -command [list
$ui_diff yview
]
2431 pack .vpane.lower.
diff.body.sbx
-side bottom
-fill x
2432 pack .vpane.lower.
diff.body.sby
-side right
-fill y
2433 pack
$ui_diff -side left
-fill both
-expand 1
2434 pack .vpane.lower.
diff.header
-side top
-fill x
2435 pack .vpane.lower.
diff.body
-side bottom
-fill both
-expand 1
2437 $ui_diff tag conf d_cr
-elide true
2438 $ui_diff tag conf d_@
-foreground blue
-font font_diffbold
2439 $ui_diff tag conf d_
+ -foreground {#00a000}
2440 $ui_diff tag conf d_-
-foreground red
2442 $ui_diff tag conf d_
++ -foreground {#00a000}
2443 $ui_diff tag conf d_--
-foreground red
2444 $ui_diff tag conf d_
+s \
2445 -foreground {#00a000} \
2446 -background {#e2effa}
2447 $ui_diff tag conf d_-s \
2449 -background {#e2effa}
2450 $ui_diff tag conf d_s
+ \
2451 -foreground {#00a000} \
2453 $ui_diff tag conf d_s- \
2457 $ui_diff tag conf d
<<<<<<< \
2458 -foreground orange \
2460 $ui_diff tag conf d
======= \
2461 -foreground orange \
2463 $ui_diff tag conf d
>>>>>>> \
2464 -foreground orange \
2467 $ui_diff tag raise sel
2469 # -- Diff Body Context Menu
2471 set ctxm .vpane.lower.
diff.body.ctxm
2472 menu
$ctxm -tearoff 0
2474 -label [mc Refresh
] \
2475 -command reshow_diff
2476 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2479 -command {tk_textCopy
$ui_diff}
2480 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2482 -label [mc
"Select All"] \
2483 -command {focus
$ui_diff;$ui_diff tag add sel
0.0 end
}
2484 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2486 -label [mc
"Copy All"] \
2488 $ui_diff tag add sel
0.0 end
2489 tk_textCopy
$ui_diff
2490 $ui_diff tag remove sel
0.0 end
2492 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2495 -label [mc
"Apply/Reverse Hunk"] \
2496 -command {apply_hunk
$cursorX $cursorY}
2497 set ui_diff_applyhunk
[$ctxm index last
]
2498 lappend diff_actions
[list
$ctxm entryconf
$ui_diff_applyhunk -state]
2501 -label [mc
"Decrease Font Size"] \
2502 -command {incr_font_size font_diff
-1}
2503 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2505 -label [mc
"Increase Font Size"] \
2506 -command {incr_font_size font_diff
1}
2507 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2510 -label [mc
"Show Less Context"] \
2511 -command {if {$repo_config(gui.diffcontext
) >= 1} {
2512 incr repo_config
(gui.diffcontext
) -1
2515 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2517 -label [mc
"Show More Context"] \
2518 -command {if {$repo_config(gui.diffcontext
) < 99} {
2519 incr repo_config
(gui.diffcontext
)
2522 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2524 $ctxm add
command -label [mc
"Options..."] \
2526 proc popup_diff_menu
{ctxm x y X Y
} {
2527 global current_diff_path file_states
2530 if {$
::ui_index eq $
::current_diff_side
} {
2531 set l
[mc
"Unstage Hunk From Commit"]
2533 set l
[mc
"Stage Hunk For Commit"]
2536 ||
$current_diff_path eq
{}
2537 ||
![info exists file_states
($current_diff_path)]
2538 ||
{_O
} eq
[lindex
$file_states($current_diff_path) 0]} {
2543 $ctxm entryconf $
::ui_diff_applyhunk
-state $s -label $l
2544 tk_popup
$ctxm $X $Y
2546 bind_button3
$ui_diff [list popup_diff_menu
$ctxm %x
%y
%X
%Y
]
2550 set main_status
[::status_bar
::new .status
]
2551 pack .status
-anchor w
-side bottom
-fill x
2552 $main_status show
[mc
"Initializing..."]
2557 set gm
$repo_config(gui.geometry
)
2558 wm geometry .
[lindex
$gm 0]
2559 .vpane sash place
0 \
2560 [lindex
[.vpane sash coord
0] 0] \
2562 .vpane.files sash place
0 \
2564 [lindex
[.vpane.files sash coord
0] 1]
2570 bind $ui_comm <$M1B-Key-Return> {do_commit
;break}
2571 bind $ui_comm <$M1B-Key-i> {do_add_all
;break}
2572 bind $ui_comm <$M1B-Key-I> {do_add_all
;break}
2573 bind $ui_comm <$M1B-Key-x> {tk_textCut
%W
;break}
2574 bind $ui_comm <$M1B-Key-X> {tk_textCut
%W
;break}
2575 bind $ui_comm <$M1B-Key-c> {tk_textCopy
%W
;break}
2576 bind $ui_comm <$M1B-Key-C> {tk_textCopy
%W
;break}
2577 bind $ui_comm <$M1B-Key-v> {tk_textPaste
%W
; %W see insert
; break}
2578 bind $ui_comm <$M1B-Key-V> {tk_textPaste
%W
; %W see insert
; break}
2579 bind $ui_comm <$M1B-Key-a> {%W tag add sel
0.0 end
;break}
2580 bind $ui_comm <$M1B-Key-A> {%W tag add sel
0.0 end
;break}
2582 bind $ui_diff <$M1B-Key-x> {tk_textCopy
%W
;break}
2583 bind $ui_diff <$M1B-Key-X> {tk_textCopy
%W
;break}
2584 bind $ui_diff <$M1B-Key-c> {tk_textCopy
%W
;break}
2585 bind $ui_diff <$M1B-Key-C> {tk_textCopy
%W
;break}
2586 bind $ui_diff <$M1B-Key-v> {break}
2587 bind $ui_diff <$M1B-Key-V> {break}
2588 bind $ui_diff <$M1B-Key-a> {%W tag add sel
0.0 end
;break}
2589 bind $ui_diff <$M1B-Key-A> {%W tag add sel
0.0 end
;break}
2590 bind $ui_diff <Key-Up
> {catch
{%W yview scroll
-1 units
};break}
2591 bind $ui_diff <Key-Down
> {catch
{%W yview scroll
1 units
};break}
2592 bind $ui_diff <Key-Left
> {catch
{%W xview scroll
-1 units
};break}
2593 bind $ui_diff <Key-Right
> {catch
{%W xview scroll
1 units
};break}
2594 bind $ui_diff <Key-k
> {catch
{%W yview scroll
-1 units
};break}
2595 bind $ui_diff <Key-j
> {catch
{%W yview scroll
1 units
};break}
2596 bind $ui_diff <Key-h
> {catch
{%W xview scroll
-1 units
};break}
2597 bind $ui_diff <Key-l
> {catch
{%W xview scroll
1 units
};break}
2598 bind $ui_diff <Control-Key-b
> {catch
{%W yview scroll
-1 pages
};break}
2599 bind $ui_diff <Control-Key-f
> {catch
{%W yview scroll
1 pages
};break}
2600 bind $ui_diff <Button-1
> {focus
%W
}
2602 if {[is_enabled branch
]} {
2603 bind .
<$M1B-Key-n> branch_create
::dialog
2604 bind .
<$M1B-Key-N> branch_create
::dialog
2605 bind .
<$M1B-Key-o> branch_checkout
::dialog
2606 bind .
<$M1B-Key-O> branch_checkout
::dialog
2607 bind .
<$M1B-Key-m> merge
::dialog
2608 bind .
<$M1B-Key-M> merge
::dialog
2610 if {[is_enabled transport
]} {
2611 bind .
<$M1B-Key-p> do_push_anywhere
2612 bind .
<$M1B-Key-P> do_push_anywhere
2615 bind .
<Key-F5
> do_rescan
2616 bind .
<$M1B-Key-r> do_rescan
2617 bind .
<$M1B-Key-R> do_rescan
2618 bind .
<$M1B-Key-s> do_signoff
2619 bind .
<$M1B-Key-S> do_signoff
2620 bind .
<$M1B-Key-i> do_add_all
2621 bind .
<$M1B-Key-I> do_add_all
2622 bind .
<$M1B-Key-Return> do_commit
2623 foreach i
[list
$ui_index $ui_workdir] {
2624 bind $i <Button-1
> "toggle_or_diff $i %x %y; break"
2625 bind $i <$M1B-Button-1> "add_one_to_selection $i %x %y; break"
2626 bind $i <Shift-Button-1
> "add_range_to_selection $i %x %y; break"
2630 set file_lists
($ui_index) [list
]
2631 set file_lists
($ui_workdir) [list
]
2633 wm title .
"[appname] ([reponame]) [file normalize [file dirname [gitdir]]]"
2634 focus
-force $ui_comm
2636 # -- Warn the user about environmental problems. Cygwin's Tcl
2637 # does *not* pass its env array onto any processes it spawns.
2638 # This means that git processes get none of our environment.
2643 set msg
[mc
"Possible environment issues exist.
2645 The following environment variables are probably
2646 going to be ignored by any Git subprocess run
2650 foreach name
[array names env
] {
2651 switch
-regexp -- $name {
2652 {^GIT_INDEX_FILE$
} -
2653 {^GIT_OBJECT_DIRECTORY$
} -
2654 {^GIT_ALTERNATE_OBJECT_DIRECTORIES$
} -
2656 {^GIT_EXTERNAL_DIFF$
} -
2660 {^GIT_CONFIG_LOCAL$
} -
2661 {^GIT_
(AUTHOR|COMMITTER
)_DATE$
} {
2662 append msg
" - $name\n"
2665 {^GIT_
(AUTHOR|COMMITTER
)_
(NAME|EMAIL
)$
} {
2666 append msg
" - $name\n"
2668 set suggest_user
$name
2672 if {$ignored_env > 0} {
2674 This is due to a known issue with the
2675 Tcl binary distributed by Cygwin."]
2677 if {$suggest_user ne
{}} {
2680 A good replacement for %s
2681 is placing values for the user.name and
2682 user.email settings into your personal
2688 unset ignored_env msg suggest_user name
2691 # -- Only initialize complex UI if we are going to stay running.
2693 if {[is_enabled transport
]} {
2700 if {[winfo exists
$ui_comm]} {
2701 set GITGUI_BCK_exists
[load_message GITGUI_BCK
]
2703 # -- If both our backup and message files exist use the
2704 # newer of the two files to initialize the buffer.
2706 if {$GITGUI_BCK_exists} {
2707 set m
[gitdir GITGUI_MSG
]
2708 if {[file isfile
$m]} {
2709 if {[file mtime
[gitdir GITGUI_BCK
]] > [file mtime
$m]} {
2710 catch
{file delete
[gitdir GITGUI_MSG
]}
2712 $ui_comm delete
0.0 end
2714 $ui_comm edit modified false
2715 catch
{file delete
[gitdir GITGUI_BCK
]}
2716 set GITGUI_BCK_exists
0
2722 proc backup_commit_buffer
{} {
2723 global ui_comm GITGUI_BCK_exists
2725 set m
[$ui_comm edit modified
]
2726 if {$m ||
$GITGUI_BCK_exists} {
2727 set msg
[string trim
[$ui_comm get
0.0 end
]]
2728 regsub
-all -line {[ \r\t]+$
} $msg {} msg
2731 if {$GITGUI_BCK_exists} {
2732 catch
{file delete
[gitdir GITGUI_BCK
]}
2733 set GITGUI_BCK_exists
0
2737 set fd
[open
[gitdir GITGUI_BCK
] w
]
2738 puts
-nonewline $fd $msg
2740 set GITGUI_BCK_exists
1
2744 $ui_comm edit modified false
2747 set ::GITGUI_BCK_i
[after
2000 backup_commit_buffer
]
2750 backup_commit_buffer
2753 lock_index begin-read
2754 if {![winfo ismapped .
]} {
2758 if {[is_enabled multicommit
]} {