2 # Tcl ignores the next line -*- tcl -*- \
5 # Copyright (C) 2006 Shawn Pearce, Paul Mackerras. All rights reserved.
6 # This program is free software; it may be used, copied, modified
7 # and distributed under the terms of the GNU General Public Licence,
8 # either version 2, or (at your option) any later version.
10 set appname [lindex [file split $argv0] end]
13 ######################################################################
17 proc is_many_config {name} {
18 switch -glob -- $name {
27 proc load_config {include_global} {
28 global repo_config global_config default_config
30 array unset global_config
31 if {$include_global} {
33 set fd_rc [open "| git repo-config --global --list" r]
34 while {[gets $fd_rc line] >= 0} {
35 if {[regexp {^([^=]+)=(.*)$} $line line name value]} {
36 if {[is_many_config $name]} {
37 lappend global_config($name) $value
39 set global_config($name) $value
47 array unset repo_config
49 set fd_rc [open "| git repo-config --list" r]
50 while {[gets $fd_rc line] >= 0} {
51 if {[regexp {^([^=]+)=(.*)$} $line line name value]} {
52 if {[is_many_config $name]} {
53 lappend repo_config($name) $value
55 set repo_config($name) $value
62 foreach name [array names default_config] {
63 if {[catch {set v $global_config($name)}]} {
64 set global_config($name) $default_config($name)
66 if {[catch {set v $repo_config($name)}]} {
67 set repo_config($name) $default_config($name)
73 global default_config font_descs
74 global repo_config global_config
75 global repo_config_new global_config_new
77 foreach option $font_descs {
78 set name [lindex $option 0]
79 set font [lindex $option 1]
80 font configure $font \
81 -family $global_config_new(gui.$font^^family) \
82 -size $global_config_new(gui.$font^^size)
83 font configure ${font}bold \
84 -family $global_config_new(gui.$font^^family) \
85 -size $global_config_new(gui.$font^^size)
86 set global_config_new(gui.$name) [font configure $font]
87 unset global_config_new(gui.$font^^family)
88 unset global_config_new(gui.$font^^size)
91 foreach name [array names default_config] {
92 set value $global_config_new($name)
93 if {$value ne $global_config($name)} {
94 if {$value eq $default_config($name)} {
95 catch {exec git repo-config --global --unset $name}
97 regsub -all "\[{}\]" $value {"} value
98 exec git repo-config --global $name $value
100 set global_config($name) $value
101 if {$value eq $repo_config($name)} {
102 catch {exec git repo-config --unset $name}
103 set repo_config($name) $value
108 foreach name [array names default_config] {
109 set value $repo_config_new($name)
110 if {$value ne $repo_config($name)} {
111 if {$value eq $global_config($name)} {
112 catch {exec git repo-config --unset $name}
114 regsub -all "\[{}\]" $value {"} value
115 exec git repo-config $name $value
117 set repo_config($name) $value
122 proc error_popup {msg} {
123 global gitdir appname
128 append title [lindex \
129 [file split [file normalize [file dirname $gitdir]]] \
133 set cmd [list tk_messageBox \
136 -title "$title: error" \
138 if {[winfo ismapped .]} {
139 lappend cmd -parent .
144 proc info_popup {msg} {
145 global gitdir appname
150 append title [lindex \
151 [file split [file normalize [file dirname $gitdir]]] \
163 ######################################################################
167 if { [catch {set gitdir $env(GIT_DIR)}]
168 && [catch {set gitdir [exec git rev-parse --git-dir]} err]} {
169 catch {wm withdraw .}
170 error_popup "Cannot find the git directory:\n\n$err"
173 if {![file isdirectory $gitdir]} {
174 catch {wm withdraw .}
175 error_popup "Git directory not found:\n\n$gitdir"
178 if {[lindex [file split $gitdir] end] ne {.git}} {
179 catch {wm withdraw .}
180 error_popup "Cannot use funny .git directory:\n\n$gitdir"
183 if {[catch {cd [file dirname $gitdir]} err]} {
184 catch {wm withdraw .}
185 error_popup "No working directory [file dirname $gitdir]:\n\n$err"
190 if {$appname eq {git-citool}} {
194 ######################################################################
202 set disable_on_lock [list]
203 set index_lock_type none
205 proc lock_index {type} {
206 global index_lock_type disable_on_lock
208 if {$index_lock_type eq {none}} {
209 set index_lock_type $type
210 foreach w $disable_on_lock {
211 uplevel #0 $w disabled
214 } elseif {$index_lock_type eq "begin-$type"} {
215 set index_lock_type $type
221 proc unlock_index {} {
222 global index_lock_type disable_on_lock
224 set index_lock_type none
225 foreach w $disable_on_lock {
230 ######################################################################
234 proc repository_state {hdvar ctvar} {
236 upvar $hdvar hd $ctvar ct
238 if {[catch {set hd [exec git rev-parse --verify HEAD]}]} {
241 } elseif {[file exists [file join $gitdir MERGE_HEAD]]} {
249 global PARENT empty_tree
254 if {$empty_tree eq {}} {
255 set empty_tree [exec git mktree << {}]
260 proc rescan {after} {
261 global HEAD PARENT commit_type
262 global ui_index ui_other ui_status_value ui_comm
263 global rescan_active file_states
266 if {$rescan_active > 0 || ![lock_index read]} return
268 repository_state new_HEAD new_type
269 if {[string match amend* $commit_type]
270 && $new_type eq {normal}
271 && $new_HEAD eq $HEAD} {
275 set commit_type $new_type
278 array unset file_states
280 if {![$ui_comm edit modified]
281 || [string trim [$ui_comm get 0.0 end]] eq {}} {
282 if {[load_message GITGUI_MSG]} {
283 } elseif {[load_message MERGE_MSG]} {
284 } elseif {[load_message SQUASH_MSG]} {
286 $ui_comm edit modified false
290 if {$repo_config(gui.trustmtime) eq {true}} {
291 rescan_stage2 {} $after
294 set ui_status_value {Refreshing file status...}
295 set cmd [list git update-index]
297 lappend cmd --unmerged
298 lappend cmd --ignore-missing
299 lappend cmd --refresh
300 set fd_rf [open "| $cmd" r]
301 fconfigure $fd_rf -blocking 0 -translation binary
302 fileevent $fd_rf readable \
303 [list rescan_stage2 $fd_rf $after]
307 proc rescan_stage2 {fd after} {
308 global gitdir ui_status_value
309 global rescan_active buf_rdi buf_rdf buf_rlo
313 if {![eof $fd]} return
317 set ls_others [list | git ls-files --others -z \
318 --exclude-per-directory=.gitignore]
319 set info_exclude [file join $gitdir info exclude]
320 if {[file readable $info_exclude]} {
321 lappend ls_others "--exclude-from=$info_exclude"
329 set ui_status_value {Scanning for modified files ...}
330 set fd_di [open "| git diff-index --cached -z [PARENT]" r]
331 set fd_df [open "| git diff-files -z" r]
332 set fd_lo [open $ls_others r]
334 fconfigure $fd_di -blocking 0 -translation binary
335 fconfigure $fd_df -blocking 0 -translation binary
336 fconfigure $fd_lo -blocking 0 -translation binary
337 fileevent $fd_di readable [list read_diff_index $fd_di $after]
338 fileevent $fd_df readable [list read_diff_files $fd_df $after]
339 fileevent $fd_lo readable [list read_ls_others $fd_lo $after]
342 proc load_message {file} {
343 global gitdir ui_comm
345 set f [file join $gitdir $file]
346 if {[file isfile $f]} {
347 if {[catch {set fd [open $f r]}]} {
350 set content [string trim [read $fd]]
352 $ui_comm delete 0.0 end
353 $ui_comm insert end $content
359 proc read_diff_index {fd after} {
362 append buf_rdi [read $fd]
364 set n [string length $buf_rdi]
366 set z1 [string first "\0" $buf_rdi $c]
369 set z2 [string first "\0" $buf_rdi $z1]
375 [string range $buf_rdi $z1 $z2] \
376 [string index $buf_rdi [expr {$z1 - 2}]]?
380 set buf_rdi [string range $buf_rdi $c end]
385 rescan_done $fd buf_rdi $after
388 proc read_diff_files {fd after} {
391 append buf_rdf [read $fd]
393 set n [string length $buf_rdf]
395 set z1 [string first "\0" $buf_rdf $c]
398 set z2 [string first "\0" $buf_rdf $z1]
404 [string range $buf_rdf $z1 $z2] \
405 ?[string index $buf_rdf [expr {$z1 - 2}]]
409 set buf_rdf [string range $buf_rdf $c end]
414 rescan_done $fd buf_rdf $after
417 proc read_ls_others {fd after} {
420 append buf_rlo [read $fd]
421 set pck [split $buf_rlo "\0"]
422 set buf_rlo [lindex $pck end]
423 foreach p [lrange $pck 0 end-1] {
426 rescan_done $fd buf_rlo $after
429 proc rescan_done {fd buf after} {
431 global file_states repo_config
434 if {![eof $fd]} return
437 if {[incr rescan_active -1] > 0} return
443 if {$repo_config(gui.partialinclude) ne {true}} {
445 foreach path [array names file_states] {
446 switch -- [lindex $file_states($path) 0] {
448 MM {lappend pathList $path}
451 if {$pathList ne {}} {
453 "Updating included files" \
455 [concat {reshow_diff;} $after]
464 proc prune_selection {} {
465 global file_states selected_paths
467 foreach path [array names selected_paths] {
468 if {[catch {set still_here $file_states($path)}]} {
469 unset selected_paths($path)
474 ######################################################################
479 global ui_diff current_diff ui_index ui_other
481 $ui_diff conf -state normal
482 $ui_diff delete 0.0 end
483 $ui_diff conf -state disabled
487 $ui_index tag remove in_diff 0.0 end
488 $ui_other tag remove in_diff 0.0 end
491 proc reshow_diff {} {
492 global current_diff ui_status_value file_states
494 if {$current_diff eq {}
495 || [catch {set s $file_states($current_diff)}]} {
498 show_diff $current_diff
502 proc handle_empty_diff {} {
503 global current_diff file_states file_lists
505 set path $current_diff
506 set s $file_states($path)
507 if {[lindex $s 0] ne {_M}} return
509 info_popup "No differences detected.
511 [short_path $path] has no changes.
513 The modification date of this file was updated
514 by another application and you currently have
515 the Trust File Modification Timestamps option
516 enabled, so Git did not automatically detect
517 that there are no content differences in this
520 This file will now be removed from the modified
521 files list, to prevent possible confusion.
523 if {[catch {exec git update-index -- $path} err]} {
524 error_popup "Failed to refresh index:\n\n$err"
528 set old_w [mapcol [lindex $file_states($path) 0] $path]
529 set lno [lsearch -sorted $file_lists($old_w) $path]
531 set file_lists($old_w) \
532 [lreplace $file_lists($old_w) $lno $lno]
534 $old_w conf -state normal
535 $old_w delete $lno.0 [expr {$lno + 1}].0
536 $old_w conf -state disabled
540 proc show_diff {path {w {}} {lno {}}} {
541 global file_states file_lists
542 global diff_3way diff_active repo_config
543 global ui_diff current_diff ui_status_value
545 if {$diff_active || ![lock_index read]} return
548 if {$w eq {} || $lno == {}} {
549 foreach w [array names file_lists] {
550 set lno [lsearch -sorted $file_lists($w) $path]
557 if {$w ne {} && $lno >= 1} {
558 $w tag add in_diff $lno.0 [expr {$lno + 1}].0
561 set s $file_states($path)
565 set current_diff $path
566 set ui_status_value "Loading diff of [escape_path $path]..."
568 set cmd [list | git diff-index]
569 lappend cmd --no-color
570 if {$repo_config(gui.diffcontext) > 0} {
571 lappend cmd "-U$repo_config(gui.diffcontext)"
581 set fd [open $path r]
582 set content [read $fd]
587 set ui_status_value "Unable to display [escape_path $path]"
588 error_popup "Error loading file:\n\n$err"
591 $ui_diff conf -state normal
592 $ui_diff insert end $content
593 $ui_diff conf -state disabled
596 set ui_status_value {Ready.}
605 if {[catch {set fd [open $cmd r]} err]} {
608 set ui_status_value "Unable to display [escape_path $path]"
609 error_popup "Error loading diff:\n\n$err"
613 fconfigure $fd -blocking 0 -translation auto
614 fileevent $fd readable [list read_diff $fd]
617 proc read_diff {fd} {
618 global ui_diff ui_status_value diff_3way diff_active
621 while {[gets $fd line] >= 0} {
622 if {[string match {diff --git *} $line]} continue
623 if {[string match {diff --combined *} $line]} continue
624 if {[string match {--- *} $line]} continue
625 if {[string match {+++ *} $line]} continue
626 if {[string match index* $line]} {
627 if {[string first , $line] >= 0} {
632 $ui_diff conf -state normal
634 set x [string index $line 0]
639 default {set tags {}}
642 set x [string range $line 0 1]
644 default {set tags {}}
646 "++" {set tags dp; set x " +"}
647 " +" {set tags {di bold}; set x "++"}
648 "+ " {set tags dni; set x "-+"}
649 "--" {set tags dm; set x " -"}
650 " -" {set tags {dm bold}; set x "--"}
651 "- " {set tags di; set x "+-"}
652 default {set tags {}}
654 set line [string replace $line 0 1 $x]
656 $ui_diff insert end $line $tags
657 $ui_diff insert end "\n"
658 $ui_diff conf -state disabled
665 set ui_status_value {Ready.}
667 if {$repo_config(gui.trustmtime) eq {true}
668 && [$ui_diff index end] eq {2.0}} {
674 ######################################################################
678 proc load_last_commit {} {
679 global HEAD PARENT commit_type ui_comm
681 if {[string match amend* $commit_type]} return
682 if {$commit_type ne {normal}} {
683 error_popup "Can't amend a $commit_type commit."
691 set fd [open "| git cat-file commit $HEAD" r]
692 while {[gets $fd line] > 0} {
693 if {[string match {parent *} $line]} {
694 set parent [string range $line 7 end]
698 set msg [string trim [read $fd]]
701 error_popup "Error loading commit data for amend:\n\n$err"
705 if {$parent_count > 1} {
706 error_popup {Can't amend a merge commit.}
710 if {$parent_count == 0} {
711 set commit_type amend-initial
713 } elseif {$parent_count == 1} {
714 set commit_type amend
718 $ui_comm delete 0.0 end
719 $ui_comm insert end $msg
720 $ui_comm edit modified false
722 rescan {set ui_status_value {Ready.}}
725 proc create_new_commit {} {
726 global commit_type ui_comm
728 set commit_type normal
729 $ui_comm delete 0.0 end
730 $ui_comm edit modified false
732 rescan {set ui_status_value {Ready.}}
735 set GIT_COMMITTER_IDENT {}
737 proc committer_ident {} {
738 global GIT_COMMITTER_IDENT
740 if {$GIT_COMMITTER_IDENT eq {}} {
741 if {[catch {set me [exec git var GIT_COMMITTER_IDENT]} err]} {
742 error_popup "Unable to obtain your identity:\n\n$err"
745 if {![regexp {^(.*) [0-9]+ [-+0-9]+$} \
746 $me me GIT_COMMITTER_IDENT]} {
747 error_popup "Invalid GIT_COMMITTER_IDENT:\n\n$me"
752 return $GIT_COMMITTER_IDENT
755 proc commit_tree {} {
756 global HEAD commit_type file_states ui_comm repo_config
758 if {![lock_index update]} return
759 if {[committer_ident] eq {}} return
761 # -- Our in memory state should match the repository.
763 repository_state curHEAD cur_type
764 if {[string match amend* $commit_type]
765 && $cur_type eq {normal}
766 && $curHEAD eq $HEAD} {
767 } elseif {$commit_type ne $cur_type || $HEAD ne $curHEAD} {
768 info_popup {Last scanned state does not match repository state.
770 Another Git program has modified this repository
771 since the last scan. A rescan must be performed
772 before another commit can be created.
774 The rescan will be automatically started now.
777 rescan {set ui_status_value {Ready.}}
781 # -- At least one file should differ in the index.
784 foreach path [array names file_states] {
785 switch -glob -- [lindex $file_states($path) 0] {
789 M? {set files_ready 1; break}
791 error_popup "Unmerged files cannot be committed.
793 File [short_path $path] has merge conflicts.
794 You must resolve them and include the file before committing.
800 error_popup "Unknown file state [lindex $s 0] detected.
802 File [short_path $path] cannot be committed by this program.
808 error_popup {No included files to commit.
810 You must include at least 1 file before you can commit.
816 # -- A message is required.
818 set msg [string trim [$ui_comm get 1.0 end]]
820 error_popup {Please supply a commit message.
822 A good commit message has the following format:
824 - First line: Describe in one sentance what you did.
826 - Remaining lines: Describe why this change is good.
832 # -- Update included files if partialincludes are off.
834 if {$repo_config(gui.partialinclude) ne {true}} {
836 foreach path [array names file_states] {
837 switch -glob -- [lindex $file_states($path) 0] {
839 M? {lappend pathList $path}
842 if {$pathList ne {}} {
845 "Updating included files" \
847 [concat {lock_index update;} \
848 [list commit_prehook $curHEAD $msg]]
853 commit_prehook $curHEAD $msg
856 proc commit_prehook {curHEAD msg} {
857 global tcl_platform gitdir ui_status_value pch_error
859 # On Cygwin [file executable] might lie so we need to ask
860 # the shell if the hook is executable. Yes that's annoying.
862 set pchook [file join $gitdir hooks pre-commit]
863 if {$tcl_platform(platform) eq {windows}
864 && [file isfile $pchook]} {
865 set pchook [list sh -c [concat \
866 "if test -x \"$pchook\";" \
867 "then exec \"$pchook\" 2>&1;" \
869 } elseif {[file executable $pchook]} {
870 set pchook [list $pchook |& cat]
872 commit_writetree $curHEAD $msg
876 set ui_status_value {Calling pre-commit hook...}
878 set fd_ph [open "| $pchook" r]
879 fconfigure $fd_ph -blocking 0 -translation binary
880 fileevent $fd_ph readable \
881 [list commit_prehook_wait $fd_ph $curHEAD $msg]
884 proc commit_prehook_wait {fd_ph curHEAD msg} {
885 global pch_error ui_status_value
887 append pch_error [read $fd_ph]
888 fconfigure $fd_ph -blocking 1
890 if {[catch {close $fd_ph}]} {
891 set ui_status_value {Commit declined by pre-commit hook.}
892 hook_failed_popup pre-commit $pch_error
895 commit_writetree $curHEAD $msg
900 fconfigure $fd_ph -blocking 0
903 proc commit_writetree {curHEAD msg} {
904 global ui_status_value
906 set ui_status_value {Committing changes...}
907 set fd_wt [open "| git write-tree" r]
908 fileevent $fd_wt readable \
909 [list commit_committree $fd_wt $curHEAD $msg]
912 proc commit_committree {fd_wt curHEAD msg} {
913 global single_commit gitdir HEAD PARENT commit_type tcl_platform
914 global ui_status_value ui_comm selected_commit_type
915 global file_states selected_paths
918 if {$tree_id eq {} || [catch {close $fd_wt} err]} {
919 error_popup "write-tree failed:\n\n$err"
920 set ui_status_value {Commit failed.}
925 # -- Create the commit.
927 set cmd [list git commit-tree $tree_id]
929 lappend cmd -p $PARENT
931 if {$commit_type eq {merge}} {
933 set fd_mh [open [file join $gitdir MERGE_HEAD] r]
934 while {[gets $fd_mh merge_head] >= 0} {
935 lappend cmd -p $merge_head
939 error_popup "Loading MERGE_HEAD failed:\n\n$err"
940 set ui_status_value {Commit failed.}
946 # git commit-tree writes to stderr during initial commit.
947 lappend cmd 2>/dev/null
950 if {[catch {set cmt_id [eval exec $cmd]} err]} {
951 error_popup "commit-tree failed:\n\n$err"
952 set ui_status_value {Commit failed.}
957 # -- Update the HEAD ref.
960 if {$commit_type ne {normal}} {
961 append reflogm " ($commit_type)"
963 set i [string first "\n" $msg]
965 append reflogm {: } [string range $msg 0 [expr {$i - 1}]]
967 append reflogm {: } $msg
969 set cmd [list git update-ref -m $reflogm HEAD $cmt_id $curHEAD]
970 if {[catch {eval exec $cmd} err]} {
971 error_popup "update-ref failed:\n\n$err"
972 set ui_status_value {Commit failed.}
977 # -- Cleanup after ourselves.
979 catch {file delete [file join $gitdir MERGE_HEAD]}
980 catch {file delete [file join $gitdir MERGE_MSG]}
981 catch {file delete [file join $gitdir SQUASH_MSG]}
982 catch {file delete [file join $gitdir GITGUI_MSG]}
984 # -- Let rerere do its thing.
986 if {[file isdirectory [file join $gitdir rr-cache]]} {
987 catch {exec git rerere}
990 # -- Run the post-commit hook.
992 set pchook [file join $gitdir hooks post-commit]
993 if {$tcl_platform(platform) eq {windows} && [file isfile $pchook]} {
994 set pchook [list sh -c [concat \
995 "if test -x \"$pchook\";" \
996 "then exec \"$pchook\";" \
998 } elseif {![file executable $pchook]} {
1001 if {$pchook ne {}} {
1002 catch {exec $pchook &}
1005 $ui_comm delete 0.0 end
1006 $ui_comm edit modified false
1009 if {$single_commit} do_quit
1011 # -- Update status without invoking any git commands.
1013 set commit_type normal
1014 set selected_commit_type new
1018 foreach path [array names file_states] {
1019 set s $file_states($path)
1021 switch -glob -- $m {
1024 D? {set m _[string index $m 1]}
1028 unset file_states($path)
1029 catch {unset selected_paths($path)}
1031 lset file_states($path) 0 $m
1038 set ui_status_value \
1039 "Changes committed as [string range $cmt_id 0 7]."
1042 ######################################################################
1046 proc fetch_from {remote} {
1047 set w [new_console "fetch $remote" \
1048 "Fetching new changes from $remote"]
1049 set cmd [list git fetch]
1051 console_exec $w $cmd
1054 proc pull_remote {remote branch} {
1055 global HEAD commit_type file_states repo_config
1057 if {![lock_index update]} return
1059 # -- Our in memory state should match the repository.
1061 repository_state curHEAD cur_type
1062 if {$commit_type ne $cur_type || $HEAD ne $curHEAD} {
1063 error_popup {Last scanned state does not match repository state.
1065 Its highly likely that another Git program modified the
1066 repository since our last scan. A rescan is required
1067 before a pull can be started.
1070 rescan {set ui_status_value {Ready.}}
1074 # -- No differences should exist before a pull.
1076 if {[array size file_states] != 0} {
1077 error_popup {Uncommitted but modified files are present.
1079 You should not perform a pull with unmodified files in your working
1080 directory as Git would be unable to recover from an incorrect merge.
1082 Commit or throw away all changes before starting a pull operation.
1088 set w [new_console "pull $remote $branch" \
1089 "Pulling new changes from branch $branch in $remote"]
1090 set cmd [list git pull]
1091 if {$repo_config(gui.pullsummary) eq {false}} {
1092 lappend cmd --no-summary
1096 console_exec $w $cmd [list post_pull_remote $remote $branch]
1099 proc post_pull_remote {remote branch success} {
1100 global HEAD PARENT commit_type selected_commit_type
1101 global ui_status_value
1105 repository_state HEAD commit_type
1107 set selected_commit_type new
1108 set $ui_status_value "Pulling $branch from $remote complete."
1110 set m "Conflicts detected while pulling $branch from $remote."
1111 rescan "set ui_status_value {$m}"
1115 proc push_to {remote} {
1116 set w [new_console "push $remote" \
1117 "Pushing changes to $remote"]
1118 set cmd [list git push]
1120 console_exec $w $cmd
1123 ######################################################################
1127 proc mapcol {state path} {
1128 global all_cols ui_other
1130 if {[catch {set r $all_cols($state)}]} {
1131 puts "error: no column for state={$state} $path"
1137 proc mapicon {state path} {
1140 if {[catch {set r $all_icons($state)}]} {
1141 puts "error: no icon for state={$state} $path"
1147 proc mapdesc {state path} {
1150 if {[catch {set r $all_descs($state)}]} {
1151 puts "error: no desc for state={$state} $path"
1157 proc escape_path {path} {
1158 regsub -all "\n" $path "\\n" path
1162 proc short_path {path} {
1163 return [escape_path [lindex [file split $path] end]]
1168 proc merge_state {path new_state} {
1169 global file_states next_icon_id
1171 set s0 [string index $new_state 0]
1172 set s1 [string index $new_state 1]
1174 if {[catch {set info $file_states($path)}]} {
1176 set icon n[incr next_icon_id]
1178 set state [lindex $info 0]
1179 set icon [lindex $info 1]
1183 set s0 [string index $state 0]
1184 } elseif {$s0 eq {_}} {
1189 set s1 [string index $state 1]
1190 } elseif {$s1 eq {_}} {
1194 set file_states($path) [list $s0$s1 $icon]
1198 proc display_file {path state} {
1199 global file_states file_lists selected_paths rescan_active
1201 set old_m [merge_state $path $state]
1202 if {$rescan_active > 0} return
1204 set s $file_states($path)
1205 set new_m [lindex $s 0]
1206 set new_w [mapcol $new_m $path]
1207 set old_w [mapcol $old_m $path]
1208 set new_icon [mapicon $new_m $path]
1210 if {$new_w ne $old_w} {
1211 set lno [lsearch -sorted $file_lists($old_w) $path]
1214 $old_w conf -state normal
1215 $old_w delete $lno.0 [expr {$lno + 1}].0
1216 $old_w conf -state disabled
1219 lappend file_lists($new_w) $path
1220 set file_lists($new_w) [lsort $file_lists($new_w)]
1221 set lno [lsearch -sorted $file_lists($new_w) $path]
1223 $new_w conf -state normal
1224 $new_w image create $lno.0 \
1225 -align center -padx 5 -pady 1 \
1226 -name [lindex $s 1] \
1228 $new_w insert $lno.1 "[escape_path $path]\n"
1229 if {[catch {set in_sel $selected_paths($path)}]} {
1233 $new_w tag add in_sel $lno.0 [expr {$lno + 1}].0
1235 $new_w conf -state disabled
1236 } elseif {$new_icon ne [mapicon $old_m $path]} {
1237 $new_w conf -state normal
1238 $new_w image conf [lindex $s 1] -image $new_icon
1239 $new_w conf -state disabled
1243 proc display_all_files {} {
1244 global ui_index ui_other
1245 global file_states file_lists
1246 global last_clicked selected_paths
1248 $ui_index conf -state normal
1249 $ui_other conf -state normal
1251 $ui_index delete 0.0 end
1252 $ui_other delete 0.0 end
1255 set file_lists($ui_index) [list]
1256 set file_lists($ui_other) [list]
1258 foreach path [lsort [array names file_states]] {
1259 set s $file_states($path)
1261 set w [mapcol $m $path]
1262 lappend file_lists($w) $path
1263 set lno [expr {[lindex [split [$w index end] .] 0] - 1}]
1264 $w image create end \
1265 -align center -padx 5 -pady 1 \
1266 -name [lindex $s 1] \
1267 -image [mapicon $m $path]
1268 $w insert end "[escape_path $path]\n"
1269 if {[catch {set in_sel $selected_paths($path)}]} {
1273 $w tag add in_sel $lno.0 [expr {$lno + 1}].0
1277 $ui_index conf -state disabled
1278 $ui_other conf -state disabled
1281 proc update_index {msg pathList after} {
1282 global update_index_cp ui_status_value
1284 if {![lock_index update]} return
1286 set update_index_cp 0
1287 set pathList [lsort $pathList]
1288 set totalCnt [llength $pathList]
1289 set batch [expr {int($totalCnt * .01) + 1}]
1290 if {$batch > 25} {set batch 25}
1292 set ui_status_value [format \
1293 "$msg... %i/%i files (%.2f%%)" \
1297 set fd [open "| git update-index --add --remove -z --stdin" w]
1303 fileevent $fd writable [list \
1304 write_update_index \
1314 proc write_update_index {fd pathList totalCnt batch msg after} {
1315 global update_index_cp ui_status_value
1316 global file_states current_diff
1318 if {$update_index_cp >= $totalCnt} {
1325 for {set i $batch} \
1326 {$update_index_cp < $totalCnt && $i > 0} \
1328 set path [lindex $pathList $update_index_cp]
1329 incr update_index_cp
1331 switch -glob -- [lindex $file_states($path) 0] {
1347 puts -nonewline $fd $path
1348 puts -nonewline $fd "\0"
1349 display_file $path $new
1352 set ui_status_value [format \
1353 "$msg... %i/%i files (%.2f%%)" \
1356 [expr {100.0 * $update_index_cp / $totalCnt}]]
1359 ######################################################################
1361 ## remote management
1363 proc load_all_remotes {} {
1364 global gitdir all_remotes repo_config
1366 set all_remotes [list]
1367 set rm_dir [file join $gitdir remotes]
1368 if {[file isdirectory $rm_dir]} {
1369 set all_remotes [concat $all_remotes [glob \
1373 -directory $rm_dir *]]
1376 foreach line [array names repo_config remote.*.url] {
1377 if {[regexp ^remote\.(.*)\.url\$ $line line name]} {
1378 lappend all_remotes $name
1382 set all_remotes [lsort -unique $all_remotes]
1385 proc populate_fetch_menu {m} {
1386 global gitdir all_remotes repo_config
1388 foreach r $all_remotes {
1390 if {![catch {set a $repo_config(remote.$r.url)}]} {
1391 if {![catch {set a $repo_config(remote.$r.fetch)}]} {
1396 set fd [open [file join $gitdir remotes $r] r]
1397 while {[gets $fd n] >= 0} {
1398 if {[regexp {^Pull:[ \t]*([^:]+):} $n]} {
1409 -label "Fetch from $r..." \
1410 -command [list fetch_from $r] \
1416 proc populate_push_menu {m} {
1417 global gitdir all_remotes repo_config
1419 foreach r $all_remotes {
1421 if {![catch {set a $repo_config(remote.$r.url)}]} {
1422 if {![catch {set a $repo_config(remote.$r.push)}]} {
1427 set fd [open [file join $gitdir remotes $r] r]
1428 while {[gets $fd n] >= 0} {
1429 if {[regexp {^Push:[ \t]*([^:]+):} $n]} {
1440 -label "Push to $r..." \
1441 -command [list push_to $r] \
1447 proc populate_pull_menu {m} {
1448 global gitdir repo_config all_remotes disable_on_lock
1450 foreach remote $all_remotes {
1452 if {[array get repo_config remote.$remote.url] ne {}} {
1453 if {[array get repo_config remote.$remote.fetch] ne {}} {
1454 regexp {^([^:]+):} \
1455 [lindex $repo_config(remote.$remote.fetch) 0] \
1460 set fd [open [file join $gitdir remotes $remote] r]
1461 while {[gets $fd line] >= 0} {
1462 if {[regexp {^Pull:[ \t]*([^:]+):} $line line rb]} {
1471 regsub ^refs/heads/ $rb {} rb_short
1472 if {$rb_short ne {}} {
1474 -label "Branch $rb_short from $remote..." \
1475 -command [list pull_remote $remote $rb] \
1477 lappend disable_on_lock \
1478 [list $m entryconf [$m index last] -state]
1483 ######################################################################
1488 #define mask_width 14
1489 #define mask_height 15
1490 static unsigned char mask_bits[] = {
1491 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
1492 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
1493 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f};
1496 image create bitmap file_plain -background white -foreground black -data {
1497 #define plain_width 14
1498 #define plain_height 15
1499 static unsigned char plain_bits[] = {
1500 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
1501 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10,
1502 0x02, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1503 } -maskdata $filemask
1505 image create bitmap file_mod -background white -foreground blue -data {
1506 #define mod_width 14
1507 #define mod_height 15
1508 static unsigned char mod_bits[] = {
1509 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
1510 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
1511 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
1512 } -maskdata $filemask
1514 image create bitmap file_fulltick -background white -foreground "#007000" -data {
1515 #define file_fulltick_width 14
1516 #define file_fulltick_height 15
1517 static unsigned char file_fulltick_bits[] = {
1518 0xfe, 0x01, 0x02, 0x1a, 0x02, 0x0c, 0x02, 0x0c, 0x02, 0x16, 0x02, 0x16,
1519 0x02, 0x13, 0x00, 0x13, 0x86, 0x11, 0x8c, 0x11, 0xd8, 0x10, 0xf2, 0x10,
1520 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1521 } -maskdata $filemask
1523 image create bitmap file_parttick -background white -foreground "#005050" -data {
1524 #define parttick_width 14
1525 #define parttick_height 15
1526 static unsigned char parttick_bits[] = {
1527 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
1528 0x7a, 0x14, 0x02, 0x16, 0x02, 0x13, 0x8a, 0x11, 0xda, 0x10, 0x72, 0x10,
1529 0x22, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1530 } -maskdata $filemask
1532 image create bitmap file_question -background white -foreground black -data {
1533 #define file_question_width 14
1534 #define file_question_height 15
1535 static unsigned char file_question_bits[] = {
1536 0xfe, 0x01, 0x02, 0x02, 0xe2, 0x04, 0xf2, 0x09, 0x1a, 0x1b, 0x0a, 0x13,
1537 0x82, 0x11, 0xc2, 0x10, 0x62, 0x10, 0x62, 0x10, 0x02, 0x10, 0x62, 0x10,
1538 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1539 } -maskdata $filemask
1541 image create bitmap file_removed -background white -foreground red -data {
1542 #define file_removed_width 14
1543 #define file_removed_height 15
1544 static unsigned char file_removed_bits[] = {
1545 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
1546 0x1a, 0x16, 0x32, 0x13, 0xe2, 0x11, 0xc2, 0x10, 0xe2, 0x11, 0x32, 0x13,
1547 0x1a, 0x16, 0x02, 0x10, 0xfe, 0x1f};
1548 } -maskdata $filemask
1550 image create bitmap file_merge -background white -foreground blue -data {
1551 #define file_merge_width 14
1552 #define file_merge_height 15
1553 static unsigned char file_merge_bits[] = {
1554 0xfe, 0x01, 0x02, 0x03, 0x62, 0x05, 0x62, 0x09, 0x62, 0x1f, 0x62, 0x10,
1555 0xfa, 0x11, 0xf2, 0x10, 0x62, 0x10, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
1556 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
1557 } -maskdata $filemask
1559 set ui_index .vpane.files.index.list
1560 set ui_other .vpane.files.other.list
1561 set max_status_desc 0
1563 {__ i plain "Unmodified"}
1564 {_M i mod "Modified"}
1565 {M_ i fulltick "Included in commit"}
1566 {MM i parttick "Partially included"}
1568 {_O o plain "Untracked"}
1569 {A_ o fulltick "Added by commit"}
1570 {AM o parttick "Partially added"}
1571 {AD o question "Added (but now gone)"}
1573 {_D i question "Missing"}
1574 {D_ i removed "Removed by commit"}
1575 {DD i removed "Removed by commit"}
1576 {DO i removed "Removed (still exists)"}
1578 {UM i merge "Merge conflicts"}
1579 {U_ i merge "Merge conflicts"}
1581 if {$max_status_desc < [string length [lindex $i 3]]} {
1582 set max_status_desc [string length [lindex $i 3]]
1584 if {[lindex $i 1] eq {i}} {
1585 set all_cols([lindex $i 0]) $ui_index
1587 set all_cols([lindex $i 0]) $ui_other
1589 set all_icons([lindex $i 0]) file_[lindex $i 2]
1590 set all_descs([lindex $i 0]) [lindex $i 3]
1594 ######################################################################
1599 global tcl_platform tk_library
1600 if {$tcl_platform(platform) eq {unix}
1601 && $tcl_platform(os) eq {Darwin}
1602 && [string match /Library/Frameworks/* $tk_library]} {
1608 proc bind_button3 {w cmd} {
1609 bind $w <Any-Button-3> $cmd
1611 bind $w <Control-Button-1> $cmd
1615 proc incr_font_size {font {amt 1}} {
1616 set sz [font configure $font -size]
1618 font configure $font -size $sz
1619 font configure ${font}bold -size $sz
1622 proc hook_failed_popup {hook msg} {
1623 global gitdir appname
1629 label $w.m.l1 -text "$hook hook failed:" \
1634 -background white -borderwidth 1 \
1636 -width 80 -height 10 \
1638 -yscrollcommand [list $w.m.sby set]
1640 -text {You must correct the above errors before committing.} \
1644 scrollbar $w.m.sby -command [list $w.m.t yview]
1645 pack $w.m.l1 -side top -fill x
1646 pack $w.m.l2 -side bottom -fill x
1647 pack $w.m.sby -side right -fill y
1648 pack $w.m.t -side left -fill both -expand 1
1649 pack $w.m -side top -fill both -expand 1 -padx 5 -pady 10
1651 $w.m.t insert 1.0 $msg
1652 $w.m.t conf -state disabled
1654 button $w.ok -text OK \
1657 -command "destroy $w"
1658 pack $w.ok -side bottom -anchor e -pady 10 -padx 10
1660 bind $w <Visibility> "grab $w; focus $w"
1661 bind $w <Key-Return> "destroy $w"
1662 wm title $w "$appname ([lindex [file split \
1663 [file normalize [file dirname $gitdir]]] \
1668 set next_console_id 0
1670 proc new_console {short_title long_title} {
1671 global next_console_id console_data
1672 set w .console[incr next_console_id]
1673 set console_data($w) [list $short_title $long_title]
1674 return [console_init $w]
1677 proc console_init {w} {
1678 global console_cr console_data
1679 global gitdir appname M1B
1681 set console_cr($w) 1.0
1684 label $w.m.l1 -text "[lindex $console_data($w) 1]:" \
1689 -background white -borderwidth 1 \
1691 -width 80 -height 10 \
1694 -yscrollcommand [list $w.m.sby set]
1695 label $w.m.s -text {Working... please wait...} \
1699 scrollbar $w.m.sby -command [list $w.m.t yview]
1700 pack $w.m.l1 -side top -fill x
1701 pack $w.m.s -side bottom -fill x
1702 pack $w.m.sby -side right -fill y
1703 pack $w.m.t -side left -fill both -expand 1
1704 pack $w.m -side top -fill both -expand 1 -padx 5 -pady 10
1706 menu $w.ctxm -tearoff 0
1707 $w.ctxm add command -label "Copy" \
1709 -command "tk_textCopy $w.m.t"
1710 $w.ctxm add command -label "Select All" \
1712 -command "$w.m.t tag add sel 0.0 end"
1713 $w.ctxm add command -label "Copy All" \
1716 $w.m.t tag add sel 0.0 end
1718 $w.m.t tag remove sel 0.0 end
1721 button $w.ok -text {Close} \
1724 -command "destroy $w"
1725 pack $w.ok -side bottom -anchor e -pady 10 -padx 10
1727 bind_button3 $w.m.t "tk_popup $w.ctxm %X %Y"
1728 bind $w.m.t <$M1B-Key-a> "$w.m.t tag add sel 0.0 end;break"
1729 bind $w.m.t <$M1B-Key-A> "$w.m.t tag add sel 0.0 end;break"
1730 bind $w <Visibility> "focus $w"
1731 wm title $w "$appname ([lindex [file split \
1732 [file normalize [file dirname $gitdir]]] \
1733 end]): [lindex $console_data($w) 0]"
1737 proc console_exec {w cmd {after {}}} {
1740 # -- Windows tosses the enviroment when we exec our child.
1741 # But most users need that so we have to relogin. :-(
1743 if {$tcl_platform(platform) eq {windows}} {
1744 set cmd [list sh --login -c "cd \"[pwd]\" && [join $cmd { }]"]
1747 # -- Tcl won't let us redirect both stdout and stderr to
1748 # the same pipe. So pass it through cat...
1750 set cmd [concat | $cmd |& cat]
1752 set fd_f [open $cmd r]
1753 fconfigure $fd_f -blocking 0 -translation binary
1754 fileevent $fd_f readable [list console_read $w $fd_f $after]
1757 proc console_read {w fd after} {
1758 global console_cr console_data
1762 if {![winfo exists $w]} {console_init $w}
1763 $w.m.t conf -state normal
1765 set n [string length $buf]
1767 set cr [string first "\r" $buf $c]
1768 set lf [string first "\n" $buf $c]
1769 if {$cr < 0} {set cr [expr {$n + 1}]}
1770 if {$lf < 0} {set lf [expr {$n + 1}]}
1773 $w.m.t insert end [string range $buf $c $lf]
1774 set console_cr($w) [$w.m.t index {end -1c}]
1778 $w.m.t delete $console_cr($w) end
1779 $w.m.t insert end "\n"
1780 $w.m.t insert end [string range $buf $c $cr]
1785 $w.m.t conf -state disabled
1789 fconfigure $fd -blocking 1
1791 if {[catch {close $fd}]} {
1792 if {![winfo exists $w]} {console_init $w}
1793 $w.m.s conf -background red -text {Error: Command Failed}
1794 $w.ok conf -state normal
1796 } elseif {[winfo exists $w]} {
1797 $w.m.s conf -background green -text {Success}
1798 $w.ok conf -state normal
1801 array unset console_cr $w
1802 array unset console_data $w
1804 uplevel #0 $after $ok
1808 fconfigure $fd -blocking 0
1811 ######################################################################
1815 set starting_gitk_msg {Please wait... Starting gitk...}
1818 global tcl_platform ui_status_value starting_gitk_msg
1820 set ui_status_value $starting_gitk_msg
1822 if {$ui_status_value eq $starting_gitk_msg} {
1823 set ui_status_value {Ready.}
1827 if {$tcl_platform(platform) eq {windows}} {
1835 set w [new_console "repack" "Repacking the object database"]
1836 set cmd [list git repack]
1839 console_exec $w $cmd
1845 global gitdir ui_comm is_quitting repo_config
1847 if {$is_quitting} return
1850 # -- Stash our current commit buffer.
1852 set save [file join $gitdir GITGUI_MSG]
1853 set msg [string trim [$ui_comm get 0.0 end]]
1854 if {[$ui_comm edit modified] && $msg ne {}} {
1856 set fd [open $save w]
1857 puts $fd [string trim [$ui_comm get 0.0 end]]
1860 } elseif {$msg eq {} && [file exists $save]} {
1864 # -- Stash our current window geometry into this repository.
1866 set cfg_geometry [list]
1867 lappend cfg_geometry [wm geometry .]
1868 lappend cfg_geometry [lindex [.vpane sash coord 0] 1]
1869 lappend cfg_geometry [lindex [.vpane.files sash coord 0] 0]
1870 if {[catch {set rc_geometry $repo_config(gui.geometry)}]} {
1873 if {$cfg_geometry ne $rc_geometry} {
1874 catch {exec git repo-config gui.geometry $cfg_geometry}
1881 rescan {set ui_status_value {Ready.}}
1884 proc include_helper {txt paths} {
1885 global file_states current_diff
1887 if {![lock_index begin-update]} return
1891 foreach path $paths {
1892 switch -- [lindex $file_states($path) 0] {
1901 lappend pathList $path
1902 if {$path eq $current_diff} {
1903 set after {reshow_diff;}
1908 if {$pathList eq {}} {
1914 [concat $after {set ui_status_value {Ready to commit.}}]
1918 proc do_include_selection {} {
1919 global current_diff selected_paths
1921 if {[array size selected_paths] > 0} {
1923 {Including selected files} \
1924 [array names selected_paths]
1925 } elseif {$current_diff ne {}} {
1927 "Including [short_path $current_diff]" \
1928 [list $current_diff]
1932 proc do_include_all {} {
1936 foreach path [array names file_states] {
1937 switch -- [lindex $file_states($path) 0] {
1942 _D {lappend paths $path}
1946 {Including all modified files} \
1950 proc do_signoff {} {
1953 set me [committer_ident]
1954 if {$me eq {}} return
1956 set sob "Signed-off-by: $me"
1957 set last [$ui_comm get {end -1c linestart} {end -1c}]
1958 if {$last ne $sob} {
1959 $ui_comm edit separator
1961 && ![regexp {^[A-Z][A-Za-z]*-[A-Za-z-]+: *} $last]} {
1962 $ui_comm insert end "\n"
1964 $ui_comm insert end "\n$sob"
1965 $ui_comm edit separator
1970 proc do_select_commit_type {} {
1971 global commit_type selected_commit_type
1973 if {$selected_commit_type eq {new}
1974 && [string match amend* $commit_type]} {
1976 } elseif {$selected_commit_type eq {amend}
1977 && ![string match amend* $commit_type]} {
1980 # The amend request was rejected...
1982 if {![string match amend* $commit_type]} {
1983 set selected_commit_type new
1992 proc do_options {} {
1993 global appname gitdir font_descs
1994 global repo_config global_config
1995 global repo_config_new global_config_new
1997 array unset repo_config_new
1998 array unset global_config_new
1999 foreach name [array names repo_config] {
2000 set repo_config_new($name) $repo_config($name)
2003 foreach name [array names repo_config] {
2005 gui.diffcontext {continue}
2007 set repo_config_new($name) $repo_config($name)
2009 foreach name [array names global_config] {
2010 set global_config_new($name) $global_config($name)
2012 set reponame [lindex [file split \
2013 [file normalize [file dirname $gitdir]]] \
2016 set w .options_editor
2018 wm geometry $w "+[winfo rootx .]+[winfo rooty .]"
2020 label $w.header -text "$appname Options" \
2022 pack $w.header -side top -fill x
2025 button $w.buttons.restore -text {Restore Defaults} \
2027 -command do_restore_defaults
2028 pack $w.buttons.restore -side left
2029 button $w.buttons.save -text Save \
2031 -command [list do_save_config $w]
2032 pack $w.buttons.save -side right
2033 button $w.buttons.cancel -text {Cancel} \
2035 -command [list destroy $w]
2036 pack $w.buttons.cancel -side right
2037 pack $w.buttons -side bottom -fill x -pady 10 -padx 10
2039 labelframe $w.repo -text "$reponame Repository" \
2041 -relief raised -borderwidth 2
2042 labelframe $w.global -text {Global (All Repositories)} \
2044 -relief raised -borderwidth 2
2045 pack $w.repo -side left -fill both -expand 1 -pady 5 -padx 5
2046 pack $w.global -side right -fill both -expand 1 -pady 5 -padx 5
2049 {b partialinclude {Allow Partially Included Files}}
2050 {b pullsummary {Show Pull Summary}}
2051 {b trustmtime {Trust File Modification Timestamps}}
2052 {i diffcontext {Number of Diff Context Lines}}
2054 set type [lindex $option 0]
2055 set name [lindex $option 1]
2056 set text [lindex $option 2]
2057 foreach f {repo global} {
2060 checkbutton $w.$f.$name -text $text \
2061 -variable ${f}_config_new(gui.$name) \
2065 pack $w.$f.$name -side top -anchor w
2069 label $w.$f.$name.l -text "$text:" -font font_ui
2070 pack $w.$f.$name.l -side left -anchor w -fill x
2071 spinbox $w.$f.$name.v \
2072 -textvariable ${f}_config_new(gui.$name) \
2073 -from 1 -to 99 -increment 1 \
2076 pack $w.$f.$name.v -side right -anchor e
2077 pack $w.$f.$name -side top -anchor w -fill x
2083 set all_fonts [lsort [font families]]
2084 foreach option $font_descs {
2085 set name [lindex $option 0]
2086 set font [lindex $option 1]
2087 set text [lindex $option 2]
2089 set global_config_new(gui.$font^^family) \
2090 [font configure $font -family]
2091 set global_config_new(gui.$font^^size) \
2092 [font configure $font -size]
2094 frame $w.global.$name
2095 label $w.global.$name.l -text "$text:" -font font_ui
2096 pack $w.global.$name.l -side left -anchor w -fill x
2097 eval tk_optionMenu $w.global.$name.family \
2098 global_config_new(gui.$font^^family) \
2100 spinbox $w.global.$name.size \
2101 -textvariable global_config_new(gui.$font^^size) \
2102 -from 2 -to 80 -increment 1 \
2105 pack $w.global.$name.size -side right -anchor e
2106 pack $w.global.$name.family -side right -anchor e
2107 pack $w.global.$name -side top -anchor w -fill x
2110 bind $w <Visibility> "grab $w; focus $w"
2111 bind $w <Key-Escape> "destroy $w"
2112 wm title $w "$appname ($reponame): Options"
2116 proc do_restore_defaults {} {
2117 global font_descs default_config repo_config
2118 global repo_config_new global_config_new
2120 foreach name [array names default_config] {
2121 set repo_config_new($name) $default_config($name)
2122 set global_config_new($name) $default_config($name)
2125 foreach option $font_descs {
2126 set name [lindex $option 0]
2127 set repo_config(gui.$name) $default_config(gui.$name)
2131 foreach option $font_descs {
2132 set name [lindex $option 0]
2133 set font [lindex $option 1]
2134 set global_config_new(gui.$font^^family) \
2135 [font configure $font -family]
2136 set global_config_new(gui.$font^^size) \
2137 [font configure $font -size]
2141 proc do_save_config {w} {
2142 if {[catch {save_config} err]} {
2143 error_popup "Failed to completely save options:\n\n$err"
2149 proc do_windows_shortcut {} {
2150 global gitdir appname argv0
2152 set reponame [lindex [file split \
2153 [file normalize [file dirname $gitdir]]] \
2157 set desktop [exec cygpath \
2165 set fn [tk_getSaveFile \
2167 -title "$appname ($reponame): Create Desktop Icon" \
2168 -initialdir $desktop \
2169 -initialfile "Git $reponame.bat"]
2173 set sh [exec cygpath \
2178 set me [exec cygpath \
2182 set gd [exec cygpath \
2186 regsub -all ' $me "'\\''" me
2187 regsub -all ' $gd "'\\''" gd
2188 puts -nonewline $fd "\"$sh\" --login -c \""
2189 puts -nonewline $fd "GIT_DIR='$gd'"
2190 puts -nonewline $fd " '$me'"
2194 error_popup "Cannot write script:\n\n$err"
2199 proc do_macosx_app {} {
2200 global gitdir appname argv0 env
2202 set reponame [lindex [file split \
2203 [file normalize [file dirname $gitdir]]] \
2206 set fn [tk_getSaveFile \
2208 -title "$appname ($reponame): Create Desktop Icon" \
2209 -initialdir [file join $env(HOME) Desktop] \
2210 -initialfile "Git $reponame.app"]
2213 set Contents [file join $fn Contents]
2214 set MacOS [file join $Contents MacOS]
2215 set exe [file join $MacOS git-gui]
2219 set fd [open [file join $Contents PkgInfo] w]
2220 puts -nonewline $fd {APPL????}
2223 set fd [open [file join $Contents Info.plist] w]
2224 puts $fd {<?xml version="1.0" encoding="UTF-8"?>
2225 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
2226 <plist version="1.0">
2228 <key>CFBundleDevelopmentRegion</key>
2229 <string>English</string>
2230 <key>CFBundleExecutable</key>
2231 <string>git-gui</string>
2232 <key>CFBundleIdentifier</key>
2233 <string>org.spearce.git-gui</string>
2234 <key>CFBundleInfoDictionaryVersion</key>
2235 <string>6.0</string>
2236 <key>CFBundlePackageType</key>
2237 <string>APPL</string>
2238 <key>CFBundleSignature</key>
2239 <string>????</string>
2240 <key>CFBundleVersion</key>
2241 <string>1.0</string>
2242 <key>NSPrincipalClass</key>
2243 <string>NSApplication</string>
2248 set fd [open $exe w]
2249 set gd [file normalize $gitdir]
2250 set ep [file normalize [exec git --exec-path]]
2251 regsub -all ' $gd "'\\''" gd
2252 regsub -all ' $ep "'\\''" ep
2253 puts $fd "#!/bin/sh"
2254 foreach name [array names env] {
2255 if {[string match GIT_* $name]} {
2256 regsub -all ' $env($name) "'\\''" v
2257 puts $fd "export $name='$v'"
2260 puts $fd "export PATH='$ep':\$PATH"
2261 puts $fd "export GIT_DIR='$gd'"
2262 puts $fd "exec [file normalize $argv0]"
2265 file attributes $exe -permissions u+x,g+x,o+x
2267 error_popup "Cannot write icon:\n\n$err"
2272 proc toggle_or_diff {w x y} {
2273 global file_lists current_diff ui_index ui_other
2274 global last_clicked selected_paths
2276 set pos [split [$w index @$x,$y] .]
2277 set lno [lindex $pos 0]
2278 set col [lindex $pos 1]
2279 set path [lindex $file_lists($w) [expr {$lno - 1}]]
2285 set last_clicked [list $w $lno]
2286 array unset selected_paths
2287 $ui_index tag remove in_sel 0.0 end
2288 $ui_other tag remove in_sel 0.0 end
2291 if {$current_diff eq $path} {
2292 set after {reshow_diff;}
2297 "Including [short_path $path]" \
2299 [concat $after {set ui_status_value {Ready.}}]
2301 show_diff $path $w $lno
2305 proc add_one_to_selection {w x y} {
2307 global last_clicked selected_paths
2309 set pos [split [$w index @$x,$y] .]
2310 set lno [lindex $pos 0]
2311 set col [lindex $pos 1]
2312 set path [lindex $file_lists($w) [expr {$lno - 1}]]
2318 set last_clicked [list $w $lno]
2319 if {[catch {set in_sel $selected_paths($path)}]} {
2323 unset selected_paths($path)
2324 $w tag remove in_sel $lno.0 [expr {$lno + 1}].0
2326 set selected_paths($path) 1
2327 $w tag add in_sel $lno.0 [expr {$lno + 1}].0
2331 proc add_range_to_selection {w x y} {
2333 global last_clicked selected_paths
2335 if {[lindex $last_clicked 0] ne $w} {
2336 toggle_or_diff $w $x $y
2340 set pos [split [$w index @$x,$y] .]
2341 set lno [lindex $pos 0]
2342 set lc [lindex $last_clicked 1]
2351 foreach path [lrange $file_lists($w) \
2352 [expr {$begin - 1}] \
2353 [expr {$end - 1}]] {
2354 set selected_paths($path) 1
2356 $w tag add in_sel $begin.0 [expr {$end + 1}].0
2359 ######################################################################
2363 set cursor_ptr arrow
2364 font create font_diff -family Courier -size 10
2368 eval font configure font_ui [font actual [.dummy cget -font]]
2372 font create font_uibold
2373 font create font_diffbold
2377 if {$tcl_platform(platform) eq {windows}} {
2380 } elseif {[is_MacOSX]} {
2385 proc apply_config {} {
2386 global repo_config font_descs
2388 foreach option $font_descs {
2389 set name [lindex $option 0]
2390 set font [lindex $option 1]
2392 foreach {cn cv} $repo_config(gui.$name) {
2393 font configure $font $cn $cv
2396 error_popup "Invalid font specified in gui.$name:\n\n$err"
2398 foreach {cn cv} [font configure $font] {
2399 font configure ${font}bold $cn $cv
2401 font configure ${font}bold -weight bold
2405 set default_config(gui.trustmtime) false
2406 set default_config(gui.pullsummary) true
2407 set default_config(gui.partialinclude) false
2408 set default_config(gui.diffcontext) 5
2409 set default_config(gui.fontui) [font configure font_ui]
2410 set default_config(gui.fontdiff) [font configure font_diff]
2412 {fontui font_ui {Main Font}}
2413 {fontdiff font_diff {Diff/Console Font}}
2418 ######################################################################
2424 menu .mbar -tearoff 0
2425 .mbar add cascade -label Project -menu .mbar.project
2426 .mbar add cascade -label Edit -menu .mbar.edit
2427 .mbar add cascade -label Commit -menu .mbar.commit
2428 if {!$single_commit} {
2429 .mbar add cascade -label Fetch -menu .mbar.fetch
2430 .mbar add cascade -label Pull -menu .mbar.pull
2431 .mbar add cascade -label Push -menu .mbar.push
2433 . configure -menu .mbar
2438 .mbar.project add command -label Visualize \
2441 if {!$single_commit} {
2442 .mbar.project add command -label {Repack Database} \
2443 -command do_repack \
2446 if {$tcl_platform(platform) eq {windows}} {
2447 .mbar.project add command \
2448 -label {Create Desktop Icon} \
2449 -command do_windows_shortcut \
2451 } elseif {[is_MacOSX]} {
2452 .mbar.project add command \
2453 -label {Create Desktop Icon} \
2454 -command do_macosx_app \
2458 .mbar.project add command -label Quit \
2460 -accelerator $M1T-Q \
2466 .mbar.edit add command -label Undo \
2467 -command {catch {[focus] edit undo}} \
2468 -accelerator $M1T-Z \
2470 .mbar.edit add command -label Redo \
2471 -command {catch {[focus] edit redo}} \
2472 -accelerator $M1T-Y \
2474 .mbar.edit add separator
2475 .mbar.edit add command -label Cut \
2476 -command {catch {tk_textCut [focus]}} \
2477 -accelerator $M1T-X \
2479 .mbar.edit add command -label Copy \
2480 -command {catch {tk_textCopy [focus]}} \
2481 -accelerator $M1T-C \
2483 .mbar.edit add command -label Paste \
2484 -command {catch {tk_textPaste [focus]; [focus] see insert}} \
2485 -accelerator $M1T-V \
2487 .mbar.edit add command -label Delete \
2488 -command {catch {[focus] delete sel.first sel.last}} \
2491 .mbar.edit add separator
2492 .mbar.edit add command -label {Select All} \
2493 -command {catch {[focus] tag add sel 0.0 end}} \
2494 -accelerator $M1T-A \
2496 .mbar.edit add separator
2497 .mbar.edit add command -label {Options...} \
2498 -command do_options \
2505 .mbar.commit add radiobutton \
2506 -label {New Commit} \
2507 -command do_select_commit_type \
2508 -variable selected_commit_type \
2511 lappend disable_on_lock \
2512 [list .mbar.commit entryconf [.mbar.commit index last] -state]
2514 .mbar.commit add radiobutton \
2515 -label {Amend Last Commit} \
2516 -command do_select_commit_type \
2517 -variable selected_commit_type \
2520 lappend disable_on_lock \
2521 [list .mbar.commit entryconf [.mbar.commit index last] -state]
2523 .mbar.commit add separator
2525 .mbar.commit add command -label Rescan \
2526 -command do_rescan \
2529 lappend disable_on_lock \
2530 [list .mbar.commit entryconf [.mbar.commit index last] -state]
2532 .mbar.commit add command -label {Include Selected Files} \
2533 -command do_include_selection \
2535 lappend disable_on_lock \
2536 [list .mbar.commit entryconf [.mbar.commit index last] -state]
2538 .mbar.commit add command -label {Include All Files} \
2539 -command do_include_all \
2540 -accelerator $M1T-I \
2542 lappend disable_on_lock \
2543 [list .mbar.commit entryconf [.mbar.commit index last] -state]
2545 .mbar.commit add command -label {Sign Off} \
2546 -command do_signoff \
2547 -accelerator $M1T-S \
2550 .mbar.commit add command -label Commit \
2551 -command do_commit \
2552 -accelerator $M1T-Return \
2554 lappend disable_on_lock \
2555 [list .mbar.commit entryconf [.mbar.commit index last] -state]
2557 # -- Transport menus
2559 if {!$single_commit} {
2565 # -- Main Window Layout
2567 panedwindow .vpane -orient vertical
2568 panedwindow .vpane.files -orient horizontal
2569 .vpane add .vpane.files -sticky nsew -height 100 -width 400
2570 pack .vpane -anchor n -side top -fill both -expand 1
2572 # -- Index File List
2574 frame .vpane.files.index -height 100 -width 400
2575 label .vpane.files.index.title -text {Modified Files} \
2578 text $ui_index -background white -borderwidth 0 \
2579 -width 40 -height 10 \
2581 -cursor $cursor_ptr \
2582 -yscrollcommand {.vpane.files.index.sb set} \
2584 scrollbar .vpane.files.index.sb -command [list $ui_index yview]
2585 pack .vpane.files.index.title -side top -fill x
2586 pack .vpane.files.index.sb -side right -fill y
2587 pack $ui_index -side left -fill both -expand 1
2588 .vpane.files add .vpane.files.index -sticky nsew
2590 # -- Other (Add) File List
2592 frame .vpane.files.other -height 100 -width 100
2593 label .vpane.files.other.title -text {Untracked Files} \
2596 text $ui_other -background white -borderwidth 0 \
2597 -width 40 -height 10 \
2599 -cursor $cursor_ptr \
2600 -yscrollcommand {.vpane.files.other.sb set} \
2602 scrollbar .vpane.files.other.sb -command [list $ui_other yview]
2603 pack .vpane.files.other.title -side top -fill x
2604 pack .vpane.files.other.sb -side right -fill y
2605 pack $ui_other -side left -fill both -expand 1
2606 .vpane.files add .vpane.files.other -sticky nsew
2608 foreach i [list $ui_index $ui_other] {
2609 $i tag conf in_diff -font font_uibold
2610 $i tag conf in_sel \
2611 -background [$i cget -foreground] \
2612 -foreground [$i cget -background]
2616 # -- Diff and Commit Area
2618 frame .vpane.lower -height 300 -width 400
2619 frame .vpane.lower.commarea
2620 frame .vpane.lower.diff -relief sunken -borderwidth 1
2621 pack .vpane.lower.commarea -side top -fill x
2622 pack .vpane.lower.diff -side bottom -fill both -expand 1
2623 .vpane add .vpane.lower -stick nsew
2625 # -- Commit Area Buttons
2627 frame .vpane.lower.commarea.buttons
2628 label .vpane.lower.commarea.buttons.l -text {} \
2632 pack .vpane.lower.commarea.buttons.l -side top -fill x
2633 pack .vpane.lower.commarea.buttons -side left -fill y
2635 button .vpane.lower.commarea.buttons.rescan -text {Rescan} \
2636 -command do_rescan \
2638 pack .vpane.lower.commarea.buttons.rescan -side top -fill x
2639 lappend disable_on_lock \
2640 {.vpane.lower.commarea.buttons.rescan conf -state}
2642 button .vpane.lower.commarea.buttons.incall -text {Include All} \
2643 -command do_include_all \
2645 pack .vpane.lower.commarea.buttons.incall -side top -fill x
2646 lappend disable_on_lock \
2647 {.vpane.lower.commarea.buttons.incall conf -state}
2649 button .vpane.lower.commarea.buttons.signoff -text {Sign Off} \
2650 -command do_signoff \
2652 pack .vpane.lower.commarea.buttons.signoff -side top -fill x
2654 button .vpane.lower.commarea.buttons.commit -text {Commit} \
2655 -command do_commit \
2657 pack .vpane.lower.commarea.buttons.commit -side top -fill x
2658 lappend disable_on_lock \
2659 {.vpane.lower.commarea.buttons.commit conf -state}
2661 # -- Commit Message Buffer
2663 frame .vpane.lower.commarea.buffer
2664 frame .vpane.lower.commarea.buffer.header
2665 set ui_comm .vpane.lower.commarea.buffer.t
2666 set ui_coml .vpane.lower.commarea.buffer.header.l
2667 radiobutton .vpane.lower.commarea.buffer.header.new \
2668 -text {New Commit} \
2669 -command do_select_commit_type \
2670 -variable selected_commit_type \
2673 lappend disable_on_lock \
2674 [list .vpane.lower.commarea.buffer.header.new conf -state]
2675 radiobutton .vpane.lower.commarea.buffer.header.amend \
2676 -text {Amend Last Commit} \
2677 -command do_select_commit_type \
2678 -variable selected_commit_type \
2681 lappend disable_on_lock \
2682 [list .vpane.lower.commarea.buffer.header.amend conf -state]
2687 proc trace_commit_type {varname args} {
2688 global ui_coml commit_type
2689 switch -glob -- $commit_type {
2690 initial {set txt {Initial Commit Message:}}
2691 amend {set txt {Amended Commit Message:}}
2692 amend-initial {set txt {Amended Initial Commit Message:}}
2693 merge {set txt {Merge Commit Message:}}
2694 * {set txt {Commit Message:}}
2696 $ui_coml conf -text $txt
2698 trace add variable commit_type write trace_commit_type
2699 pack $ui_coml -side left -fill x
2700 pack .vpane.lower.commarea.buffer.header.amend -side right
2701 pack .vpane.lower.commarea.buffer.header.new -side right
2703 text $ui_comm -background white -borderwidth 1 \
2706 -autoseparators true \
2708 -width 75 -height 9 -wrap none \
2710 -yscrollcommand {.vpane.lower.commarea.buffer.sby set}
2711 scrollbar .vpane.lower.commarea.buffer.sby \
2712 -command [list $ui_comm yview]
2713 pack .vpane.lower.commarea.buffer.header -side top -fill x
2714 pack .vpane.lower.commarea.buffer.sby -side right -fill y
2715 pack $ui_comm -side left -fill y
2716 pack .vpane.lower.commarea.buffer -side left -fill y
2718 # -- Commit Message Buffer Context Menu
2720 set ctxm .vpane.lower.commarea.buffer.ctxm
2721 menu $ctxm -tearoff 0
2725 -command {tk_textCut $ui_comm}
2729 -command {tk_textCopy $ui_comm}
2733 -command {tk_textPaste $ui_comm}
2737 -command {$ui_comm delete sel.first sel.last}
2740 -label {Select All} \
2742 -command {$ui_comm tag add sel 0.0 end}
2747 $ui_comm tag add sel 0.0 end
2748 tk_textCopy $ui_comm
2749 $ui_comm tag remove sel 0.0 end
2756 bind_button3 $ui_comm "tk_popup $ctxm %X %Y"
2761 set diff_actions [list]
2762 proc trace_current_diff {varname args} {
2763 global current_diff diff_actions file_states
2764 if {$current_diff eq {}} {
2771 set s [mapdesc [lindex $file_states($p) 0] $p]
2773 set p [escape_path $p]
2777 .vpane.lower.diff.header.status configure -text $s
2778 .vpane.lower.diff.header.file configure -text $f
2779 .vpane.lower.diff.header.path configure -text $p
2780 foreach w $diff_actions {
2784 trace add variable current_diff write trace_current_diff
2786 frame .vpane.lower.diff.header -background orange
2787 label .vpane.lower.diff.header.status \
2788 -background orange \
2789 -width $max_status_desc \
2793 label .vpane.lower.diff.header.file \
2794 -background orange \
2798 label .vpane.lower.diff.header.path \
2799 -background orange \
2803 pack .vpane.lower.diff.header.status -side left
2804 pack .vpane.lower.diff.header.file -side left
2805 pack .vpane.lower.diff.header.path -fill x
2806 set ctxm .vpane.lower.diff.header.ctxm
2807 menu $ctxm -tearoff 0
2818 lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
2819 bind_button3 .vpane.lower.diff.header.path "tk_popup $ctxm %X %Y"
2823 frame .vpane.lower.diff.body
2824 set ui_diff .vpane.lower.diff.body.t
2825 text $ui_diff -background white -borderwidth 0 \
2826 -width 80 -height 15 -wrap none \
2828 -xscrollcommand {.vpane.lower.diff.body.sbx set} \
2829 -yscrollcommand {.vpane.lower.diff.body.sby set} \
2831 scrollbar .vpane.lower.diff.body.sbx -orient horizontal \
2832 -command [list $ui_diff xview]
2833 scrollbar .vpane.lower.diff.body.sby -orient vertical \
2834 -command [list $ui_diff yview]
2835 pack .vpane.lower.diff.body.sbx -side bottom -fill x
2836 pack .vpane.lower.diff.body.sby -side right -fill y
2837 pack $ui_diff -side left -fill both -expand 1
2838 pack .vpane.lower.diff.header -side top -fill x
2839 pack .vpane.lower.diff.body -side bottom -fill both -expand 1
2841 $ui_diff tag conf dm -foreground red
2842 $ui_diff tag conf dp -foreground blue
2843 $ui_diff tag conf di -foreground {#00a000}
2844 $ui_diff tag conf dni -foreground {#a000a0}
2845 $ui_diff tag conf da -font font_diffbold
2846 $ui_diff tag conf bold -font font_diffbold
2848 # -- Diff Body Context Menu
2850 set ctxm .vpane.lower.diff.body.ctxm
2851 menu $ctxm -tearoff 0
2855 -command {tk_textCopy $ui_diff}
2856 lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
2858 -label {Select All} \
2860 -command {$ui_diff tag add sel 0.0 end}
2861 lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
2866 $ui_diff tag add sel 0.0 end
2867 tk_textCopy $ui_diff
2868 $ui_diff tag remove sel 0.0 end
2870 lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
2873 -label {Decrease Font Size} \
2875 -command {incr_font_size font_diff -1}
2876 lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
2878 -label {Increase Font Size} \
2880 -command {incr_font_size font_diff 1}
2881 lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
2884 -label {Show Less Context} \
2886 -command {if {$repo_config(gui.diffcontext) >= 2} {
2887 incr repo_config(gui.diffcontext) -1
2890 lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
2892 -label {Show More Context} \
2895 incr repo_config(gui.diffcontext)
2898 lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
2900 $ctxm add command -label {Options...} \
2903 bind_button3 $ui_diff "tk_popup $ctxm %X %Y"
2907 set ui_status_value {Initializing...}
2908 label .status -textvariable ui_status_value \
2914 pack .status -anchor w -side bottom -fill x
2919 set gm $repo_config(gui.geometry)
2920 wm geometry . [lindex $gm 0]
2921 .vpane sash place 0 \
2922 [lindex [.vpane sash coord 0] 0] \
2924 .vpane.files sash place 0 \
2926 [lindex [.vpane.files sash coord 0] 1]
2932 bind $ui_comm <$M1B-Key-Return> {do_commit;break}
2933 bind $ui_comm <$M1B-Key-i> {do_include_all;break}
2934 bind $ui_comm <$M1B-Key-I> {do_include_all;break}
2935 bind $ui_comm <$M1B-Key-x> {tk_textCut %W;break}
2936 bind $ui_comm <$M1B-Key-X> {tk_textCut %W;break}
2937 bind $ui_comm <$M1B-Key-c> {tk_textCopy %W;break}
2938 bind $ui_comm <$M1B-Key-C> {tk_textCopy %W;break}
2939 bind $ui_comm <$M1B-Key-v> {tk_textPaste %W; %W see insert; break}
2940 bind $ui_comm <$M1B-Key-V> {tk_textPaste %W; %W see insert; break}
2941 bind $ui_comm <$M1B-Key-a> {%W tag add sel 0.0 end;break}
2942 bind $ui_comm <$M1B-Key-A> {%W tag add sel 0.0 end;break}
2944 bind $ui_diff <$M1B-Key-x> {tk_textCopy %W;break}
2945 bind $ui_diff <$M1B-Key-X> {tk_textCopy %W;break}
2946 bind $ui_diff <$M1B-Key-c> {tk_textCopy %W;break}
2947 bind $ui_diff <$M1B-Key-C> {tk_textCopy %W;break}
2948 bind $ui_diff <$M1B-Key-v> {break}
2949 bind $ui_diff <$M1B-Key-V> {break}
2950 bind $ui_diff <$M1B-Key-a> {%W tag add sel 0.0 end;break}
2951 bind $ui_diff <$M1B-Key-A> {%W tag add sel 0.0 end;break}
2952 bind $ui_diff <Key-Up> {catch {%W yview scroll -1 units};break}
2953 bind $ui_diff <Key-Down> {catch {%W yview scroll 1 units};break}
2954 bind $ui_diff <Key-Left> {catch {%W xview scroll -1 units};break}
2955 bind $ui_diff <Key-Right> {catch {%W xview scroll 1 units};break}
2957 bind . <Destroy> do_quit
2958 bind all <Key-F5> do_rescan
2959 bind all <$M1B-Key-r> do_rescan
2960 bind all <$M1B-Key-R> do_rescan
2961 bind . <$M1B-Key-s> do_signoff
2962 bind . <$M1B-Key-S> do_signoff
2963 bind . <$M1B-Key-i> do_include_all
2964 bind . <$M1B-Key-I> do_include_all
2965 bind . <$M1B-Key-Return> do_commit
2966 bind all <$M1B-Key-q> do_quit
2967 bind all <$M1B-Key-Q> do_quit
2968 bind all <$M1B-Key-w> {destroy [winfo toplevel %W]}
2969 bind all <$M1B-Key-W> {destroy [winfo toplevel %W]}
2970 foreach i [list $ui_index $ui_other] {
2971 bind $i <Button-1> "toggle_or_diff $i %x %y; break"
2972 bind $i <$M1B-Button-1> "add_one_to_selection $i %x %y; break"
2973 bind $i <Shift-Button-1> "add_range_to_selection $i %x %y; break"
2977 set file_lists($ui_index) [list]
2978 set file_lists($ui_other) [list]
2985 set selected_commit_type new
2987 wm title . "$appname ([file normalize [file dirname $gitdir]])"
2988 focus -force $ui_comm
2989 if {!$single_commit} {
2991 populate_fetch_menu .mbar.fetch
2992 populate_pull_menu .mbar.pull
2993 populate_push_menu .mbar.push
2995 lock_index begin-read