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
668 regsub {\.[a-zA-Z]+\.[0-9]+$} $_git_version {} _git_version
670 if {![regexp {^[1-9]+(\.[0-9]+)+$} $_git_version]} {
671 catch {wm withdraw .}
676 -title "[appname
]: warning
" \
677 -message [mc "Git version cannot be determined.
679 %s claims it is version
'%s'.
681 %s requires
at least Git
1.5.0 or later.
683 Assume
'%s' is version
1.5.0?
684 " $_git $_real_git_version [appname] $_real_git_version]] eq {yes}} {
685 set _git_version 1.5.0
690 unset _real_git_version
692 proc git-version {args} {
695 switch [llength $args] {
701 set op [lindex $args 0]
702 set vr [lindex $args 1]
703 set cm [package vcompare $_git_version $vr]
704 return [expr $cm $op 0]
708 set type [lindex $args 0]
709 set name [lindex $args 1]
710 set parm [lindex $args 2]
711 set body [lindex $args 3]
713 if {($type ne {proc} && $type ne {method})} {
714 error "Invalid arguments to git-version
"
716 if {[llength $body] < 2 || [lindex $body end-1] ne {default}} {
717 error "Last arm of
$type $name must be default
"
720 foreach {op vr cb} [lrange $body 0 end-2] {
721 if {[git-version $op $vr]} {
722 return [uplevel [list $type $name $parm $cb]]
726 return [uplevel [list $type $name $parm [lindex $body end]]]
730 error "git-version
>= x
"
736 if {[git-version < 1.5]} {
737 catch {wm withdraw .}
741 -title [mc "git-gui
: fatal error
"] \
742 -message "[appname
] requires Git
1.5.0 or later.
744 You are using
[git-version
]:
750 ######################################################################
752 ## configure our library
754 set idx [file join $oguilib tclIndex]
755 if {[catch {set fd [open $idx r]} err]} {
756 catch {wm withdraw .}
760 -title [mc "git-gui
: fatal error
"] \
764 if {[gets $fd] eq {# Autogenerated by git-gui Makefile}} {
766 while {[gets $fd n] >= 0} {
767 if {$n ne {} && ![string match #* $n]} {
779 if {[lsearch -exact $loaded $p] >= 0} continue
780 source [file join $oguilib $p]
785 set auto_path [concat [list $oguilib] $auto_path]
787 unset -nocomplain idx fd
789 ######################################################################
791 ## feature option selection
793 if {[regexp {^git-(.+)$} [file tail $argv0] _junk subcommand]} {
798 if {$subcommand eq {gui.sh}} {
801 if {$subcommand eq {gui} && [llength $argv] > 0} {
802 set subcommand [lindex $argv 0]
803 set argv [lrange $argv 1 end]
806 enable_option multicommit
808 enable_option transport
811 switch -- $subcommand {
816 disable_option multicommit
817 disable_option branch
818 disable_option transport
821 enable_option singlecommit
823 disable_option multicommit
824 disable_option branch
825 disable_option transport
829 ######################################################################
834 set _gitdir $env(GIT_DIR)
838 set _gitdir [git rev-parse --git-dir]
839 set _prefix [git rev-parse --show-prefix]
843 choose_repository::pick
845 if {![file isdirectory $_gitdir] && [is_Cygwin]} {
846 catch {set _gitdir [exec cygpath --windows $_gitdir]}
848 if {![file isdirectory $_gitdir]} {
849 catch {wm withdraw .}
850 error_popup [strcat [mc "Git directory not found
:"] "\n\n$_gitdir"]
853 if {$_prefix ne {}} {
854 regsub -all {[^/]+/} $_prefix ../ cdup
855 if {[catch {cd $cdup} err]} {
856 catch {wm withdraw .}
857 error_popup [strcat [mc "Cannot move to top of working directory
:"] "\n\n$err"]
861 } elseif {![is_enabled bare]} {
862 if {[lindex [file split $_gitdir] end] ne {.git}} {
863 catch {wm withdraw .}
864 error_popup [strcat [mc "Cannot use funny .git directory
:"] "\n\n$_gitdir"]
867 if {[catch {cd [file dirname $_gitdir]} err]} {
868 catch {wm withdraw .}
869 error_popup [strcat [mc "No working directory
"] " [file dirname $_gitdir]:\n\n$err"]
873 set _reponame [file split [file normalize $_gitdir]]
874 if {[lindex $_reponame end] eq {.git}} {
875 set _reponame [lindex $_reponame end-1]
877 set _reponame [lindex $_reponame end]
880 ######################################################################
884 set current_diff_path {}
885 set current_diff_side {}
886 set diff_actions [list]
890 set MERGE_HEAD [list]
893 set current_branch {}
895 set current_diff_path {}
897 set selected_commit_type new
899 ######################################################################
907 set disable_on_lock [list]
908 set index_lock_type none
910 proc lock_index {type} {
911 global index_lock_type disable_on_lock
913 if {$index_lock_type eq {none}} {
914 set index_lock_type $type
915 foreach w $disable_on_lock {
916 uplevel #0 $w disabled
919 } elseif {$index_lock_type eq "begin-
$type"} {
920 set index_lock_type $type
926 proc unlock_index {} {
927 global index_lock_type disable_on_lock
929 set index_lock_type none
930 foreach w $disable_on_lock {
935 ######################################################################
939 proc repository_state {ctvar hdvar mhvar} {
940 global current_branch
941 upvar $ctvar ct $hdvar hd $mhvar mh
946 if {[catch {set hd [git rev-parse --verify HEAD]}]} {
952 set merge_head [gitdir MERGE_HEAD]
953 if {[file exists $merge_head]} {
955 set fd_mh [open $merge_head r]
956 while {[gets $fd_mh line] >= 0} {
967 global PARENT empty_tree
969 set p [lindex $PARENT 0]
973 if {$empty_tree eq {}} {
974 set empty_tree [git mktree << {}]
979 proc rescan {after {honor_trustmtime 1}} {
980 global HEAD PARENT MERGE_HEAD commit_type
981 global ui_index ui_workdir ui_comm
982 global rescan_active file_states
985 if {$rescan_active > 0 || ![lock_index read]} return
987 repository_state newType newHEAD newMERGE_HEAD
988 if {[string match amend* $commit_type]
989 && $newType eq {normal}
990 && $newHEAD eq $HEAD} {
994 set MERGE_HEAD $newMERGE_HEAD
995 set commit_type $newType
998 array unset file_states
1000 if {!$::GITGUI_BCK_exists &&
1001 (![$ui_comm edit modified]
1002 || [string trim [$ui_comm get 0.0 end]] eq {})} {
1003 if {[string match amend* $commit_type]} {
1004 } elseif {[load_message GITGUI_MSG]} {
1005 } elseif {[load_message MERGE_MSG]} {
1006 } elseif {[load_message SQUASH_MSG]} {
1009 $ui_comm edit modified false
1012 if {$honor_trustmtime && $repo_config(gui.trustmtime) eq {true}} {
1013 rescan_stage2 {} $after
1016 ui_status [mc "Refreshing
file status...
"]
1017 set fd_rf [git_read update-index \
1023 fconfigure $fd_rf -blocking 0 -translation binary
1024 fileevent $fd_rf readable \
1025 [list rescan_stage2 $fd_rf $after]
1030 set is_git_info_link {}
1031 set is_git_info_exclude {}
1032 proc have_info_exclude {} {
1033 global is_git_info_link is_git_info_exclude
1035 if {$is_git_info_link eq {}} {
1036 set is_git_info_link [file isfile [gitdir info.lnk]]
1039 if {$is_git_info_link} {
1040 if {$is_git_info_exclude eq {}} {
1041 if {[catch {exec test -f [gitdir info exclude]}]} {
1042 set is_git_info_exclude 0
1044 set is_git_info_exclude 1
1047 return $is_git_info_exclude
1049 return [file readable [gitdir info exclude]]
1053 proc have_info_exclude {} {
1054 return [file readable [gitdir info exclude]]
1058 proc rescan_stage2 {fd after} {
1059 global rescan_active buf_rdi buf_rdf buf_rlo
1063 if {![eof $fd]} return
1067 set ls_others [list --exclude-per-directory=.gitignore]
1068 if {[have_info_exclude]} {
1069 lappend ls_others "--exclude-from=[gitdir info exclude
]"
1071 set user_exclude [get_config core.excludesfile]
1072 if {$user_exclude ne {} && [file readable $user_exclude]} {
1073 lappend ls_others "--exclude-from=$user_exclude"
1081 ui_status [mc "Scanning
for modified files ...
"]
1082 set fd_di [git_read diff-index --cached -z [PARENT]]
1083 set fd_df [git_read diff-files -z]
1084 set fd_lo [eval git_read ls-files --others -z $ls_others]
1086 fconfigure $fd_di -blocking 0 -translation binary -encoding binary
1087 fconfigure $fd_df -blocking 0 -translation binary -encoding binary
1088 fconfigure $fd_lo -blocking 0 -translation binary -encoding binary
1089 fileevent $fd_di readable [list read_diff_index $fd_di $after]
1090 fileevent $fd_df readable [list read_diff_files $fd_df $after]
1091 fileevent $fd_lo readable [list read_ls_others $fd_lo $after]
1094 proc load_message {file} {
1097 set f [gitdir $file]
1098 if {[file isfile $f]} {
1099 if {[catch {set fd [open $f r]}]} {
1102 fconfigure $fd -eofchar {}
1103 set content [string trim [read $fd]]
1105 regsub -all -line {[ \r\t]+$} $content {} content
1106 $ui_comm delete 0.0 end
1107 $ui_comm insert end $content
1113 proc read_diff_index {fd after} {
1116 append buf_rdi [read $fd]
1118 set n [string length $buf_rdi]
1120 set z1 [string first "\
0" $buf_rdi $c]
1121 if {$z1 == -1} break
1123 set z2 [string first "\
0" $buf_rdi $z1]
1124 if {$z2 == -1} break
1127 set i [split [string range $buf_rdi $c [expr {$z1 - 2}]] { }]
1128 set p [string range $buf_rdi $z1 [expr {$z2 - 1}]]
1130 [encoding convertfrom $p] \
1132 [list [lindex $i 0] [lindex $i 2]] \
1138 set buf_rdi [string range $buf_rdi $c end]
1143 rescan_done $fd buf_rdi $after
1146 proc read_diff_files {fd after} {
1149 append buf_rdf [read $fd]
1151 set n [string length $buf_rdf]
1153 set z1 [string first "\
0" $buf_rdf $c]
1154 if {$z1 == -1} break
1156 set z2 [string first "\
0" $buf_rdf $z1]
1157 if {$z2 == -1} break
1160 set i [split [string range $buf_rdf $c [expr {$z1 - 2}]] { }]
1161 set p [string range $buf_rdf $z1 [expr {$z2 - 1}]]
1163 [encoding convertfrom $p] \
1166 [list [lindex $i 0] [lindex $i 2]]
1171 set buf_rdf [string range $buf_rdf $c end]
1176 rescan_done $fd buf_rdf $after
1179 proc read_ls_others {fd after} {
1182 append buf_rlo [read $fd]
1183 set pck [split $buf_rlo "\
0"]
1184 set buf_rlo [lindex $pck end]
1185 foreach p [lrange $pck 0 end-1] {
1186 set p [encoding convertfrom $p]
1187 if {[string index $p end] eq {/}} {
1188 set p [string range $p 0 end-1]
1192 rescan_done $fd buf_rlo $after
1195 proc rescan_done {fd buf after} {
1196 global rescan_active current_diff_path
1197 global file_states repo_config
1200 if {![eof $fd]} return
1203 if {[incr rescan_active -1] > 0} return
1208 if {$current_diff_path ne {}} reshow_diff
1212 proc prune_selection {} {
1213 global file_states selected_paths
1215 foreach path [array names selected_paths] {
1216 if {[catch {set still_here $file_states($path)}]} {
1217 unset selected_paths($path)
1222 ######################################################################
1226 proc mapicon {w state path} {
1229 if {[catch {set r $all_icons($state$w)}]} {
1230 puts "error
: no icon
for $w state
={$state} $path"
1236 proc mapdesc {state path} {
1239 if {[catch {set r $all_descs($state)}]} {
1240 puts "error
: no desc
for state
={$state} $path"
1246 proc ui_status {msg} {
1248 if {[info exists main_status]} {
1249 $main_status show $msg
1253 proc ui_ready {{test {}}} {
1255 if {[info exists main_status]} {
1256 $main_status show [mc "Ready.
"] $test
1260 proc escape_path {path} {
1261 regsub -all {\\} $path "\\\\" path
1262 regsub -all "\n" $path "\\n
" path
1266 proc short_path {path} {
1267 return [escape_path [lindex [file split $path] end]]
1271 set null_sha1 [string repeat 0 40]
1273 proc merge_state {path new_state {head_info {}} {index_info {}}} {
1274 global file_states next_icon_id null_sha1
1276 set s0 [string index $new_state 0]
1277 set s1 [string index $new_state 1]
1279 if {[catch {set info $file_states($path)}]} {
1281 set icon n[incr next_icon_id]
1283 set state [lindex $info 0]
1284 set icon [lindex $info 1]
1285 if {$head_info eq {}} {set head_info [lindex $info 2]}
1286 if {$index_info eq {}} {set index_info [lindex $info 3]}
1289 if {$s0 eq {?}} {set s0 [string index $state 0]} \
1290 elseif {$s0 eq {_}} {set s0 _}
1292 if {$s1 eq {?}} {set s1 [string index $state 1]} \
1293 elseif {$s1 eq {_}} {set s1 _}
1295 if {$s0 eq {A} && $s1 eq {_} && $head_info eq {}} {
1296 set head_info [list 0 $null_sha1]
1297 } elseif {$s0 ne {_} && [string index $state 0] eq {_}
1298 && $head_info eq {}} {
1299 set head_info $index_info
1302 set file_states($path) [list $s0$s1 $icon \
1303 $head_info $index_info \
1308 proc display_file_helper {w path icon_name old_m new_m} {
1311 if {$new_m eq {_}} {
1312 set lno [lsearch -sorted -exact $file_lists($w) $path]
1314 set file_lists($w) [lreplace $file_lists($w) $lno $lno]
1316 $w conf -state normal
1317 $w delete $lno.0 [expr {$lno + 1}].0
1318 $w conf -state disabled
1320 } elseif {$old_m eq {_} && $new_m ne {_}} {
1321 lappend file_lists($w) $path
1322 set file_lists($w) [lsort -unique $file_lists($w)]
1323 set lno [lsearch -sorted -exact $file_lists($w) $path]
1325 $w conf -state normal
1326 $w image create $lno.0 \
1327 -align center -padx 5 -pady 1 \
1329 -image [mapicon $w $new_m $path]
1330 $w insert $lno.1 "[escape_path
$path]\n"
1331 $w conf -state disabled
1332 } elseif {$old_m ne $new_m} {
1333 $w conf -state normal
1334 $w image conf $icon_name -image [mapicon $w $new_m $path]
1335 $w conf -state disabled
1339 proc display_file {path state} {
1340 global file_states selected_paths
1341 global ui_index ui_workdir
1343 set old_m [merge_state $path $state]
1344 set s $file_states($path)
1345 set new_m [lindex $s 0]
1346 set icon_name [lindex $s 1]
1348 set o [string index $old_m 0]
1349 set n [string index $new_m 0]
1356 display_file_helper $ui_index $path $icon_name $o $n
1358 if {[string index $old_m 0] eq {U}} {
1361 set o [string index $old_m 1]
1363 if {[string index $new_m 0] eq {U}} {
1366 set n [string index $new_m 1]
1368 display_file_helper $ui_workdir $path $icon_name $o $n
1370 if {$new_m eq {__}} {
1371 unset file_states($path)
1372 catch {unset selected_paths($path)}
1376 proc display_all_files_helper {w path icon_name m} {
1379 lappend file_lists($w) $path
1380 set lno [expr {[lindex [split [$w index end] .] 0] - 1}]
1381 $w image create end \
1382 -align center -padx 5 -pady 1 \
1384 -image [mapicon $w $m $path]
1385 $w insert end "[escape_path
$path]\n"
1388 proc display_all_files {} {
1389 global ui_index ui_workdir
1390 global file_states file_lists
1393 $ui_index conf -state normal
1394 $ui_workdir conf -state normal
1396 $ui_index delete 0.0 end
1397 $ui_workdir delete 0.0 end
1400 set file_lists($ui_index) [list]
1401 set file_lists($ui_workdir) [list]
1403 foreach path [lsort [array names file_states]] {
1404 set s $file_states($path)
1406 set icon_name [lindex $s 1]
1408 set s [string index $m 0]
1409 if {$s ne {U} && $s ne {_}} {
1410 display_all_files_helper $ui_index $path \
1414 if {[string index $m 0] eq {U}} {
1417 set s [string index $m 1]
1420 display_all_files_helper $ui_workdir $path \
1425 $ui_index conf -state disabled
1426 $ui_workdir conf -state disabled
1429 ######################################################################
1434 #define mask_width 14
1435 #define mask_height 15
1436 static unsigned char mask_bits[] = {
1437 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
1438 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
1439 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f};
1442 image create bitmap file_plain -background white -foreground black -data {
1443 #define plain_width 14
1444 #define plain_height 15
1445 static unsigned char plain_bits[] = {
1446 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
1447 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10,
1448 0x02, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1449 } -maskdata $filemask
1451 image create bitmap file_mod -background white -foreground blue -data {
1452 #define mod_width 14
1453 #define mod_height 15
1454 static unsigned char mod_bits[] = {
1455 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
1456 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
1457 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
1458 } -maskdata $filemask
1460 image create bitmap file_fulltick -background white -foreground "#007000" -data {
1461 #define file_fulltick_width 14
1462 #define file_fulltick_height 15
1463 static unsigned char file_fulltick_bits
[] = {
1464 0xfe, 0x01, 0x02, 0x1a, 0x02, 0x0c, 0x02, 0x0c, 0x02, 0x16, 0x02, 0x16,
1465 0x02, 0x13, 0x00, 0x13, 0x86, 0x11, 0x8c, 0x11, 0xd8, 0x10, 0xf2, 0x10,
1466 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1467 } -maskdata $filemask
1469 image create bitmap file_parttick
-background white
-foreground "#005050" -data {
1470 #define parttick_width 14
1471 #define parttick_height 15
1472 static unsigned char parttick_bits
[] = {
1473 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
1474 0x7a, 0x14, 0x02, 0x16, 0x02, 0x13, 0x8a, 0x11, 0xda, 0x10, 0x72, 0x10,
1475 0x22, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1476 } -maskdata $filemask
1478 image create bitmap file_question
-background white
-foreground black
-data {
1479 #define file_question_width 14
1480 #define file_question_height 15
1481 static unsigned char file_question_bits
[] = {
1482 0xfe, 0x01, 0x02, 0x02, 0xe2, 0x04, 0xf2, 0x09, 0x1a, 0x1b, 0x0a, 0x13,
1483 0x82, 0x11, 0xc2, 0x10, 0x62, 0x10, 0x62, 0x10, 0x02, 0x10, 0x62, 0x10,
1484 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1485 } -maskdata $filemask
1487 image create bitmap file_removed
-background white
-foreground red
-data {
1488 #define file_removed_width 14
1489 #define file_removed_height 15
1490 static unsigned char file_removed_bits
[] = {
1491 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
1492 0x1a, 0x16, 0x32, 0x13, 0xe2, 0x11, 0xc2, 0x10, 0xe2, 0x11, 0x32, 0x13,
1493 0x1a, 0x16, 0x02, 0x10, 0xfe, 0x1f};
1494 } -maskdata $filemask
1496 image create bitmap file_merge
-background white
-foreground blue
-data {
1497 #define file_merge_width 14
1498 #define file_merge_height 15
1499 static unsigned char file_merge_bits
[] = {
1500 0xfe, 0x01, 0x02, 0x03, 0x62, 0x05, 0x62, 0x09, 0x62, 0x1f, 0x62, 0x10,
1501 0xfa, 0x11, 0xf2, 0x10, 0x62, 0x10, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
1502 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
1503 } -maskdata $filemask
1505 set ui_index .vpane.files.index.list
1506 set ui_workdir .vpane.files.workdir.list
1508 set all_icons
(_
$ui_index) file_plain
1509 set all_icons
(A
$ui_index) file_fulltick
1510 set all_icons
(M
$ui_index) file_fulltick
1511 set all_icons
(D
$ui_index) file_removed
1512 set all_icons
(U
$ui_index) file_merge
1514 set all_icons
(_
$ui_workdir) file_plain
1515 set all_icons
(M
$ui_workdir) file_mod
1516 set all_icons
(D
$ui_workdir) file_question
1517 set all_icons
(U
$ui_workdir) file_merge
1518 set all_icons
(O
$ui_workdir) file_plain
1520 set max_status_desc
0
1522 {__
{mc
"Unmodified"}}
1524 {_M
{mc
"Modified, not staged"}}
1525 {M_
{mc
"Staged for commit"}}
1526 {MM
{mc
"Portions staged for commit"}}
1527 {MD
{mc
"Staged for commit, missing"}}
1529 {_O
{mc
"Untracked, not staged"}}
1530 {A_
{mc
"Staged for commit"}}
1531 {AM
{mc
"Portions staged for commit"}}
1532 {AD
{mc
"Staged for commit, missing"}}
1535 {D_
{mc
"Staged for removal"}}
1536 {DO
{mc
"Staged for removal, still present"}}
1538 {U_
{mc
"Requires merge resolution"}}
1539 {UU
{mc
"Requires merge resolution"}}
1540 {UM
{mc
"Requires merge resolution"}}
1541 {UD
{mc
"Requires merge resolution"}}
1543 set text
[eval [lindex
$i 1]]
1544 if {$max_status_desc < [string length
$text]} {
1545 set max_status_desc
[string length
$text]
1547 set all_descs
([lindex
$i 0]) $text
1551 ######################################################################
1555 proc scrollbar2many
{list mode args
} {
1556 foreach w
$list {eval $w $mode $args}
1559 proc many2scrollbar
{list mode sb top bottom
} {
1560 $sb set $top $bottom
1561 foreach w
$list {$w $mode moveto
$top}
1564 proc incr_font_size
{font
{amt
1}} {
1565 set sz
[font configure
$font -size]
1567 font configure
$font -size $sz
1568 font configure
${font}bold
-size $sz
1569 font configure
${font}italic
-size $sz
1572 ######################################################################
1576 set starting_gitk_msg
[mc
"Starting gitk... please wait..."]
1578 proc do_gitk
{revs
} {
1579 # -- Always start gitk through whatever we were loaded with. This
1580 # lets us bypass using shell process on Windows systems.
1582 set exe
[file join [file dirname $
::_git
] gitk
]
1583 set cmd
[list
[info nameofexecutable
] $exe]
1584 if {! [file exists
$exe]} {
1585 error_popup
[mc
"Unable to start gitk:\n\n%s does not exist" $exe]
1589 if {[info exists env
(GIT_DIR
)]} {
1590 set old_GIT_DIR
$env(GIT_DIR
)
1596 cd [file dirname [gitdir
]]
1597 set env
(GIT_DIR
) [file tail [gitdir
]]
1599 eval exec $cmd $revs &
1601 if {$old_GIT_DIR eq
{}} {
1604 set env
(GIT_DIR
) $old_GIT_DIR
1608 ui_status $
::starting_gitk_msg
1610 ui_ready
$starting_gitk_msg
1618 global ui_comm is_quitting repo_config commit_type
1619 global GITGUI_BCK_exists GITGUI_BCK_i
1621 if {$is_quitting} return
1624 if {[winfo exists
$ui_comm]} {
1625 # -- Stash our current commit buffer.
1627 set save
[gitdir GITGUI_MSG
]
1628 if {$GITGUI_BCK_exists && ![$ui_comm edit modified
]} {
1629 file rename
-force [gitdir GITGUI_BCK
] $save
1630 set GITGUI_BCK_exists
0
1632 set msg
[string trim
[$ui_comm get
0.0 end
]]
1633 regsub
-all -line {[ \r\t]+$
} $msg {} msg
1634 if {(![string match amend
* $commit_type]
1635 ||
[$ui_comm edit modified
])
1638 set fd
[open
$save w
]
1639 puts
-nonewline $fd $msg
1643 catch
{file delete
$save}
1647 # -- Remove our editor backup, its not needed.
1649 after cancel
$GITGUI_BCK_i
1650 if {$GITGUI_BCK_exists} {
1651 catch
{file delete
[gitdir GITGUI_BCK
]}
1654 # -- Stash our current window geometry into this repository.
1656 set cfg_geometry
[list
]
1657 lappend cfg_geometry
[wm geometry .
]
1658 lappend cfg_geometry
[lindex
[.vpane sash coord
0] 1]
1659 lappend cfg_geometry
[lindex
[.vpane.files sash coord
0] 0]
1660 if {[catch
{set rc_geometry
$repo_config(gui.geometry
)}]} {
1663 if {$cfg_geometry ne
$rc_geometry} {
1664 catch
{git config gui.geometry
$cfg_geometry}
1679 proc toggle_or_diff
{w x y
} {
1680 global file_states file_lists current_diff_path ui_index ui_workdir
1681 global last_clicked selected_paths
1683 set pos
[split [$w index @
$x,$y] .
]
1684 set lno
[lindex
$pos 0]
1685 set col [lindex
$pos 1]
1686 set path
[lindex
$file_lists($w) [expr {$lno - 1}]]
1692 set last_clicked
[list
$w $lno]
1693 array
unset selected_paths
1694 $ui_index tag remove in_sel
0.0 end
1695 $ui_workdir tag remove in_sel
0.0 end
1698 if {$current_diff_path eq
$path} {
1699 set after
{reshow_diff
;}
1703 if {$w eq
$ui_index} {
1705 "Unstaging [short_path $path] from commit" \
1707 [concat
$after [list ui_ready
]]
1708 } elseif
{$w eq
$ui_workdir} {
1710 "Adding [short_path $path]" \
1712 [concat
$after [list ui_ready
]]
1715 show_diff
$path $w $lno
1719 proc add_one_to_selection
{w x y
} {
1720 global file_lists last_clicked selected_paths
1722 set lno
[lindex
[split [$w index @
$x,$y] .
] 0]
1723 set path
[lindex
$file_lists($w) [expr {$lno - 1}]]
1729 if {$last_clicked ne
{}
1730 && [lindex
$last_clicked 0] ne
$w} {
1731 array
unset selected_paths
1732 [lindex
$last_clicked 0] tag remove in_sel
0.0 end
1735 set last_clicked
[list
$w $lno]
1736 if {[catch
{set in_sel
$selected_paths($path)}]} {
1740 unset selected_paths
($path)
1741 $w tag remove in_sel
$lno.0 [expr {$lno + 1}].0
1743 set selected_paths
($path) 1
1744 $w tag add in_sel
$lno.0 [expr {$lno + 1}].0
1748 proc add_range_to_selection
{w x y
} {
1749 global file_lists last_clicked selected_paths
1751 if {[lindex
$last_clicked 0] ne
$w} {
1752 toggle_or_diff
$w $x $y
1756 set lno
[lindex
[split [$w index @
$x,$y] .
] 0]
1757 set lc
[lindex
$last_clicked 1]
1766 foreach path
[lrange
$file_lists($w) \
1767 [expr {$begin - 1}] \
1768 [expr {$end - 1}]] {
1769 set selected_paths
($path) 1
1771 $w tag add in_sel
$begin.0 [expr {$end + 1}].0
1774 ######################################################################
1784 menu .mbar
-tearoff 0
1785 .mbar add cascade
-label [mc Repository
] -menu .mbar.repository
1786 .mbar add cascade
-label [mc Edit
] -menu .mbar.edit
1787 if {[is_enabled branch
]} {
1788 .mbar add cascade
-label [mc Branch
] -menu .mbar.branch
1790 if {[is_enabled multicommit
] ||
[is_enabled singlecommit
]} {
1791 .mbar add cascade
-label [mc Commit@@noun
] -menu .mbar.commit
1793 if {[is_enabled transport
]} {
1794 .mbar add cascade
-label [mc Merge
] -menu .mbar.merge
1795 .mbar add cascade
-label [mc Remote
] -menu .mbar.remote
1797 . configure
-menu .mbar
1799 # -- Repository Menu
1801 menu .mbar.repository
1803 .mbar.repository add
command \
1804 -label [mc
"Browse Current Branch's Files"] \
1805 -command {browser
::new
$current_branch}
1806 set ui_browse_current
[.mbar.repository index last
]
1807 .mbar.repository add
command \
1808 -label [mc
"Browse Branch Files..."] \
1809 -command browser_open
::dialog
1810 .mbar.repository add separator
1812 .mbar.repository add
command \
1813 -label [mc
"Visualize Current Branch's History"] \
1814 -command {do_gitk
$current_branch}
1815 set ui_visualize_current
[.mbar.repository index last
]
1816 .mbar.repository add
command \
1817 -label [mc
"Visualize All Branch History"] \
1818 -command {do_gitk
--all}
1819 .mbar.repository add separator
1821 proc current_branch_write
{args
} {
1822 global current_branch
1823 .mbar.repository entryconf $
::ui_browse_current \
1824 -label [mc
"Browse %s's Files" $current_branch]
1825 .mbar.repository entryconf $
::ui_visualize_current \
1826 -label [mc
"Visualize %s's History" $current_branch]
1828 trace add variable current_branch
write current_branch_write
1830 if {[is_enabled multicommit
]} {
1831 .mbar.repository add
command -label [mc
"Database Statistics"] \
1834 .mbar.repository add
command -label [mc
"Compress Database"] \
1837 .mbar.repository add
command -label [mc
"Verify Database"] \
1838 -command do_fsck_objects
1840 .mbar.repository add separator
1843 .mbar.repository add
command \
1844 -label [mc
"Create Desktop Icon"] \
1845 -command do_cygwin_shortcut
1846 } elseif
{[is_Windows
]} {
1847 .mbar.repository add
command \
1848 -label [mc
"Create Desktop Icon"] \
1849 -command do_windows_shortcut
1850 } elseif
{[is_MacOSX
]} {
1851 .mbar.repository add
command \
1852 -label [mc
"Create Desktop Icon"] \
1853 -command do_macosx_app
1857 .mbar.repository add
command -label [mc Quit
] \
1864 .mbar.edit add
command -label [mc Undo
] \
1865 -command {catch
{[focus
] edit undo
}} \
1867 .mbar.edit add
command -label [mc Redo
] \
1868 -command {catch
{[focus
] edit redo
}} \
1870 .mbar.edit add separator
1871 .mbar.edit add
command -label [mc Cut
] \
1872 -command {catch
{tk_textCut
[focus
]}} \
1874 .mbar.edit add
command -label [mc Copy
] \
1875 -command {catch
{tk_textCopy
[focus
]}} \
1877 .mbar.edit add
command -label [mc Paste
] \
1878 -command {catch
{tk_textPaste
[focus
]; [focus
] see insert
}} \
1880 .mbar.edit add
command -label [mc Delete
] \
1881 -command {catch
{[focus
] delete sel.first sel.last
}} \
1883 .mbar.edit add separator
1884 .mbar.edit add
command -label [mc
"Select All"] \
1885 -command {catch
{[focus
] tag add sel
0.0 end
}} \
1890 if {[is_enabled branch
]} {
1893 .mbar.branch add
command -label [mc
"Create..."] \
1894 -command branch_create
::dialog \
1896 lappend disable_on_lock
[list .mbar.branch entryconf \
1897 [.mbar.branch index last
] -state]
1899 .mbar.branch add
command -label [mc
"Checkout..."] \
1900 -command branch_checkout
::dialog \
1902 lappend disable_on_lock
[list .mbar.branch entryconf \
1903 [.mbar.branch index last
] -state]
1905 .mbar.branch add
command -label [mc
"Rename..."] \
1906 -command branch_rename
::dialog
1907 lappend disable_on_lock
[list .mbar.branch entryconf \
1908 [.mbar.branch index last
] -state]
1910 .mbar.branch add
command -label [mc
"Delete..."] \
1911 -command branch_delete
::dialog
1912 lappend disable_on_lock
[list .mbar.branch entryconf \
1913 [.mbar.branch index last
] -state]
1915 .mbar.branch add
command -label [mc
"Reset..."] \
1916 -command merge
::reset_hard
1917 lappend disable_on_lock
[list .mbar.branch entryconf \
1918 [.mbar.branch index last
] -state]
1923 if {[is_enabled multicommit
] ||
[is_enabled singlecommit
]} {
1926 .mbar.commit add radiobutton \
1927 -label [mc
"New Commit"] \
1928 -command do_select_commit_type \
1929 -variable selected_commit_type \
1931 lappend disable_on_lock \
1932 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1934 .mbar.commit add radiobutton \
1935 -label [mc
"Amend Last Commit"] \
1936 -command do_select_commit_type \
1937 -variable selected_commit_type \
1939 lappend disable_on_lock \
1940 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1942 .mbar.commit add separator
1944 .mbar.commit add
command -label [mc Rescan
] \
1945 -command do_rescan \
1947 lappend disable_on_lock \
1948 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1950 .mbar.commit add
command -label [mc
"Stage To Commit"] \
1951 -command do_add_selection
1952 lappend disable_on_lock \
1953 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1955 .mbar.commit add
command -label [mc
"Stage Changed Files To Commit"] \
1956 -command do_add_all \
1958 lappend disable_on_lock \
1959 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1961 .mbar.commit add
command -label [mc
"Unstage From Commit"] \
1962 -command do_unstage_selection
1963 lappend disable_on_lock \
1964 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1966 .mbar.commit add
command -label [mc
"Revert Changes"] \
1967 -command do_revert_selection
1968 lappend disable_on_lock \
1969 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1971 .mbar.commit add separator
1973 .mbar.commit add
command -label [mc
"Sign Off"] \
1974 -command do_signoff \
1977 .mbar.commit add
command -label [mc Commit@@verb
] \
1978 -command do_commit \
1979 -accelerator $M1T-Return
1980 lappend disable_on_lock \
1981 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1986 if {[is_enabled branch
]} {
1988 .mbar.merge add
command -label [mc
"Local Merge..."] \
1989 -command merge
::dialog \
1991 lappend disable_on_lock \
1992 [list .mbar.merge entryconf
[.mbar.merge index last
] -state]
1993 .mbar.merge add
command -label [mc
"Abort Merge..."] \
1994 -command merge
::reset_hard
1995 lappend disable_on_lock \
1996 [list .mbar.merge entryconf
[.mbar.merge index last
] -state]
2001 if {[is_enabled transport
]} {
2004 .mbar.remote add
command \
2005 -label [mc
"Push..."] \
2006 -command do_push_anywhere \
2008 .mbar.remote add
command \
2009 -label [mc
"Delete..."] \
2010 -command remote_branch_delete
::dialog
2014 # -- Apple Menu (Mac OS X only)
2016 .mbar add cascade
-label [mc Apple
] -menu .mbar.apple
2019 .mbar.apple add
command -label [mc
"About %s" [appname
]] \
2021 .mbar.apple add
command -label [mc
"Options..."] \
2026 .mbar.edit add separator
2027 .mbar.edit add
command -label [mc
"Options..."] \
2033 .mbar add cascade
-label [mc Help
] -menu .mbar.
help
2037 .mbar.
help add
command -label [mc
"About %s" [appname
]] \
2042 catch
{set browser
$repo_config(instaweb.browser
)}
2043 set doc_path
[file dirname [gitexec
]]
2044 set doc_path
[file join $doc_path Documentation index.html
]
2047 set doc_path
[exec cygpath
--mixed $doc_path]
2050 if {$browser eq
{}} {
2053 } elseif
{[is_Cygwin
]} {
2054 set program_files
[file dirname [exec cygpath
--windir]]
2055 set program_files
[file join $program_files {Program Files
}]
2056 set firefox
[file join $program_files {Mozilla Firefox
} firefox.exe
]
2057 set ie
[file join $program_files {Internet Explorer
} IEXPLORE.EXE
]
2058 if {[file exists
$firefox]} {
2059 set browser
$firefox
2060 } elseif
{[file exists
$ie]} {
2063 unset program_files firefox ie
2067 if {[file isfile
$doc_path]} {
2068 set doc_url
"file:$doc_path"
2070 set doc_url
{http
://www.kernel.org
/pub
/software
/scm
/git
/docs
/}
2073 if {$browser ne
{}} {
2074 .mbar.
help add
command -label [mc
"Online Documentation"] \
2075 -command [list
exec $browser $doc_url &]
2077 unset browser doc_path doc_url
2079 # -- Standard bindings
2081 wm protocol . WM_DELETE_WINDOW do_quit
2082 bind all
<$M1B-Key-q> do_quit
2083 bind all
<$M1B-Key-Q> do_quit
2084 bind all
<$M1B-Key-w> {destroy
[winfo toplevel
%W
]}
2085 bind all
<$M1B-Key-W> {destroy
[winfo toplevel
%W
]}
2087 set subcommand_args
{}
2089 puts stderr
"usage: $::argv0 $::subcommand $::subcommand_args"
2093 # -- Not a normal commit type invocation? Do that instead!
2095 switch
-- $subcommand {
2098 set subcommand_args
{rev? path
}
2099 if {$argv eq
{}} usage
2104 if {$is_path ||
[file exists
$_prefix$a]} {
2105 if {$path ne
{}} usage
2108 } elseif
{$a eq
{--}} {
2110 if {$head ne
{}} usage
2115 } elseif
{$head eq
{}} {
2116 if {$head ne
{}} usage
2125 if {$head ne
{} && $path eq
{}} {
2126 set path
$_prefix$head
2133 if {[regexp
{^
[0-9a-f]{1,39}$
} $head]} {
2135 set head [git rev-parse
--verify $head]
2141 set current_branch
$head
2144 switch
-- $subcommand {
2147 if {$path ne
{} && [file isdirectory
$path]} {
2148 set head $current_branch
2154 browser
::new
$head $path
2157 if {$head eq
{} && ![file exists
$path]} {
2158 puts stderr
[mc
"fatal: cannot stat path %s: No such file or directory" $path]
2161 blame
::new
$head $path
2168 if {[llength
$argv] != 0} {
2169 puts
-nonewline stderr
"usage: $argv0"
2170 if {$subcommand ne
{gui
}
2171 && [file tail $argv0] ne
"git-$subcommand"} {
2172 puts
-nonewline stderr
" $subcommand"
2177 # fall through to setup UI for commits
2180 puts stderr
"usage: $argv0 \[{blame|browser|citool}\]"
2191 -text [mc
"Current Branch:"] \
2195 -textvariable current_branch \
2198 pack .branch.l1
-side left
2199 pack .branch.cb
-side left
-fill x
2200 pack .branch
-side top
-fill x
2202 # -- Main Window Layout
2204 panedwindow .vpane
-orient vertical
2205 panedwindow .vpane.files
-orient horizontal
2206 .vpane add .vpane.files
-sticky nsew
-height 100 -width 200
2207 pack .vpane
-anchor n
-side top
-fill both
-expand 1
2209 # -- Index File List
2211 frame .vpane.files.index
-height 100 -width 200
2212 label .vpane.files.index.title
-text [mc
"Staged Changes (Will Be Committed)"] \
2213 -background lightgreen
2214 text
$ui_index -background white
-borderwidth 0 \
2215 -width 20 -height 10 \
2217 -cursor $cursor_ptr \
2218 -xscrollcommand {.vpane.files.index.sx
set} \
2219 -yscrollcommand {.vpane.files.index.sy
set} \
2221 scrollbar .vpane.files.index.sx
-orient h
-command [list
$ui_index xview
]
2222 scrollbar .vpane.files.index.sy
-orient v
-command [list
$ui_index yview
]
2223 pack .vpane.files.index.title
-side top
-fill x
2224 pack .vpane.files.index.sx
-side bottom
-fill x
2225 pack .vpane.files.index.sy
-side right
-fill y
2226 pack
$ui_index -side left
-fill both
-expand 1
2227 .vpane.files add .vpane.files.index
-sticky nsew
2229 # -- Working Directory File List
2231 frame .vpane.files.workdir
-height 100 -width 200
2232 label .vpane.files.workdir.title
-text [mc
"Unstaged Changes (Will Not Be Committed)"] \
2233 -background lightsalmon
2234 text
$ui_workdir -background white
-borderwidth 0 \
2235 -width 20 -height 10 \
2237 -cursor $cursor_ptr \
2238 -xscrollcommand {.vpane.files.workdir.sx
set} \
2239 -yscrollcommand {.vpane.files.workdir.sy
set} \
2241 scrollbar .vpane.files.workdir.sx
-orient h
-command [list
$ui_workdir xview
]
2242 scrollbar .vpane.files.workdir.sy
-orient v
-command [list
$ui_workdir yview
]
2243 pack .vpane.files.workdir.title
-side top
-fill x
2244 pack .vpane.files.workdir.sx
-side bottom
-fill x
2245 pack .vpane.files.workdir.sy
-side right
-fill y
2246 pack
$ui_workdir -side left
-fill both
-expand 1
2247 .vpane.files add .vpane.files.workdir
-sticky nsew
2249 foreach i
[list
$ui_index $ui_workdir] {
2251 $i tag conf in_diff
-background [$i tag cget in_sel
-background]
2255 # -- Diff and Commit Area
2257 frame .vpane.lower
-height 300 -width 400
2258 frame .vpane.lower.commarea
2259 frame .vpane.lower.
diff -relief sunken
-borderwidth 1
2260 pack .vpane.lower.commarea
-side top
-fill x
2261 pack .vpane.lower.
diff -side bottom
-fill both
-expand 1
2262 .vpane add .vpane.lower
-sticky nsew
2264 # -- Commit Area Buttons
2266 frame .vpane.lower.commarea.buttons
2267 label .vpane.lower.commarea.buttons.l
-text {} \
2270 pack .vpane.lower.commarea.buttons.l
-side top
-fill x
2271 pack .vpane.lower.commarea.buttons
-side left
-fill y
2273 button .vpane.lower.commarea.buttons.rescan
-text [mc Rescan
] \
2275 pack .vpane.lower.commarea.buttons.rescan
-side top
-fill x
2276 lappend disable_on_lock \
2277 {.vpane.lower.commarea.buttons.rescan conf
-state}
2279 button .vpane.lower.commarea.buttons.incall
-text [mc
"Stage Changed"] \
2281 pack .vpane.lower.commarea.buttons.incall
-side top
-fill x
2282 lappend disable_on_lock \
2283 {.vpane.lower.commarea.buttons.incall conf
-state}
2285 button .vpane.lower.commarea.buttons.signoff
-text [mc
"Sign Off"] \
2287 pack .vpane.lower.commarea.buttons.signoff
-side top
-fill x
2289 button .vpane.lower.commarea.buttons.commit
-text [mc Commit@@verb
] \
2291 pack .vpane.lower.commarea.buttons.commit
-side top
-fill x
2292 lappend disable_on_lock \
2293 {.vpane.lower.commarea.buttons.commit conf
-state}
2295 button .vpane.lower.commarea.buttons.push
-text [mc Push
] \
2296 -command do_push_anywhere
2297 pack .vpane.lower.commarea.buttons.push
-side top
-fill x
2299 # -- Commit Message Buffer
2301 frame .vpane.lower.commarea.buffer
2302 frame .vpane.lower.commarea.buffer.header
2303 set ui_comm .vpane.lower.commarea.buffer.t
2304 set ui_coml .vpane.lower.commarea.buffer.header.l
2305 radiobutton .vpane.lower.commarea.buffer.header.new \
2306 -text [mc
"New Commit"] \
2307 -command do_select_commit_type \
2308 -variable selected_commit_type \
2310 lappend disable_on_lock \
2311 [list .vpane.lower.commarea.buffer.header.new conf
-state]
2312 radiobutton .vpane.lower.commarea.buffer.header.amend \
2313 -text [mc
"Amend Last Commit"] \
2314 -command do_select_commit_type \
2315 -variable selected_commit_type \
2317 lappend disable_on_lock \
2318 [list .vpane.lower.commarea.buffer.header.amend conf
-state]
2322 proc trace_commit_type
{varname args
} {
2323 global ui_coml commit_type
2324 switch
-glob -- $commit_type {
2325 initial
{set txt
[mc
"Initial Commit Message:"]}
2326 amend
{set txt
[mc
"Amended Commit Message:"]}
2327 amend-initial
{set txt
[mc
"Amended Initial Commit Message:"]}
2328 amend-merge
{set txt
[mc
"Amended Merge Commit Message:"]}
2329 merge
{set txt
[mc
"Merge Commit Message:"]}
2330 * {set txt
[mc
"Commit Message:"]}
2332 $ui_coml conf
-text $txt
2334 trace add variable commit_type
write trace_commit_type
2335 pack
$ui_coml -side left
-fill x
2336 pack .vpane.lower.commarea.buffer.header.amend
-side right
2337 pack .vpane.lower.commarea.buffer.header.new
-side right
2339 text
$ui_comm -background white
-borderwidth 1 \
2342 -autoseparators true \
2344 -width 75 -height 9 -wrap none \
2346 -yscrollcommand {.vpane.lower.commarea.buffer.sby
set}
2347 scrollbar .vpane.lower.commarea.buffer.sby \
2348 -command [list
$ui_comm yview
]
2349 pack .vpane.lower.commarea.buffer.header
-side top
-fill x
2350 pack .vpane.lower.commarea.buffer.sby
-side right
-fill y
2351 pack
$ui_comm -side left
-fill y
2352 pack .vpane.lower.commarea.buffer
-side left
-fill y
2354 # -- Commit Message Buffer Context Menu
2356 set ctxm .vpane.lower.commarea.buffer.ctxm
2357 menu
$ctxm -tearoff 0
2360 -command {tk_textCut
$ui_comm}
2363 -command {tk_textCopy
$ui_comm}
2366 -command {tk_textPaste
$ui_comm}
2368 -label [mc Delete
] \
2369 -command {$ui_comm delete sel.first sel.last
}
2372 -label [mc
"Select All"] \
2373 -command {focus
$ui_comm;$ui_comm tag add sel
0.0 end
}
2375 -label [mc
"Copy All"] \
2377 $ui_comm tag add sel
0.0 end
2378 tk_textCopy
$ui_comm
2379 $ui_comm tag remove sel
0.0 end
2383 -label [mc
"Sign Off"] \
2385 bind_button3
$ui_comm "tk_popup $ctxm %X %Y"
2389 proc trace_current_diff_path
{varname args
} {
2390 global current_diff_path diff_actions file_states
2391 if {$current_diff_path eq
{}} {
2397 set p
$current_diff_path
2398 set s
[mapdesc
[lindex
$file_states($p) 0] $p]
2400 set p
[escape_path
$p]
2404 .vpane.lower.
diff.header.status configure
-text $s
2405 .vpane.lower.
diff.header.
file configure
-text $f
2406 .vpane.lower.
diff.header.path configure
-text $p
2407 foreach w
$diff_actions {
2411 trace add variable current_diff_path
write trace_current_diff_path
2413 frame .vpane.lower.
diff.header
-background gold
2414 label .vpane.lower.
diff.header.status \
2416 -width $max_status_desc \
2419 label .vpane.lower.
diff.header.
file \
2423 label .vpane.lower.
diff.header.path \
2427 pack .vpane.lower.
diff.header.status
-side left
2428 pack .vpane.lower.
diff.header.
file -side left
2429 pack .vpane.lower.
diff.header.path
-fill x
2430 set ctxm .vpane.lower.
diff.header.ctxm
2431 menu
$ctxm -tearoff 0
2439 -- $current_diff_path
2441 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2442 bind_button3 .vpane.lower.
diff.header.path
"tk_popup $ctxm %X %Y"
2446 frame .vpane.lower.
diff.body
2447 set ui_diff .vpane.lower.
diff.body.t
2448 text
$ui_diff -background white
-borderwidth 0 \
2449 -width 80 -height 15 -wrap none \
2451 -xscrollcommand {.vpane.lower.
diff.body.sbx
set} \
2452 -yscrollcommand {.vpane.lower.
diff.body.sby
set} \
2454 scrollbar .vpane.lower.
diff.body.sbx
-orient horizontal \
2455 -command [list
$ui_diff xview
]
2456 scrollbar .vpane.lower.
diff.body.sby
-orient vertical \
2457 -command [list
$ui_diff yview
]
2458 pack .vpane.lower.
diff.body.sbx
-side bottom
-fill x
2459 pack .vpane.lower.
diff.body.sby
-side right
-fill y
2460 pack
$ui_diff -side left
-fill both
-expand 1
2461 pack .vpane.lower.
diff.header
-side top
-fill x
2462 pack .vpane.lower.
diff.body
-side bottom
-fill both
-expand 1
2464 $ui_diff tag conf d_cr
-elide true
2465 $ui_diff tag conf d_@
-foreground blue
-font font_diffbold
2466 $ui_diff tag conf d_
+ -foreground {#00a000}
2467 $ui_diff tag conf d_-
-foreground red
2469 $ui_diff tag conf d_
++ -foreground {#00a000}
2470 $ui_diff tag conf d_--
-foreground red
2471 $ui_diff tag conf d_
+s \
2472 -foreground {#00a000} \
2473 -background {#e2effa}
2474 $ui_diff tag conf d_-s \
2476 -background {#e2effa}
2477 $ui_diff tag conf d_s
+ \
2478 -foreground {#00a000} \
2480 $ui_diff tag conf d_s- \
2484 $ui_diff tag conf d
<<<<<<< \
2485 -foreground orange \
2487 $ui_diff tag conf d
======= \
2488 -foreground orange \
2490 $ui_diff tag conf d
>>>>>>> \
2491 -foreground orange \
2494 $ui_diff tag raise sel
2496 # -- Diff Body Context Menu
2498 set ctxm .vpane.lower.
diff.body.ctxm
2499 menu
$ctxm -tearoff 0
2501 -label [mc Refresh
] \
2502 -command reshow_diff
2503 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2506 -command {tk_textCopy
$ui_diff}
2507 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2509 -label [mc
"Select All"] \
2510 -command {focus
$ui_diff;$ui_diff tag add sel
0.0 end
}
2511 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2513 -label [mc
"Copy All"] \
2515 $ui_diff tag add sel
0.0 end
2516 tk_textCopy
$ui_diff
2517 $ui_diff tag remove sel
0.0 end
2519 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2522 -label [mc
"Apply/Reverse Hunk"] \
2523 -command {apply_hunk
$cursorX $cursorY}
2524 set ui_diff_applyhunk
[$ctxm index last
]
2525 lappend diff_actions
[list
$ctxm entryconf
$ui_diff_applyhunk -state]
2528 -label [mc
"Decrease Font Size"] \
2529 -command {incr_font_size font_diff
-1}
2530 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2532 -label [mc
"Increase Font Size"] \
2533 -command {incr_font_size font_diff
1}
2534 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2537 -label [mc
"Show Less Context"] \
2538 -command {if {$repo_config(gui.diffcontext
) >= 1} {
2539 incr repo_config
(gui.diffcontext
) -1
2542 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2544 -label [mc
"Show More Context"] \
2545 -command {if {$repo_config(gui.diffcontext
) < 99} {
2546 incr repo_config
(gui.diffcontext
)
2549 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2551 $ctxm add
command -label [mc
"Options..."] \
2553 proc popup_diff_menu
{ctxm x y X Y
} {
2554 global current_diff_path file_states
2557 if {$
::ui_index eq $
::current_diff_side
} {
2558 set l
[mc
"Unstage Hunk From Commit"]
2560 set l
[mc
"Stage Hunk For Commit"]
2563 ||
$current_diff_path eq
{}
2564 ||
![info exists file_states
($current_diff_path)]
2565 ||
{_O
} eq
[lindex
$file_states($current_diff_path) 0]} {
2570 $ctxm entryconf $
::ui_diff_applyhunk
-state $s -label $l
2571 tk_popup
$ctxm $X $Y
2573 bind_button3
$ui_diff [list popup_diff_menu
$ctxm %x
%y
%X
%Y
]
2577 set main_status
[::status_bar
::new .status
]
2578 pack .status
-anchor w
-side bottom
-fill x
2579 $main_status show
[mc
"Initializing..."]
2584 set gm
$repo_config(gui.geometry
)
2585 wm geometry .
[lindex
$gm 0]
2586 .vpane sash place
0 \
2587 [lindex
[.vpane sash coord
0] 0] \
2589 .vpane.files sash place
0 \
2591 [lindex
[.vpane.files sash coord
0] 1]
2597 bind $ui_comm <$M1B-Key-Return> {do_commit
;break}
2598 bind $ui_comm <$M1B-Key-i> {do_add_all
;break}
2599 bind $ui_comm <$M1B-Key-I> {do_add_all
;break}
2600 bind $ui_comm <$M1B-Key-x> {tk_textCut
%W
;break}
2601 bind $ui_comm <$M1B-Key-X> {tk_textCut
%W
;break}
2602 bind $ui_comm <$M1B-Key-c> {tk_textCopy
%W
;break}
2603 bind $ui_comm <$M1B-Key-C> {tk_textCopy
%W
;break}
2604 bind $ui_comm <$M1B-Key-v> {tk_textPaste
%W
; %W see insert
; break}
2605 bind $ui_comm <$M1B-Key-V> {tk_textPaste
%W
; %W see insert
; break}
2606 bind $ui_comm <$M1B-Key-a> {%W tag add sel
0.0 end
;break}
2607 bind $ui_comm <$M1B-Key-A> {%W tag add sel
0.0 end
;break}
2609 bind $ui_diff <$M1B-Key-x> {tk_textCopy
%W
;break}
2610 bind $ui_diff <$M1B-Key-X> {tk_textCopy
%W
;break}
2611 bind $ui_diff <$M1B-Key-c> {tk_textCopy
%W
;break}
2612 bind $ui_diff <$M1B-Key-C> {tk_textCopy
%W
;break}
2613 bind $ui_diff <$M1B-Key-v> {break}
2614 bind $ui_diff <$M1B-Key-V> {break}
2615 bind $ui_diff <$M1B-Key-a> {%W tag add sel
0.0 end
;break}
2616 bind $ui_diff <$M1B-Key-A> {%W tag add sel
0.0 end
;break}
2617 bind $ui_diff <Key-Up
> {catch
{%W yview scroll
-1 units
};break}
2618 bind $ui_diff <Key-Down
> {catch
{%W yview scroll
1 units
};break}
2619 bind $ui_diff <Key-Left
> {catch
{%W xview scroll
-1 units
};break}
2620 bind $ui_diff <Key-Right
> {catch
{%W xview scroll
1 units
};break}
2621 bind $ui_diff <Key-k
> {catch
{%W yview scroll
-1 units
};break}
2622 bind $ui_diff <Key-j
> {catch
{%W yview scroll
1 units
};break}
2623 bind $ui_diff <Key-h
> {catch
{%W xview scroll
-1 units
};break}
2624 bind $ui_diff <Key-l
> {catch
{%W xview scroll
1 units
};break}
2625 bind $ui_diff <Control-Key-b
> {catch
{%W yview scroll
-1 pages
};break}
2626 bind $ui_diff <Control-Key-f
> {catch
{%W yview scroll
1 pages
};break}
2627 bind $ui_diff <Button-1
> {focus
%W
}
2629 if {[is_enabled branch
]} {
2630 bind .
<$M1B-Key-n> branch_create
::dialog
2631 bind .
<$M1B-Key-N> branch_create
::dialog
2632 bind .
<$M1B-Key-o> branch_checkout
::dialog
2633 bind .
<$M1B-Key-O> branch_checkout
::dialog
2634 bind .
<$M1B-Key-m> merge
::dialog
2635 bind .
<$M1B-Key-M> merge
::dialog
2637 if {[is_enabled transport
]} {
2638 bind .
<$M1B-Key-p> do_push_anywhere
2639 bind .
<$M1B-Key-P> do_push_anywhere
2642 bind .
<Key-F5
> do_rescan
2643 bind .
<$M1B-Key-r> do_rescan
2644 bind .
<$M1B-Key-R> do_rescan
2645 bind .
<$M1B-Key-s> do_signoff
2646 bind .
<$M1B-Key-S> do_signoff
2647 bind .
<$M1B-Key-i> do_add_all
2648 bind .
<$M1B-Key-I> do_add_all
2649 bind .
<$M1B-Key-Return> do_commit
2650 foreach i
[list
$ui_index $ui_workdir] {
2651 bind $i <Button-1
> "toggle_or_diff $i %x %y; break"
2652 bind $i <$M1B-Button-1> "add_one_to_selection $i %x %y; break"
2653 bind $i <Shift-Button-1
> "add_range_to_selection $i %x %y; break"
2657 set file_lists
($ui_index) [list
]
2658 set file_lists
($ui_workdir) [list
]
2660 wm title .
"[appname] ([reponame]) [file normalize [file dirname [gitdir]]]"
2661 focus
-force $ui_comm
2663 # -- Warn the user about environmental problems. Cygwin's Tcl
2664 # does *not* pass its env array onto any processes it spawns.
2665 # This means that git processes get none of our environment.
2670 set msg
[mc
"Possible environment issues exist.
2672 The following environment variables are probably
2673 going to be ignored by any Git subprocess run
2677 foreach name
[array names env
] {
2678 switch
-regexp -- $name {
2679 {^GIT_INDEX_FILE$
} -
2680 {^GIT_OBJECT_DIRECTORY$
} -
2681 {^GIT_ALTERNATE_OBJECT_DIRECTORIES$
} -
2683 {^GIT_EXTERNAL_DIFF$
} -
2687 {^GIT_CONFIG_LOCAL$
} -
2688 {^GIT_
(AUTHOR|COMMITTER
)_DATE$
} {
2689 append msg
" - $name\n"
2692 {^GIT_
(AUTHOR|COMMITTER
)_
(NAME|EMAIL
)$
} {
2693 append msg
" - $name\n"
2695 set suggest_user
$name
2699 if {$ignored_env > 0} {
2701 This is due to a known issue with the
2702 Tcl binary distributed by Cygwin."]
2704 if {$suggest_user ne
{}} {
2707 A good replacement for %s
2708 is placing values for the user.name and
2709 user.email settings into your personal
2715 unset ignored_env msg suggest_user name
2718 # -- Only initialize complex UI if we are going to stay running.
2720 if {[is_enabled transport
]} {
2723 set n
[.mbar.remote index end
]
2726 set n
[expr {[.mbar.remote index end
] - $n}]
2728 .mbar.remote insert
$n separator
2733 if {[winfo exists
$ui_comm]} {
2734 set GITGUI_BCK_exists
[load_message GITGUI_BCK
]
2736 # -- If both our backup and message files exist use the
2737 # newer of the two files to initialize the buffer.
2739 if {$GITGUI_BCK_exists} {
2740 set m
[gitdir GITGUI_MSG
]
2741 if {[file isfile
$m]} {
2742 if {[file mtime
[gitdir GITGUI_BCK
]] > [file mtime
$m]} {
2743 catch
{file delete
[gitdir GITGUI_MSG
]}
2745 $ui_comm delete
0.0 end
2747 $ui_comm edit modified false
2748 catch
{file delete
[gitdir GITGUI_BCK
]}
2749 set GITGUI_BCK_exists
0
2755 proc backup_commit_buffer
{} {
2756 global ui_comm GITGUI_BCK_exists
2758 set m
[$ui_comm edit modified
]
2759 if {$m ||
$GITGUI_BCK_exists} {
2760 set msg
[string trim
[$ui_comm get
0.0 end
]]
2761 regsub
-all -line {[ \r\t]+$
} $msg {} msg
2764 if {$GITGUI_BCK_exists} {
2765 catch
{file delete
[gitdir GITGUI_BCK
]}
2766 set GITGUI_BCK_exists
0
2770 set fd
[open
[gitdir GITGUI_BCK
] w
]
2771 puts
-nonewline $fd $msg
2773 set GITGUI_BCK_exists
1
2777 $ui_comm edit modified false
2780 set ::GITGUI_BCK_i
[after
2000 backup_commit_buffer
]
2783 backup_commit_buffer
2786 lock_index begin-read
2787 if {![winfo ismapped .
]} {
2791 if {[is_enabled multicommit
]} {