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 load_repo_config {} {
19 global cfg_trust_mtime
21 array unset repo_config
23 set fd_rc [open "| git repo-config --list" r]
24 while {[gets $fd_rc line] >= 0} {
25 if {[regexp {^([^=]+)=(.*)$} $line line name value]} {
26 lappend repo_config($name) $value
32 if {[catch {set cfg_trust_mtime \
33 [lindex $repo_config(gui.trustmtime) 0]
35 set cfg_trust_mtime false
39 proc save_my_config {} {
41 global cfg_trust_mtime
43 if {[catch {set rc_trustMTime $repo_config(gui.trustmtime)}]} {
44 set rc_trustMTime [list false]
46 if {$cfg_trust_mtime != [lindex $rc_trustMTime 0]} {
47 exec git repo-config gui.trustMTime $cfg_trust_mtime
48 set repo_config(gui.trustmtime) [list $cfg_trust_mtime]
51 set cfg_geometry [wm geometry .]
52 append cfg_geometry " [lindex [.vpane sash coord 0] 1]"
53 append cfg_geometry " [lindex [.vpane.files sash coord 0] 0]"
54 if {[catch {set rc_geometry $repo_config(gui.geometry)}]} {
55 set rc_geometry [list [list]]
57 if {$cfg_geometry != [lindex $rc_geometry 0]} {
58 exec git repo-config gui.geometry $cfg_geometry
59 set repo_config(gui.geometry) [list $cfg_geometry]
63 proc error_popup {msg} {
69 append title [lindex \
70 [file split [file normalize [file dirname $gitdir]]] \
78 -title "$title: error" \
82 proc info_popup {msg} {
88 append title [lindex \
89 [file split [file normalize [file dirname $gitdir]]] \
101 ######################################################################
105 if { [catch {set cdup [exec git rev-parse --show-cdup]} err]
106 || [catch {set gitdir [exec git rev-parse --git-dir]} err]} {
107 catch {wm withdraw .}
108 error_popup "Cannot find the git directory:\n\n$err"
116 if {$appname == {git-citool}} {
122 ######################################################################
131 set update_index_fd {}
133 set disable_on_lock [list]
134 set index_lock_type none
140 proc lock_index {type} {
141 global index_lock_type disable_on_lock
143 if {$index_lock_type == {none}} {
144 set index_lock_type $type
145 foreach w $disable_on_lock {
146 uplevel #0 $w disabled
149 } elseif {$index_lock_type == {begin-update} && $type == {update}} {
150 set index_lock_type $type
156 proc unlock_index {} {
157 global index_lock_type disable_on_lock
159 set index_lock_type none
160 foreach w $disable_on_lock {
165 ######################################################################
169 proc repository_state {hdvar ctvar} {
171 upvar $hdvar hd $ctvar ct
173 if {[catch {set hd [exec git rev-parse --verify HEAD]}]} {
175 } elseif {[file exists [file join $gitdir MERGE_HEAD]]} {
182 proc update_status {{final Ready.}} {
183 global HEAD PARENT commit_type
184 global ui_index ui_other ui_status_value ui_comm
185 global status_active file_states
186 global cfg_trust_mtime
188 if {$status_active || ![lock_index read]} return
190 repository_state new_HEAD new_type
191 if {$commit_type == {amend}
192 && $new_type == {normal}
193 && $new_HEAD == $HEAD} {
197 set commit_type $new_type
200 array unset file_states
202 if {![$ui_comm edit modified]
203 || [string trim [$ui_comm get 0.0 end]] == {}} {
204 if {[load_message GITGUI_MSG]} {
205 } elseif {[load_message MERGE_MSG]} {
206 } elseif {[load_message SQUASH_MSG]} {
208 $ui_comm edit modified false
212 if {$cfg_trust_mtime == {true}} {
213 update_status_stage2 {} $final
216 set ui_status_value {Refreshing file status...}
217 set cmd [list git update-index]
219 lappend cmd --unmerged
220 lappend cmd --ignore-missing
221 lappend cmd --refresh
222 set fd_rf [open "| $cmd" r]
223 fconfigure $fd_rf -blocking 0 -translation binary
224 fileevent $fd_rf readable \
225 [list update_status_stage2 $fd_rf $final]
229 proc update_status_stage2 {fd final} {
230 global gitdir PARENT commit_type
231 global ui_index ui_other ui_status_value ui_comm
233 global buf_rdi buf_rdf buf_rlo
237 if {![eof $fd]} return
241 set ls_others [list | git ls-files --others -z \
242 --exclude-per-directory=.gitignore]
243 set info_exclude [file join $gitdir info exclude]
244 if {[file readable $info_exclude]} {
245 lappend ls_others "--exclude-from=$info_exclude"
253 set ui_status_value {Scanning for modified files ...}
254 set fd_di [open "| git diff-index --cached -z $PARENT" r]
255 set fd_df [open "| git diff-files -z" r]
256 set fd_lo [open $ls_others r]
258 fconfigure $fd_di -blocking 0 -translation binary
259 fconfigure $fd_df -blocking 0 -translation binary
260 fconfigure $fd_lo -blocking 0 -translation binary
261 fileevent $fd_di readable [list read_diff_index $fd_di $final]
262 fileevent $fd_df readable [list read_diff_files $fd_df $final]
263 fileevent $fd_lo readable [list read_ls_others $fd_lo $final]
266 proc load_message {file} {
267 global gitdir ui_comm
269 set f [file join $gitdir $file]
270 if {[file isfile $f]} {
271 if {[catch {set fd [open $f r]}]} {
274 set content [string trim [read $fd]]
276 $ui_comm delete 0.0 end
277 $ui_comm insert end $content
283 proc read_diff_index {fd final} {
286 append buf_rdi [read $fd]
288 set n [string length $buf_rdi]
290 set z1 [string first "\0" $buf_rdi $c]
293 set z2 [string first "\0" $buf_rdi $z1]
299 [string range $buf_rdi $z1 $z2] \
300 [string index $buf_rdi [expr $z1 - 2]]_
304 set buf_rdi [string range $buf_rdi $c end]
309 status_eof $fd buf_rdi $final
312 proc read_diff_files {fd final} {
315 append buf_rdf [read $fd]
317 set n [string length $buf_rdf]
319 set z1 [string first "\0" $buf_rdf $c]
322 set z2 [string first "\0" $buf_rdf $z1]
328 [string range $buf_rdf $z1 $z2] \
329 _[string index $buf_rdf [expr $z1 - 2]]
333 set buf_rdf [string range $buf_rdf $c end]
338 status_eof $fd buf_rdf $final
341 proc read_ls_others {fd final} {
344 append buf_rlo [read $fd]
345 set pck [split $buf_rlo "\0"]
346 set buf_rlo [lindex $pck end]
347 foreach p [lrange $pck 0 end-1] {
350 status_eof $fd buf_rlo $final
353 proc status_eof {fd buf final} {
354 global status_active ui_status_value
361 if {[incr status_active -1] == 0} {
365 set ui_status_value $final
370 ######################################################################
375 global ui_diff ui_fname_value ui_fstatus_value ui_index ui_other
377 $ui_diff conf -state normal
378 $ui_diff delete 0.0 end
379 $ui_diff conf -state disabled
381 set ui_fname_value {}
382 set ui_fstatus_value {}
384 $ui_index tag remove in_diff 0.0 end
385 $ui_other tag remove in_diff 0.0 end
388 proc reshow_diff {} {
389 global ui_fname_value ui_status_value file_states
391 if {$ui_fname_value == {}
392 || [catch {set s $file_states($ui_fname_value)}]} {
395 show_diff $ui_fname_value
399 proc handle_empty_diff {} {
400 global ui_fname_value file_states file_lists
402 set path $ui_fname_value
403 set s $file_states($path)
404 if {[lindex $s 0] != {_M}} return
406 info_popup "No differences detected.
408 [short_path $path] has no changes.
410 The modification date of this file was updated by another
411 application and you currently have the Trust File Modification
412 Timestamps feature enabled, so Git did not automatically detect
413 that there are no content differences in this file.
415 This file will now be removed from the modified files list, to
416 prevent possible confusion.
418 if {[catch {exec git update-index -- $path} err]} {
419 error_popup "Failed to refresh index:\n\n$err"
423 set old_w [mapcol [lindex $file_states($path) 0] $path]
424 set lno [lsearch -sorted $file_lists($old_w) $path]
426 set file_lists($old_w) \
427 [lreplace $file_lists($old_w) $lno $lno]
429 $old_w conf -state normal
430 $old_w delete $lno.0 [expr $lno + 1].0
431 $old_w conf -state disabled
435 proc show_diff {path {w {}} {lno {}}} {
436 global file_states file_lists
437 global PARENT diff_3way diff_active
438 global ui_diff ui_fname_value ui_fstatus_value ui_status_value
440 if {$diff_active || ![lock_index read]} return
443 if {$w == {} || $lno == {}} {
444 foreach w [array names file_lists] {
445 set lno [lsearch -sorted $file_lists($w) $path]
452 if {$w != {} && $lno >= 1} {
453 $w tag add in_diff $lno.0 [expr $lno + 1].0
456 set s $file_states($path)
460 set ui_fname_value [escape_path $path]
461 set ui_fstatus_value [mapdesc $m $path]
462 set ui_status_value "Loading diff of [escape_path $path]..."
464 set cmd [list | git diff-index -p $PARENT -- $path]
467 set cmd [list | git diff-index -p -c $PARENT $path]
471 set fd [open $path r]
472 set content [read $fd]
477 set ui_status_value "Unable to display [escape_path $path]"
478 error_popup "Error loading file:\n\n$err"
481 $ui_diff conf -state normal
482 $ui_diff insert end $content
483 $ui_diff conf -state disabled
486 set ui_status_value {Ready.}
491 if {[catch {set fd [open $cmd r]} err]} {
494 set ui_status_value "Unable to display [escape_path $path]"
495 error_popup "Error loading diff:\n\n$err"
499 fconfigure $fd -blocking 0 -translation auto
500 fileevent $fd readable [list read_diff $fd]
503 proc read_diff {fd} {
504 global ui_diff ui_status_value diff_3way diff_active
505 global cfg_trust_mtime
507 while {[gets $fd line] >= 0} {
508 if {[string match {diff --git *} $line]} continue
509 if {[string match {diff --combined *} $line]} continue
510 if {[string match {--- *} $line]} continue
511 if {[string match {+++ *} $line]} continue
512 if {[string match index* $line]} {
513 if {[string first , $line] >= 0} {
518 $ui_diff conf -state normal
520 set x [string index $line 0]
525 default {set tags {}}
528 set x [string range $line 0 1]
530 default {set tags {}}
532 "++" {set tags dp; set x " +"}
533 " +" {set tags {di bold}; set x "++"}
534 "+ " {set tags dni; set x "-+"}
535 "--" {set tags dm; set x " -"}
536 " -" {set tags {dm bold}; set x "--"}
537 "- " {set tags di; set x "+-"}
538 default {set tags {}}
540 set line [string replace $line 0 1 $x]
542 $ui_diff insert end $line $tags
543 $ui_diff insert end "\n"
544 $ui_diff conf -state disabled
551 set ui_status_value {Ready.}
553 if {$cfg_trust_mtime && [$ui_diff index end] == {2.0}} {
559 ######################################################################
563 proc load_last_commit {} {
564 global HEAD PARENT commit_type ui_comm
566 if {$commit_type == {amend}} return
567 if {$commit_type != {normal}} {
568 error_popup "Can't amend a $commit_type commit."
576 set fd [open "| git cat-file commit $HEAD" r]
577 while {[gets $fd line] > 0} {
578 if {[string match {parent *} $line]} {
579 set parent [string range $line 7 end]
583 set msg [string trim [read $fd]]
586 error_popup "Error loading commit data for amend:\n\n$err"
590 if {$parent_count == 0} {
591 set commit_type amend
595 } elseif {$parent_count == 1} {
596 set commit_type amend
598 $ui_comm delete 0.0 end
599 $ui_comm insert end $msg
600 $ui_comm edit modified false
604 error_popup {You can't amend a merge commit.}
609 proc commit_tree {} {
610 global tcl_platform HEAD gitdir commit_type file_states
611 global commit_active ui_status_value
614 if {$commit_active || ![lock_index update]} return
616 # -- Our in memory state should match the repository.
618 repository_state curHEAD cur_type
619 if {$commit_type == {amend}
620 && $cur_type == {normal}
621 && $curHEAD == $HEAD} {
622 } elseif {$commit_type != $cur_type || $HEAD != $curHEAD} {
623 error_popup {Last scanned state does not match repository state.
625 Its highly likely that another Git program modified the
626 repository since our last scan. A rescan is required
634 # -- At least one file should differ in the index.
637 foreach path [array names file_states] {
638 set s $file_states($path)
639 switch -glob -- [lindex $s 0] {
643 M? {set files_ready 1; break}
645 error_popup "Unmerged files cannot be committed.
647 File [short_path $path] has merge conflicts.
648 You must resolve them and include the file before committing.
654 error_popup "Unknown file state [lindex $s 0] detected.
656 File [short_path $path] cannot be committed by this program.
662 error_popup {No included files to commit.
664 You must include at least 1 file before you can commit.
670 # -- A message is required.
672 set msg [string trim [$ui_comm get 1.0 end]]
674 error_popup {Please supply a commit message.
676 A good commit message has the following format:
678 - First line: Describe in one sentance what you did.
680 - Remaining lines: Describe why this change is good.
686 # -- Ask the pre-commit hook for the go-ahead.
688 set pchook [file join $gitdir hooks pre-commit]
689 if {$tcl_platform(platform) == {windows} && [file isfile $pchook]} {
690 set pchook [list sh -c \
691 "if test -x \"$pchook\"; then exec \"$pchook\"; fi"]
692 } elseif {[file executable $pchook]} {
693 set pchook [list $pchook]
697 if {$pchook != {} && [catch {eval exec $pchook} err]} {
698 hook_failed_popup pre-commit $err
703 # -- Write the tree in the background.
706 set ui_status_value {Committing changes...}
708 set fd_wt [open "| git write-tree" r]
709 fileevent $fd_wt readable [list commit_stage2 $fd_wt $curHEAD $msg]
712 proc commit_stage2 {fd_wt curHEAD msg} {
713 global single_commit gitdir HEAD PARENT commit_type
714 global commit_active ui_status_value ui_comm
718 if {$tree_id == {} || [catch {close $fd_wt} err]} {
719 error_popup "write-tree failed:\n\n$err"
721 set ui_status_value {Commit failed.}
726 # -- Create the commit.
728 set cmd [list git commit-tree $tree_id]
730 lappend cmd -p $PARENT
732 if {$commit_type == {merge}} {
734 set fd_mh [open [file join $gitdir MERGE_HEAD] r]
735 while {[gets $fd_mh merge_head] >= 0} {
736 lappend cmd -p $merge_head
740 error_popup "Loading MERGE_HEAD failed:\n\n$err"
742 set ui_status_value {Commit failed.}
748 # git commit-tree writes to stderr during initial commit.
749 lappend cmd 2>/dev/null
752 if {[catch {set cmt_id [eval exec $cmd]} err]} {
753 error_popup "commit-tree failed:\n\n$err"
755 set ui_status_value {Commit failed.}
760 # -- Update the HEAD ref.
763 if {$commit_type != {normal}} {
764 append reflogm " ($commit_type)"
766 set i [string first "\n" $msg]
768 append reflogm {: } [string range $msg 0 [expr $i - 1]]
770 append reflogm {: } $msg
772 set cmd [list git update-ref -m $reflogm HEAD $cmt_id $curHEAD]
773 if {[catch {eval exec $cmd} err]} {
774 error_popup "update-ref failed:\n\n$err"
776 set ui_status_value {Commit failed.}
781 # -- Cleanup after ourselves.
783 catch {file delete [file join $gitdir MERGE_HEAD]}
784 catch {file delete [file join $gitdir MERGE_MSG]}
785 catch {file delete [file join $gitdir SQUASH_MSG]}
786 catch {file delete [file join $gitdir GITGUI_MSG]}
788 # -- Let rerere do its thing.
790 if {[file isdirectory [file join $gitdir rr-cache]]} {
791 catch {exec git rerere}
794 $ui_comm delete 0.0 end
795 $ui_comm edit modified false
798 if {$single_commit} do_quit
800 # -- Update status without invoking any git commands.
803 set commit_type normal
807 foreach path [array names file_states] {
808 set s $file_states($path)
813 D? {set m _[string index $m 1]}
817 unset file_states($path)
819 lset file_states($path) 0 $m
826 set ui_status_value \
827 "Changes committed as [string range $cmt_id 0 7]."
830 ######################################################################
834 proc fetch_from {remote} {
835 set w [new_console "fetch $remote" \
836 "Fetching new changes from $remote"]
837 set cmd [list git fetch]
842 proc pull_remote {remote branch} {
843 global HEAD commit_type
846 if {![lock_index update]} return
848 # -- Our in memory state should match the repository.
850 repository_state curHEAD cur_type
851 if {$commit_type != $cur_type || $HEAD != $curHEAD} {
852 error_popup {Last scanned state does not match repository state.
854 Its highly likely that another Git program modified the
855 repository since our last scan. A rescan is required
856 before a pull can be started.
863 # -- No differences should exist before a pull.
865 if {[array size file_states] != 0} {
866 error_popup {Uncommitted but modified files are present.
868 You should not perform a pull with unmodified files in your working
869 directory as Git would be unable to recover from an incorrect merge.
871 Commit or throw away all changes before starting a pull operation.
877 set w [new_console "pull $remote $branch" \
878 "Pulling new changes from branch $branch in $remote"]
879 set cmd [list git pull]
882 console_exec $w $cmd [list post_pull_remote $remote $branch]
885 proc post_pull_remote {remote branch success} {
886 global HEAD PARENT commit_type
887 global ui_status_value
891 repository_state HEAD commit_type
893 set $ui_status_value {Ready.}
896 "Conflicts detected while pulling $branch from $remote."
900 proc push_to {remote} {
901 set w [new_console "push $remote" \
902 "Pushing changes to $remote"]
903 set cmd [list git push]
908 ######################################################################
912 proc mapcol {state path} {
913 global all_cols ui_other
915 if {[catch {set r $all_cols($state)}]} {
916 puts "error: no column for state={$state} $path"
922 proc mapicon {state path} {
925 if {[catch {set r $all_icons($state)}]} {
926 puts "error: no icon for state={$state} $path"
932 proc mapdesc {state path} {
935 if {[catch {set r $all_descs($state)}]} {
936 puts "error: no desc for state={$state} $path"
942 proc escape_path {path} {
943 regsub -all "\n" $path "\\n" path
947 proc short_path {path} {
948 return [escape_path [lindex [file split $path] end]]
953 proc merge_state {path new_state} {
954 global file_states next_icon_id
956 set s0 [string index $new_state 0]
957 set s1 [string index $new_state 1]
959 if {[catch {set info $file_states($path)}]} {
961 set icon n[incr next_icon_id]
963 set state [lindex $info 0]
964 set icon [lindex $info 1]
968 set s0 [string index $state 0]
969 } elseif {$s0 == {*}} {
974 set s1 [string index $state 1]
975 } elseif {$s1 == {*}} {
979 set file_states($path) [list $s0$s1 $icon]
983 proc display_file {path state} {
984 global file_states file_lists status_active
986 set old_m [merge_state $path $state]
987 if {$status_active} return
989 set s $file_states($path)
990 set new_m [lindex $s 0]
991 set new_w [mapcol $new_m $path]
992 set old_w [mapcol $old_m $path]
993 set new_icon [mapicon $new_m $path]
995 if {$new_w != $old_w} {
996 set lno [lsearch -sorted $file_lists($old_w) $path]
999 $old_w conf -state normal
1000 $old_w delete $lno.0 [expr $lno + 1].0
1001 $old_w conf -state disabled
1004 lappend file_lists($new_w) $path
1005 set file_lists($new_w) [lsort $file_lists($new_w)]
1006 set lno [lsearch -sorted $file_lists($new_w) $path]
1008 $new_w conf -state normal
1009 $new_w image create $lno.0 \
1010 -align center -padx 5 -pady 1 \
1011 -name [lindex $s 1] \
1013 $new_w insert $lno.1 "[escape_path $path]\n"
1014 $new_w conf -state disabled
1015 } elseif {$new_icon != [mapicon $old_m $path]} {
1016 $new_w conf -state normal
1017 $new_w image conf [lindex $s 1] -image $new_icon
1018 $new_w conf -state disabled
1022 proc display_all_files {} {
1023 global ui_index ui_other file_states file_lists
1025 $ui_index conf -state normal
1026 $ui_other conf -state normal
1028 $ui_index delete 0.0 end
1029 $ui_other delete 0.0 end
1031 set file_lists($ui_index) [list]
1032 set file_lists($ui_other) [list]
1034 foreach path [lsort [array names file_states]] {
1035 set s $file_states($path)
1037 set w [mapcol $m $path]
1038 lappend file_lists($w) $path
1039 $w image create end \
1040 -align center -padx 5 -pady 1 \
1041 -name [lindex $s 1] \
1042 -image [mapicon $m $path]
1043 $w insert end "[escape_path $path]\n"
1046 $ui_index conf -state disabled
1047 $ui_other conf -state disabled
1050 proc with_update_index {body} {
1051 global update_index_fd
1053 if {$update_index_fd == {}} {
1054 if {![lock_index update]} return
1055 set update_index_fd [open \
1056 "| git update-index --add --remove -z --stdin" \
1058 fconfigure $update_index_fd -translation binary
1060 close $update_index_fd
1061 set update_index_fd {}
1068 proc update_index {path} {
1069 global update_index_fd
1071 if {$update_index_fd == {}} {
1072 error {not in with_update_index}
1074 puts -nonewline $update_index_fd "$path\0"
1078 proc toggle_mode {path} {
1079 global file_states ui_fname_value
1081 set s $file_states($path)
1094 with_update_index {update_index $path}
1095 display_file $path $new
1096 if {$ui_fname_value == $path} {
1101 ######################################################################
1103 ## remote management
1105 proc load_all_remotes {} {
1106 global gitdir all_remotes repo_config
1108 set all_remotes [list]
1109 set rm_dir [file join $gitdir remotes]
1110 if {[file isdirectory $rm_dir]} {
1111 set all_remotes [concat $all_remotes [glob \
1115 -directory $rm_dir *]]
1118 foreach line [array names repo_config remote.*.url] {
1119 if {[regexp ^remote\.(.*)\.url\$ $line line name]} {
1120 lappend all_remotes $name
1124 set all_remotes [lsort -unique $all_remotes]
1127 proc populate_remote_menu {m pfx op} {
1130 foreach remote $all_remotes {
1131 $m add command -label "$pfx $remote..." \
1132 -command [list $op $remote] \
1137 proc populate_pull_menu {m} {
1138 global gitdir repo_config all_remotes disable_on_lock
1140 foreach remote $all_remotes {
1142 if {[array get repo_config remote.$remote.url] != {}} {
1143 if {[array get repo_config remote.$remote.fetch] != {}} {
1144 regexp {^([^:]+):} \
1145 [lindex $repo_config(remote.$remote.fetch) 0] \
1150 set fd [open [file join $gitdir remotes $remote] r]
1151 while {[gets $fd line] >= 0} {
1152 if {[regexp {^Pull:[ \t]*([^:]+):} $line line rb]} {
1161 regsub ^refs/heads/ $rb {} rb_short
1162 if {$rb_short != {}} {
1164 -label "Branch $rb_short from $remote..." \
1165 -command [list pull_remote $remote $rb] \
1167 lappend disable_on_lock \
1168 [list $m entryconf [$m index last] -state]
1173 ######################################################################
1178 #define mask_width 14
1179 #define mask_height 15
1180 static unsigned char mask_bits[] = {
1181 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
1182 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
1183 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f};
1186 image create bitmap file_plain -background white -foreground black -data {
1187 #define plain_width 14
1188 #define plain_height 15
1189 static unsigned char plain_bits[] = {
1190 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
1191 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10,
1192 0x02, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1193 } -maskdata $filemask
1195 image create bitmap file_mod -background white -foreground blue -data {
1196 #define mod_width 14
1197 #define mod_height 15
1198 static unsigned char mod_bits[] = {
1199 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
1200 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
1201 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
1202 } -maskdata $filemask
1204 image create bitmap file_fulltick -background white -foreground "#007000" -data {
1205 #define file_fulltick_width 14
1206 #define file_fulltick_height 15
1207 static unsigned char file_fulltick_bits[] = {
1208 0xfe, 0x01, 0x02, 0x1a, 0x02, 0x0c, 0x02, 0x0c, 0x02, 0x16, 0x02, 0x16,
1209 0x02, 0x13, 0x00, 0x13, 0x86, 0x11, 0x8c, 0x11, 0xd8, 0x10, 0xf2, 0x10,
1210 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1211 } -maskdata $filemask
1213 image create bitmap file_parttick -background white -foreground "#005050" -data {
1214 #define parttick_width 14
1215 #define parttick_height 15
1216 static unsigned char parttick_bits[] = {
1217 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
1218 0x7a, 0x14, 0x02, 0x16, 0x02, 0x13, 0x8a, 0x11, 0xda, 0x10, 0x72, 0x10,
1219 0x22, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1220 } -maskdata $filemask
1222 image create bitmap file_question -background white -foreground black -data {
1223 #define file_question_width 14
1224 #define file_question_height 15
1225 static unsigned char file_question_bits[] = {
1226 0xfe, 0x01, 0x02, 0x02, 0xe2, 0x04, 0xf2, 0x09, 0x1a, 0x1b, 0x0a, 0x13,
1227 0x82, 0x11, 0xc2, 0x10, 0x62, 0x10, 0x62, 0x10, 0x02, 0x10, 0x62, 0x10,
1228 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
1229 } -maskdata $filemask
1231 image create bitmap file_removed -background white -foreground red -data {
1232 #define file_removed_width 14
1233 #define file_removed_height 15
1234 static unsigned char file_removed_bits[] = {
1235 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
1236 0x1a, 0x16, 0x32, 0x13, 0xe2, 0x11, 0xc2, 0x10, 0xe2, 0x11, 0x32, 0x13,
1237 0x1a, 0x16, 0x02, 0x10, 0xfe, 0x1f};
1238 } -maskdata $filemask
1240 image create bitmap file_merge -background white -foreground blue -data {
1241 #define file_merge_width 14
1242 #define file_merge_height 15
1243 static unsigned char file_merge_bits[] = {
1244 0xfe, 0x01, 0x02, 0x03, 0x62, 0x05, 0x62, 0x09, 0x62, 0x1f, 0x62, 0x10,
1245 0xfa, 0x11, 0xf2, 0x10, 0x62, 0x10, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
1246 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
1247 } -maskdata $filemask
1249 set ui_index .vpane.files.index.list
1250 set ui_other .vpane.files.other.list
1251 set max_status_desc 0
1253 {__ i plain "Unmodified"}
1254 {_M i mod "Modified"}
1255 {M_ i fulltick "Checked in"}
1256 {MM i parttick "Partially included"}
1258 {_O o plain "Untracked"}
1259 {A_ o fulltick "Added"}
1260 {AM o parttick "Partially added"}
1261 {AD o question "Added (but now gone)"}
1263 {_D i question "Missing"}
1264 {D_ i removed "Removed"}
1265 {DD i removed "Removed"}
1266 {DO i removed "Removed (still exists)"}
1268 {UM i merge "Merge conflicts"}
1269 {U_ i merge "Merge conflicts"}
1271 if {$max_status_desc < [string length [lindex $i 3]]} {
1272 set max_status_desc [string length [lindex $i 3]]
1274 if {[lindex $i 1] == {i}} {
1275 set all_cols([lindex $i 0]) $ui_index
1277 set all_cols([lindex $i 0]) $ui_other
1279 set all_icons([lindex $i 0]) file_[lindex $i 2]
1280 set all_descs([lindex $i 0]) [lindex $i 3]
1284 ######################################################################
1288 proc incr_font_size {font {amt 1}} {
1289 set sz [font configure $font -size]
1291 font configure $font -size $sz
1292 font configure ${font}bold -size $sz
1295 proc hook_failed_popup {hook msg} {
1296 global gitdir appname
1303 label $w.m.l1 -text "$hook hook failed:" \
1308 -background white -borderwidth 1 \
1310 -width 80 -height 10 \
1312 -yscrollcommand [list $w.m.sby set]
1314 -text {You must correct the above errors before committing.} \
1318 scrollbar $w.m.sby -command [list $w.m.t yview]
1319 pack $w.m.l1 -side top -fill x
1320 pack $w.m.l2 -side bottom -fill x
1321 pack $w.m.sby -side right -fill y
1322 pack $w.m.t -side left -fill both -expand 1
1323 pack $w.m -side top -fill both -expand 1 -padx 5 -pady 10
1325 $w.m.t insert 1.0 $msg
1326 $w.m.t conf -state disabled
1328 button $w.ok -text OK \
1331 -command "destroy $w"
1332 pack $w.ok -side bottom
1334 bind $w <Visibility> "grab $w; focus $w"
1335 bind $w <Key-Return> "destroy $w"
1336 wm title $w "$appname ([lindex [file split \
1337 [file normalize [file dirname $gitdir]]] \
1342 set next_console_id 0
1344 proc new_console {short_title long_title} {
1345 global next_console_id console_data
1346 set w .console[incr next_console_id]
1347 set console_data($w) [list $short_title $long_title]
1348 return [console_init $w]
1351 proc console_init {w} {
1352 global console_cr console_data
1353 global gitdir appname M1B
1355 set console_cr($w) 1.0
1358 label $w.m.l1 -text "[lindex $console_data($w) 1]:" \
1363 -background white -borderwidth 1 \
1365 -width 80 -height 10 \
1368 -yscrollcommand [list $w.m.sby set]
1369 label $w.m.s -anchor w \
1372 scrollbar $w.m.sby -command [list $w.m.t yview]
1373 pack $w.m.l1 -side top -fill x
1374 pack $w.m.s -side bottom -fill x
1375 pack $w.m.sby -side right -fill y
1376 pack $w.m.t -side left -fill both -expand 1
1377 pack $w.m -side top -fill both -expand 1 -padx 5 -pady 10
1379 menu $w.ctxm -tearoff 0
1380 $w.ctxm add command -label "Copy" \
1382 -command "tk_textCopy $w.m.t"
1383 $w.ctxm add command -label "Select All" \
1385 -command "$w.m.t tag add sel 0.0 end"
1386 $w.ctxm add command -label "Copy All" \
1389 $w.m.t tag add sel 0.0 end
1391 $w.m.t tag remove sel 0.0 end
1394 button $w.ok -text {Running...} \
1398 -command "destroy $w"
1399 pack $w.ok -side bottom
1401 bind $w.m.t <Any-Button-3> "tk_popup $w.ctxm %X %Y"
1402 bind $w.m.t <$M1B-Key-a> "$w.m.t tag add sel 0.0 end;break"
1403 bind $w.m.t <$M1B-Key-A> "$w.m.t tag add sel 0.0 end;break"
1404 bind $w <Visibility> "focus $w"
1405 wm title $w "$appname ([lindex [file split \
1406 [file normalize [file dirname $gitdir]]] \
1407 end]): [lindex $console_data($w) 0]"
1411 proc console_exec {w cmd {after {}}} {
1414 # -- Windows tosses the enviroment when we exec our child.
1415 # But most users need that so we have to relogin. :-(
1417 if {$tcl_platform(platform) == {windows}} {
1418 set cmd [list sh --login -c "cd \"[pwd]\" && [join $cmd { }]"]
1421 # -- Tcl won't let us redirect both stdout and stderr to
1422 # the same pipe. So pass it through cat...
1424 set cmd [concat | $cmd |& cat]
1426 set fd_f [open $cmd r]
1427 fconfigure $fd_f -blocking 0 -translation binary
1428 fileevent $fd_f readable [list console_read $w $fd_f $after]
1431 proc console_read {w fd after} {
1432 global console_cr console_data
1436 if {![winfo exists $w]} {console_init $w}
1437 $w.m.t conf -state normal
1439 set n [string length $buf]
1441 set cr [string first "\r" $buf $c]
1442 set lf [string first "\n" $buf $c]
1443 if {$cr < 0} {set cr [expr $n + 1]}
1444 if {$lf < 0} {set lf [expr $n + 1]}
1447 $w.m.t insert end [string range $buf $c $lf]
1448 set console_cr($w) [$w.m.t index {end -1c}]
1452 $w.m.t delete $console_cr($w) end
1453 $w.m.t insert end "\n"
1454 $w.m.t insert end [string range $buf $c $cr]
1459 $w.m.t conf -state disabled
1463 fconfigure $fd -blocking 1
1465 if {[catch {close $fd}]} {
1466 if {![winfo exists $w]} {console_init $w}
1467 $w.m.s conf -background red -text {Error: Command Failed}
1468 $w.ok conf -text Close
1469 $w.ok conf -state normal
1471 } elseif {[winfo exists $w]} {
1472 $w.m.s conf -background green -text {Success}
1473 $w.ok conf -text Close
1474 $w.ok conf -state normal
1477 array unset console_cr $w
1478 array unset console_data $w
1480 uplevel #0 $after $ok
1484 fconfigure $fd -blocking 0
1487 ######################################################################
1491 set starting_gitk_msg {Please wait... Starting gitk...}
1494 global tcl_platform ui_status_value starting_gitk_msg
1496 set ui_status_value $starting_gitk_msg
1498 if {$ui_status_value == $starting_gitk_msg} {
1499 set ui_status_value {Ready.}
1503 if {$tcl_platform(platform) == {windows}} {
1511 set w [new_console "repack" "Repacking the object database"]
1512 set cmd [list git repack]
1515 console_exec $w $cmd
1521 global gitdir ui_comm quitting
1523 if {$quitting} return
1526 set save [file join $gitdir GITGUI_MSG]
1527 set msg [string trim [$ui_comm get 0.0 end]]
1528 if {[$ui_comm edit modified] && $msg != {}} {
1530 set fd [open $save w]
1531 puts $fd [string trim [$ui_comm get 0.0 end]]
1534 } elseif {$msg == {} && [file exists $save]} {
1546 proc do_include_all {} {
1547 global update_active ui_status_value
1549 if {$update_active || ![lock_index begin-update]} return
1552 set ui_status_value {Including all modified files...}
1555 foreach path [array names file_states] {
1556 set s $file_states($path)
1562 _D {toggle_mode $path}
1567 set ui_status_value {Ready.}
1571 set GIT_COMMITTER_IDENT {}
1573 proc do_signoff {} {
1574 global ui_comm GIT_COMMITTER_IDENT
1576 if {$GIT_COMMITTER_IDENT == {}} {
1577 if {[catch {set me [exec git var GIT_COMMITTER_IDENT]} err]} {
1578 error_popup "Unable to obtain your identity:\n\n$err"
1581 if {![regexp {^(.*) [0-9]+ [-+0-9]+$} \
1582 $me me GIT_COMMITTER_IDENT]} {
1583 error_popup "Invalid GIT_COMMITTER_IDENT:\n\n$me"
1588 set sob "Signed-off-by: $GIT_COMMITTER_IDENT"
1589 set last [$ui_comm get {end -1c linestart} {end -1c}]
1590 if {$last != $sob} {
1591 $ui_comm edit separator
1593 && ![regexp {^[A-Z][A-Za-z]*-[A-Za-z-]+: *} $last]} {
1594 $ui_comm insert end "\n"
1596 $ui_comm insert end "\n$sob"
1597 $ui_comm edit separator
1602 proc do_amend_last {} {
1610 # shift == 1: left click
1612 proc click {w x y shift wx wy} {
1613 global ui_index ui_other file_lists
1615 set pos [split [$w index @$x,$y] .]
1616 set lno [lindex $pos 0]
1617 set col [lindex $pos 1]
1618 set path [lindex $file_lists($w) [expr $lno - 1]]
1619 if {$path == {}} return
1621 if {$col > 0 && $shift == 1} {
1622 show_diff $path $w $lno
1626 proc unclick {w x y} {
1629 set pos [split [$w index @$x,$y] .]
1630 set lno [lindex $pos 0]
1631 set col [lindex $pos 1]
1632 set path [lindex $file_lists($w) [expr $lno - 1]]
1633 if {$path == {}} return
1640 ######################################################################
1644 set cursor_ptr left_ptr
1645 font create font_diff -family Courier -size 10
1649 eval font configure font_ui [font actual [.dummy cget -font]]
1653 eval font create font_uibold [font configure font_ui]
1654 font configure font_uibold -weight bold
1655 eval font create font_diffbold [font configure font_diff]
1656 font configure font_diffbold -weight bold
1658 switch -glob -- "$tcl_platform(platform),$tcl_platform(os)" {
1659 windows,* {set M1B Control; set M1T Ctrl}
1660 unix,Darwin {set M1B M1; set M1T Cmd}
1661 * {set M1B M1; set M1T M1}
1665 menu .mbar -tearoff 0
1666 .mbar add cascade -label Project -menu .mbar.project
1667 .mbar add cascade -label Edit -menu .mbar.edit
1668 .mbar add cascade -label Commit -menu .mbar.commit
1669 .mbar add cascade -label Fetch -menu .mbar.fetch
1670 .mbar add cascade -label Pull -menu .mbar.pull
1671 .mbar add cascade -label Push -menu .mbar.push
1672 .mbar add cascade -label Options -menu .mbar.options
1673 . configure -menu .mbar
1677 .mbar.project add command -label Visualize \
1680 .mbar.project add command -label {Repack Database} \
1681 -command do_repack \
1683 .mbar.project add command -label Quit \
1685 -accelerator $M1T-Q \
1691 .mbar.edit add command -label Undo \
1692 -command {catch {[focus] edit undo}} \
1693 -accelerator $M1T-Z \
1695 .mbar.edit add command -label Redo \
1696 -command {catch {[focus] edit redo}} \
1697 -accelerator $M1T-Y \
1699 .mbar.edit add separator
1700 .mbar.edit add command -label Cut \
1701 -command {catch {tk_textCut [focus]}} \
1702 -accelerator $M1T-X \
1704 .mbar.edit add command -label Copy \
1705 -command {catch {tk_textCopy [focus]}} \
1706 -accelerator $M1T-C \
1708 .mbar.edit add command -label Paste \
1709 -command {catch {tk_textPaste [focus]; [focus] see insert}} \
1710 -accelerator $M1T-V \
1712 .mbar.edit add command -label Delete \
1713 -command {catch {[focus] delete sel.first sel.last}} \
1716 .mbar.edit add separator
1717 .mbar.edit add command -label {Select All} \
1718 -command {catch {[focus] tag add sel 0.0 end}} \
1719 -accelerator $M1T-A \
1724 .mbar.commit add command -label Rescan \
1725 -command do_rescan \
1728 lappend disable_on_lock \
1729 [list .mbar.commit entryconf [.mbar.commit index last] -state]
1730 .mbar.commit add command -label {Amend Last Commit} \
1731 -command do_amend_last \
1733 lappend disable_on_lock \
1734 [list .mbar.commit entryconf [.mbar.commit index last] -state]
1735 .mbar.commit add command -label {Include All Files} \
1736 -command do_include_all \
1737 -accelerator $M1T-I \
1739 lappend disable_on_lock \
1740 [list .mbar.commit entryconf [.mbar.commit index last] -state]
1741 .mbar.commit add command -label {Sign Off} \
1742 -command do_signoff \
1743 -accelerator $M1T-S \
1745 .mbar.commit add command -label Commit \
1746 -command do_commit \
1747 -accelerator $M1T-Return \
1749 lappend disable_on_lock \
1750 [list .mbar.commit entryconf [.mbar.commit index last] -state]
1763 .mbar.options add checkbutton \
1764 -label {Trust File Modification Timestamps} \
1768 -variable cfg_trust_mtime
1770 # -- Main Window Layout
1771 panedwindow .vpane -orient vertical
1772 panedwindow .vpane.files -orient horizontal
1773 .vpane add .vpane.files -sticky nsew -height 100 -width 400
1774 pack .vpane -anchor n -side top -fill both -expand 1
1776 # -- Index File List
1777 frame .vpane.files.index -height 100 -width 400
1778 label .vpane.files.index.title -text {Modified Files} \
1781 text $ui_index -background white -borderwidth 0 \
1782 -width 40 -height 10 \
1784 -cursor $cursor_ptr \
1785 -yscrollcommand {.vpane.files.index.sb set} \
1787 scrollbar .vpane.files.index.sb -command [list $ui_index yview]
1788 pack .vpane.files.index.title -side top -fill x
1789 pack .vpane.files.index.sb -side right -fill y
1790 pack $ui_index -side left -fill both -expand 1
1791 .vpane.files add .vpane.files.index -sticky nsew
1793 # -- Other (Add) File List
1794 frame .vpane.files.other -height 100 -width 100
1795 label .vpane.files.other.title -text {Untracked Files} \
1798 text $ui_other -background white -borderwidth 0 \
1799 -width 40 -height 10 \
1801 -cursor $cursor_ptr \
1802 -yscrollcommand {.vpane.files.other.sb set} \
1804 scrollbar .vpane.files.other.sb -command [list $ui_other yview]
1805 pack .vpane.files.other.title -side top -fill x
1806 pack .vpane.files.other.sb -side right -fill y
1807 pack $ui_other -side left -fill both -expand 1
1808 .vpane.files add .vpane.files.other -sticky nsew
1810 $ui_index tag conf in_diff -font font_uibold
1811 $ui_other tag conf in_diff -font font_uibold
1813 # -- Diff and Commit Area
1814 frame .vpane.lower -height 400 -width 400
1815 frame .vpane.lower.commarea
1816 frame .vpane.lower.diff -relief sunken -borderwidth 1
1817 pack .vpane.lower.commarea -side top -fill x
1818 pack .vpane.lower.diff -side bottom -fill both -expand 1
1819 .vpane add .vpane.lower -stick nsew
1821 # -- Commit Area Buttons
1822 frame .vpane.lower.commarea.buttons
1823 label .vpane.lower.commarea.buttons.l -text {} \
1827 pack .vpane.lower.commarea.buttons.l -side top -fill x
1828 pack .vpane.lower.commarea.buttons -side left -fill y
1830 button .vpane.lower.commarea.buttons.rescan -text {Rescan} \
1831 -command do_rescan \
1833 pack .vpane.lower.commarea.buttons.rescan -side top -fill x
1834 lappend disable_on_lock \
1835 {.vpane.lower.commarea.buttons.rescan conf -state}
1837 button .vpane.lower.commarea.buttons.amend -text {Amend Last} \
1838 -command do_amend_last \
1840 pack .vpane.lower.commarea.buttons.amend -side top -fill x
1841 lappend disable_on_lock \
1842 {.vpane.lower.commarea.buttons.amend conf -state}
1844 button .vpane.lower.commarea.buttons.incall -text {Include All} \
1845 -command do_include_all \
1847 pack .vpane.lower.commarea.buttons.incall -side top -fill x
1848 lappend disable_on_lock \
1849 {.vpane.lower.commarea.buttons.incall conf -state}
1851 button .vpane.lower.commarea.buttons.signoff -text {Sign Off} \
1852 -command do_signoff \
1854 pack .vpane.lower.commarea.buttons.signoff -side top -fill x
1856 button .vpane.lower.commarea.buttons.commit -text {Commit} \
1857 -command do_commit \
1859 pack .vpane.lower.commarea.buttons.commit -side top -fill x
1860 lappend disable_on_lock \
1861 {.vpane.lower.commarea.buttons.commit conf -state}
1863 # -- Commit Message Buffer
1864 frame .vpane.lower.commarea.buffer
1865 set ui_comm .vpane.lower.commarea.buffer.t
1866 set ui_coml .vpane.lower.commarea.buffer.l
1867 label $ui_coml -text {Commit Message:} \
1871 trace add variable commit_type write {uplevel #0 {
1872 switch -glob $commit_type \
1873 initial {$ui_coml conf -text {Initial Commit Message:}} \
1874 amend {$ui_coml conf -text {Amended Commit Message:}} \
1875 merge {$ui_coml conf -text {Merge Commit Message:}} \
1876 * {$ui_coml conf -text {Commit Message:}}
1878 text $ui_comm -background white -borderwidth 1 \
1881 -autoseparators true \
1883 -width 75 -height 9 -wrap none \
1885 -yscrollcommand {.vpane.lower.commarea.buffer.sby set}
1886 scrollbar .vpane.lower.commarea.buffer.sby \
1887 -command [list $ui_comm yview]
1888 pack $ui_coml -side top -fill x
1889 pack .vpane.lower.commarea.buffer.sby -side right -fill y
1890 pack $ui_comm -side left -fill y
1891 pack .vpane.lower.commarea.buffer -side left -fill y
1893 # -- Commit Message Buffer Context Menu
1895 menu $ui_comm.ctxm -tearoff 0
1896 $ui_comm.ctxm add command -label "Cut" \
1898 -command "tk_textCut $ui_comm"
1899 $ui_comm.ctxm add command -label "Copy" \
1901 -command "tk_textCopy $ui_comm"
1902 $ui_comm.ctxm add command -label "Paste" \
1904 -command "tk_textPaste $ui_comm"
1905 $ui_comm.ctxm add command -label "Delete" \
1907 -command "$ui_comm delete sel.first sel.last"
1908 $ui_comm.ctxm add separator
1909 $ui_comm.ctxm add command -label "Select All" \
1911 -command "$ui_comm tag add sel 0.0 end"
1912 $ui_comm.ctxm add command -label "Copy All" \
1915 $ui_comm tag add sel 0.0 end
1916 tk_textCopy $ui_comm
1917 $ui_comm tag remove sel 0.0 end
1919 $ui_comm.ctxm add separator
1920 $ui_comm.ctxm add command -label "Sign Off" \
1923 bind $ui_comm <Any-Button-3> "tk_popup $ui_comm.ctxm %X %Y"
1926 set ui_fname_value {}
1927 set ui_fstatus_value {}
1928 frame .vpane.lower.diff.header -background orange
1929 label .vpane.lower.diff.header.l1 -text {File:} \
1930 -background orange \
1932 label .vpane.lower.diff.header.l2 -textvariable ui_fname_value \
1933 -background orange \
1937 label .vpane.lower.diff.header.l3 -text {Status:} \
1938 -background orange \
1940 label .vpane.lower.diff.header.l4 -textvariable ui_fstatus_value \
1941 -background orange \
1942 -width $max_status_desc \
1946 pack .vpane.lower.diff.header.l1 -side left
1947 pack .vpane.lower.diff.header.l2 -side left -fill x
1948 pack .vpane.lower.diff.header.l4 -side right
1949 pack .vpane.lower.diff.header.l3 -side right
1952 frame .vpane.lower.diff.body
1953 set ui_diff .vpane.lower.diff.body.t
1954 text $ui_diff -background white -borderwidth 0 \
1955 -width 80 -height 15 -wrap none \
1957 -xscrollcommand {.vpane.lower.diff.body.sbx set} \
1958 -yscrollcommand {.vpane.lower.diff.body.sby set} \
1960 scrollbar .vpane.lower.diff.body.sbx -orient horizontal \
1961 -command [list $ui_diff xview]
1962 scrollbar .vpane.lower.diff.body.sby -orient vertical \
1963 -command [list $ui_diff yview]
1964 pack .vpane.lower.diff.body.sbx -side bottom -fill x
1965 pack .vpane.lower.diff.body.sby -side right -fill y
1966 pack $ui_diff -side left -fill both -expand 1
1967 pack .vpane.lower.diff.header -side top -fill x
1968 pack .vpane.lower.diff.body -side bottom -fill both -expand 1
1970 $ui_diff tag conf dm -foreground red
1971 $ui_diff tag conf dp -foreground blue
1972 $ui_diff tag conf di -foreground {#00a000}
1973 $ui_diff tag conf dni -foreground {#a000a0}
1974 $ui_diff tag conf da -font font_diffbold
1975 $ui_diff tag conf bold -font font_diffbold
1977 # -- Diff Body Context Menu
1979 menu $ui_diff.ctxm -tearoff 0
1980 $ui_diff.ctxm add command -label "Copy" \
1982 -command "tk_textCopy $ui_diff"
1983 $ui_diff.ctxm add command -label "Select All" \
1985 -command "$ui_diff tag add sel 0.0 end"
1986 $ui_diff.ctxm add command -label "Copy All" \
1989 $ui_diff tag add sel 0.0 end
1990 tk_textCopy $ui_diff
1991 $ui_diff tag remove sel 0.0 end
1993 $ui_diff.ctxm add separator
1994 $ui_diff.ctxm add command -label "Decrease Font Size" \
1996 -command {incr_font_size font_diff -1}
1997 $ui_diff.ctxm add command -label "Increase Font Size" \
1999 -command {incr_font_size font_diff 1}
2000 bind $ui_diff <Any-Button-3> "tk_popup $ui_diff.ctxm %X %Y"
2003 set ui_status_value {Initializing...}
2004 label .status -textvariable ui_status_value \
2010 pack .status -anchor w -side bottom -fill x
2014 set gm [lindex $repo_config(gui.geometry) 0]
2015 wm geometry . [lindex $gm 0]
2016 .vpane sash place 0 \
2017 [lindex [.vpane sash coord 0] 0] \
2019 .vpane.files sash place 0 \
2021 [lindex [.vpane.files sash coord 0] 1]
2026 bind $ui_comm <$M1B-Key-Return> {do_commit;break}
2027 bind $ui_comm <$M1B-Key-i> {do_include_all;break}
2028 bind $ui_comm <$M1B-Key-I> {do_include_all;break}
2029 bind $ui_comm <$M1B-Key-x> {tk_textCut %W;break}
2030 bind $ui_comm <$M1B-Key-X> {tk_textCut %W;break}
2031 bind $ui_comm <$M1B-Key-c> {tk_textCopy %W;break}
2032 bind $ui_comm <$M1B-Key-C> {tk_textCopy %W;break}
2033 bind $ui_comm <$M1B-Key-v> {tk_textPaste %W; %W see insert; break}
2034 bind $ui_comm <$M1B-Key-V> {tk_textPaste %W; %W see insert; break}
2035 bind $ui_comm <$M1B-Key-a> {%W tag add sel 0.0 end;break}
2036 bind $ui_comm <$M1B-Key-A> {%W tag add sel 0.0 end;break}
2038 bind $ui_diff <$M1B-Key-x> {tk_textCopy %W;break}
2039 bind $ui_diff <$M1B-Key-X> {tk_textCopy %W;break}
2040 bind $ui_diff <$M1B-Key-c> {tk_textCopy %W;break}
2041 bind $ui_diff <$M1B-Key-C> {tk_textCopy %W;break}
2042 bind $ui_diff <$M1B-Key-v> {break}
2043 bind $ui_diff <$M1B-Key-V> {break}
2044 bind $ui_diff <$M1B-Key-a> {%W tag add sel 0.0 end;break}
2045 bind $ui_diff <$M1B-Key-A> {%W tag add sel 0.0 end;break}
2046 bind $ui_diff <Key-Up> {catch {%W yview scroll -1 units};break}
2047 bind $ui_diff <Key-Down> {catch {%W yview scroll 1 units};break}
2048 bind $ui_diff <Key-Left> {catch {%W xview scroll -1 units};break}
2049 bind $ui_diff <Key-Right> {catch {%W xview scroll 1 units};break}
2051 bind . <Destroy> do_quit
2052 bind all <Key-F5> do_rescan
2053 bind all <$M1B-Key-r> do_rescan
2054 bind all <$M1B-Key-R> do_rescan
2055 bind . <$M1B-Key-s> do_signoff
2056 bind . <$M1B-Key-S> do_signoff
2057 bind . <$M1B-Key-i> do_include_all
2058 bind . <$M1B-Key-I> do_include_all
2059 bind . <$M1B-Key-Return> do_commit
2060 bind all <$M1B-Key-q> do_quit
2061 bind all <$M1B-Key-Q> do_quit
2062 bind all <$M1B-Key-w> {destroy [winfo toplevel %W]}
2063 bind all <$M1B-Key-W> {destroy [winfo toplevel %W]}
2064 foreach i [list $ui_index $ui_other] {
2065 bind $i <Button-1> {click %W %x %y 1 %X %Y; break}
2066 bind $i <Button-3> {click %W %x %y 3 %X %Y; break}
2067 bind $i <ButtonRelease-1> {unclick %W %x %y; break}
2071 set file_lists($ui_index) [list]
2072 set file_lists($ui_other) [list]
2074 wm title . "$appname ([file normalize [file dirname $gitdir]])"
2075 focus -force $ui_comm
2077 populate_remote_menu .mbar.fetch From fetch_from
2078 populate_remote_menu .mbar.push To push_to
2079 populate_pull_menu .mbar.pull