2 # Tcl ignores the next line -*- tcl -*- \
3 if test "z$*" = zversion \
4 ||
test "z$*" = z--version
; \
6 echo 'git-gui version @@GITGUI_VERSION@@'; \
10 exec wish
"$argv0" -- "$@"
12 set appvers
{@@GITGUI_VERSION@@
}
13 set copyright
[encoding convertfrom utf-8
{
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 {
217 proc is_config_true
{name
} {
219 if {[catch
{set v
$repo_config($name)}]} {
221 } elseif
{$v eq
{true
} ||
$v eq
{1} ||
$v eq
{yes}} {
228 proc get_config
{name
} {
230 if {[catch
{set v
$repo_config($name)}]} {
237 ######################################################################
241 proc _git_cmd
{name
} {
244 if {[catch
{set v
$_git_cmd_path($name)}]} {
248 --exec-path { return [list $
::_git
$name] }
251 set p
[gitexec git-
$name$
::_search_exe
]
252 if {[file exists
$p]} {
254 } elseif
{[is_Windows
] && [file exists
[gitexec git-
$name]]} {
255 # Try to determine what sort of magic will make
256 # git-$name go and do its thing, because native
257 # Tcl on Windows doesn't know it.
259 set p
[gitexec git-
$name]
264 switch
-glob -- [lindex
$s 0] {
266 #!*perl { set i perl }
267 #!*python { set i python }
268 default
{ error
"git-$name is not supported: $s" }
272 if {![info exists interp
]} {
273 set interp
[_which
$i]
276 error
"git-$name requires $i (not in PATH)"
278 set v
[concat
[list
$interp] [lrange
$s 1 end
] [list
$p]]
280 # Assume it is builtin to git somehow and we
281 # aren't actually able to see a file for it.
283 set v
[list $
::_git
$name]
285 set _git_cmd_path
($name) $v
291 global env _search_exe _search_path
293 if {$_search_path eq
{}} {
294 if {[is_Cygwin
] && [regexp
{^
(/|\.
:)} $env(PATH
)]} {
295 set _search_path
[split [exec cygpath \
301 } elseif
{[is_Windows
]} {
302 set gitguidir
[file dirname [info
script]]
303 regsub
-all ";" $gitguidir "\\;" gitguidir
304 set env
(PATH
) "$gitguidir;$env(PATH)"
305 set _search_path
[split $env(PATH
) {;}]
308 set _search_path
[split $env(PATH
) :]
313 foreach p
$_search_path {
314 set p
[file join $p $what$_search_exe]
315 if {[file exists
$p]} {
316 return [file normalize
$p]
322 proc _lappend_nice
{cmd_var
} {
326 if {![info exists _nice
]} {
327 set _nice
[_which nice
]
338 switch
-- [lindex
$args 0] {
349 set args
[lrange
$args 1 end
]
352 set cmdp
[_git_cmd
[lindex
$args 0]]
353 set args
[lrange
$args 1 end
]
355 return [eval $opt $cmdp $args]
358 proc _open_stdout_stderr
{cmd
} {
362 if { [lindex
$cmd end
] eq
{2>@
1}
363 && $err eq
{can not
find channel named
"1"}
365 # Older versions of Tcl 8.4 don't have this 2>@1 IO
366 # redirect operator. Fallback to |& cat for those.
367 # The command was not actually started, so its safe
368 # to try to start it a second time.
370 set fd
[open
[concat \
371 [lrange
$cmd 0 end-1
] \
378 fconfigure
$fd -eofchar {}
382 proc git_read
{args
} {
386 switch
-- [lindex
$args 0] {
401 set args
[lrange
$args 1 end
]
404 set cmdp
[_git_cmd
[lindex
$args 0]]
405 set args
[lrange
$args 1 end
]
407 return [_open_stdout_stderr
[concat
$opt $cmdp $args]]
410 proc git_write
{args
} {
414 switch
-- [lindex
$args 0] {
425 set args
[lrange
$args 1 end
]
428 set cmdp
[_git_cmd
[lindex
$args 0]]
429 set args
[lrange
$args 1 end
]
431 return [open
[concat
$opt $cmdp $args] w
]
435 regsub
-all ' $value "'\\''" value
439 proc load_current_branch {} {
440 global current_branch is_detached
442 set fd [open [gitdir HEAD] r]
443 if {[gets $fd ref] < 1} {
448 set pfx {ref: refs/heads/}
449 set len [string length $pfx]
450 if {[string equal -length $len $pfx $ref]} {
451 # We're on a branch. It might not exist. But
452 # HEAD looks good enough to be a branch.
454 set current_branch [string range $ref $len end]
457 # Assume this is a detached head.
459 set current_branch HEAD
464 auto_load tk_optionMenu
465 rename tk_optionMenu real__tkOptionMenu
466 proc tk_optionMenu {w varName args} {
467 set m [eval real__tkOptionMenu $w $varName $args]
468 $m configure -font font_ui
469 $w configure -font font_ui
473 proc rmsel_tag {text} {
475 -background [$text cget -background] \
476 -foreground [$text cget -foreground] \
478 $text tag conf in_sel -background lightgray
479 bind $text <Motion> break
484 bind . <Visibility> {
485 bind . <Visibility> {}
490 wm iconbitmap . -default $oguilib/git-gui.ico
493 ######################################################################
498 font create font_diff -family Courier -size 10
502 eval font configure font_ui [font actual [.dummy cget -font]]
506 font create font_uiitalic
507 font create font_uibold
508 font create font_diffbold
509 font create font_diffitalic
511 foreach class {Button Checkbutton Entry Label
512 Labelframe Listbox Menu Message
513 Radiobutton Spinbox Text} {
514 option add *$class.font font_ui
518 if {[is_Windows] || [is_MacOSX]} {
519 option add *Menu.tearOff 0
530 proc bind_button3 {w cmd} {
531 bind $w <Any-Button-3> $cmd
533 # Mac OS X sends Button-2 on right click through three-button mouse,
534 # or through trackpad right-clicking (two-finger touch + click).
535 bind $w <Any-Button-2> $cmd
536 bind $w <Control-Button-1> $cmd
540 proc apply_config {} {
541 global repo_config font_descs
543 foreach option $font_descs {
544 set name [lindex $option 0]
545 set font [lindex $option 1]
547 foreach {cn cv} $repo_config(gui.$name) {
548 font configure $font $cn $cv -weight normal
551 error_popup [strcat [mc "Invalid font specified
in %s
:" "gui.
$name"] "\n\n$err"]
553 foreach {cn cv} [font configure $font] {
554 font configure ${font}bold $cn $cv
555 font configure ${font}italic $cn $cv
557 font configure ${font}bold -weight bold
558 font configure ${font}italic -slant italic
562 set default_config(merge.diffstat) true
563 set default_config(merge.summary) false
564 set default_config(merge.verbosity) 2
565 set default_config(user.name) {}
566 set default_config(user.email) {}
568 set default_config(gui.matchtrackingbranch) false
569 set default_config(gui.pruneduringfetch) false
570 set default_config(gui.trustmtime) false
571 set default_config(gui.diffcontext) 5
572 set default_config(gui.newbranchtemplate) {}
573 set default_config(gui.fontui) [font configure font_ui]
574 set default_config(gui.fontdiff) [font configure font_diff]
576 {fontui font_ui {mc "Main Font
"}}
577 {fontdiff font_diff {mc "Diff
/Console Font
"}}
580 ######################################################################
584 set _git [_which git]
586 catch {wm withdraw .}
590 -title [mc "git-gui
: fatal error
"] \
591 -message [mc "Cannot
find git
in PATH.
"]
595 ######################################################################
599 if {[catch {set _git_version [git --version]} err]} {
600 catch {wm withdraw .}
604 -title [mc "git-gui
: fatal error
"] \
605 -message "Cannot determine Git version
:
609 [appname
] requires Git
1.5.0 or later.
"
612 if {![regsub {^git version } $_git_version {} _git_version]} {
613 catch {wm withdraw .}
617 -title [mc "git-gui
: fatal error
"] \
618 -message [strcat [mc "Cannot parse Git version string
:"] "\n\n$_git_version"]
622 set _real_git_version $_git_version
623 regsub -- {-dirty$} $_git_version {} _git_version
624 regsub {\.[0-9]+\.g[0-9a-f]+$} $_git_version {} _git_version
625 regsub {\.rc[0-9]+$} $_git_version {} _git_version
626 regsub {\.GIT$} $_git_version {} _git_version
627 regsub {\.[a-zA-Z]+\.[0-9]+$} $_git_version {} _git_version
629 if {![regexp {^[1-9]+(\.[0-9]+)+$} $_git_version]} {
630 catch {wm withdraw .}
635 -title "[appname
]: warning
" \
636 -message [mc "Git version cannot be determined.
638 %s claims it is version
'%s'.
640 %s requires
at least Git
1.5.0 or later.
642 Assume
'%s' is version
1.5.0?
643 " $_git $_real_git_version [appname] $_real_git_version]] eq {yes}} {
644 set _git_version 1.5.0
649 unset _real_git_version
651 proc git-version {args} {
654 switch [llength $args] {
660 set op [lindex $args 0]
661 set vr [lindex $args 1]
662 set cm [package vcompare $_git_version $vr]
663 return [expr $cm $op 0]
667 set type [lindex $args 0]
668 set name [lindex $args 1]
669 set parm [lindex $args 2]
670 set body [lindex $args 3]
672 if {($type ne {proc} && $type ne {method})} {
673 error "Invalid arguments to git-version
"
675 if {[llength $body] < 2 || [lindex $body end-1] ne {default}} {
676 error "Last arm of
$type $name must be default
"
679 foreach {op vr cb} [lrange $body 0 end-2] {
680 if {[git-version $op $vr]} {
681 return [uplevel [list $type $name $parm $cb]]
685 return [uplevel [list $type $name $parm [lindex $body end]]]
689 error "git-version
>= x
"
695 if {[git-version < 1.5]} {
696 catch {wm withdraw .}
700 -title [mc "git-gui
: fatal error
"] \
701 -message "[appname
] requires Git
1.5.0 or later.
703 You are using
[git-version
]:
709 ######################################################################
711 ## configure our library
713 set idx [file join $oguilib tclIndex]
714 if {[catch {set fd [open $idx r]} err]} {
715 catch {wm withdraw .}
719 -title [mc "git-gui
: fatal error
"] \
723 if {[gets $fd] eq {# Autogenerated by git-gui Makefile}} {
725 while {[gets $fd n] >= 0} {
726 if {$n ne {} && ![string match #* $n]} {
738 if {[lsearch -exact $loaded $p] >= 0} continue
739 source [file join $oguilib $p]
744 set auto_path [concat [list $oguilib] $auto_path]
746 unset -nocomplain idx fd
748 ######################################################################
750 ## config file parsing
752 git-version proc _parse_config {arr_name args} {
758 set fd_rc [eval [list git_read config --null --list] $args]
759 fconfigure $fd_rc -translation binary
760 set buf [read $fd_rc]
763 foreach line [split $buf "\
0"] {
764 if {[regexp {^([^\n]+)\n(.*)$} $line line name value]} {
765 if {[is_many_config $name]} {
766 lappend arr($name) $value
768 set arr($name) $value
777 set fd_rc [eval [list git_read config --list] $args]
778 while {[gets $fd_rc line] >= 0} {
779 if {[regexp {^([^=]+)=(.*)$} $line line name value]} {
780 if {[is_many_config $name]} {
781 lappend arr($name) $value
783 set arr($name) $value
792 proc load_config {include_global} {
793 global repo_config global_config default_config
795 if {$include_global} {
796 _parse_config global_config --global
798 _parse_config repo_config
800 foreach name [array names default_config] {
801 if {[catch {set v $global_config($name)}]} {
802 set global_config($name) $default_config($name)
804 if {[catch {set v $repo_config($name)}]} {
805 set repo_config($name) $default_config($name)
810 ######################################################################
812 ## feature option selection
814 if {[regexp {^git-(.+)$} [file tail $argv0] _junk subcommand]} {
819 if {$subcommand eq {gui.sh}} {
822 if {$subcommand eq {gui} && [llength $argv] > 0} {
823 set subcommand [lindex $argv 0]
824 set argv [lrange $argv 1 end]
827 enable_option multicommit
829 enable_option transport
832 switch -- $subcommand {
837 disable_option multicommit
838 disable_option branch
839 disable_option transport
842 enable_option singlecommit
844 disable_option multicommit
845 disable_option branch
846 disable_option transport
850 ######################################################################
855 set _gitdir $env(GIT_DIR)
859 set _gitdir [git rev-parse --git-dir]
860 set _prefix [git rev-parse --show-prefix]
864 choose_repository::pick
866 if {![file isdirectory $_gitdir] && [is_Cygwin]} {
867 catch {set _gitdir [exec cygpath --windows $_gitdir]}
869 if {![file isdirectory $_gitdir]} {
870 catch {wm withdraw .}
871 error_popup [strcat [mc "Git directory not found
:"] "\n\n$_gitdir"]
874 if {$_prefix ne {}} {
875 regsub -all {[^/]+/} $_prefix ../ cdup
876 if {[catch {cd $cdup} err]} {
877 catch {wm withdraw .}
878 error_popup [strcat [mc "Cannot move to top of working directory
:"] "\n\n$err"]
882 } elseif {![is_enabled bare]} {
883 if {[lindex [file split $_gitdir] end] ne {.git}} {
884 catch {wm withdraw .}
885 error_popup [strcat [mc "Cannot use funny .git directory
:"] "\n\n$_gitdir"]
888 if {[catch {cd [file dirname $_gitdir]} err]} {
889 catch {wm withdraw .}
890 error_popup [strcat [mc "No working directory
"] " [file dirname $_gitdir]:\n\n$err"]
894 set _reponame [file split [file normalize $_gitdir]]
895 if {[lindex $_reponame end] eq {.git}} {
896 set _reponame [lindex $_reponame end-1]
898 set _reponame [lindex $_reponame end]
901 ######################################################################
905 set current_diff_path {}
906 set current_diff_side {}
907 set diff_actions [list]
911 set MERGE_HEAD [list]
914 set current_branch {}
916 set current_diff_path {}
918 set selected_commit_type new
920 ######################################################################
928 set disable_on_lock [list]
929 set index_lock_type none
931 proc lock_index {type} {
932 global index_lock_type disable_on_lock
934 if {$index_lock_type eq {none}} {
935 set index_lock_type $type
936 foreach w $disable_on_lock {
937 uplevel #0 $w disabled
940 } elseif {$index_lock_type eq "begin-
$type"} {
941 set index_lock_type $type
947 proc unlock_index {} {
948 global index_lock_type disable_on_lock
950 set index_lock_type none
951 foreach w $disable_on_lock {
956 ######################################################################
960 proc repository_state {ctvar hdvar mhvar} {
961 global current_branch
962 upvar $ctvar ct $hdvar hd $mhvar mh
967 if {[catch {set hd [git rev-parse --verify HEAD]}]} {
973 set merge_head [gitdir MERGE_HEAD]
974 if {[file exists $merge_head]} {
976 set fd_mh [open $merge_head r]
977 while {[gets $fd_mh line] >= 0} {
988 global PARENT empty_tree
990 set p [lindex $PARENT 0]
994 if {$empty_tree eq {}} {
995 set empty_tree [git mktree << {}]
1000 proc rescan {after {honor_trustmtime 1}} {
1001 global HEAD PARENT MERGE_HEAD commit_type
1002 global ui_index ui_workdir ui_comm
1003 global rescan_active file_states
1006 if {$rescan_active > 0 || ![lock_index read]} return
1008 repository_state newType newHEAD newMERGE_HEAD
1009 if {[string match amend* $commit_type]
1010 && $newType eq {normal}
1011 && $newHEAD eq $HEAD} {
1015 set MERGE_HEAD $newMERGE_HEAD
1016 set commit_type $newType
1019 array unset file_states
1021 if {!$::GITGUI_BCK_exists &&
1022 (![$ui_comm edit modified]
1023 || [string trim [$ui_comm get 0.0 end]] eq {})} {
1024 if {[string match amend* $commit_type]} {
1025 } elseif {[load_message GITGUI_MSG]} {
1026 } elseif {[load_message MERGE_MSG]} {
1027 } elseif {[load_message SQUASH_MSG]} {
1030 $ui_comm edit modified false
1033 if {$honor_trustmtime && $repo_config(gui.trustmtime) eq {true}} {
1034 rescan_stage2 {} $after
1037 ui_status [mc "Refreshing
file status...
"]
1038 set fd_rf [git_read update-index \
1044 fconfigure $fd_rf -blocking 0 -translation binary
1045 fileevent $fd_rf readable \
1046 [list rescan_stage2 $fd_rf $after]
1051 set is_git_info_link {}
1052 set is_git_info_exclude {}
1053 proc have_info_exclude {} {
1054 global is_git_info_link is_git_info_exclude
1056 if {$is_git_info_link eq {}} {
1057 set is_git_info_link [file isfile [gitdir info.lnk]]
1060 if {$is_git_info_link} {
1061 if {$is_git_info_exclude eq {}} {
1062 if {[catch {exec test -f [gitdir info exclude]}]} {
1063 set is_git_info_exclude 0
1065 set is_git_info_exclude 1
1068 return $is_git_info_exclude
1070 return [file readable [gitdir info exclude]]
1074 proc have_info_exclude {} {
1075 return [file readable [gitdir info exclude]]
1079 proc rescan_stage2 {fd after} {
1080 global rescan_active buf_rdi buf_rdf buf_rlo
1084 if {![eof $fd]} return
1088 set ls_others [list --exclude-per-directory=.gitignore]
1089 if {[have_info_exclude]} {
1090 lappend ls_others "--exclude-from=[gitdir info exclude
]"
1092 set user_exclude [get_config core.excludesfile]
1093 if {$user_exclude ne {} && [file readable $user_exclude]} {
1094 lappend ls_others "--exclude-from=$user_exclude"
1102 ui_status [mc "Scanning
for modified files ...
"]
1103 set fd_di [git_read diff-index --cached -z [PARENT]]
1104 set fd_df [git_read diff-files -z]
1105 set fd_lo [eval git_read ls-files --others -z $ls_others]
1107 fconfigure $fd_di -blocking 0 -translation binary -encoding binary
1108 fconfigure $fd_df -blocking 0 -translation binary -encoding binary
1109 fconfigure $fd_lo -blocking 0 -translation binary -encoding binary
1110 fileevent $fd_di readable [list read_diff_index $fd_di $after]
1111 fileevent $fd_df readable [list read_diff_files $fd_df $after]
1112 fileevent $fd_lo readable [list read_ls_others $fd_lo $after]
1115 proc load_message {file} {
1118 set f [gitdir $file]
1119 if {[file isfile $f]} {
1120 if {[catch {set fd [open $f r]}]} {
1123 fconfigure $fd -eofchar {}
1124 set content [string trim [read $fd]]
1126 regsub -all -line {[ \r\t]+$} $content {} content
1127 $ui_comm delete 0.0 end
1128 $ui_comm insert end $content
1134 proc read_diff_index {fd after} {
1137 append buf_rdi [read $fd]
1139 set n [string length $buf_rdi]
1141 set z1 [string first "\
0" $buf_rdi $c]
1142 if {$z1 == -1} break
1144 set z2 [string first "\
0" $buf_rdi $z1]
1145 if {$z2 == -1} break
1148 set i [split [string range $buf_rdi $c [expr {$z1 - 2}]] { }]
1149 set p [string range $buf_rdi $z1 [expr {$z2 - 1}]]
1151 [encoding convertfrom $p] \
1153 [list [lindex $i 0] [lindex $i 2]] \
1159 set buf_rdi [string range $buf_rdi $c end]
1164 rescan_done $fd buf_rdi $after
1167 proc read_diff_files {fd after} {
1170 append buf_rdf [read $fd]
1172 set n [string length $buf_rdf]
1174 set z1 [string first "\
0" $buf_rdf $c]
1175 if {$z1 == -1} break
1177 set z2 [string first "\
0" $buf_rdf $z1]
1178 if {$z2 == -1} break
1181 set i [split [string range $buf_rdf $c [expr {$z1 - 2}]] { }]
1182 set p [string range $buf_rdf $z1 [expr {$z2 - 1}]]
1184 [encoding convertfrom $p] \
1187 [list [lindex $i 0] [lindex $i 2]]
1192 set buf_rdf [string range $buf_rdf $c end]
1197 rescan_done $fd buf_rdf $after
1200 proc read_ls_others {fd after} {
1203 append buf_rlo [read $fd]
1204 set pck [split $buf_rlo "\
0"]
1205 set buf_rlo [lindex $pck end]
1206 foreach p [lrange $pck 0 end-1] {
1207 set p [encoding convertfrom $p]
1208 if {[string index $p end] eq {/}} {
1209 set p [string range $p 0 end-1]
1213 rescan_done $fd buf_rlo $after
1216 proc rescan_done {fd buf after} {
1217 global rescan_active current_diff_path
1218 global file_states repo_config
1221 if {![eof $fd]} return
1224 if {[incr rescan_active -1] > 0} return
1229 if {$current_diff_path ne {}} reshow_diff
1233 proc prune_selection {} {
1234 global file_states selected_paths
1236 foreach path [array names selected_paths] {
1237 if {[catch {set still_here $file_states($path)}]} {
1238 unset selected_paths($path)
1243 ######################################################################
1247 proc mapicon {w state path} {
1250 if {[catch {set r $all_icons($state$w)}]} {
1251 puts "error
: no icon
for $w state
={$state} $path"
1257 proc mapdesc {state path} {
1260 if {[catch {set r $all_descs($state)}]} {
1261 puts "error
: no desc
for state
={$state} $path"
1267 proc ui_status {msg} {
1269 if {[info exists main_status]} {
1270 $main_status show $msg
1274 proc ui_ready {{test {}}} {
1276 if {[info exists main_status]} {
1277 $main_status show [mc "Ready.
"] $test
1281 proc escape_path {path} {
1282 regsub -all {\\} $path "\\\\" path
1283 regsub -all "\n" $path "\\n
" path
1287 proc short_path {path} {
1288 return [escape_path [lindex [file split $path] end]]
1292 set null_sha1 [string repeat 0 40]
1294 proc merge_state {path new_state {head_info {}} {index_info {}}} {
1295 global file_states next_icon_id null_sha1
1297 set s0 [string index $new_state 0]
1298 set s1 [string index $new_state 1]
1300 if {[catch {set info $file_states($path)}]} {
1302 set icon n[incr next_icon_id]
1304 set state [lindex $info 0]
1305 set icon [lindex $info 1]
1306 if {$head_info eq {}} {set head_info [lindex $info 2]}
1307 if {$index_info eq {}} {set index_info [lindex $info 3]}
1310 if {$s0 eq {?}} {set s0 [string index $state 0]} \
1311 elseif {$s0 eq {_}} {set s0 _}
1313 if {$s1 eq {?}} {set s1 [string index $state 1]} \
1314 elseif {$s1 eq {_}} {set s1 _}
1316 if {$s0 eq {A} && $s1 eq {_} && $head_info eq {}} {
1317 set head_info [list 0 $null_sha1]
1318 } elseif {$s0 ne {_} && [string index $state 0] eq {_}
1319 && $head_info eq {}} {
1320 set head_info $index_info
1323 set file_states($path) [list $s0$s1 $icon \
1324 $head_info $index_info \
1329 proc display_file_helper {w path icon_name old_m new_m} {
1332 if {$new_m eq {_}} {
1333 set lno [lsearch -sorted -exact $file_lists($w) $path]
1335 set file_lists($w) [lreplace $file_lists($w) $lno $lno]
1337 $w conf -state normal
1338 $w delete $lno.0 [expr {$lno + 1}].0
1339 $w conf -state disabled
1341 } elseif {$old_m eq {_} && $new_m ne {_}} {
1342 lappend file_lists($w) $path
1343 set file_lists($w) [lsort -unique $file_lists($w)]
1344 set lno [lsearch -sorted -exact $file_lists($w) $path]
1346 $w conf -state normal
1347 $w image create $lno.0 \
1348 -align center -padx 5 -pady 1 \
1350 -image [mapicon $w $new_m $path]
1351 $w insert $lno.1 "[escape_path
$path]\n"
1352 $w conf -state disabled
1353 } elseif {$old_m ne $new_m} {
1354 $w conf -state normal
1355 $w image conf $icon_name -image [mapicon $w $new_m $path]
1356 $w conf -state disabled
1360 proc display_file {path state} {
1361 global file_states selected_paths
1362 global ui_index ui_workdir
1364 set old_m [merge_state $path $state]
1365 set s $file_states($path)
1366 set new_m [lindex $s 0]
1367 set icon_name [lindex $s 1]
1369 set o [string index $old_m 0]
1370 set n [string index $new_m 0]
1377 display_file_helper $ui_index $path $icon_name $o $n
1379 if {[string index $old_m 0] eq {U}} {
1382 set o [string index $old_m 1]
1384 if {[string index $new_m 0] eq {U}} {
1387 set n [string index $new_m 1]
1389 display_file_helper $ui_workdir $path $icon_name $o $n
1391 if {$new_m eq {__}} {
1392 unset file_states($path)
1393 catch {unset selected_paths($path)}
1397 proc display_all_files_helper {w path icon_name m} {
1400 lappend file_lists($w) $path
1401 set lno [expr {[lindex [split [$w index end] .] 0] - 1}]
1402 $w image create end \
1403 -align center -padx 5 -pady 1 \
1405 -image [mapicon $w $m $path]
1406 $w insert end "[escape_path
$path]\n"
1409 proc display_all_files {} {
1410 global ui_index ui_workdir
1411 global file_states file_lists
1414 $ui_index conf -state normal
1415 $ui_workdir conf -state normal
1417 $ui_index delete 0.0 end
1418 $ui_workdir delete 0.0 end
1421 set file_lists($ui_index) [list]
1422 set file_lists($ui_workdir) [list]
1424 foreach path [lsort [array names file_states]] {
1425 set s $file_states($path)
1427 set icon_name [lindex $s 1]
1429 set s [string index $m 0]
1430 if {$s ne {U} && $s ne {_}} {
1431 display_all_files_helper $ui_index $path \
1435 if {[string index $m 0] eq {U}} {
1438 set s [string index $m 1]
1441 display_all_files_helper $ui_workdir $path \
1446 $ui_index conf -state disabled
1447 $ui_workdir conf -state disabled
1450 ######################################################################
1455 #define mask_width 14
1456 #define mask_height 15
1457 static unsigned char mask_bits[] = {
1458 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
1459 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
1460 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f};
1463 image create bitmap file_plain -background white -foreground black -data {
1464 #define plain_width 14
1465 #define plain_height 15
1466 static unsigned char plain_bits[] = {
1467 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
1468 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10,
1469 0x02, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1470 } -maskdata $filemask
1472 image create bitmap file_mod -background white -foreground blue -data {
1473 #define mod_width 14
1474 #define mod_height 15
1475 static unsigned char mod_bits[] = {
1476 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
1477 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
1478 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
1479 } -maskdata $filemask
1481 image create bitmap file_fulltick -background white -foreground "#007000" -data {
1482 #define file_fulltick_width 14
1483 #define file_fulltick_height 15
1484 static unsigned char file_fulltick_bits
[] = {
1485 0xfe, 0x01, 0x02, 0x1a, 0x02, 0x0c, 0x02, 0x0c, 0x02, 0x16, 0x02, 0x16,
1486 0x02, 0x13, 0x00, 0x13, 0x86, 0x11, 0x8c, 0x11, 0xd8, 0x10, 0xf2, 0x10,
1487 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1488 } -maskdata $filemask
1490 image create bitmap file_parttick
-background white
-foreground "#005050" -data {
1491 #define parttick_width 14
1492 #define parttick_height 15
1493 static unsigned char parttick_bits
[] = {
1494 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
1495 0x7a, 0x14, 0x02, 0x16, 0x02, 0x13, 0x8a, 0x11, 0xda, 0x10, 0x72, 0x10,
1496 0x22, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1497 } -maskdata $filemask
1499 image create bitmap file_question
-background white
-foreground black
-data {
1500 #define file_question_width 14
1501 #define file_question_height 15
1502 static unsigned char file_question_bits
[] = {
1503 0xfe, 0x01, 0x02, 0x02, 0xe2, 0x04, 0xf2, 0x09, 0x1a, 0x1b, 0x0a, 0x13,
1504 0x82, 0x11, 0xc2, 0x10, 0x62, 0x10, 0x62, 0x10, 0x02, 0x10, 0x62, 0x10,
1505 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1506 } -maskdata $filemask
1508 image create bitmap file_removed
-background white
-foreground red
-data {
1509 #define file_removed_width 14
1510 #define file_removed_height 15
1511 static unsigned char file_removed_bits
[] = {
1512 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
1513 0x1a, 0x16, 0x32, 0x13, 0xe2, 0x11, 0xc2, 0x10, 0xe2, 0x11, 0x32, 0x13,
1514 0x1a, 0x16, 0x02, 0x10, 0xfe, 0x1f};
1515 } -maskdata $filemask
1517 image create bitmap file_merge
-background white
-foreground blue
-data {
1518 #define file_merge_width 14
1519 #define file_merge_height 15
1520 static unsigned char file_merge_bits
[] = {
1521 0xfe, 0x01, 0x02, 0x03, 0x62, 0x05, 0x62, 0x09, 0x62, 0x1f, 0x62, 0x10,
1522 0xfa, 0x11, 0xf2, 0x10, 0x62, 0x10, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
1523 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
1524 } -maskdata $filemask
1526 set ui_index .vpane.files.index.list
1527 set ui_workdir .vpane.files.workdir.list
1529 set all_icons
(_
$ui_index) file_plain
1530 set all_icons
(A
$ui_index) file_fulltick
1531 set all_icons
(M
$ui_index) file_fulltick
1532 set all_icons
(D
$ui_index) file_removed
1533 set all_icons
(U
$ui_index) file_merge
1535 set all_icons
(_
$ui_workdir) file_plain
1536 set all_icons
(M
$ui_workdir) file_mod
1537 set all_icons
(D
$ui_workdir) file_question
1538 set all_icons
(U
$ui_workdir) file_merge
1539 set all_icons
(O
$ui_workdir) file_plain
1541 set max_status_desc
0
1543 {__
{mc
"Unmodified"}}
1545 {_M
{mc
"Modified, not staged"}}
1546 {M_
{mc
"Staged for commit"}}
1547 {MM
{mc
"Portions staged for commit"}}
1548 {MD
{mc
"Staged for commit, missing"}}
1550 {_O
{mc
"Untracked, not staged"}}
1551 {A_
{mc
"Staged for commit"}}
1552 {AM
{mc
"Portions staged for commit"}}
1553 {AD
{mc
"Staged for commit, missing"}}
1556 {D_
{mc
"Staged for removal"}}
1557 {DO
{mc
"Staged for removal, still present"}}
1559 {U_
{mc
"Requires merge resolution"}}
1560 {UU
{mc
"Requires merge resolution"}}
1561 {UM
{mc
"Requires merge resolution"}}
1562 {UD
{mc
"Requires merge resolution"}}
1564 set text
[eval [lindex
$i 1]]
1565 if {$max_status_desc < [string length
$text]} {
1566 set max_status_desc
[string length
$text]
1568 set all_descs
([lindex
$i 0]) $text
1572 ######################################################################
1576 proc scrollbar2many
{list mode args
} {
1577 foreach w
$list {eval $w $mode $args}
1580 proc many2scrollbar
{list mode sb top bottom
} {
1581 $sb set $top $bottom
1582 foreach w
$list {$w $mode moveto
$top}
1585 proc incr_font_size
{font
{amt
1}} {
1586 set sz
[font configure
$font -size]
1588 font configure
$font -size $sz
1589 font configure
${font}bold
-size $sz
1590 font configure
${font}italic
-size $sz
1593 ######################################################################
1597 set starting_gitk_msg
[mc
"Starting gitk... please wait..."]
1599 proc do_gitk
{revs
} {
1600 # -- Always start gitk through whatever we were loaded with. This
1601 # lets us bypass using shell process on Windows systems.
1603 set exe
[file join [file dirname $
::_git
] gitk
]
1604 set cmd
[list
[info nameofexecutable
] $exe]
1605 if {! [file exists
$exe]} {
1606 error_popup
[mc
"Unable to start gitk:\n\n%s does not exist" $exe]
1610 if {[info exists env
(GIT_DIR
)]} {
1611 set old_GIT_DIR
$env(GIT_DIR
)
1617 cd [file dirname [gitdir
]]
1618 set env
(GIT_DIR
) [file tail [gitdir
]]
1620 eval exec $cmd $revs &
1622 if {$old_GIT_DIR eq
{}} {
1625 set env
(GIT_DIR
) $old_GIT_DIR
1629 ui_status $
::starting_gitk_msg
1631 ui_ready
$starting_gitk_msg
1639 global ui_comm is_quitting repo_config commit_type
1640 global GITGUI_BCK_exists GITGUI_BCK_i
1642 if {$is_quitting} return
1645 if {[winfo exists
$ui_comm]} {
1646 # -- Stash our current commit buffer.
1648 set save
[gitdir GITGUI_MSG
]
1649 if {$GITGUI_BCK_exists && ![$ui_comm edit modified
]} {
1650 file rename
-force [gitdir GITGUI_BCK
] $save
1651 set GITGUI_BCK_exists
0
1653 set msg
[string trim
[$ui_comm get
0.0 end
]]
1654 regsub
-all -line {[ \r\t]+$
} $msg {} msg
1655 if {(![string match amend
* $commit_type]
1656 ||
[$ui_comm edit modified
])
1659 set fd
[open
$save w
]
1660 puts
-nonewline $fd $msg
1664 catch
{file delete
$save}
1668 # -- Remove our editor backup, its not needed.
1670 after cancel
$GITGUI_BCK_i
1671 if {$GITGUI_BCK_exists} {
1672 catch
{file delete
[gitdir GITGUI_BCK
]}
1675 # -- Stash our current window geometry into this repository.
1677 set cfg_geometry
[list
]
1678 lappend cfg_geometry
[wm geometry .
]
1679 lappend cfg_geometry
[lindex
[.vpane sash coord
0] 0]
1680 lappend cfg_geometry
[lindex
[.vpane.files sash coord
0] 1]
1681 if {[catch
{set rc_geometry
$repo_config(gui.geometry
)}]} {
1684 if {$cfg_geometry ne
$rc_geometry} {
1685 catch
{git config gui.geometry
$cfg_geometry}
1700 proc toggle_or_diff
{w x y
} {
1701 global file_states file_lists current_diff_path ui_index ui_workdir
1702 global last_clicked selected_paths
1704 set pos
[split [$w index @
$x,$y] .
]
1705 set lno
[lindex
$pos 0]
1706 set col [lindex
$pos 1]
1707 set path
[lindex
$file_lists($w) [expr {$lno - 1}]]
1713 set last_clicked
[list
$w $lno]
1714 array
unset selected_paths
1715 $ui_index tag remove in_sel
0.0 end
1716 $ui_workdir tag remove in_sel
0.0 end
1719 if {$current_diff_path eq
$path} {
1720 set after
{reshow_diff
;}
1724 if {$w eq
$ui_index} {
1726 "Unstaging [short_path $path] from commit" \
1728 [concat
$after [list ui_ready
]]
1729 } elseif
{$w eq
$ui_workdir} {
1731 "Adding [short_path $path]" \
1733 [concat
$after [list ui_ready
]]
1736 show_diff
$path $w $lno
1740 proc add_one_to_selection
{w x y
} {
1741 global file_lists last_clicked selected_paths
1743 set lno
[lindex
[split [$w index @
$x,$y] .
] 0]
1744 set path
[lindex
$file_lists($w) [expr {$lno - 1}]]
1750 if {$last_clicked ne
{}
1751 && [lindex
$last_clicked 0] ne
$w} {
1752 array
unset selected_paths
1753 [lindex
$last_clicked 0] tag remove in_sel
0.0 end
1756 set last_clicked
[list
$w $lno]
1757 if {[catch
{set in_sel
$selected_paths($path)}]} {
1761 unset selected_paths
($path)
1762 $w tag remove in_sel
$lno.0 [expr {$lno + 1}].0
1764 set selected_paths
($path) 1
1765 $w tag add in_sel
$lno.0 [expr {$lno + 1}].0
1769 proc add_range_to_selection
{w x y
} {
1770 global file_lists last_clicked selected_paths
1772 if {[lindex
$last_clicked 0] ne
$w} {
1773 toggle_or_diff
$w $x $y
1777 set lno
[lindex
[split [$w index @
$x,$y] .
] 0]
1778 set lc
[lindex
$last_clicked 1]
1787 foreach path
[lrange
$file_lists($w) \
1788 [expr {$begin - 1}] \
1789 [expr {$end - 1}]] {
1790 set selected_paths
($path) 1
1792 $w tag add in_sel
$begin.0 [expr {$end + 1}].0
1795 ######################################################################
1805 menu .mbar
-tearoff 0
1806 .mbar add cascade
-label [mc Repository
] -menu .mbar.repository
1807 .mbar add cascade
-label [mc Edit
] -menu .mbar.edit
1808 if {[is_enabled branch
]} {
1809 .mbar add cascade
-label [mc Branch
] -menu .mbar.branch
1811 if {[is_enabled multicommit
] ||
[is_enabled singlecommit
]} {
1812 .mbar add cascade
-label [mc Commit@@noun
] -menu .mbar.commit
1814 if {[is_enabled transport
]} {
1815 .mbar add cascade
-label [mc Merge
] -menu .mbar.merge
1816 .mbar add cascade
-label [mc Remote
] -menu .mbar.remote
1818 . configure
-menu .mbar
1820 # -- Repository Menu
1822 menu .mbar.repository
1824 .mbar.repository add
command \
1825 -label [mc
"Browse Current Branch's Files"] \
1826 -command {browser
::new
$current_branch}
1827 set ui_browse_current
[.mbar.repository index last
]
1828 .mbar.repository add
command \
1829 -label [mc
"Browse Branch Files..."] \
1830 -command browser_open
::dialog
1831 .mbar.repository add separator
1833 .mbar.repository add
command \
1834 -label [mc
"Visualize Current Branch's History"] \
1835 -command {do_gitk
$current_branch}
1836 set ui_visualize_current
[.mbar.repository index last
]
1837 .mbar.repository add
command \
1838 -label [mc
"Visualize All Branch History"] \
1839 -command {do_gitk
--all}
1840 .mbar.repository add separator
1842 proc current_branch_write
{args
} {
1843 global current_branch
1844 .mbar.repository entryconf $
::ui_browse_current \
1845 -label [mc
"Browse %s's Files" $current_branch]
1846 .mbar.repository entryconf $
::ui_visualize_current \
1847 -label [mc
"Visualize %s's History" $current_branch]
1849 trace add variable current_branch
write current_branch_write
1851 if {[is_enabled multicommit
]} {
1852 .mbar.repository add
command -label [mc
"Database Statistics"] \
1855 .mbar.repository add
command -label [mc
"Compress Database"] \
1858 .mbar.repository add
command -label [mc
"Verify Database"] \
1859 -command do_fsck_objects
1861 .mbar.repository add separator
1864 .mbar.repository add
command \
1865 -label [mc
"Create Desktop Icon"] \
1866 -command do_cygwin_shortcut
1867 } elseif
{[is_Windows
]} {
1868 .mbar.repository add
command \
1869 -label [mc
"Create Desktop Icon"] \
1870 -command do_windows_shortcut
1871 } elseif
{[is_MacOSX
]} {
1872 .mbar.repository add
command \
1873 -label [mc
"Create Desktop Icon"] \
1874 -command do_macosx_app
1878 .mbar.repository add
command -label [mc Quit
] \
1885 .mbar.edit add
command -label [mc Undo
] \
1886 -command {catch
{[focus
] edit undo
}} \
1888 .mbar.edit add
command -label [mc Redo
] \
1889 -command {catch
{[focus
] edit redo
}} \
1891 .mbar.edit add separator
1892 .mbar.edit add
command -label [mc Cut
] \
1893 -command {catch
{tk_textCut
[focus
]}} \
1895 .mbar.edit add
command -label [mc Copy
] \
1896 -command {catch
{tk_textCopy
[focus
]}} \
1898 .mbar.edit add
command -label [mc Paste
] \
1899 -command {catch
{tk_textPaste
[focus
]; [focus
] see insert
}} \
1901 .mbar.edit add
command -label [mc Delete
] \
1902 -command {catch
{[focus
] delete sel.first sel.last
}} \
1904 .mbar.edit add separator
1905 .mbar.edit add
command -label [mc
"Select All"] \
1906 -command {catch
{[focus
] tag add sel
0.0 end
}} \
1911 if {[is_enabled branch
]} {
1914 .mbar.branch add
command -label [mc
"Create..."] \
1915 -command branch_create
::dialog \
1917 lappend disable_on_lock
[list .mbar.branch entryconf \
1918 [.mbar.branch index last
] -state]
1920 .mbar.branch add
command -label [mc
"Checkout..."] \
1921 -command branch_checkout
::dialog \
1923 lappend disable_on_lock
[list .mbar.branch entryconf \
1924 [.mbar.branch index last
] -state]
1926 .mbar.branch add
command -label [mc
"Rename..."] \
1927 -command branch_rename
::dialog
1928 lappend disable_on_lock
[list .mbar.branch entryconf \
1929 [.mbar.branch index last
] -state]
1931 .mbar.branch add
command -label [mc
"Delete..."] \
1932 -command branch_delete
::dialog
1933 lappend disable_on_lock
[list .mbar.branch entryconf \
1934 [.mbar.branch index last
] -state]
1936 .mbar.branch add
command -label [mc
"Reset..."] \
1937 -command merge
::reset_hard
1938 lappend disable_on_lock
[list .mbar.branch entryconf \
1939 [.mbar.branch index last
] -state]
1944 if {[is_enabled multicommit
] ||
[is_enabled singlecommit
]} {
1947 .mbar.commit add radiobutton \
1948 -label [mc
"New Commit"] \
1949 -command do_select_commit_type \
1950 -variable selected_commit_type \
1952 lappend disable_on_lock \
1953 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1955 .mbar.commit add radiobutton \
1956 -label [mc
"Amend Last Commit"] \
1957 -command do_select_commit_type \
1958 -variable selected_commit_type \
1960 lappend disable_on_lock \
1961 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1963 .mbar.commit add separator
1965 .mbar.commit add
command -label [mc Rescan
] \
1966 -command do_rescan \
1968 lappend disable_on_lock \
1969 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1971 .mbar.commit add
command -label [mc
"Stage To Commit"] \
1972 -command do_add_selection
1973 lappend disable_on_lock \
1974 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1976 .mbar.commit add
command -label [mc
"Stage Changed Files To Commit"] \
1977 -command do_add_all \
1979 lappend disable_on_lock \
1980 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1982 .mbar.commit add
command -label [mc
"Unstage From Commit"] \
1983 -command do_unstage_selection
1984 lappend disable_on_lock \
1985 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1987 .mbar.commit add
command -label [mc
"Revert Changes"] \
1988 -command do_revert_selection
1989 lappend disable_on_lock \
1990 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1992 .mbar.commit add separator
1994 .mbar.commit add
command -label [mc
"Sign Off"] \
1995 -command do_signoff \
1998 .mbar.commit add
command -label [mc Commit@@verb
] \
1999 -command do_commit \
2000 -accelerator $M1T-Return
2001 lappend disable_on_lock \
2002 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
2007 if {[is_enabled branch
]} {
2009 .mbar.merge add
command -label [mc
"Local Merge..."] \
2010 -command merge
::dialog \
2012 lappend disable_on_lock \
2013 [list .mbar.merge entryconf
[.mbar.merge index last
] -state]
2014 .mbar.merge add
command -label [mc
"Abort Merge..."] \
2015 -command merge
::reset_hard
2016 lappend disable_on_lock \
2017 [list .mbar.merge entryconf
[.mbar.merge index last
] -state]
2022 if {[is_enabled transport
]} {
2025 .mbar.remote add
command \
2026 -label [mc
"Push..."] \
2027 -command do_push_anywhere \
2029 .mbar.remote add
command \
2030 -label [mc
"Delete..."] \
2031 -command remote_branch_delete
::dialog
2035 # -- Apple Menu (Mac OS X only)
2037 .mbar add cascade
-label [mc Apple
] -menu .mbar.apple
2040 .mbar.apple add
command -label [mc
"About %s" [appname
]] \
2042 .mbar.apple add separator
2043 .mbar.apple add
command \
2044 -label [mc
"Preferences..."] \
2045 -command do_options \
2047 bind .
<$M1B-,> do_options
2051 .mbar.edit add separator
2052 .mbar.edit add
command -label [mc
"Options..."] \
2058 .mbar add cascade
-label [mc Help
] -menu .mbar.
help
2062 .mbar.
help add
command -label [mc
"About %s" [appname
]] \
2067 catch
{set browser
$repo_config(instaweb.browser
)}
2068 set doc_path
[file dirname [gitexec
]]
2069 set doc_path
[file join $doc_path Documentation index.html
]
2072 set doc_path
[exec cygpath
--mixed $doc_path]
2075 if {$browser eq
{}} {
2078 } elseif
{[is_Cygwin
]} {
2079 set program_files
[file dirname [exec cygpath
--windir]]
2080 set program_files
[file join $program_files {Program Files
}]
2081 set firefox
[file join $program_files {Mozilla Firefox
} firefox.exe
]
2082 set ie
[file join $program_files {Internet Explorer
} IEXPLORE.EXE
]
2083 if {[file exists
$firefox]} {
2084 set browser
$firefox
2085 } elseif
{[file exists
$ie]} {
2088 unset program_files firefox ie
2092 if {[file isfile
$doc_path]} {
2093 set doc_url
"file:$doc_path"
2095 set doc_url
{http
://www.kernel.org
/pub
/software
/scm
/git
/docs
/}
2098 if {$browser ne
{}} {
2099 .mbar.
help add
command -label [mc
"Online Documentation"] \
2100 -command [list
exec $browser $doc_url &]
2102 unset browser doc_path doc_url
2104 # -- Standard bindings
2106 wm protocol . WM_DELETE_WINDOW do_quit
2107 bind all
<$M1B-Key-q> do_quit
2108 bind all
<$M1B-Key-Q> do_quit
2109 bind all
<$M1B-Key-w> {destroy
[winfo toplevel
%W
]}
2110 bind all
<$M1B-Key-W> {destroy
[winfo toplevel
%W
]}
2112 set subcommand_args
{}
2114 puts stderr
"usage: $::argv0 $::subcommand $::subcommand_args"
2118 # -- Not a normal commit type invocation? Do that instead!
2120 switch
-- $subcommand {
2123 set subcommand_args
{rev? path
}
2124 if {$argv eq
{}} usage
2129 if {$is_path ||
[file exists
$_prefix$a]} {
2130 if {$path ne
{}} usage
2133 } elseif
{$a eq
{--}} {
2135 if {$head ne
{}} usage
2140 } elseif
{$head eq
{}} {
2141 if {$head ne
{}} usage
2150 if {$head ne
{} && $path eq
{}} {
2151 set path
$_prefix$head
2158 if {[regexp
{^
[0-9a-f]{1,39}$
} $head]} {
2160 set head [git rev-parse
--verify $head]
2166 set current_branch
$head
2169 switch
-- $subcommand {
2172 if {$path ne
{} && [file isdirectory
$path]} {
2173 set head $current_branch
2179 browser
::new
$head $path
2182 if {$head eq
{} && ![file exists
$path]} {
2183 puts stderr
[mc
"fatal: cannot stat path %s: No such file or directory" $path]
2186 blame
::new
$head $path
2193 if {[llength
$argv] != 0} {
2194 puts
-nonewline stderr
"usage: $argv0"
2195 if {$subcommand ne
{gui
}
2196 && [file tail $argv0] ne
"git-$subcommand"} {
2197 puts
-nonewline stderr
" $subcommand"
2202 # fall through to setup UI for commits
2205 puts stderr
"usage: $argv0 \[{blame|browser|citool}\]"
2216 -text [mc
"Current Branch:"] \
2220 -textvariable current_branch \
2223 pack .branch.l1
-side left
2224 pack .branch.cb
-side left
-fill x
2225 pack .branch
-side top
-fill x
2227 # -- Main Window Layout
2229 panedwindow .vpane
-orient horizontal
2230 panedwindow .vpane.files
-orient vertical
2231 .vpane add .vpane.files
-sticky nsew
-height 100 -width 200
2232 pack .vpane
-anchor n
-side top
-fill both
-expand 1
2234 # -- Index File List
2236 frame .vpane.files.index
-height 100 -width 200
2237 label .vpane.files.index.title
-text [mc
"Staged Changes (Will Commit)"] \
2238 -background lightgreen
2239 text
$ui_index -background white
-borderwidth 0 \
2240 -width 20 -height 10 \
2242 -cursor $cursor_ptr \
2243 -xscrollcommand {.vpane.files.index.sx
set} \
2244 -yscrollcommand {.vpane.files.index.sy
set} \
2246 scrollbar .vpane.files.index.sx
-orient h
-command [list
$ui_index xview
]
2247 scrollbar .vpane.files.index.sy
-orient v
-command [list
$ui_index yview
]
2248 pack .vpane.files.index.title
-side top
-fill x
2249 pack .vpane.files.index.sx
-side bottom
-fill x
2250 pack .vpane.files.index.sy
-side right
-fill y
2251 pack
$ui_index -side left
-fill both
-expand 1
2253 # -- Working Directory File List
2255 frame .vpane.files.workdir
-height 100 -width 200
2256 label .vpane.files.workdir.title
-text [mc
"Unstaged Changes"] \
2257 -background lightsalmon
2258 text
$ui_workdir -background white
-borderwidth 0 \
2259 -width 20 -height 10 \
2261 -cursor $cursor_ptr \
2262 -xscrollcommand {.vpane.files.workdir.sx
set} \
2263 -yscrollcommand {.vpane.files.workdir.sy
set} \
2265 scrollbar .vpane.files.workdir.sx
-orient h
-command [list
$ui_workdir xview
]
2266 scrollbar .vpane.files.workdir.sy
-orient v
-command [list
$ui_workdir yview
]
2267 pack .vpane.files.workdir.title
-side top
-fill x
2268 pack .vpane.files.workdir.sx
-side bottom
-fill x
2269 pack .vpane.files.workdir.sy
-side right
-fill y
2270 pack
$ui_workdir -side left
-fill both
-expand 1
2272 .vpane.files add .vpane.files.workdir
-sticky nsew
2273 .vpane.files add .vpane.files.index
-sticky nsew
2275 foreach i
[list
$ui_index $ui_workdir] {
2277 $i tag conf in_diff
-background [$i tag cget in_sel
-background]
2281 # -- Diff and Commit Area
2283 frame .vpane.lower
-height 300 -width 400
2284 frame .vpane.lower.commarea
2285 frame .vpane.lower.
diff -relief sunken
-borderwidth 1
2286 pack .vpane.lower.
diff -fill both
-expand 1
2287 pack .vpane.lower.commarea
-side bottom
-fill x
2288 .vpane add .vpane.lower
-sticky nsew
2290 # -- Commit Area Buttons
2292 frame .vpane.lower.commarea.buttons
2293 label .vpane.lower.commarea.buttons.l
-text {} \
2296 pack .vpane.lower.commarea.buttons.l
-side top
-fill x
2297 pack .vpane.lower.commarea.buttons
-side left
-fill y
2299 button .vpane.lower.commarea.buttons.rescan
-text [mc Rescan
] \
2301 pack .vpane.lower.commarea.buttons.rescan
-side top
-fill x
2302 lappend disable_on_lock \
2303 {.vpane.lower.commarea.buttons.rescan conf
-state}
2305 button .vpane.lower.commarea.buttons.incall
-text [mc
"Stage Changed"] \
2307 pack .vpane.lower.commarea.buttons.incall
-side top
-fill x
2308 lappend disable_on_lock \
2309 {.vpane.lower.commarea.buttons.incall conf
-state}
2311 button .vpane.lower.commarea.buttons.signoff
-text [mc
"Sign Off"] \
2313 pack .vpane.lower.commarea.buttons.signoff
-side top
-fill x
2315 button .vpane.lower.commarea.buttons.commit
-text [mc Commit@@verb
] \
2317 pack .vpane.lower.commarea.buttons.commit
-side top
-fill x
2318 lappend disable_on_lock \
2319 {.vpane.lower.commarea.buttons.commit conf
-state}
2321 button .vpane.lower.commarea.buttons.push
-text [mc Push
] \
2322 -command do_push_anywhere
2323 pack .vpane.lower.commarea.buttons.push
-side top
-fill x
2325 # -- Commit Message Buffer
2327 frame .vpane.lower.commarea.buffer
2328 frame .vpane.lower.commarea.buffer.header
2329 set ui_comm .vpane.lower.commarea.buffer.t
2330 set ui_coml .vpane.lower.commarea.buffer.header.l
2331 radiobutton .vpane.lower.commarea.buffer.header.new \
2332 -text [mc
"New Commit"] \
2333 -command do_select_commit_type \
2334 -variable selected_commit_type \
2336 lappend disable_on_lock \
2337 [list .vpane.lower.commarea.buffer.header.new conf
-state]
2338 radiobutton .vpane.lower.commarea.buffer.header.amend \
2339 -text [mc
"Amend Last Commit"] \
2340 -command do_select_commit_type \
2341 -variable selected_commit_type \
2343 lappend disable_on_lock \
2344 [list .vpane.lower.commarea.buffer.header.amend conf
-state]
2348 proc trace_commit_type
{varname args
} {
2349 global ui_coml commit_type
2350 switch
-glob -- $commit_type {
2351 initial
{set txt
[mc
"Initial Commit Message:"]}
2352 amend
{set txt
[mc
"Amended Commit Message:"]}
2353 amend-initial
{set txt
[mc
"Amended Initial Commit Message:"]}
2354 amend-merge
{set txt
[mc
"Amended Merge Commit Message:"]}
2355 merge
{set txt
[mc
"Merge Commit Message:"]}
2356 * {set txt
[mc
"Commit Message:"]}
2358 $ui_coml conf
-text $txt
2360 trace add variable commit_type
write trace_commit_type
2361 pack
$ui_coml -side left
-fill x
2362 pack .vpane.lower.commarea.buffer.header.amend
-side right
2363 pack .vpane.lower.commarea.buffer.header.new
-side right
2365 text
$ui_comm -background white
-borderwidth 1 \
2368 -autoseparators true \
2370 -width 75 -height 9 -wrap none \
2372 -yscrollcommand {.vpane.lower.commarea.buffer.sby
set}
2373 scrollbar .vpane.lower.commarea.buffer.sby \
2374 -command [list
$ui_comm yview
]
2375 pack .vpane.lower.commarea.buffer.header
-side top
-fill x
2376 pack .vpane.lower.commarea.buffer.sby
-side right
-fill y
2377 pack
$ui_comm -side left
-fill y
2378 pack .vpane.lower.commarea.buffer
-side left
-fill y
2380 # -- Commit Message Buffer Context Menu
2382 set ctxm .vpane.lower.commarea.buffer.ctxm
2383 menu
$ctxm -tearoff 0
2386 -command {tk_textCut
$ui_comm}
2389 -command {tk_textCopy
$ui_comm}
2392 -command {tk_textPaste
$ui_comm}
2394 -label [mc Delete
] \
2395 -command {$ui_comm delete sel.first sel.last
}
2398 -label [mc
"Select All"] \
2399 -command {focus
$ui_comm;$ui_comm tag add sel
0.0 end
}
2401 -label [mc
"Copy All"] \
2403 $ui_comm tag add sel
0.0 end
2404 tk_textCopy
$ui_comm
2405 $ui_comm tag remove sel
0.0 end
2409 -label [mc
"Sign Off"] \
2411 bind_button3
$ui_comm "tk_popup $ctxm %X %Y"
2415 proc trace_current_diff_path
{varname args
} {
2416 global current_diff_path diff_actions file_states
2417 if {$current_diff_path eq
{}} {
2423 set p
$current_diff_path
2424 set s
[mapdesc
[lindex
$file_states($p) 0] $p]
2426 set p
[escape_path
$p]
2430 .vpane.lower.
diff.header.status configure
-text $s
2431 .vpane.lower.
diff.header.
file configure
-text $f
2432 .vpane.lower.
diff.header.path configure
-text $p
2433 foreach w
$diff_actions {
2437 trace add variable current_diff_path
write trace_current_diff_path
2439 frame .vpane.lower.
diff.header
-background gold
2440 label .vpane.lower.
diff.header.status \
2442 -width $max_status_desc \
2445 label .vpane.lower.
diff.header.
file \
2449 label .vpane.lower.
diff.header.path \
2453 pack .vpane.lower.
diff.header.status
-side left
2454 pack .vpane.lower.
diff.header.
file -side left
2455 pack .vpane.lower.
diff.header.path
-fill x
2456 set ctxm .vpane.lower.
diff.header.ctxm
2457 menu
$ctxm -tearoff 0
2465 -- $current_diff_path
2467 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2468 bind_button3 .vpane.lower.
diff.header.path
"tk_popup $ctxm %X %Y"
2472 frame .vpane.lower.
diff.body
2473 set ui_diff .vpane.lower.
diff.body.t
2474 text
$ui_diff -background white
-borderwidth 0 \
2475 -width 80 -height 15 -wrap none \
2477 -xscrollcommand {.vpane.lower.
diff.body.sbx
set} \
2478 -yscrollcommand {.vpane.lower.
diff.body.sby
set} \
2480 scrollbar .vpane.lower.
diff.body.sbx
-orient horizontal \
2481 -command [list
$ui_diff xview
]
2482 scrollbar .vpane.lower.
diff.body.sby
-orient vertical \
2483 -command [list
$ui_diff yview
]
2484 pack .vpane.lower.
diff.body.sbx
-side bottom
-fill x
2485 pack .vpane.lower.
diff.body.sby
-side right
-fill y
2486 pack
$ui_diff -side left
-fill both
-expand 1
2487 pack .vpane.lower.
diff.header
-side top
-fill x
2488 pack .vpane.lower.
diff.body
-side bottom
-fill both
-expand 1
2490 $ui_diff tag conf d_cr
-elide true
2491 $ui_diff tag conf d_@
-foreground blue
-font font_diffbold
2492 $ui_diff tag conf d_
+ -foreground {#00a000}
2493 $ui_diff tag conf d_-
-foreground red
2495 $ui_diff tag conf d_
++ -foreground {#00a000}
2496 $ui_diff tag conf d_--
-foreground red
2497 $ui_diff tag conf d_
+s \
2498 -foreground {#00a000} \
2499 -background {#e2effa}
2500 $ui_diff tag conf d_-s \
2502 -background {#e2effa}
2503 $ui_diff tag conf d_s
+ \
2504 -foreground {#00a000} \
2506 $ui_diff tag conf d_s- \
2510 $ui_diff tag conf d
<<<<<<< \
2511 -foreground orange \
2513 $ui_diff tag conf d
======= \
2514 -foreground orange \
2516 $ui_diff tag conf d
>>>>>>> \
2517 -foreground orange \
2520 $ui_diff tag raise sel
2522 # -- Diff Body Context Menu
2524 set ctxm .vpane.lower.
diff.body.ctxm
2525 menu
$ctxm -tearoff 0
2527 -label [mc Refresh
] \
2528 -command reshow_diff
2529 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2532 -command {tk_textCopy
$ui_diff}
2533 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2535 -label [mc
"Select All"] \
2536 -command {focus
$ui_diff;$ui_diff tag add sel
0.0 end
}
2537 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2539 -label [mc
"Copy All"] \
2541 $ui_diff tag add sel
0.0 end
2542 tk_textCopy
$ui_diff
2543 $ui_diff tag remove sel
0.0 end
2545 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2548 -label [mc
"Apply/Reverse Hunk"] \
2549 -command {apply_hunk
$cursorX $cursorY}
2550 set ui_diff_applyhunk
[$ctxm index last
]
2551 lappend diff_actions
[list
$ctxm entryconf
$ui_diff_applyhunk -state]
2554 -label [mc
"Decrease Font Size"] \
2555 -command {incr_font_size font_diff
-1}
2556 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2558 -label [mc
"Increase Font Size"] \
2559 -command {incr_font_size font_diff
1}
2560 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2563 -label [mc
"Show Less Context"] \
2564 -command {if {$repo_config(gui.diffcontext
) >= 1} {
2565 incr repo_config
(gui.diffcontext
) -1
2568 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2570 -label [mc
"Show More Context"] \
2571 -command {if {$repo_config(gui.diffcontext
) < 99} {
2572 incr repo_config
(gui.diffcontext
)
2575 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2577 $ctxm add
command -label [mc
"Options..."] \
2579 proc popup_diff_menu
{ctxm x y X Y
} {
2580 global current_diff_path file_states
2583 if {$
::ui_index eq $
::current_diff_side
} {
2584 set l
[mc
"Unstage Hunk From Commit"]
2586 set l
[mc
"Stage Hunk For Commit"]
2589 ||
$current_diff_path eq
{}
2590 ||
![info exists file_states
($current_diff_path)]
2591 ||
{_O
} eq
[lindex
$file_states($current_diff_path) 0]} {
2596 $ctxm entryconf $
::ui_diff_applyhunk
-state $s -label $l
2597 tk_popup
$ctxm $X $Y
2599 bind_button3
$ui_diff [list popup_diff_menu
$ctxm %x
%y
%X
%Y
]
2603 set main_status
[::status_bar
::new .status
]
2604 pack .status
-anchor w
-side bottom
-fill x
2605 $main_status show
[mc
"Initializing..."]
2610 set gm
$repo_config(gui.geometry
)
2611 wm geometry .
[lindex
$gm 0]
2612 .vpane sash place
0 \
2614 [lindex
[.vpane sash coord
0] 1]
2615 .vpane.files sash place
0 \
2616 [lindex
[.vpane.files sash coord
0] 0] \
2623 bind $ui_comm <$M1B-Key-Return> {do_commit
;break}
2624 bind $ui_comm <$M1B-Key-i> {do_add_all
;break}
2625 bind $ui_comm <$M1B-Key-I> {do_add_all
;break}
2626 bind $ui_comm <$M1B-Key-x> {tk_textCut
%W
;break}
2627 bind $ui_comm <$M1B-Key-X> {tk_textCut
%W
;break}
2628 bind $ui_comm <$M1B-Key-c> {tk_textCopy
%W
;break}
2629 bind $ui_comm <$M1B-Key-C> {tk_textCopy
%W
;break}
2630 bind $ui_comm <$M1B-Key-v> {tk_textPaste
%W
; %W see insert
; break}
2631 bind $ui_comm <$M1B-Key-V> {tk_textPaste
%W
; %W see insert
; break}
2632 bind $ui_comm <$M1B-Key-a> {%W tag add sel
0.0 end
;break}
2633 bind $ui_comm <$M1B-Key-A> {%W tag add sel
0.0 end
;break}
2635 bind $ui_diff <$M1B-Key-x> {tk_textCopy
%W
;break}
2636 bind $ui_diff <$M1B-Key-X> {tk_textCopy
%W
;break}
2637 bind $ui_diff <$M1B-Key-c> {tk_textCopy
%W
;break}
2638 bind $ui_diff <$M1B-Key-C> {tk_textCopy
%W
;break}
2639 bind $ui_diff <$M1B-Key-v> {break}
2640 bind $ui_diff <$M1B-Key-V> {break}
2641 bind $ui_diff <$M1B-Key-a> {%W tag add sel
0.0 end
;break}
2642 bind $ui_diff <$M1B-Key-A> {%W tag add sel
0.0 end
;break}
2643 bind $ui_diff <Key-Up
> {catch
{%W yview scroll
-1 units
};break}
2644 bind $ui_diff <Key-Down
> {catch
{%W yview scroll
1 units
};break}
2645 bind $ui_diff <Key-Left
> {catch
{%W xview scroll
-1 units
};break}
2646 bind $ui_diff <Key-Right
> {catch
{%W xview scroll
1 units
};break}
2647 bind $ui_diff <Key-k
> {catch
{%W yview scroll
-1 units
};break}
2648 bind $ui_diff <Key-j
> {catch
{%W yview scroll
1 units
};break}
2649 bind $ui_diff <Key-h
> {catch
{%W xview scroll
-1 units
};break}
2650 bind $ui_diff <Key-l
> {catch
{%W xview scroll
1 units
};break}
2651 bind $ui_diff <Control-Key-b
> {catch
{%W yview scroll
-1 pages
};break}
2652 bind $ui_diff <Control-Key-f
> {catch
{%W yview scroll
1 pages
};break}
2653 bind $ui_diff <Button-1
> {focus
%W
}
2655 if {[is_enabled branch
]} {
2656 bind .
<$M1B-Key-n> branch_create
::dialog
2657 bind .
<$M1B-Key-N> branch_create
::dialog
2658 bind .
<$M1B-Key-o> branch_checkout
::dialog
2659 bind .
<$M1B-Key-O> branch_checkout
::dialog
2660 bind .
<$M1B-Key-m> merge
::dialog
2661 bind .
<$M1B-Key-M> merge
::dialog
2663 if {[is_enabled transport
]} {
2664 bind .
<$M1B-Key-p> do_push_anywhere
2665 bind .
<$M1B-Key-P> do_push_anywhere
2668 bind .
<Key-F5
> do_rescan
2669 bind .
<$M1B-Key-r> do_rescan
2670 bind .
<$M1B-Key-R> do_rescan
2671 bind .
<$M1B-Key-s> do_signoff
2672 bind .
<$M1B-Key-S> do_signoff
2673 bind .
<$M1B-Key-i> do_add_all
2674 bind .
<$M1B-Key-I> do_add_all
2675 bind .
<$M1B-Key-Return> do_commit
2676 foreach i
[list
$ui_index $ui_workdir] {
2677 bind $i <Button-1
> "toggle_or_diff $i %x %y; break"
2678 bind $i <$M1B-Button-1> "add_one_to_selection $i %x %y; break"
2679 bind $i <Shift-Button-1
> "add_range_to_selection $i %x %y; break"
2683 set file_lists
($ui_index) [list
]
2684 set file_lists
($ui_workdir) [list
]
2686 wm title .
"[appname] ([reponame]) [file normalize [file dirname [gitdir]]]"
2687 focus
-force $ui_comm
2689 # -- Warn the user about environmental problems. Cygwin's Tcl
2690 # does *not* pass its env array onto any processes it spawns.
2691 # This means that git processes get none of our environment.
2696 set msg
[mc
"Possible environment issues exist.
2698 The following environment variables are probably
2699 going to be ignored by any Git subprocess run
2703 foreach name
[array names env
] {
2704 switch
-regexp -- $name {
2705 {^GIT_INDEX_FILE$
} -
2706 {^GIT_OBJECT_DIRECTORY$
} -
2707 {^GIT_ALTERNATE_OBJECT_DIRECTORIES$
} -
2709 {^GIT_EXTERNAL_DIFF$
} -
2713 {^GIT_CONFIG_LOCAL$
} -
2714 {^GIT_
(AUTHOR|COMMITTER
)_DATE$
} {
2715 append msg
" - $name\n"
2718 {^GIT_
(AUTHOR|COMMITTER
)_
(NAME|EMAIL
)$
} {
2719 append msg
" - $name\n"
2721 set suggest_user
$name
2725 if {$ignored_env > 0} {
2727 This is due to a known issue with the
2728 Tcl binary distributed by Cygwin."]
2730 if {$suggest_user ne
{}} {
2733 A good replacement for %s
2734 is placing values for the user.name and
2735 user.email settings into your personal
2741 unset ignored_env msg suggest_user name
2744 # -- Only initialize complex UI if we are going to stay running.
2746 if {[is_enabled transport
]} {
2749 set n
[.mbar.remote index end
]
2752 set n
[expr {[.mbar.remote index end
] - $n}]
2754 .mbar.remote insert
$n separator
2759 if {[winfo exists
$ui_comm]} {
2760 set GITGUI_BCK_exists
[load_message GITGUI_BCK
]
2762 # -- If both our backup and message files exist use the
2763 # newer of the two files to initialize the buffer.
2765 if {$GITGUI_BCK_exists} {
2766 set m
[gitdir GITGUI_MSG
]
2767 if {[file isfile
$m]} {
2768 if {[file mtime
[gitdir GITGUI_BCK
]] > [file mtime
$m]} {
2769 catch
{file delete
[gitdir GITGUI_MSG
]}
2771 $ui_comm delete
0.0 end
2773 $ui_comm edit modified false
2774 catch
{file delete
[gitdir GITGUI_BCK
]}
2775 set GITGUI_BCK_exists
0
2781 proc backup_commit_buffer
{} {
2782 global ui_comm GITGUI_BCK_exists
2784 set m
[$ui_comm edit modified
]
2785 if {$m ||
$GITGUI_BCK_exists} {
2786 set msg
[string trim
[$ui_comm get
0.0 end
]]
2787 regsub
-all -line {[ \r\t]+$
} $msg {} msg
2790 if {$GITGUI_BCK_exists} {
2791 catch
{file delete
[gitdir GITGUI_BCK
]}
2792 set GITGUI_BCK_exists
0
2796 set fd
[open
[gitdir GITGUI_BCK
] w
]
2797 puts
-nonewline $fd $msg
2799 set GITGUI_BCK_exists
1
2803 $ui_comm edit modified false
2806 set ::GITGUI_BCK_i
[after
2000 backup_commit_buffer
]
2809 backup_commit_buffer
2812 lock_index begin-read
2813 if {![winfo ismapped .
]} {
2817 if {[is_enabled multicommit
]} {