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} {
759 [list git_read config] \
761 [list --null --list]]
762 fconfigure $fd_rc -translation binary
763 set buf [read $fd_rc]
766 foreach line [split $buf "\
0"] {
767 if {[regexp {^([^\n]+)\n(.*)$} $line line name value]} {
768 if {[is_many_config $name]} {
769 lappend arr($name) $value
771 set arr($name) $value
780 set fd_rc [eval [list git_read config --list] $args]
781 while {[gets $fd_rc line] >= 0} {
782 if {[regexp {^([^=]+)=(.*)$} $line line name value]} {
783 if {[is_many_config $name]} {
784 lappend arr($name) $value
786 set arr($name) $value
795 proc load_config {include_global} {
796 global repo_config global_config default_config
798 if {$include_global} {
799 _parse_config global_config --global
801 _parse_config repo_config
803 foreach name [array names default_config] {
804 if {[catch {set v $global_config($name)}]} {
805 set global_config($name) $default_config($name)
807 if {[catch {set v $repo_config($name)}]} {
808 set repo_config($name) $default_config($name)
813 ######################################################################
815 ## feature option selection
817 if {[regexp {^git-(.+)$} [file tail $argv0] _junk subcommand]} {
822 if {$subcommand eq {gui.sh}} {
825 if {$subcommand eq {gui} && [llength $argv] > 0} {
826 set subcommand [lindex $argv 0]
827 set argv [lrange $argv 1 end]
830 enable_option multicommit
832 enable_option transport
835 switch -- $subcommand {
840 disable_option multicommit
841 disable_option branch
842 disable_option transport
845 enable_option singlecommit
847 disable_option multicommit
848 disable_option branch
849 disable_option transport
853 ######################################################################
858 set _gitdir $env(GIT_DIR)
862 set _gitdir [git rev-parse --git-dir]
863 set _prefix [git rev-parse --show-prefix]
867 choose_repository::pick
869 if {![file isdirectory $_gitdir] && [is_Cygwin]} {
870 catch {set _gitdir [exec cygpath --windows $_gitdir]}
872 if {![file isdirectory $_gitdir]} {
873 catch {wm withdraw .}
874 error_popup [strcat [mc "Git directory not found
:"] "\n\n$_gitdir"]
877 if {$_prefix ne {}} {
878 regsub -all {[^/]+/} $_prefix ../ cdup
879 if {[catch {cd $cdup} err]} {
880 catch {wm withdraw .}
881 error_popup [strcat [mc "Cannot move to top of working directory
:"] "\n\n$err"]
885 } elseif {![is_enabled bare]} {
886 if {[lindex [file split $_gitdir] end] ne {.git}} {
887 catch {wm withdraw .}
888 error_popup [strcat [mc "Cannot use funny .git directory
:"] "\n\n$_gitdir"]
891 if {[catch {cd [file dirname $_gitdir]} err]} {
892 catch {wm withdraw .}
893 error_popup [strcat [mc "No working directory
"] " [file dirname $_gitdir]:\n\n$err"]
897 set _reponame [file split [file normalize $_gitdir]]
898 if {[lindex $_reponame end] eq {.git}} {
899 set _reponame [lindex $_reponame end-1]
901 set _reponame [lindex $_reponame end]
904 ######################################################################
908 set current_diff_path {}
909 set current_diff_side {}
910 set diff_actions [list]
914 set MERGE_HEAD [list]
917 set current_branch {}
919 set current_diff_path {}
921 set selected_commit_type new
923 ######################################################################
931 set disable_on_lock [list]
932 set index_lock_type none
934 proc lock_index {type} {
935 global index_lock_type disable_on_lock
937 if {$index_lock_type eq {none}} {
938 set index_lock_type $type
939 foreach w $disable_on_lock {
940 uplevel #0 $w disabled
943 } elseif {$index_lock_type eq "begin-
$type"} {
944 set index_lock_type $type
950 proc unlock_index {} {
951 global index_lock_type disable_on_lock
953 set index_lock_type none
954 foreach w $disable_on_lock {
959 ######################################################################
963 proc repository_state {ctvar hdvar mhvar} {
964 global current_branch
965 upvar $ctvar ct $hdvar hd $mhvar mh
970 if {[catch {set hd [git rev-parse --verify HEAD]}]} {
976 set merge_head [gitdir MERGE_HEAD]
977 if {[file exists $merge_head]} {
979 set fd_mh [open $merge_head r]
980 while {[gets $fd_mh line] >= 0} {
991 global PARENT empty_tree
993 set p [lindex $PARENT 0]
997 if {$empty_tree eq {}} {
998 set empty_tree [git mktree << {}]
1003 proc rescan {after {honor_trustmtime 1}} {
1004 global HEAD PARENT MERGE_HEAD commit_type
1005 global ui_index ui_workdir ui_comm
1006 global rescan_active file_states
1009 if {$rescan_active > 0 || ![lock_index read]} return
1011 repository_state newType newHEAD newMERGE_HEAD
1012 if {[string match amend* $commit_type]
1013 && $newType eq {normal}
1014 && $newHEAD eq $HEAD} {
1018 set MERGE_HEAD $newMERGE_HEAD
1019 set commit_type $newType
1022 array unset file_states
1024 if {!$::GITGUI_BCK_exists &&
1025 (![$ui_comm edit modified]
1026 || [string trim [$ui_comm get 0.0 end]] eq {})} {
1027 if {[string match amend* $commit_type]} {
1028 } elseif {[load_message GITGUI_MSG]} {
1029 } elseif {[load_message MERGE_MSG]} {
1030 } elseif {[load_message SQUASH_MSG]} {
1033 $ui_comm edit modified false
1036 if {$honor_trustmtime && $repo_config(gui.trustmtime) eq {true}} {
1037 rescan_stage2 {} $after
1040 ui_status [mc "Refreshing
file status...
"]
1041 set fd_rf [git_read update-index \
1047 fconfigure $fd_rf -blocking 0 -translation binary
1048 fileevent $fd_rf readable \
1049 [list rescan_stage2 $fd_rf $after]
1054 set is_git_info_link {}
1055 set is_git_info_exclude {}
1056 proc have_info_exclude {} {
1057 global is_git_info_link is_git_info_exclude
1059 if {$is_git_info_link eq {}} {
1060 set is_git_info_link [file isfile [gitdir info.lnk]]
1063 if {$is_git_info_link} {
1064 if {$is_git_info_exclude eq {}} {
1065 if {[catch {exec test -f [gitdir info exclude]}]} {
1066 set is_git_info_exclude 0
1068 set is_git_info_exclude 1
1071 return $is_git_info_exclude
1073 return [file readable [gitdir info exclude]]
1077 proc have_info_exclude {} {
1078 return [file readable [gitdir info exclude]]
1082 proc rescan_stage2 {fd after} {
1083 global rescan_active buf_rdi buf_rdf buf_rlo
1087 if {![eof $fd]} return
1091 set ls_others [list --exclude-per-directory=.gitignore]
1092 if {[have_info_exclude]} {
1093 lappend ls_others "--exclude-from=[gitdir info exclude
]"
1095 set user_exclude [get_config core.excludesfile]
1096 if {$user_exclude ne {} && [file readable $user_exclude]} {
1097 lappend ls_others "--exclude-from=$user_exclude"
1105 ui_status [mc "Scanning
for modified files ...
"]
1106 set fd_di [git_read diff-index --cached -z [PARENT]]
1107 set fd_df [git_read diff-files -z]
1108 set fd_lo [eval git_read ls-files --others -z $ls_others]
1110 fconfigure $fd_di -blocking 0 -translation binary -encoding binary
1111 fconfigure $fd_df -blocking 0 -translation binary -encoding binary
1112 fconfigure $fd_lo -blocking 0 -translation binary -encoding binary
1113 fileevent $fd_di readable [list read_diff_index $fd_di $after]
1114 fileevent $fd_df readable [list read_diff_files $fd_df $after]
1115 fileevent $fd_lo readable [list read_ls_others $fd_lo $after]
1118 proc load_message {file} {
1121 set f [gitdir $file]
1122 if {[file isfile $f]} {
1123 if {[catch {set fd [open $f r]}]} {
1126 fconfigure $fd -eofchar {}
1127 set content [string trim [read $fd]]
1129 regsub -all -line {[ \r\t]+$} $content {} content
1130 $ui_comm delete 0.0 end
1131 $ui_comm insert end $content
1137 proc read_diff_index {fd after} {
1140 append buf_rdi [read $fd]
1142 set n [string length $buf_rdi]
1144 set z1 [string first "\
0" $buf_rdi $c]
1145 if {$z1 == -1} break
1147 set z2 [string first "\
0" $buf_rdi $z1]
1148 if {$z2 == -1} break
1151 set i [split [string range $buf_rdi $c [expr {$z1 - 2}]] { }]
1152 set p [string range $buf_rdi $z1 [expr {$z2 - 1}]]
1154 [encoding convertfrom $p] \
1156 [list [lindex $i 0] [lindex $i 2]] \
1162 set buf_rdi [string range $buf_rdi $c end]
1167 rescan_done $fd buf_rdi $after
1170 proc read_diff_files {fd after} {
1173 append buf_rdf [read $fd]
1175 set n [string length $buf_rdf]
1177 set z1 [string first "\
0" $buf_rdf $c]
1178 if {$z1 == -1} break
1180 set z2 [string first "\
0" $buf_rdf $z1]
1181 if {$z2 == -1} break
1184 set i [split [string range $buf_rdf $c [expr {$z1 - 2}]] { }]
1185 set p [string range $buf_rdf $z1 [expr {$z2 - 1}]]
1187 [encoding convertfrom $p] \
1190 [list [lindex $i 0] [lindex $i 2]]
1195 set buf_rdf [string range $buf_rdf $c end]
1200 rescan_done $fd buf_rdf $after
1203 proc read_ls_others {fd after} {
1206 append buf_rlo [read $fd]
1207 set pck [split $buf_rlo "\
0"]
1208 set buf_rlo [lindex $pck end]
1209 foreach p [lrange $pck 0 end-1] {
1210 set p [encoding convertfrom $p]
1211 if {[string index $p end] eq {/}} {
1212 set p [string range $p 0 end-1]
1216 rescan_done $fd buf_rlo $after
1219 proc rescan_done {fd buf after} {
1220 global rescan_active current_diff_path
1221 global file_states repo_config
1224 if {![eof $fd]} return
1227 if {[incr rescan_active -1] > 0} return
1232 if {$current_diff_path ne {}} reshow_diff
1236 proc prune_selection {} {
1237 global file_states selected_paths
1239 foreach path [array names selected_paths] {
1240 if {[catch {set still_here $file_states($path)}]} {
1241 unset selected_paths($path)
1246 ######################################################################
1250 proc mapicon {w state path} {
1253 if {[catch {set r $all_icons($state$w)}]} {
1254 puts "error
: no icon
for $w state
={$state} $path"
1260 proc mapdesc {state path} {
1263 if {[catch {set r $all_descs($state)}]} {
1264 puts "error
: no desc
for state
={$state} $path"
1270 proc ui_status {msg} {
1272 if {[info exists main_status]} {
1273 $main_status show $msg
1277 proc ui_ready {{test {}}} {
1279 if {[info exists main_status]} {
1280 $main_status show [mc "Ready.
"] $test
1284 proc escape_path {path} {
1285 regsub -all {\\} $path "\\\\" path
1286 regsub -all "\n" $path "\\n
" path
1290 proc short_path {path} {
1291 return [escape_path [lindex [file split $path] end]]
1295 set null_sha1 [string repeat 0 40]
1297 proc merge_state {path new_state {head_info {}} {index_info {}}} {
1298 global file_states next_icon_id null_sha1
1300 set s0 [string index $new_state 0]
1301 set s1 [string index $new_state 1]
1303 if {[catch {set info $file_states($path)}]} {
1305 set icon n[incr next_icon_id]
1307 set state [lindex $info 0]
1308 set icon [lindex $info 1]
1309 if {$head_info eq {}} {set head_info [lindex $info 2]}
1310 if {$index_info eq {}} {set index_info [lindex $info 3]}
1313 if {$s0 eq {?}} {set s0 [string index $state 0]} \
1314 elseif {$s0 eq {_}} {set s0 _}
1316 if {$s1 eq {?}} {set s1 [string index $state 1]} \
1317 elseif {$s1 eq {_}} {set s1 _}
1319 if {$s0 eq {A} && $s1 eq {_} && $head_info eq {}} {
1320 set head_info [list 0 $null_sha1]
1321 } elseif {$s0 ne {_} && [string index $state 0] eq {_}
1322 && $head_info eq {}} {
1323 set head_info $index_info
1326 set file_states($path) [list $s0$s1 $icon \
1327 $head_info $index_info \
1332 proc display_file_helper {w path icon_name old_m new_m} {
1335 if {$new_m eq {_}} {
1336 set lno [lsearch -sorted -exact $file_lists($w) $path]
1338 set file_lists($w) [lreplace $file_lists($w) $lno $lno]
1340 $w conf -state normal
1341 $w delete $lno.0 [expr {$lno + 1}].0
1342 $w conf -state disabled
1344 } elseif {$old_m eq {_} && $new_m ne {_}} {
1345 lappend file_lists($w) $path
1346 set file_lists($w) [lsort -unique $file_lists($w)]
1347 set lno [lsearch -sorted -exact $file_lists($w) $path]
1349 $w conf -state normal
1350 $w image create $lno.0 \
1351 -align center -padx 5 -pady 1 \
1353 -image [mapicon $w $new_m $path]
1354 $w insert $lno.1 "[escape_path
$path]\n"
1355 $w conf -state disabled
1356 } elseif {$old_m ne $new_m} {
1357 $w conf -state normal
1358 $w image conf $icon_name -image [mapicon $w $new_m $path]
1359 $w conf -state disabled
1363 proc display_file {path state} {
1364 global file_states selected_paths
1365 global ui_index ui_workdir
1367 set old_m [merge_state $path $state]
1368 set s $file_states($path)
1369 set new_m [lindex $s 0]
1370 set icon_name [lindex $s 1]
1372 set o [string index $old_m 0]
1373 set n [string index $new_m 0]
1380 display_file_helper $ui_index $path $icon_name $o $n
1382 if {[string index $old_m 0] eq {U}} {
1385 set o [string index $old_m 1]
1387 if {[string index $new_m 0] eq {U}} {
1390 set n [string index $new_m 1]
1392 display_file_helper $ui_workdir $path $icon_name $o $n
1394 if {$new_m eq {__}} {
1395 unset file_states($path)
1396 catch {unset selected_paths($path)}
1400 proc display_all_files_helper {w path icon_name m} {
1403 lappend file_lists($w) $path
1404 set lno [expr {[lindex [split [$w index end] .] 0] - 1}]
1405 $w image create end \
1406 -align center -padx 5 -pady 1 \
1408 -image [mapicon $w $m $path]
1409 $w insert end "[escape_path
$path]\n"
1412 proc display_all_files {} {
1413 global ui_index ui_workdir
1414 global file_states file_lists
1417 $ui_index conf -state normal
1418 $ui_workdir conf -state normal
1420 $ui_index delete 0.0 end
1421 $ui_workdir delete 0.0 end
1424 set file_lists($ui_index) [list]
1425 set file_lists($ui_workdir) [list]
1427 foreach path [lsort [array names file_states]] {
1428 set s $file_states($path)
1430 set icon_name [lindex $s 1]
1432 set s [string index $m 0]
1433 if {$s ne {U} && $s ne {_}} {
1434 display_all_files_helper $ui_index $path \
1438 if {[string index $m 0] eq {U}} {
1441 set s [string index $m 1]
1444 display_all_files_helper $ui_workdir $path \
1449 $ui_index conf -state disabled
1450 $ui_workdir conf -state disabled
1453 ######################################################################
1458 #define mask_width 14
1459 #define mask_height 15
1460 static unsigned char mask_bits[] = {
1461 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
1462 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
1463 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f};
1466 image create bitmap file_plain -background white -foreground black -data {
1467 #define plain_width 14
1468 #define plain_height 15
1469 static unsigned char plain_bits[] = {
1470 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
1471 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10,
1472 0x02, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1473 } -maskdata $filemask
1475 image create bitmap file_mod -background white -foreground blue -data {
1476 #define mod_width 14
1477 #define mod_height 15
1478 static unsigned char mod_bits[] = {
1479 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
1480 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
1481 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
1482 } -maskdata $filemask
1484 image create bitmap file_fulltick -background white -foreground "#007000" -data {
1485 #define file_fulltick_width 14
1486 #define file_fulltick_height 15
1487 static unsigned char file_fulltick_bits
[] = {
1488 0xfe, 0x01, 0x02, 0x1a, 0x02, 0x0c, 0x02, 0x0c, 0x02, 0x16, 0x02, 0x16,
1489 0x02, 0x13, 0x00, 0x13, 0x86, 0x11, 0x8c, 0x11, 0xd8, 0x10, 0xf2, 0x10,
1490 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1491 } -maskdata $filemask
1493 image create bitmap file_parttick
-background white
-foreground "#005050" -data {
1494 #define parttick_width 14
1495 #define parttick_height 15
1496 static unsigned char parttick_bits
[] = {
1497 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
1498 0x7a, 0x14, 0x02, 0x16, 0x02, 0x13, 0x8a, 0x11, 0xda, 0x10, 0x72, 0x10,
1499 0x22, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1500 } -maskdata $filemask
1502 image create bitmap file_question
-background white
-foreground black
-data {
1503 #define file_question_width 14
1504 #define file_question_height 15
1505 static unsigned char file_question_bits
[] = {
1506 0xfe, 0x01, 0x02, 0x02, 0xe2, 0x04, 0xf2, 0x09, 0x1a, 0x1b, 0x0a, 0x13,
1507 0x82, 0x11, 0xc2, 0x10, 0x62, 0x10, 0x62, 0x10, 0x02, 0x10, 0x62, 0x10,
1508 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1509 } -maskdata $filemask
1511 image create bitmap file_removed
-background white
-foreground red
-data {
1512 #define file_removed_width 14
1513 #define file_removed_height 15
1514 static unsigned char file_removed_bits
[] = {
1515 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
1516 0x1a, 0x16, 0x32, 0x13, 0xe2, 0x11, 0xc2, 0x10, 0xe2, 0x11, 0x32, 0x13,
1517 0x1a, 0x16, 0x02, 0x10, 0xfe, 0x1f};
1518 } -maskdata $filemask
1520 image create bitmap file_merge
-background white
-foreground blue
-data {
1521 #define file_merge_width 14
1522 #define file_merge_height 15
1523 static unsigned char file_merge_bits
[] = {
1524 0xfe, 0x01, 0x02, 0x03, 0x62, 0x05, 0x62, 0x09, 0x62, 0x1f, 0x62, 0x10,
1525 0xfa, 0x11, 0xf2, 0x10, 0x62, 0x10, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
1526 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
1527 } -maskdata $filemask
1529 set ui_index .vpane.files.index.list
1530 set ui_workdir .vpane.files.workdir.list
1532 set all_icons
(_
$ui_index) file_plain
1533 set all_icons
(A
$ui_index) file_fulltick
1534 set all_icons
(M
$ui_index) file_fulltick
1535 set all_icons
(D
$ui_index) file_removed
1536 set all_icons
(U
$ui_index) file_merge
1538 set all_icons
(_
$ui_workdir) file_plain
1539 set all_icons
(M
$ui_workdir) file_mod
1540 set all_icons
(D
$ui_workdir) file_question
1541 set all_icons
(U
$ui_workdir) file_merge
1542 set all_icons
(O
$ui_workdir) file_plain
1544 set max_status_desc
0
1546 {__
{mc
"Unmodified"}}
1548 {_M
{mc
"Modified, not staged"}}
1549 {M_
{mc
"Staged for commit"}}
1550 {MM
{mc
"Portions staged for commit"}}
1551 {MD
{mc
"Staged for commit, missing"}}
1553 {_O
{mc
"Untracked, not staged"}}
1554 {A_
{mc
"Staged for commit"}}
1555 {AM
{mc
"Portions staged for commit"}}
1556 {AD
{mc
"Staged for commit, missing"}}
1559 {D_
{mc
"Staged for removal"}}
1560 {DO
{mc
"Staged for removal, still present"}}
1562 {U_
{mc
"Requires merge resolution"}}
1563 {UU
{mc
"Requires merge resolution"}}
1564 {UM
{mc
"Requires merge resolution"}}
1565 {UD
{mc
"Requires merge resolution"}}
1567 set text
[eval [lindex
$i 1]]
1568 if {$max_status_desc < [string length
$text]} {
1569 set max_status_desc
[string length
$text]
1571 set all_descs
([lindex
$i 0]) $text
1575 ######################################################################
1579 proc scrollbar2many
{list mode args
} {
1580 foreach w
$list {eval $w $mode $args}
1583 proc many2scrollbar
{list mode sb top bottom
} {
1584 $sb set $top $bottom
1585 foreach w
$list {$w $mode moveto
$top}
1588 proc incr_font_size
{font
{amt
1}} {
1589 set sz
[font configure
$font -size]
1591 font configure
$font -size $sz
1592 font configure
${font}bold
-size $sz
1593 font configure
${font}italic
-size $sz
1596 ######################################################################
1600 set starting_gitk_msg
[mc
"Starting gitk... please wait..."]
1602 proc do_gitk
{revs
} {
1603 # -- Always start gitk through whatever we were loaded with. This
1604 # lets us bypass using shell process on Windows systems.
1606 set exe
[file join [file dirname $
::_git
] gitk
]
1607 set cmd
[list
[info nameofexecutable
] $exe]
1608 if {! [file exists
$exe]} {
1609 error_popup
[mc
"Unable to start gitk:\n\n%s does not exist" $exe]
1613 if {[info exists env
(GIT_DIR
)]} {
1614 set old_GIT_DIR
$env(GIT_DIR
)
1620 cd [file dirname [gitdir
]]
1621 set env
(GIT_DIR
) [file tail [gitdir
]]
1623 eval exec $cmd $revs &
1625 if {$old_GIT_DIR eq
{}} {
1628 set env
(GIT_DIR
) $old_GIT_DIR
1632 ui_status $
::starting_gitk_msg
1634 ui_ready
$starting_gitk_msg
1642 global ui_comm is_quitting repo_config commit_type
1643 global GITGUI_BCK_exists GITGUI_BCK_i
1645 if {$is_quitting} return
1648 if {[winfo exists
$ui_comm]} {
1649 # -- Stash our current commit buffer.
1651 set save
[gitdir GITGUI_MSG
]
1652 if {$GITGUI_BCK_exists && ![$ui_comm edit modified
]} {
1653 file rename
-force [gitdir GITGUI_BCK
] $save
1654 set GITGUI_BCK_exists
0
1656 set msg
[string trim
[$ui_comm get
0.0 end
]]
1657 regsub
-all -line {[ \r\t]+$
} $msg {} msg
1658 if {(![string match amend
* $commit_type]
1659 ||
[$ui_comm edit modified
])
1662 set fd
[open
$save w
]
1663 puts
-nonewline $fd $msg
1667 catch
{file delete
$save}
1671 # -- Remove our editor backup, its not needed.
1673 after cancel
$GITGUI_BCK_i
1674 if {$GITGUI_BCK_exists} {
1675 catch
{file delete
[gitdir GITGUI_BCK
]}
1678 # -- Stash our current window geometry into this repository.
1680 set cfg_geometry
[list
]
1681 lappend cfg_geometry
[wm geometry .
]
1682 lappend cfg_geometry
[lindex
[.vpane sash coord
0] 0]
1683 lappend cfg_geometry
[lindex
[.vpane.files sash coord
0] 1]
1684 if {[catch
{set rc_geometry
$repo_config(gui.geometry
)}]} {
1687 if {$cfg_geometry ne
$rc_geometry} {
1688 catch
{git config gui.geometry
$cfg_geometry}
1703 proc toggle_or_diff
{w x y
} {
1704 global file_states file_lists current_diff_path ui_index ui_workdir
1705 global last_clicked selected_paths
1707 set pos
[split [$w index @
$x,$y] .
]
1708 set lno
[lindex
$pos 0]
1709 set col [lindex
$pos 1]
1710 set path
[lindex
$file_lists($w) [expr {$lno - 1}]]
1716 set last_clicked
[list
$w $lno]
1717 array
unset selected_paths
1718 $ui_index tag remove in_sel
0.0 end
1719 $ui_workdir tag remove in_sel
0.0 end
1722 if {$current_diff_path eq
$path} {
1723 set after
{reshow_diff
;}
1727 if {$w eq
$ui_index} {
1729 "Unstaging [short_path $path] from commit" \
1731 [concat
$after [list ui_ready
]]
1732 } elseif
{$w eq
$ui_workdir} {
1734 "Adding [short_path $path]" \
1736 [concat
$after [list ui_ready
]]
1739 show_diff
$path $w $lno
1743 proc add_one_to_selection
{w x y
} {
1744 global file_lists last_clicked selected_paths
1746 set lno
[lindex
[split [$w index @
$x,$y] .
] 0]
1747 set path
[lindex
$file_lists($w) [expr {$lno - 1}]]
1753 if {$last_clicked ne
{}
1754 && [lindex
$last_clicked 0] ne
$w} {
1755 array
unset selected_paths
1756 [lindex
$last_clicked 0] tag remove in_sel
0.0 end
1759 set last_clicked
[list
$w $lno]
1760 if {[catch
{set in_sel
$selected_paths($path)}]} {
1764 unset selected_paths
($path)
1765 $w tag remove in_sel
$lno.0 [expr {$lno + 1}].0
1767 set selected_paths
($path) 1
1768 $w tag add in_sel
$lno.0 [expr {$lno + 1}].0
1772 proc add_range_to_selection
{w x y
} {
1773 global file_lists last_clicked selected_paths
1775 if {[lindex
$last_clicked 0] ne
$w} {
1776 toggle_or_diff
$w $x $y
1780 set lno
[lindex
[split [$w index @
$x,$y] .
] 0]
1781 set lc
[lindex
$last_clicked 1]
1790 foreach path
[lrange
$file_lists($w) \
1791 [expr {$begin - 1}] \
1792 [expr {$end - 1}]] {
1793 set selected_paths
($path) 1
1795 $w tag add in_sel
$begin.0 [expr {$end + 1}].0
1798 ######################################################################
1808 menu .mbar
-tearoff 0
1809 .mbar add cascade
-label [mc Repository
] -menu .mbar.repository
1810 .mbar add cascade
-label [mc Edit
] -menu .mbar.edit
1811 if {[is_enabled branch
]} {
1812 .mbar add cascade
-label [mc Branch
] -menu .mbar.branch
1814 if {[is_enabled multicommit
] ||
[is_enabled singlecommit
]} {
1815 .mbar add cascade
-label [mc Commit@@noun
] -menu .mbar.commit
1817 if {[is_enabled transport
]} {
1818 .mbar add cascade
-label [mc Merge
] -menu .mbar.merge
1819 .mbar add cascade
-label [mc Remote
] -menu .mbar.remote
1821 . configure
-menu .mbar
1823 # -- Repository Menu
1825 menu .mbar.repository
1827 .mbar.repository add
command \
1828 -label [mc
"Browse Current Branch's Files"] \
1829 -command {browser
::new
$current_branch}
1830 set ui_browse_current
[.mbar.repository index last
]
1831 .mbar.repository add
command \
1832 -label [mc
"Browse Branch Files..."] \
1833 -command browser_open
::dialog
1834 .mbar.repository add separator
1836 .mbar.repository add
command \
1837 -label [mc
"Visualize Current Branch's History"] \
1838 -command {do_gitk
$current_branch}
1839 set ui_visualize_current
[.mbar.repository index last
]
1840 .mbar.repository add
command \
1841 -label [mc
"Visualize All Branch History"] \
1842 -command {do_gitk
--all}
1843 .mbar.repository add separator
1845 proc current_branch_write
{args
} {
1846 global current_branch
1847 .mbar.repository entryconf $
::ui_browse_current \
1848 -label [mc
"Browse %s's Files" $current_branch]
1849 .mbar.repository entryconf $
::ui_visualize_current \
1850 -label [mc
"Visualize %s's History" $current_branch]
1852 trace add variable current_branch
write current_branch_write
1854 if {[is_enabled multicommit
]} {
1855 .mbar.repository add
command -label [mc
"Database Statistics"] \
1858 .mbar.repository add
command -label [mc
"Compress Database"] \
1861 .mbar.repository add
command -label [mc
"Verify Database"] \
1862 -command do_fsck_objects
1864 .mbar.repository add separator
1867 .mbar.repository add
command \
1868 -label [mc
"Create Desktop Icon"] \
1869 -command do_cygwin_shortcut
1870 } elseif
{[is_Windows
]} {
1871 .mbar.repository add
command \
1872 -label [mc
"Create Desktop Icon"] \
1873 -command do_windows_shortcut
1874 } elseif
{[is_MacOSX
]} {
1875 .mbar.repository add
command \
1876 -label [mc
"Create Desktop Icon"] \
1877 -command do_macosx_app
1881 .mbar.repository add
command -label [mc Quit
] \
1888 .mbar.edit add
command -label [mc Undo
] \
1889 -command {catch
{[focus
] edit undo
}} \
1891 .mbar.edit add
command -label [mc Redo
] \
1892 -command {catch
{[focus
] edit redo
}} \
1894 .mbar.edit add separator
1895 .mbar.edit add
command -label [mc Cut
] \
1896 -command {catch
{tk_textCut
[focus
]}} \
1898 .mbar.edit add
command -label [mc Copy
] \
1899 -command {catch
{tk_textCopy
[focus
]}} \
1901 .mbar.edit add
command -label [mc Paste
] \
1902 -command {catch
{tk_textPaste
[focus
]; [focus
] see insert
}} \
1904 .mbar.edit add
command -label [mc Delete
] \
1905 -command {catch
{[focus
] delete sel.first sel.last
}} \
1907 .mbar.edit add separator
1908 .mbar.edit add
command -label [mc
"Select All"] \
1909 -command {catch
{[focus
] tag add sel
0.0 end
}} \
1914 if {[is_enabled branch
]} {
1917 .mbar.branch add
command -label [mc
"Create..."] \
1918 -command branch_create
::dialog \
1920 lappend disable_on_lock
[list .mbar.branch entryconf \
1921 [.mbar.branch index last
] -state]
1923 .mbar.branch add
command -label [mc
"Checkout..."] \
1924 -command branch_checkout
::dialog \
1926 lappend disable_on_lock
[list .mbar.branch entryconf \
1927 [.mbar.branch index last
] -state]
1929 .mbar.branch add
command -label [mc
"Rename..."] \
1930 -command branch_rename
::dialog
1931 lappend disable_on_lock
[list .mbar.branch entryconf \
1932 [.mbar.branch index last
] -state]
1934 .mbar.branch add
command -label [mc
"Delete..."] \
1935 -command branch_delete
::dialog
1936 lappend disable_on_lock
[list .mbar.branch entryconf \
1937 [.mbar.branch index last
] -state]
1939 .mbar.branch add
command -label [mc
"Reset..."] \
1940 -command merge
::reset_hard
1941 lappend disable_on_lock
[list .mbar.branch entryconf \
1942 [.mbar.branch index last
] -state]
1947 if {[is_enabled multicommit
] ||
[is_enabled singlecommit
]} {
1950 .mbar.commit add radiobutton \
1951 -label [mc
"New Commit"] \
1952 -command do_select_commit_type \
1953 -variable selected_commit_type \
1955 lappend disable_on_lock \
1956 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1958 .mbar.commit add radiobutton \
1959 -label [mc
"Amend Last Commit"] \
1960 -command do_select_commit_type \
1961 -variable selected_commit_type \
1963 lappend disable_on_lock \
1964 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1966 .mbar.commit add separator
1968 .mbar.commit add
command -label [mc Rescan
] \
1969 -command do_rescan \
1971 lappend disable_on_lock \
1972 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1974 .mbar.commit add
command -label [mc
"Stage To Commit"] \
1975 -command do_add_selection
1976 lappend disable_on_lock \
1977 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1979 .mbar.commit add
command -label [mc
"Stage Changed Files To Commit"] \
1980 -command do_add_all \
1982 lappend disable_on_lock \
1983 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1985 .mbar.commit add
command -label [mc
"Unstage From Commit"] \
1986 -command do_unstage_selection
1987 lappend disable_on_lock \
1988 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1990 .mbar.commit add
command -label [mc
"Revert Changes"] \
1991 -command do_revert_selection
1992 lappend disable_on_lock \
1993 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1995 .mbar.commit add separator
1997 .mbar.commit add
command -label [mc
"Sign Off"] \
1998 -command do_signoff \
2001 .mbar.commit add
command -label [mc Commit@@verb
] \
2002 -command do_commit \
2003 -accelerator $M1T-Return
2004 lappend disable_on_lock \
2005 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
2010 if {[is_enabled branch
]} {
2012 .mbar.merge add
command -label [mc
"Local Merge..."] \
2013 -command merge
::dialog \
2015 lappend disable_on_lock \
2016 [list .mbar.merge entryconf
[.mbar.merge index last
] -state]
2017 .mbar.merge add
command -label [mc
"Abort Merge..."] \
2018 -command merge
::reset_hard
2019 lappend disable_on_lock \
2020 [list .mbar.merge entryconf
[.mbar.merge index last
] -state]
2025 if {[is_enabled transport
]} {
2028 .mbar.remote add
command \
2029 -label [mc
"Push..."] \
2030 -command do_push_anywhere \
2032 .mbar.remote add
command \
2033 -label [mc
"Delete..."] \
2034 -command remote_branch_delete
::dialog
2038 # -- Apple Menu (Mac OS X only)
2040 .mbar add cascade
-label [mc Apple
] -menu .mbar.apple
2043 .mbar.apple add
command -label [mc
"About %s" [appname
]] \
2045 .mbar.apple add separator
2046 .mbar.apple add
command \
2047 -label [mc
"Preferences..."] \
2048 -command do_options \
2050 bind .
<$M1B-,> do_options
2054 .mbar.edit add separator
2055 .mbar.edit add
command -label [mc
"Options..."] \
2061 .mbar add cascade
-label [mc Help
] -menu .mbar.
help
2065 .mbar.
help add
command -label [mc
"About %s" [appname
]] \
2070 catch
{set browser
$repo_config(instaweb.browser
)}
2071 set doc_path
[file dirname [gitexec
]]
2072 set doc_path
[file join $doc_path Documentation index.html
]
2075 set doc_path
[exec cygpath
--mixed $doc_path]
2078 if {$browser eq
{}} {
2081 } elseif
{[is_Cygwin
]} {
2082 set program_files
[file dirname [exec cygpath
--windir]]
2083 set program_files
[file join $program_files {Program Files
}]
2084 set firefox
[file join $program_files {Mozilla Firefox
} firefox.exe
]
2085 set ie
[file join $program_files {Internet Explorer
} IEXPLORE.EXE
]
2086 if {[file exists
$firefox]} {
2087 set browser
$firefox
2088 } elseif
{[file exists
$ie]} {
2091 unset program_files firefox ie
2095 if {[file isfile
$doc_path]} {
2096 set doc_url
"file:$doc_path"
2098 set doc_url
{http
://www.kernel.org
/pub
/software
/scm
/git
/docs
/}
2101 if {$browser ne
{}} {
2102 .mbar.
help add
command -label [mc
"Online Documentation"] \
2103 -command [list
exec $browser $doc_url &]
2105 unset browser doc_path doc_url
2107 # -- Standard bindings
2109 wm protocol . WM_DELETE_WINDOW do_quit
2110 bind all
<$M1B-Key-q> do_quit
2111 bind all
<$M1B-Key-Q> do_quit
2112 bind all
<$M1B-Key-w> {destroy
[winfo toplevel
%W
]}
2113 bind all
<$M1B-Key-W> {destroy
[winfo toplevel
%W
]}
2115 set subcommand_args
{}
2117 puts stderr
"usage: $::argv0 $::subcommand $::subcommand_args"
2121 # -- Not a normal commit type invocation? Do that instead!
2123 switch
-- $subcommand {
2126 set subcommand_args
{rev? path
}
2127 if {$argv eq
{}} usage
2132 if {$is_path ||
[file exists
$_prefix$a]} {
2133 if {$path ne
{}} usage
2136 } elseif
{$a eq
{--}} {
2138 if {$head ne
{}} usage
2143 } elseif
{$head eq
{}} {
2144 if {$head ne
{}} usage
2153 if {$head ne
{} && $path eq
{}} {
2154 set path
$_prefix$head
2161 if {[regexp
{^
[0-9a-f]{1,39}$
} $head]} {
2163 set head [git rev-parse
--verify $head]
2169 set current_branch
$head
2172 switch
-- $subcommand {
2175 if {$path ne
{} && [file isdirectory
$path]} {
2176 set head $current_branch
2182 browser
::new
$head $path
2185 if {$head eq
{} && ![file exists
$path]} {
2186 puts stderr
[mc
"fatal: cannot stat path %s: No such file or directory" $path]
2189 blame
::new
$head $path
2196 if {[llength
$argv] != 0} {
2197 puts
-nonewline stderr
"usage: $argv0"
2198 if {$subcommand ne
{gui
}
2199 && [file tail $argv0] ne
"git-$subcommand"} {
2200 puts
-nonewline stderr
" $subcommand"
2205 # fall through to setup UI for commits
2208 puts stderr
"usage: $argv0 \[{blame|browser|citool}\]"
2219 -text [mc
"Current Branch:"] \
2223 -textvariable current_branch \
2226 pack .branch.l1
-side left
2227 pack .branch.cb
-side left
-fill x
2228 pack .branch
-side top
-fill x
2230 # -- Main Window Layout
2232 panedwindow .vpane
-orient horizontal
2233 panedwindow .vpane.files
-orient vertical
2234 .vpane add .vpane.files
-sticky nsew
-height 100 -width 200
2235 pack .vpane
-anchor n
-side top
-fill both
-expand 1
2237 # -- Index File List
2239 frame .vpane.files.index
-height 100 -width 200
2240 label .vpane.files.index.title
-text [mc
"Staged Changes (Will Commit)"] \
2241 -background lightgreen
2242 text
$ui_index -background white
-borderwidth 0 \
2243 -width 20 -height 10 \
2245 -cursor $cursor_ptr \
2246 -xscrollcommand {.vpane.files.index.sx
set} \
2247 -yscrollcommand {.vpane.files.index.sy
set} \
2249 scrollbar .vpane.files.index.sx
-orient h
-command [list
$ui_index xview
]
2250 scrollbar .vpane.files.index.sy
-orient v
-command [list
$ui_index yview
]
2251 pack .vpane.files.index.title
-side top
-fill x
2252 pack .vpane.files.index.sx
-side bottom
-fill x
2253 pack .vpane.files.index.sy
-side right
-fill y
2254 pack
$ui_index -side left
-fill both
-expand 1
2256 # -- Working Directory File List
2258 frame .vpane.files.workdir
-height 100 -width 200
2259 label .vpane.files.workdir.title
-text [mc
"Unstaged Changes"] \
2260 -background lightsalmon
2261 text
$ui_workdir -background white
-borderwidth 0 \
2262 -width 20 -height 10 \
2264 -cursor $cursor_ptr \
2265 -xscrollcommand {.vpane.files.workdir.sx
set} \
2266 -yscrollcommand {.vpane.files.workdir.sy
set} \
2268 scrollbar .vpane.files.workdir.sx
-orient h
-command [list
$ui_workdir xview
]
2269 scrollbar .vpane.files.workdir.sy
-orient v
-command [list
$ui_workdir yview
]
2270 pack .vpane.files.workdir.title
-side top
-fill x
2271 pack .vpane.files.workdir.sx
-side bottom
-fill x
2272 pack .vpane.files.workdir.sy
-side right
-fill y
2273 pack
$ui_workdir -side left
-fill both
-expand 1
2275 .vpane.files add .vpane.files.workdir
-sticky nsew
2276 .vpane.files add .vpane.files.index
-sticky nsew
2278 foreach i
[list
$ui_index $ui_workdir] {
2280 $i tag conf in_diff
-background [$i tag cget in_sel
-background]
2284 # -- Diff and Commit Area
2286 frame .vpane.lower
-height 300 -width 400
2287 frame .vpane.lower.commarea
2288 frame .vpane.lower.
diff -relief sunken
-borderwidth 1
2289 pack .vpane.lower.
diff -fill both
-expand 1
2290 pack .vpane.lower.commarea
-side bottom
-fill x
2291 .vpane add .vpane.lower
-sticky nsew
2293 # -- Commit Area Buttons
2295 frame .vpane.lower.commarea.buttons
2296 label .vpane.lower.commarea.buttons.l
-text {} \
2299 pack .vpane.lower.commarea.buttons.l
-side top
-fill x
2300 pack .vpane.lower.commarea.buttons
-side left
-fill y
2302 button .vpane.lower.commarea.buttons.rescan
-text [mc Rescan
] \
2304 pack .vpane.lower.commarea.buttons.rescan
-side top
-fill x
2305 lappend disable_on_lock \
2306 {.vpane.lower.commarea.buttons.rescan conf
-state}
2308 button .vpane.lower.commarea.buttons.incall
-text [mc
"Stage Changed"] \
2310 pack .vpane.lower.commarea.buttons.incall
-side top
-fill x
2311 lappend disable_on_lock \
2312 {.vpane.lower.commarea.buttons.incall conf
-state}
2314 button .vpane.lower.commarea.buttons.signoff
-text [mc
"Sign Off"] \
2316 pack .vpane.lower.commarea.buttons.signoff
-side top
-fill x
2318 button .vpane.lower.commarea.buttons.commit
-text [mc Commit@@verb
] \
2320 pack .vpane.lower.commarea.buttons.commit
-side top
-fill x
2321 lappend disable_on_lock \
2322 {.vpane.lower.commarea.buttons.commit conf
-state}
2324 button .vpane.lower.commarea.buttons.push
-text [mc Push
] \
2325 -command do_push_anywhere
2326 pack .vpane.lower.commarea.buttons.push
-side top
-fill x
2328 # -- Commit Message Buffer
2330 frame .vpane.lower.commarea.buffer
2331 frame .vpane.lower.commarea.buffer.header
2332 set ui_comm .vpane.lower.commarea.buffer.t
2333 set ui_coml .vpane.lower.commarea.buffer.header.l
2334 radiobutton .vpane.lower.commarea.buffer.header.new \
2335 -text [mc
"New Commit"] \
2336 -command do_select_commit_type \
2337 -variable selected_commit_type \
2339 lappend disable_on_lock \
2340 [list .vpane.lower.commarea.buffer.header.new conf
-state]
2341 radiobutton .vpane.lower.commarea.buffer.header.amend \
2342 -text [mc
"Amend Last Commit"] \
2343 -command do_select_commit_type \
2344 -variable selected_commit_type \
2346 lappend disable_on_lock \
2347 [list .vpane.lower.commarea.buffer.header.amend conf
-state]
2351 proc trace_commit_type
{varname args
} {
2352 global ui_coml commit_type
2353 switch
-glob -- $commit_type {
2354 initial
{set txt
[mc
"Initial Commit Message:"]}
2355 amend
{set txt
[mc
"Amended Commit Message:"]}
2356 amend-initial
{set txt
[mc
"Amended Initial Commit Message:"]}
2357 amend-merge
{set txt
[mc
"Amended Merge Commit Message:"]}
2358 merge
{set txt
[mc
"Merge Commit Message:"]}
2359 * {set txt
[mc
"Commit Message:"]}
2361 $ui_coml conf
-text $txt
2363 trace add variable commit_type
write trace_commit_type
2364 pack
$ui_coml -side left
-fill x
2365 pack .vpane.lower.commarea.buffer.header.amend
-side right
2366 pack .vpane.lower.commarea.buffer.header.new
-side right
2368 text
$ui_comm -background white
-borderwidth 1 \
2371 -autoseparators true \
2373 -width 75 -height 9 -wrap none \
2375 -yscrollcommand {.vpane.lower.commarea.buffer.sby
set}
2376 scrollbar .vpane.lower.commarea.buffer.sby \
2377 -command [list
$ui_comm yview
]
2378 pack .vpane.lower.commarea.buffer.header
-side top
-fill x
2379 pack .vpane.lower.commarea.buffer.sby
-side right
-fill y
2380 pack
$ui_comm -side left
-fill y
2381 pack .vpane.lower.commarea.buffer
-side left
-fill y
2383 # -- Commit Message Buffer Context Menu
2385 set ctxm .vpane.lower.commarea.buffer.ctxm
2386 menu
$ctxm -tearoff 0
2389 -command {tk_textCut
$ui_comm}
2392 -command {tk_textCopy
$ui_comm}
2395 -command {tk_textPaste
$ui_comm}
2397 -label [mc Delete
] \
2398 -command {$ui_comm delete sel.first sel.last
}
2401 -label [mc
"Select All"] \
2402 -command {focus
$ui_comm;$ui_comm tag add sel
0.0 end
}
2404 -label [mc
"Copy All"] \
2406 $ui_comm tag add sel
0.0 end
2407 tk_textCopy
$ui_comm
2408 $ui_comm tag remove sel
0.0 end
2412 -label [mc
"Sign Off"] \
2414 bind_button3
$ui_comm "tk_popup $ctxm %X %Y"
2418 proc trace_current_diff_path
{varname args
} {
2419 global current_diff_path diff_actions file_states
2420 if {$current_diff_path eq
{}} {
2426 set p
$current_diff_path
2427 set s
[mapdesc
[lindex
$file_states($p) 0] $p]
2429 set p
[escape_path
$p]
2433 .vpane.lower.
diff.header.status configure
-text $s
2434 .vpane.lower.
diff.header.
file configure
-text $f
2435 .vpane.lower.
diff.header.path configure
-text $p
2436 foreach w
$diff_actions {
2440 trace add variable current_diff_path
write trace_current_diff_path
2442 frame .vpane.lower.
diff.header
-background gold
2443 label .vpane.lower.
diff.header.status \
2445 -width $max_status_desc \
2448 label .vpane.lower.
diff.header.
file \
2452 label .vpane.lower.
diff.header.path \
2456 pack .vpane.lower.
diff.header.status
-side left
2457 pack .vpane.lower.
diff.header.
file -side left
2458 pack .vpane.lower.
diff.header.path
-fill x
2459 set ctxm .vpane.lower.
diff.header.ctxm
2460 menu
$ctxm -tearoff 0
2468 -- $current_diff_path
2470 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2471 bind_button3 .vpane.lower.
diff.header.path
"tk_popup $ctxm %X %Y"
2475 frame .vpane.lower.
diff.body
2476 set ui_diff .vpane.lower.
diff.body.t
2477 text
$ui_diff -background white
-borderwidth 0 \
2478 -width 80 -height 15 -wrap none \
2480 -xscrollcommand {.vpane.lower.
diff.body.sbx
set} \
2481 -yscrollcommand {.vpane.lower.
diff.body.sby
set} \
2483 scrollbar .vpane.lower.
diff.body.sbx
-orient horizontal \
2484 -command [list
$ui_diff xview
]
2485 scrollbar .vpane.lower.
diff.body.sby
-orient vertical \
2486 -command [list
$ui_diff yview
]
2487 pack .vpane.lower.
diff.body.sbx
-side bottom
-fill x
2488 pack .vpane.lower.
diff.body.sby
-side right
-fill y
2489 pack
$ui_diff -side left
-fill both
-expand 1
2490 pack .vpane.lower.
diff.header
-side top
-fill x
2491 pack .vpane.lower.
diff.body
-side bottom
-fill both
-expand 1
2493 $ui_diff tag conf d_cr
-elide true
2494 $ui_diff tag conf d_@
-foreground blue
-font font_diffbold
2495 $ui_diff tag conf d_
+ -foreground {#00a000}
2496 $ui_diff tag conf d_-
-foreground red
2498 $ui_diff tag conf d_
++ -foreground {#00a000}
2499 $ui_diff tag conf d_--
-foreground red
2500 $ui_diff tag conf d_
+s \
2501 -foreground {#00a000} \
2502 -background {#e2effa}
2503 $ui_diff tag conf d_-s \
2505 -background {#e2effa}
2506 $ui_diff tag conf d_s
+ \
2507 -foreground {#00a000} \
2509 $ui_diff tag conf d_s- \
2513 $ui_diff tag conf d
<<<<<<< \
2514 -foreground orange \
2516 $ui_diff tag conf d
======= \
2517 -foreground orange \
2519 $ui_diff tag conf d
>>>>>>> \
2520 -foreground orange \
2523 $ui_diff tag raise sel
2525 # -- Diff Body Context Menu
2527 set ctxm .vpane.lower.
diff.body.ctxm
2528 menu
$ctxm -tearoff 0
2530 -label [mc Refresh
] \
2531 -command reshow_diff
2532 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2535 -command {tk_textCopy
$ui_diff}
2536 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2538 -label [mc
"Select All"] \
2539 -command {focus
$ui_diff;$ui_diff tag add sel
0.0 end
}
2540 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2542 -label [mc
"Copy All"] \
2544 $ui_diff tag add sel
0.0 end
2545 tk_textCopy
$ui_diff
2546 $ui_diff tag remove sel
0.0 end
2548 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2551 -label [mc
"Apply/Reverse Hunk"] \
2552 -command {apply_hunk
$cursorX $cursorY}
2553 set ui_diff_applyhunk
[$ctxm index last
]
2554 lappend diff_actions
[list
$ctxm entryconf
$ui_diff_applyhunk -state]
2557 -label [mc
"Decrease Font Size"] \
2558 -command {incr_font_size font_diff
-1}
2559 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2561 -label [mc
"Increase Font Size"] \
2562 -command {incr_font_size font_diff
1}
2563 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2566 -label [mc
"Show Less Context"] \
2567 -command {if {$repo_config(gui.diffcontext
) >= 1} {
2568 incr repo_config
(gui.diffcontext
) -1
2571 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2573 -label [mc
"Show More Context"] \
2574 -command {if {$repo_config(gui.diffcontext
) < 99} {
2575 incr repo_config
(gui.diffcontext
)
2578 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2580 $ctxm add
command -label [mc
"Options..."] \
2582 proc popup_diff_menu
{ctxm x y X Y
} {
2583 global current_diff_path file_states
2586 if {$
::ui_index eq $
::current_diff_side
} {
2587 set l
[mc
"Unstage Hunk From Commit"]
2589 set l
[mc
"Stage Hunk For Commit"]
2592 ||
$current_diff_path eq
{}
2593 ||
![info exists file_states
($current_diff_path)]
2594 ||
{_O
} eq
[lindex
$file_states($current_diff_path) 0]} {
2599 $ctxm entryconf $
::ui_diff_applyhunk
-state $s -label $l
2600 tk_popup
$ctxm $X $Y
2602 bind_button3
$ui_diff [list popup_diff_menu
$ctxm %x
%y
%X
%Y
]
2606 set main_status
[::status_bar
::new .status
]
2607 pack .status
-anchor w
-side bottom
-fill x
2608 $main_status show
[mc
"Initializing..."]
2613 set gm
$repo_config(gui.geometry
)
2614 wm geometry .
[lindex
$gm 0]
2615 .vpane sash place
0 \
2617 [lindex
[.vpane sash coord
0] 1]
2618 .vpane.files sash place
0 \
2619 [lindex
[.vpane.files sash coord
0] 0] \
2626 bind $ui_comm <$M1B-Key-Return> {do_commit
;break}
2627 bind $ui_comm <$M1B-Key-i> {do_add_all
;break}
2628 bind $ui_comm <$M1B-Key-I> {do_add_all
;break}
2629 bind $ui_comm <$M1B-Key-x> {tk_textCut
%W
;break}
2630 bind $ui_comm <$M1B-Key-X> {tk_textCut
%W
;break}
2631 bind $ui_comm <$M1B-Key-c> {tk_textCopy
%W
;break}
2632 bind $ui_comm <$M1B-Key-C> {tk_textCopy
%W
;break}
2633 bind $ui_comm <$M1B-Key-v> {tk_textPaste
%W
; %W see insert
; break}
2634 bind $ui_comm <$M1B-Key-V> {tk_textPaste
%W
; %W see insert
; break}
2635 bind $ui_comm <$M1B-Key-a> {%W tag add sel
0.0 end
;break}
2636 bind $ui_comm <$M1B-Key-A> {%W tag add sel
0.0 end
;break}
2638 bind $ui_diff <$M1B-Key-x> {tk_textCopy
%W
;break}
2639 bind $ui_diff <$M1B-Key-X> {tk_textCopy
%W
;break}
2640 bind $ui_diff <$M1B-Key-c> {tk_textCopy
%W
;break}
2641 bind $ui_diff <$M1B-Key-C> {tk_textCopy
%W
;break}
2642 bind $ui_diff <$M1B-Key-v> {break}
2643 bind $ui_diff <$M1B-Key-V> {break}
2644 bind $ui_diff <$M1B-Key-a> {%W tag add sel
0.0 end
;break}
2645 bind $ui_diff <$M1B-Key-A> {%W tag add sel
0.0 end
;break}
2646 bind $ui_diff <Key-Up
> {catch
{%W yview scroll
-1 units
};break}
2647 bind $ui_diff <Key-Down
> {catch
{%W yview scroll
1 units
};break}
2648 bind $ui_diff <Key-Left
> {catch
{%W xview scroll
-1 units
};break}
2649 bind $ui_diff <Key-Right
> {catch
{%W xview scroll
1 units
};break}
2650 bind $ui_diff <Key-k
> {catch
{%W yview scroll
-1 units
};break}
2651 bind $ui_diff <Key-j
> {catch
{%W yview scroll
1 units
};break}
2652 bind $ui_diff <Key-h
> {catch
{%W xview scroll
-1 units
};break}
2653 bind $ui_diff <Key-l
> {catch
{%W xview scroll
1 units
};break}
2654 bind $ui_diff <Control-Key-b
> {catch
{%W yview scroll
-1 pages
};break}
2655 bind $ui_diff <Control-Key-f
> {catch
{%W yview scroll
1 pages
};break}
2656 bind $ui_diff <Button-1
> {focus
%W
}
2658 if {[is_enabled branch
]} {
2659 bind .
<$M1B-Key-n> branch_create
::dialog
2660 bind .
<$M1B-Key-N> branch_create
::dialog
2661 bind .
<$M1B-Key-o> branch_checkout
::dialog
2662 bind .
<$M1B-Key-O> branch_checkout
::dialog
2663 bind .
<$M1B-Key-m> merge
::dialog
2664 bind .
<$M1B-Key-M> merge
::dialog
2666 if {[is_enabled transport
]} {
2667 bind .
<$M1B-Key-p> do_push_anywhere
2668 bind .
<$M1B-Key-P> do_push_anywhere
2671 bind .
<Key-F5
> do_rescan
2672 bind .
<$M1B-Key-r> do_rescan
2673 bind .
<$M1B-Key-R> do_rescan
2674 bind .
<$M1B-Key-s> do_signoff
2675 bind .
<$M1B-Key-S> do_signoff
2676 bind .
<$M1B-Key-i> do_add_all
2677 bind .
<$M1B-Key-I> do_add_all
2678 bind .
<$M1B-Key-Return> do_commit
2679 foreach i
[list
$ui_index $ui_workdir] {
2680 bind $i <Button-1
> "toggle_or_diff $i %x %y; break"
2681 bind $i <$M1B-Button-1> "add_one_to_selection $i %x %y; break"
2682 bind $i <Shift-Button-1
> "add_range_to_selection $i %x %y; break"
2686 set file_lists
($ui_index) [list
]
2687 set file_lists
($ui_workdir) [list
]
2689 wm title .
"[appname] ([reponame]) [file normalize [file dirname [gitdir]]]"
2690 focus
-force $ui_comm
2692 # -- Warn the user about environmental problems. Cygwin's Tcl
2693 # does *not* pass its env array onto any processes it spawns.
2694 # This means that git processes get none of our environment.
2699 set msg
[mc
"Possible environment issues exist.
2701 The following environment variables are probably
2702 going to be ignored by any Git subprocess run
2706 foreach name
[array names env
] {
2707 switch
-regexp -- $name {
2708 {^GIT_INDEX_FILE$
} -
2709 {^GIT_OBJECT_DIRECTORY$
} -
2710 {^GIT_ALTERNATE_OBJECT_DIRECTORIES$
} -
2712 {^GIT_EXTERNAL_DIFF$
} -
2716 {^GIT_CONFIG_LOCAL$
} -
2717 {^GIT_
(AUTHOR|COMMITTER
)_DATE$
} {
2718 append msg
" - $name\n"
2721 {^GIT_
(AUTHOR|COMMITTER
)_
(NAME|EMAIL
)$
} {
2722 append msg
" - $name\n"
2724 set suggest_user
$name
2728 if {$ignored_env > 0} {
2730 This is due to a known issue with the
2731 Tcl binary distributed by Cygwin."]
2733 if {$suggest_user ne
{}} {
2736 A good replacement for %s
2737 is placing values for the user.name and
2738 user.email settings into your personal
2744 unset ignored_env msg suggest_user name
2747 # -- Only initialize complex UI if we are going to stay running.
2749 if {[is_enabled transport
]} {
2752 set n
[.mbar.remote index end
]
2755 set n
[expr {[.mbar.remote index end
] - $n}]
2757 .mbar.remote insert
$n separator
2762 if {[winfo exists
$ui_comm]} {
2763 set GITGUI_BCK_exists
[load_message GITGUI_BCK
]
2765 # -- If both our backup and message files exist use the
2766 # newer of the two files to initialize the buffer.
2768 if {$GITGUI_BCK_exists} {
2769 set m
[gitdir GITGUI_MSG
]
2770 if {[file isfile
$m]} {
2771 if {[file mtime
[gitdir GITGUI_BCK
]] > [file mtime
$m]} {
2772 catch
{file delete
[gitdir GITGUI_MSG
]}
2774 $ui_comm delete
0.0 end
2776 $ui_comm edit modified false
2777 catch
{file delete
[gitdir GITGUI_BCK
]}
2778 set GITGUI_BCK_exists
0
2784 proc backup_commit_buffer
{} {
2785 global ui_comm GITGUI_BCK_exists
2787 set m
[$ui_comm edit modified
]
2788 if {$m ||
$GITGUI_BCK_exists} {
2789 set msg
[string trim
[$ui_comm get
0.0 end
]]
2790 regsub
-all -line {[ \r\t]+$
} $msg {} msg
2793 if {$GITGUI_BCK_exists} {
2794 catch
{file delete
[gitdir GITGUI_BCK
]}
2795 set GITGUI_BCK_exists
0
2799 set fd
[open
[gitdir GITGUI_BCK
] w
]
2800 puts
-nonewline $fd $msg
2802 set GITGUI_BCK_exists
1
2806 $ui_comm edit modified false
2809 set ::GITGUI_BCK_i
[after
2000 backup_commit_buffer
]
2812 backup_commit_buffer
2815 lock_index begin-read
2816 if {![winfo ismapped .
]} {
2820 if {[is_enabled multicommit
]} {