2 # Tcl ignores the next line -*- tcl -*- \
5 set appvers
{@@GITGUI_VERSION@@
}
7 Copyright ©
2006, 2007 Shawn Pearce
, et. al.
9 This program is free software
; you can redistribute it and
/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation
; either version
2 of the License
, or
12 (at your option
) any later version.
14 This program is distributed
in the hope that it will be useful
,
15 but WITHOUT ANY WARRANTY
; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License
for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program
; if not
, write to the Free Software
21 Foundation
, Inc.
, 59 Temple Place
, Suite
330, Boston
, MA
02111-1307 USA
}
23 ######################################################################
25 ## Tcl/Tk sanity check
27 if {[catch
{package require Tcl
8.4} err
]
28 ||
[catch
{package require Tk
8.4} err
]
34 -title "git-gui: fatal error" \
39 ######################################################################
41 ## configure our library
43 set oguilib
{@@GITGUI_LIBDIR@@
}
44 set oguirel
{@@GITGUI_RELATIVE@@
}
45 if {$oguirel eq
{1}} {
46 set oguilib
[file dirname [file dirname [file normalize
$argv0]]]
47 set oguilib
[file join $oguilib share git-gui lib
]
48 } elseif
{[string match @@
* $oguirel]} {
49 set oguilib
[file join [file dirname [file normalize
$argv0]] lib
]
51 set idx
[file join $oguilib tclIndex
]
54 if {[gets
$fd] eq
{# Autogenerated by git-gui Makefile}} {
56 while {[gets
$fd n
] >= 0} {
57 if {$n ne
{} && ![string match
#* $n]} {
69 if {[lsearch
-exact $loaded $p] >= 0} continue
71 source [file join $oguilib $p]
76 set auto_path
[concat
[list
$oguilib] $auto_path]
78 unset -nocomplain oguilib oguirel idx fd
80 if {![catch
{set _verbose
$env(GITGUI_VERBOSE
)}]} {
82 rename auto_load real__auto_load
83 proc auto_load
{name args
} {
84 puts stderr
"auto_load $name"
85 return [uplevel
1 real__auto_load
$name $args]
87 rename
source real__source
89 puts stderr
"source $name"
90 uplevel
1 real__source
$name
94 ######################################################################
98 set _appname
[lindex
[file split $argv0] end
]
114 return [eval [concat
[list
file join $_gitdir] $args]]
117 proc gitexec
{args
} {
119 if {$_gitexec eq
{}} {
120 if {[catch
{set _gitexec
[git
--exec-path]} err
]} {
121 error
"Git not installed?\n\n$err"
127 return [eval [concat
[list
file join $_gitexec] $args]]
136 global tcl_platform tk_library
137 if {[tk windowingsystem
] eq
{aqua
}} {
145 if {$tcl_platform(platform
) eq
{windows
}} {
152 global tcl_platform _iscygwin
153 if {$_iscygwin eq
{}} {
154 if {$tcl_platform(platform
) eq
{windows
}} {
155 if {[catch
{set p
[exec cygpath
--windir]} err
]} {
167 proc is_enabled
{option
} {
168 global enabled_options
169 if {[catch
{set on
$enabled_options($option)}]} {return 0}
173 proc enable_option
{option
} {
174 global enabled_options
175 set enabled_options
($option) 1
178 proc disable_option
{option
} {
179 global enabled_options
180 set enabled_options
($option) 0
183 ######################################################################
187 proc is_many_config
{name
} {
188 switch
-glob -- $name {
197 proc is_config_true
{name
} {
199 if {[catch
{set v
$repo_config($name)}]} {
201 } elseif
{$v eq
{true
} ||
$v eq
{1} ||
$v eq
{yes}} {
208 proc load_config
{include_global
} {
209 global repo_config global_config default_config
211 array
unset global_config
212 if {$include_global} {
214 set fd_rc
[open
"| git config --global --list" r
]
215 while {[gets
$fd_rc line
] >= 0} {
216 if {[regexp
{^
([^
=]+)=(.
*)$
} $line line name value
]} {
217 if {[is_many_config
$name]} {
218 lappend global_config
($name) $value
220 set global_config
($name) $value
228 array
unset repo_config
230 set fd_rc
[open
"| git config --list" r
]
231 while {[gets
$fd_rc line
] >= 0} {
232 if {[regexp
{^
([^
=]+)=(.
*)$
} $line line name value
]} {
233 if {[is_many_config
$name]} {
234 lappend repo_config
($name) $value
236 set repo_config
($name) $value
243 foreach name
[array names default_config
] {
244 if {[catch
{set v
$global_config($name)}]} {
245 set global_config
($name) $default_config($name)
247 if {[catch
{set v
$repo_config($name)}]} {
248 set repo_config
($name) $default_config($name)
253 ######################################################################
258 return [eval exec git
$args]
261 auto_load tk_optionMenu
262 rename tk_optionMenu real__tkOptionMenu
263 proc tk_optionMenu
{w varName args
} {
264 set m
[eval real__tkOptionMenu
$w $varName $args]
265 $m configure
-font font_ui
266 $w configure
-font font_ui
270 ######################################################################
274 if {{--version} eq
$argv ||
{version
} eq
$argv} {
275 puts
"git-gui version $appvers"
282 if {[catch
{set v
[git
--version]} err
]} {
283 catch
{wm withdraw .
}
284 error_popup
"Cannot determine Git version:
288 [appname] requires Git $req_maj.$req_min or later."
291 if {[regexp
{^git version
(\d
+)\.
(\d
+)} $v _junk act_maj act_min
]} {
292 if {$act_maj < $req_maj
293 ||
($act_maj == $req_maj && $act_min < $req_min)} {
294 catch
{wm withdraw .
}
295 error_popup
"[appname] requires Git $req_maj.$req_min or later.
301 catch
{wm withdraw .
}
302 error_popup
"Cannot parse Git version string:\n\n$v"
305 unset -nocomplain v _junk act_maj act_min req_maj req_min
307 ######################################################################
312 set _gitdir
$env(GIT_DIR
)
316 set _gitdir
[git rev-parse
--git-dir]
317 set _prefix
[git rev-parse
--show-prefix]
319 catch
{wm withdraw .
}
320 error_popup
"Cannot find the git directory:\n\n$err"
323 if {![file isdirectory
$_gitdir] && [is_Cygwin
]} {
324 catch
{set _gitdir
[exec cygpath
--unix $_gitdir]}
326 if {![file isdirectory
$_gitdir]} {
327 catch
{wm withdraw .
}
328 error_popup
"Git directory not found:\n\n$_gitdir"
331 if {[lindex
[file split $_gitdir] end
] ne
{.git
}} {
332 catch
{wm withdraw .
}
333 error_popup
"Cannot use funny .git directory:\n\n$_gitdir"
336 if {[catch
{cd [file dirname $_gitdir]} err
]} {
337 catch
{wm withdraw .
}
338 error_popup
"No working directory [file dirname $_gitdir]:\n\n$err"
341 set _reponame
[lindex
[file split \
342 [file normalize
[file dirname $_gitdir]]] \
345 ######################################################################
349 set current_diff_path
{}
350 set current_diff_side
{}
351 set diff_actions
[list
]
352 set ui_status_value
{Initializing...
}
356 set MERGE_HEAD
[list
]
359 set current_branch
{}
360 set current_diff_path
{}
361 set selected_commit_type new
363 ######################################################################
371 set disable_on_lock
[list
]
372 set index_lock_type none
374 proc lock_index
{type} {
375 global index_lock_type disable_on_lock
377 if {$index_lock_type eq
{none
}} {
378 set index_lock_type
$type
379 foreach w
$disable_on_lock {
380 uplevel
#0 $w disabled
383 } elseif
{$index_lock_type eq
"begin-$type"} {
384 set index_lock_type
$type
390 proc unlock_index
{} {
391 global index_lock_type disable_on_lock
393 set index_lock_type none
394 foreach w
$disable_on_lock {
399 ######################################################################
403 proc repository_state
{ctvar hdvar mhvar
} {
404 global current_branch
405 upvar
$ctvar ct
$hdvar hd
$mhvar mh
409 if {[catch
{set current_branch
[git symbolic-ref HEAD
]}]} {
410 set current_branch
{}
412 regsub ^refs
/((heads|tags|remotes
)/)? \
418 if {[catch
{set hd
[git rev-parse
--verify HEAD
]}]} {
424 set merge_head
[gitdir MERGE_HEAD
]
425 if {[file exists
$merge_head]} {
427 set fd_mh
[open
$merge_head r
]
428 while {[gets
$fd_mh line
] >= 0} {
439 global PARENT empty_tree
441 set p
[lindex
$PARENT 0]
445 if {$empty_tree eq
{}} {
446 set empty_tree
[git mktree
<< {}]
451 proc rescan
{after
{honor_trustmtime
1}} {
452 global HEAD PARENT MERGE_HEAD commit_type
453 global ui_index ui_workdir ui_status_value ui_comm
454 global rescan_active file_states
457 if {$rescan_active > 0 ||
![lock_index
read]} return
459 repository_state newType newHEAD newMERGE_HEAD
460 if {[string match amend
* $commit_type]
461 && $newType eq
{normal
}
462 && $newHEAD eq
$HEAD} {
466 set MERGE_HEAD
$newMERGE_HEAD
467 set commit_type
$newType
470 array
unset file_states
472 if {![$ui_comm edit modified
]
473 ||
[string trim
[$ui_comm get
0.0 end
]] eq
{}} {
474 if {[load_message GITGUI_MSG
]} {
475 } elseif
{[load_message MERGE_MSG
]} {
476 } elseif
{[load_message SQUASH_MSG
]} {
479 $ui_comm edit modified false
482 if {[is_enabled branch
]} {
487 if {$honor_trustmtime && $repo_config(gui.trustmtime
) eq
{true
}} {
488 rescan_stage2
{} $after
491 set ui_status_value
{Refreshing
file status...
}
492 set cmd
[list git update-index
]
494 lappend cmd
--unmerged
495 lappend cmd
--ignore-missing
496 lappend cmd
--refresh
497 set fd_rf
[open
"| $cmd" r
]
498 fconfigure
$fd_rf -blocking 0 -translation binary
499 fileevent
$fd_rf readable \
500 [list rescan_stage2
$fd_rf $after]
504 proc rescan_stage2
{fd after
} {
505 global ui_status_value
506 global rescan_active buf_rdi buf_rdf buf_rlo
510 if {![eof
$fd]} return
514 set ls_others
[list | git ls-files
--others -z \
515 --exclude-per-directory=.gitignore
]
516 set info_exclude
[gitdir info exclude
]
517 if {[file readable
$info_exclude]} {
518 lappend ls_others
"--exclude-from=$info_exclude"
526 set ui_status_value
{Scanning
for modified files ...
}
527 set fd_di
[open
"| git diff-index --cached -z [PARENT]" r
]
528 set fd_df
[open
"| git diff-files -z" r
]
529 set fd_lo
[open
$ls_others r
]
531 fconfigure
$fd_di -blocking 0 -translation binary
-encoding binary
532 fconfigure
$fd_df -blocking 0 -translation binary
-encoding binary
533 fconfigure
$fd_lo -blocking 0 -translation binary
-encoding binary
534 fileevent
$fd_di readable
[list read_diff_index
$fd_di $after]
535 fileevent
$fd_df readable
[list read_diff_files
$fd_df $after]
536 fileevent
$fd_lo readable
[list read_ls_others
$fd_lo $after]
539 proc load_message
{file} {
543 if {[file isfile
$f]} {
544 if {[catch
{set fd
[open
$f r
]}]} {
547 set content
[string trim
[read $fd]]
549 regsub
-all -line {[ \r\t]+$
} $content {} content
550 $ui_comm delete
0.0 end
551 $ui_comm insert end
$content
557 proc read_diff_index
{fd after
} {
560 append buf_rdi
[read $fd]
562 set n
[string length
$buf_rdi]
564 set z1
[string first
"\0" $buf_rdi $c]
567 set z2
[string first
"\0" $buf_rdi $z1]
571 set i
[split [string range
$buf_rdi $c [expr {$z1 - 2}]] { }]
572 set p
[string range
$buf_rdi $z1 [expr {$z2 - 1}]]
574 [encoding convertfrom
$p] \
576 [list
[lindex
$i 0] [lindex
$i 2]] \
582 set buf_rdi
[string range
$buf_rdi $c end
]
587 rescan_done
$fd buf_rdi
$after
590 proc read_diff_files
{fd after
} {
593 append buf_rdf
[read $fd]
595 set n
[string length
$buf_rdf]
597 set z1
[string first
"\0" $buf_rdf $c]
600 set z2
[string first
"\0" $buf_rdf $z1]
604 set i
[split [string range
$buf_rdf $c [expr {$z1 - 2}]] { }]
605 set p
[string range
$buf_rdf $z1 [expr {$z2 - 1}]]
607 [encoding convertfrom
$p] \
610 [list
[lindex
$i 0] [lindex
$i 2]]
615 set buf_rdf
[string range
$buf_rdf $c end
]
620 rescan_done
$fd buf_rdf
$after
623 proc read_ls_others
{fd after
} {
626 append buf_rlo
[read $fd]
627 set pck
[split $buf_rlo "\0"]
628 set buf_rlo
[lindex
$pck end
]
629 foreach p
[lrange
$pck 0 end-1
] {
630 merge_state
[encoding convertfrom
$p] ?O
632 rescan_done
$fd buf_rlo
$after
635 proc rescan_done
{fd buf after
} {
636 global rescan_active current_diff_path
637 global file_states repo_config
640 if {![eof
$fd]} return
643 if {[incr rescan_active
-1] > 0} return
648 if {$current_diff_path ne
{}} reshow_diff
652 proc prune_selection
{} {
653 global file_states selected_paths
655 foreach path
[array names selected_paths
] {
656 if {[catch
{set still_here
$file_states($path)}]} {
657 unset selected_paths
($path)
662 ######################################################################
666 proc mapicon
{w state path
} {
669 if {[catch
{set r
$all_icons($state$w)}]} {
670 puts
"error: no icon for $w state={$state} $path"
676 proc mapdesc
{state path
} {
679 if {[catch
{set r
$all_descs($state)}]} {
680 puts
"error: no desc for state={$state} $path"
686 proc escape_path
{path
} {
687 regsub
-all {\\} $path "\\\\" path
688 regsub
-all "\n" $path "\\n" path
692 proc short_path
{path
} {
693 return [escape_path
[lindex
[file split $path] end
]]
697 set null_sha1
[string repeat
0 40]
699 proc merge_state
{path new_state
{head_info
{}} {index_info
{}}} {
700 global file_states next_icon_id null_sha1
702 set s0
[string index
$new_state 0]
703 set s1
[string index
$new_state 1]
705 if {[catch
{set info
$file_states($path)}]} {
707 set icon n
[incr next_icon_id
]
709 set state
[lindex
$info 0]
710 set icon
[lindex
$info 1]
711 if {$head_info eq
{}} {set head_info
[lindex
$info 2]}
712 if {$index_info eq
{}} {set index_info
[lindex
$info 3]}
715 if {$s0 eq
{?
}} {set s0
[string index
$state 0]} \
716 elseif
{$s0 eq
{_
}} {set s0 _
}
718 if {$s1 eq
{?
}} {set s1
[string index
$state 1]} \
719 elseif
{$s1 eq
{_
}} {set s1 _
}
721 if {$s0 eq
{A
} && $s1 eq
{_
} && $head_info eq
{}} {
722 set head_info
[list
0 $null_sha1]
723 } elseif
{$s0 ne
{_
} && [string index
$state 0] eq
{_
}
724 && $head_info eq
{}} {
725 set head_info
$index_info
728 set file_states
($path) [list
$s0$s1 $icon \
729 $head_info $index_info \
734 proc display_file_helper
{w path icon_name old_m new_m
} {
738 set lno
[lsearch
-sorted -exact $file_lists($w) $path]
740 set file_lists
($w) [lreplace
$file_lists($w) $lno $lno]
742 $w conf
-state normal
743 $w delete
$lno.0 [expr {$lno + 1}].0
744 $w conf
-state disabled
746 } elseif
{$old_m eq
{_
} && $new_m ne
{_
}} {
747 lappend file_lists
($w) $path
748 set file_lists
($w) [lsort
-unique $file_lists($w)]
749 set lno
[lsearch
-sorted -exact $file_lists($w) $path]
751 $w conf
-state normal
752 $w image create
$lno.0 \
753 -align center
-padx 5 -pady 1 \
755 -image [mapicon
$w $new_m $path]
756 $w insert
$lno.1 "[escape_path $path]\n"
757 $w conf
-state disabled
758 } elseif
{$old_m ne
$new_m} {
759 $w conf
-state normal
760 $w image conf
$icon_name -image [mapicon
$w $new_m $path]
761 $w conf
-state disabled
765 proc display_file
{path state
} {
766 global file_states selected_paths
767 global ui_index ui_workdir
769 set old_m
[merge_state
$path $state]
770 set s
$file_states($path)
771 set new_m
[lindex
$s 0]
772 set icon_name
[lindex
$s 1]
774 set o
[string index
$old_m 0]
775 set n
[string index
$new_m 0]
782 display_file_helper
$ui_index $path $icon_name $o $n
784 if {[string index
$old_m 0] eq
{U
}} {
787 set o
[string index
$old_m 1]
789 if {[string index
$new_m 0] eq
{U
}} {
792 set n
[string index
$new_m 1]
794 display_file_helper
$ui_workdir $path $icon_name $o $n
796 if {$new_m eq
{__
}} {
797 unset file_states
($path)
798 catch
{unset selected_paths
($path)}
802 proc display_all_files_helper
{w path icon_name m
} {
805 lappend file_lists
($w) $path
806 set lno
[expr {[lindex
[split [$w index end
] .
] 0] - 1}]
807 $w image create end \
808 -align center
-padx 5 -pady 1 \
810 -image [mapicon
$w $m $path]
811 $w insert end
"[escape_path $path]\n"
814 proc display_all_files
{} {
815 global ui_index ui_workdir
816 global file_states file_lists
819 $ui_index conf
-state normal
820 $ui_workdir conf
-state normal
822 $ui_index delete
0.0 end
823 $ui_workdir delete
0.0 end
826 set file_lists
($ui_index) [list
]
827 set file_lists
($ui_workdir) [list
]
829 foreach path
[lsort
[array names file_states
]] {
830 set s
$file_states($path)
832 set icon_name
[lindex
$s 1]
834 set s
[string index
$m 0]
835 if {$s ne
{U
} && $s ne
{_
}} {
836 display_all_files_helper
$ui_index $path \
840 if {[string index
$m 0] eq
{U
}} {
843 set s
[string index
$m 1]
846 display_all_files_helper
$ui_workdir $path \
851 $ui_index conf
-state disabled
852 $ui_workdir conf
-state disabled
855 ######################################################################
860 #define mask_width 14
861 #define mask_height 15
862 static unsigned char mask_bits
[] = {
863 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
864 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
865 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f};
868 image create bitmap file_plain
-background white
-foreground black
-data {
869 #define plain_width 14
870 #define plain_height 15
871 static unsigned char plain_bits
[] = {
872 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
873 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10,
874 0x02, 0x10, 0x02, 0x10, 0xfe, 0x1f};
875 } -maskdata $filemask
877 image create bitmap file_mod
-background white
-foreground blue
-data {
879 #define mod_height 15
880 static unsigned char mod_bits
[] = {
881 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
882 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
883 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
884 } -maskdata $filemask
886 image create bitmap file_fulltick
-background white
-foreground "#007000" -data {
887 #define file_fulltick_width 14
888 #define file_fulltick_height 15
889 static unsigned char file_fulltick_bits
[] = {
890 0xfe, 0x01, 0x02, 0x1a, 0x02, 0x0c, 0x02, 0x0c, 0x02, 0x16, 0x02, 0x16,
891 0x02, 0x13, 0x00, 0x13, 0x86, 0x11, 0x8c, 0x11, 0xd8, 0x10, 0xf2, 0x10,
892 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
893 } -maskdata $filemask
895 image create bitmap file_parttick
-background white
-foreground "#005050" -data {
896 #define parttick_width 14
897 #define parttick_height 15
898 static unsigned char parttick_bits
[] = {
899 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
900 0x7a, 0x14, 0x02, 0x16, 0x02, 0x13, 0x8a, 0x11, 0xda, 0x10, 0x72, 0x10,
901 0x22, 0x10, 0x02, 0x10, 0xfe, 0x1f};
902 } -maskdata $filemask
904 image create bitmap file_question
-background white
-foreground black
-data {
905 #define file_question_width 14
906 #define file_question_height 15
907 static unsigned char file_question_bits
[] = {
908 0xfe, 0x01, 0x02, 0x02, 0xe2, 0x04, 0xf2, 0x09, 0x1a, 0x1b, 0x0a, 0x13,
909 0x82, 0x11, 0xc2, 0x10, 0x62, 0x10, 0x62, 0x10, 0x02, 0x10, 0x62, 0x10,
910 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
911 } -maskdata $filemask
913 image create bitmap file_removed
-background white
-foreground red
-data {
914 #define file_removed_width 14
915 #define file_removed_height 15
916 static unsigned char file_removed_bits
[] = {
917 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
918 0x1a, 0x16, 0x32, 0x13, 0xe2, 0x11, 0xc2, 0x10, 0xe2, 0x11, 0x32, 0x13,
919 0x1a, 0x16, 0x02, 0x10, 0xfe, 0x1f};
920 } -maskdata $filemask
922 image create bitmap file_merge
-background white
-foreground blue
-data {
923 #define file_merge_width 14
924 #define file_merge_height 15
925 static unsigned char file_merge_bits
[] = {
926 0xfe, 0x01, 0x02, 0x03, 0x62, 0x05, 0x62, 0x09, 0x62, 0x1f, 0x62, 0x10,
927 0xfa, 0x11, 0xf2, 0x10, 0x62, 0x10, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
928 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
929 } -maskdata $filemask
932 #define file_width 18
933 #define file_height 18
934 static unsigned char file_bits
[] = {
935 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0x00,
936 0x0c, 0x03, 0x00, 0x04, 0xfe, 0x00, 0x06, 0x80, 0x00, 0xff, 0x9f, 0x00,
937 0x03, 0x98, 0x00, 0x02, 0x90, 0x00, 0x06, 0xb0, 0x00, 0x04, 0xa0, 0x00,
938 0x0c, 0xe0, 0x00, 0x08, 0xc0, 0x00, 0xf8, 0xff, 0x00, 0x00, 0x00, 0x00,
939 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
941 image create bitmap file_dir
-background white
-foreground blue \
942 -data $file_dir_data -maskdata $file_dir_data
945 set file_uplevel_data
{
948 static unsigned char up_bits
[] = {
949 0x80, 0x00, 0xc0, 0x01, 0xe0, 0x03, 0xf0, 0x07, 0xf8, 0x0f, 0xfc, 0x1f,
950 0xfe, 0x3f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
951 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00};
953 image create bitmap file_uplevel
-background white
-foreground red \
954 -data $file_uplevel_data -maskdata $file_uplevel_data
955 unset file_uplevel_data
957 set ui_index .vpane.files.index.list
958 set ui_workdir .vpane.files.workdir.list
960 set all_icons
(_
$ui_index) file_plain
961 set all_icons
(A
$ui_index) file_fulltick
962 set all_icons
(M
$ui_index) file_fulltick
963 set all_icons
(D
$ui_index) file_removed
964 set all_icons
(U
$ui_index) file_merge
966 set all_icons
(_
$ui_workdir) file_plain
967 set all_icons
(M
$ui_workdir) file_mod
968 set all_icons
(D
$ui_workdir) file_question
969 set all_icons
(U
$ui_workdir) file_merge
970 set all_icons
(O
$ui_workdir) file_plain
972 set max_status_desc
0
976 {_M
"Modified, not staged"}
977 {M_
"Staged for commit"}
978 {MM
"Portions staged for commit"}
979 {MD
"Staged for commit, missing"}
981 {_O
"Untracked, not staged"}
982 {A_
"Staged for commit"}
983 {AM
"Portions staged for commit"}
984 {AD
"Staged for commit, missing"}
987 {D_
"Staged for removal"}
988 {DO
"Staged for removal, still present"}
990 {U_
"Requires merge resolution"}
991 {UU
"Requires merge resolution"}
992 {UM
"Requires merge resolution"}
993 {UD
"Requires merge resolution"}
995 if {$max_status_desc < [string length
[lindex
$i 1]]} {
996 set max_status_desc
[string length
[lindex
$i 1]]
998 set all_descs
([lindex
$i 0]) [lindex
$i 1]
1002 ######################################################################
1006 proc bind_button3
{w cmd
} {
1007 bind $w <Any-Button-3
> $cmd
1009 bind $w <Control-Button-1
> $cmd
1013 proc scrollbar2many
{list mode args
} {
1014 foreach w
$list {eval $w $mode $args}
1017 proc many2scrollbar
{list mode sb top bottom
} {
1018 $sb set $top $bottom
1019 foreach w
$list {$w $mode moveto
$top}
1022 proc incr_font_size
{font
{amt
1}} {
1023 set sz
[font configure
$font -size]
1025 font configure
$font -size $sz
1026 font configure
${font}bold
-size $sz
1029 ######################################################################
1033 set starting_gitk_msg
{Starting gitk... please
wait...
}
1035 proc do_gitk
{revs
} {
1036 global env ui_status_value starting_gitk_msg
1038 # -- Always start gitk through whatever we were loaded with. This
1039 # lets us bypass using shell process on Windows systems.
1041 set cmd
[list
[info nameofexecutable
]]
1042 lappend cmd
[gitexec gitk
]
1048 if {[catch
{eval exec $cmd &} err
]} {
1049 error_popup
"Failed to start gitk:\n\n$err"
1051 set ui_status_value
$starting_gitk_msg
1053 if {$ui_status_value eq
$starting_gitk_msg} {
1054 set ui_status_value
{Ready.
}
1063 global ui_comm is_quitting repo_config commit_type
1065 if {$is_quitting} return
1068 if {[winfo exists
$ui_comm]} {
1069 # -- Stash our current commit buffer.
1071 set save
[gitdir GITGUI_MSG
]
1072 set msg
[string trim
[$ui_comm get
0.0 end
]]
1073 regsub
-all -line {[ \r\t]+$
} $msg {} msg
1074 if {(![string match amend
* $commit_type]
1075 ||
[$ui_comm edit modified
])
1078 set fd
[open
$save w
]
1079 puts
-nonewline $fd $msg
1083 catch
{file delete
$save}
1086 # -- Stash our current window geometry into this repository.
1088 set cfg_geometry
[list
]
1089 lappend cfg_geometry
[wm geometry .
]
1090 lappend cfg_geometry
[lindex
[.vpane sash coord
0] 1]
1091 lappend cfg_geometry
[lindex
[.vpane.files sash coord
0] 0]
1092 if {[catch
{set rc_geometry
$repo_config(gui.geometry
)}]} {
1095 if {$cfg_geometry ne
$rc_geometry} {
1096 catch
{git config gui.geometry
$cfg_geometry}
1104 rescan
{set ui_status_value
{Ready.
}}
1111 proc toggle_or_diff
{w x y
} {
1112 global file_states file_lists current_diff_path ui_index ui_workdir
1113 global last_clicked selected_paths
1115 set pos
[split [$w index @
$x,$y] .
]
1116 set lno
[lindex
$pos 0]
1117 set col [lindex
$pos 1]
1118 set path
[lindex
$file_lists($w) [expr {$lno - 1}]]
1124 set last_clicked
[list
$w $lno]
1125 array
unset selected_paths
1126 $ui_index tag remove in_sel
0.0 end
1127 $ui_workdir tag remove in_sel
0.0 end
1130 if {$current_diff_path eq
$path} {
1131 set after
{reshow_diff
;}
1135 if {$w eq
$ui_index} {
1137 "Unstaging [short_path $path] from commit" \
1139 [concat
$after {set ui_status_value
{Ready.
}}]
1140 } elseif
{$w eq
$ui_workdir} {
1142 "Adding [short_path $path]" \
1144 [concat
$after {set ui_status_value
{Ready.
}}]
1147 show_diff
$path $w $lno
1151 proc add_one_to_selection
{w x y
} {
1152 global file_lists last_clicked selected_paths
1154 set lno
[lindex
[split [$w index @
$x,$y] .
] 0]
1155 set path
[lindex
$file_lists($w) [expr {$lno - 1}]]
1161 if {$last_clicked ne
{}
1162 && [lindex
$last_clicked 0] ne
$w} {
1163 array
unset selected_paths
1164 [lindex
$last_clicked 0] tag remove in_sel
0.0 end
1167 set last_clicked
[list
$w $lno]
1168 if {[catch
{set in_sel
$selected_paths($path)}]} {
1172 unset selected_paths
($path)
1173 $w tag remove in_sel
$lno.0 [expr {$lno + 1}].0
1175 set selected_paths
($path) 1
1176 $w tag add in_sel
$lno.0 [expr {$lno + 1}].0
1180 proc add_range_to_selection
{w x y
} {
1181 global file_lists last_clicked selected_paths
1183 if {[lindex
$last_clicked 0] ne
$w} {
1184 toggle_or_diff
$w $x $y
1188 set lno
[lindex
[split [$w index @
$x,$y] .
] 0]
1189 set lc
[lindex
$last_clicked 1]
1198 foreach path
[lrange
$file_lists($w) \
1199 [expr {$begin - 1}] \
1200 [expr {$end - 1}]] {
1201 set selected_paths
($path) 1
1203 $w tag add in_sel
$begin.0 [expr {$end + 1}].0
1206 ######################################################################
1210 set cursor_ptr arrow
1211 font create font_diff
-family Courier
-size 10
1215 eval font configure font_ui
[font actual
[.dummy cget
-font]]
1219 font create font_uibold
1220 font create font_diffbold
1222 foreach class
{Button Checkbutton Entry Label
1223 Labelframe Listbox Menu Message
1224 Radiobutton Spinbox Text
} {
1225 option add
*$class.font font_ui
1237 proc apply_config
{} {
1238 global repo_config font_descs
1240 foreach option
$font_descs {
1241 set name
[lindex
$option 0]
1242 set font
[lindex
$option 1]
1244 foreach
{cn cv
} $repo_config(gui.
$name) {
1245 font configure
$font $cn $cv
1248 error_popup
"Invalid font specified in gui.$name:\n\n$err"
1250 foreach
{cn cv
} [font configure
$font] {
1251 font configure
${font}bold
$cn $cv
1253 font configure
${font}bold
-weight bold
1257 set default_config
(merge.summary
) false
1258 set default_config
(merge.verbosity
) 2
1259 set default_config
(user.name
) {}
1260 set default_config
(user.email
) {}
1262 set default_config
(gui.trustmtime
) false
1263 set default_config
(gui.diffcontext
) 5
1264 set default_config
(gui.newbranchtemplate
) {}
1265 set default_config
(gui.fontui
) [font configure font_ui
]
1266 set default_config
(gui.fontdiff
) [font configure font_diff
]
1268 {fontui font_ui
{Main Font
}}
1269 {fontdiff font_diff
{Diff
/Console Font
}}
1274 ######################################################################
1276 ## feature option selection
1278 if {[regexp
{^git-
(.
+)$
} [appname
] _junk subcommand
]} {
1283 if {$subcommand eq
{gui.sh
}} {
1286 if {$subcommand eq
{gui
} && [llength
$argv] > 0} {
1287 set subcommand
[lindex
$argv 0]
1288 set argv
[lrange
$argv 1 end
]
1291 enable_option multicommit
1292 enable_option branch
1293 enable_option transport
1295 switch
-- $subcommand {
1298 disable_option multicommit
1299 disable_option branch
1300 disable_option transport
1303 enable_option singlecommit
1305 disable_option multicommit
1306 disable_option branch
1307 disable_option transport
1311 ######################################################################
1319 menu .mbar
-tearoff 0
1320 .mbar add cascade
-label Repository
-menu .mbar.repository
1321 .mbar add cascade
-label Edit
-menu .mbar.edit
1322 if {[is_enabled branch
]} {
1323 .mbar add cascade
-label Branch
-menu .mbar.branch
1325 if {[is_enabled multicommit
] ||
[is_enabled singlecommit
]} {
1326 .mbar add cascade
-label Commit
-menu .mbar.commit
1328 if {[is_enabled transport
]} {
1329 .mbar add cascade
-label Merge
-menu .mbar.merge
1330 .mbar add cascade
-label Fetch
-menu .mbar.fetch
1331 .mbar add cascade
-label Push
-menu .mbar.push
1333 . configure
-menu .mbar
1335 # -- Repository Menu
1337 menu .mbar.repository
1339 .mbar.repository add
command \
1340 -label {Browse Current Branch
} \
1341 -command {browser
::new
$current_branch}
1342 trace add variable current_branch
write ".mbar.repository entryconf [.mbar.repository index last] -label \"Browse \$current_branch\" ;#"
1343 .mbar.repository add separator
1345 .mbar.repository add
command \
1346 -label {Visualize Current Branch
} \
1347 -command {do_gitk
$current_branch}
1348 trace add variable current_branch
write ".mbar.repository entryconf [.mbar.repository index last] -label \"Visualize \$current_branch\" ;#"
1349 .mbar.repository add
command \
1350 -label {Visualize All Branches
} \
1351 -command {do_gitk
--all}
1352 .mbar.repository add separator
1354 if {[is_enabled multicommit
]} {
1355 .mbar.repository add
command -label {Database Statistics
} \
1358 .mbar.repository add
command -label {Compress Database
} \
1361 .mbar.repository add
command -label {Verify Database
} \
1362 -command do_fsck_objects
1364 .mbar.repository add separator
1367 .mbar.repository add
command \
1368 -label {Create Desktop Icon
} \
1369 -command do_cygwin_shortcut
1370 } elseif
{[is_Windows
]} {
1371 .mbar.repository add
command \
1372 -label {Create Desktop Icon
} \
1373 -command do_windows_shortcut
1374 } elseif
{[is_MacOSX
]} {
1375 .mbar.repository add
command \
1376 -label {Create Desktop Icon
} \
1377 -command do_macosx_app
1381 .mbar.repository add
command -label Quit \
1388 .mbar.edit add
command -label Undo \
1389 -command {catch
{[focus
] edit undo
}} \
1391 .mbar.edit add
command -label Redo \
1392 -command {catch
{[focus
] edit redo
}} \
1394 .mbar.edit add separator
1395 .mbar.edit add
command -label Cut \
1396 -command {catch
{tk_textCut
[focus
]}} \
1398 .mbar.edit add
command -label Copy \
1399 -command {catch
{tk_textCopy
[focus
]}} \
1401 .mbar.edit add
command -label Paste \
1402 -command {catch
{tk_textPaste
[focus
]; [focus
] see insert
}} \
1404 .mbar.edit add
command -label Delete \
1405 -command {catch
{[focus
] delete sel.first sel.last
}} \
1407 .mbar.edit add separator
1408 .mbar.edit add
command -label {Select All
} \
1409 -command {catch
{[focus
] tag add sel
0.0 end
}} \
1414 if {[is_enabled branch
]} {
1417 .mbar.branch add
command -label {Create...
} \
1418 -command do_create_branch \
1420 lappend disable_on_lock
[list .mbar.branch entryconf \
1421 [.mbar.branch index last
] -state]
1423 .mbar.branch add
command -label {Delete...
} \
1424 -command do_delete_branch
1425 lappend disable_on_lock
[list .mbar.branch entryconf \
1426 [.mbar.branch index last
] -state]
1428 .mbar.branch add
command -label {Reset...
} \
1429 -command merge
::reset_hard
1430 lappend disable_on_lock
[list .mbar.branch entryconf \
1431 [.mbar.branch index last
] -state]
1436 if {[is_enabled multicommit
] ||
[is_enabled singlecommit
]} {
1439 .mbar.commit add radiobutton \
1440 -label {New Commit
} \
1441 -command do_select_commit_type \
1442 -variable selected_commit_type \
1444 lappend disable_on_lock \
1445 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1447 .mbar.commit add radiobutton \
1448 -label {Amend Last Commit
} \
1449 -command do_select_commit_type \
1450 -variable selected_commit_type \
1452 lappend disable_on_lock \
1453 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1455 .mbar.commit add separator
1457 .mbar.commit add
command -label Rescan \
1458 -command do_rescan \
1460 lappend disable_on_lock \
1461 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1463 .mbar.commit add
command -label {Add To Commit
} \
1464 -command do_add_selection
1465 lappend disable_on_lock \
1466 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1468 .mbar.commit add
command -label {Add Existing To Commit
} \
1469 -command do_add_all \
1471 lappend disable_on_lock \
1472 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1474 .mbar.commit add
command -label {Unstage From Commit
} \
1475 -command do_unstage_selection
1476 lappend disable_on_lock \
1477 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1479 .mbar.commit add
command -label {Revert Changes
} \
1480 -command do_revert_selection
1481 lappend disable_on_lock \
1482 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1484 .mbar.commit add separator
1486 .mbar.commit add
command -label {Sign Off
} \
1487 -command do_signoff \
1490 .mbar.commit add
command -label Commit \
1491 -command do_commit \
1492 -accelerator $M1T-Return
1493 lappend disable_on_lock \
1494 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1499 if {[is_enabled branch
]} {
1501 .mbar.merge add
command -label {Local Merge...
} \
1502 -command merge
::dialog
1503 lappend disable_on_lock \
1504 [list .mbar.merge entryconf
[.mbar.merge index last
] -state]
1505 .mbar.merge add
command -label {Abort Merge...
} \
1506 -command merge
::reset_hard
1507 lappend disable_on_lock \
1508 [list .mbar.merge entryconf
[.mbar.merge index last
] -state]
1514 if {[is_enabled transport
]} {
1518 .mbar.push add
command -label {Push...
} \
1519 -command do_push_anywhere
1523 # -- Apple Menu (Mac OS X only)
1525 .mbar add cascade
-label Apple
-menu .mbar.apple
1528 .mbar.apple add
command -label "About [appname]" \
1530 .mbar.apple add
command -label "Options..." \
1535 .mbar.edit add separator
1536 .mbar.edit add
command -label {Options...
} \
1541 if {[file exists
/usr
/local
/miga
/lib
/gui-miga
]
1542 && [file exists .pvcsrc
]} {
1544 global ui_status_value
1545 if {![lock_index update
]} return
1546 set cmd
[list sh
--login -c "/usr/local/miga/lib/gui-miga \"[pwd]\""]
1547 set miga_fd
[open
"|$cmd" r
]
1548 fconfigure
$miga_fd -blocking 0
1549 fileevent
$miga_fd readable
[list miga_done
$miga_fd]
1550 set ui_status_value
{Running miga...
}
1552 proc miga_done
{fd
} {
1557 rescan
[list
set ui_status_value
{Ready.
}]
1560 .mbar add cascade
-label Tools
-menu .mbar.tools
1562 .mbar.tools add
command -label "Migrate" \
1564 lappend disable_on_lock \
1565 [list .mbar.tools entryconf
[.mbar.tools index last
] -state]
1571 .mbar add cascade
-label Help
-menu .mbar.
help
1575 .mbar.
help add
command -label "About [appname]" \
1580 catch
{set browser
$repo_config(instaweb.browser
)}
1581 set doc_path
[file dirname [gitexec
]]
1582 set doc_path
[file join $doc_path Documentation index.html
]
1585 set doc_path
[exec cygpath
--mixed $doc_path]
1588 if {$browser eq
{}} {
1591 } elseif
{[is_Cygwin
]} {
1592 set program_files
[file dirname [exec cygpath
--windir]]
1593 set program_files
[file join $program_files {Program Files
}]
1594 set firefox
[file join $program_files {Mozilla Firefox
} firefox.exe
]
1595 set ie
[file join $program_files {Internet Explorer
} IEXPLORE.EXE
]
1596 if {[file exists
$firefox]} {
1597 set browser
$firefox
1598 } elseif
{[file exists
$ie]} {
1601 unset program_files firefox ie
1605 if {[file isfile
$doc_path]} {
1606 set doc_url
"file:$doc_path"
1608 set doc_url
{http
://www.kernel.org
/pub
/software
/scm
/git
/docs
/}
1611 if {$browser ne
{}} {
1612 .mbar.
help add
command -label {Online Documentation
} \
1613 -command [list
exec $browser $doc_url &]
1615 unset browser doc_path doc_url
1617 # -- Standard bindings
1619 bind .
<Destroy
> {if {{%W
} eq
{.
}} do_quit
}
1620 bind all
<$M1B-Key-q> do_quit
1621 bind all
<$M1B-Key-Q> do_quit
1622 bind all
<$M1B-Key-w> {destroy
[winfo toplevel
%W
]}
1623 bind all
<$M1B-Key-W> {destroy
[winfo toplevel
%W
]}
1625 set subcommand_args
{}
1627 puts stderr
"usage: $::argv0 $::subcommand $::subcommand_args"
1631 # -- Not a normal commit type invocation? Do that instead!
1633 switch
-- $subcommand {
1635 set subcommand_args
{rev?
}
1636 switch
[llength
$argv] {
1638 set current_branch
[git symbolic-ref HEAD
]
1639 regsub ^refs
/((heads|tags|remotes
)/)? \
1640 $current_branch {} current_branch
1643 set current_branch
[lindex
$argv 0]
1647 browser
::new
$current_branch
1651 set subcommand_args
{rev? path?
}
1656 if {$is_path ||
[file exists
$_prefix$a]} {
1657 if {$path ne
{}} usage
1660 } elseif
{$a eq
{--}} {
1662 if {$head ne
{}} usage
1667 } elseif
{$head eq
{}} {
1668 if {$head ne
{}} usage
1677 set current_branch
[git symbolic-ref HEAD
]
1678 regsub ^refs
/((heads|tags|remotes
)/)? \
1679 $current_branch {} current_branch
1681 set current_branch
$head
1684 if {$path eq
{}} usage
1685 blame
::new
$head $path
1690 if {[llength
$argv] != 0} {
1691 puts
-nonewline stderr
"usage: $argv0"
1692 if {$subcommand ne
{gui
} && [appname
] ne
"git-$subcommand"} {
1693 puts
-nonewline stderr
" $subcommand"
1698 # fall through to setup UI for commits
1701 puts stderr
"usage: $argv0 \[{blame|browser|citool}\]"
1712 -text {Current Branch
:} \
1716 -textvariable current_branch \
1719 pack .branch.l1
-side left
1720 pack .branch.cb
-side left
-fill x
1721 pack .branch
-side top
-fill x
1723 # -- Main Window Layout
1725 panedwindow .vpane
-orient vertical
1726 panedwindow .vpane.files
-orient horizontal
1727 .vpane add .vpane.files
-sticky nsew
-height 100 -width 200
1728 pack .vpane
-anchor n
-side top
-fill both
-expand 1
1730 # -- Index File List
1732 frame .vpane.files.index
-height 100 -width 200
1733 label .vpane.files.index.title
-text {Staged Changes
(Will Be Committed
)} \
1734 -background lightgreen
1735 text
$ui_index -background white
-borderwidth 0 \
1736 -width 20 -height 10 \
1738 -cursor $cursor_ptr \
1739 -xscrollcommand {.vpane.files.index.sx
set} \
1740 -yscrollcommand {.vpane.files.index.sy
set} \
1742 scrollbar .vpane.files.index.sx
-orient h
-command [list
$ui_index xview
]
1743 scrollbar .vpane.files.index.sy
-orient v
-command [list
$ui_index yview
]
1744 pack .vpane.files.index.title
-side top
-fill x
1745 pack .vpane.files.index.sx
-side bottom
-fill x
1746 pack .vpane.files.index.sy
-side right
-fill y
1747 pack
$ui_index -side left
-fill both
-expand 1
1748 .vpane.files add .vpane.files.index
-sticky nsew
1750 # -- Working Directory File List
1752 frame .vpane.files.workdir
-height 100 -width 200
1753 label .vpane.files.workdir.title
-text {Unstaged Changes
(Will Not Be Committed
)} \
1754 -background lightsalmon
1755 text
$ui_workdir -background white
-borderwidth 0 \
1756 -width 20 -height 10 \
1758 -cursor $cursor_ptr \
1759 -xscrollcommand {.vpane.files.workdir.sx
set} \
1760 -yscrollcommand {.vpane.files.workdir.sy
set} \
1762 scrollbar .vpane.files.workdir.sx
-orient h
-command [list
$ui_workdir xview
]
1763 scrollbar .vpane.files.workdir.sy
-orient v
-command [list
$ui_workdir yview
]
1764 pack .vpane.files.workdir.title
-side top
-fill x
1765 pack .vpane.files.workdir.sx
-side bottom
-fill x
1766 pack .vpane.files.workdir.sy
-side right
-fill y
1767 pack
$ui_workdir -side left
-fill both
-expand 1
1768 .vpane.files add .vpane.files.workdir
-sticky nsew
1770 foreach i
[list
$ui_index $ui_workdir] {
1771 $i tag conf in_diff
-background lightgray
1772 $i tag conf in_sel
-background lightgray
1776 # -- Diff and Commit Area
1778 frame .vpane.lower
-height 300 -width 400
1779 frame .vpane.lower.commarea
1780 frame .vpane.lower.
diff -relief sunken
-borderwidth 1
1781 pack .vpane.lower.commarea
-side top
-fill x
1782 pack .vpane.lower.
diff -side bottom
-fill both
-expand 1
1783 .vpane add .vpane.lower
-sticky nsew
1785 # -- Commit Area Buttons
1787 frame .vpane.lower.commarea.buttons
1788 label .vpane.lower.commarea.buttons.l
-text {} \
1791 pack .vpane.lower.commarea.buttons.l
-side top
-fill x
1792 pack .vpane.lower.commarea.buttons
-side left
-fill y
1794 button .vpane.lower.commarea.buttons.rescan
-text {Rescan
} \
1796 pack .vpane.lower.commarea.buttons.rescan
-side top
-fill x
1797 lappend disable_on_lock \
1798 {.vpane.lower.commarea.buttons.rescan conf
-state}
1800 button .vpane.lower.commarea.buttons.incall
-text {Add Existing
} \
1802 pack .vpane.lower.commarea.buttons.incall
-side top
-fill x
1803 lappend disable_on_lock \
1804 {.vpane.lower.commarea.buttons.incall conf
-state}
1806 button .vpane.lower.commarea.buttons.signoff
-text {Sign Off
} \
1808 pack .vpane.lower.commarea.buttons.signoff
-side top
-fill x
1810 button .vpane.lower.commarea.buttons.commit
-text {Commit
} \
1812 pack .vpane.lower.commarea.buttons.commit
-side top
-fill x
1813 lappend disable_on_lock \
1814 {.vpane.lower.commarea.buttons.commit conf
-state}
1816 # -- Commit Message Buffer
1818 frame .vpane.lower.commarea.buffer
1819 frame .vpane.lower.commarea.buffer.header
1820 set ui_comm .vpane.lower.commarea.buffer.t
1821 set ui_coml .vpane.lower.commarea.buffer.header.l
1822 radiobutton .vpane.lower.commarea.buffer.header.new \
1823 -text {New Commit
} \
1824 -command do_select_commit_type \
1825 -variable selected_commit_type \
1827 lappend disable_on_lock \
1828 [list .vpane.lower.commarea.buffer.header.new conf
-state]
1829 radiobutton .vpane.lower.commarea.buffer.header.amend \
1830 -text {Amend Last Commit
} \
1831 -command do_select_commit_type \
1832 -variable selected_commit_type \
1834 lappend disable_on_lock \
1835 [list .vpane.lower.commarea.buffer.header.amend conf
-state]
1839 proc trace_commit_type
{varname args
} {
1840 global ui_coml commit_type
1841 switch
-glob -- $commit_type {
1842 initial
{set txt
{Initial Commit Message
:}}
1843 amend
{set txt
{Amended Commit Message
:}}
1844 amend-initial
{set txt
{Amended Initial Commit Message
:}}
1845 amend-merge
{set txt
{Amended Merge Commit Message
:}}
1846 merge
{set txt
{Merge Commit Message
:}}
1847 * {set txt
{Commit Message
:}}
1849 $ui_coml conf
-text $txt
1851 trace add variable commit_type
write trace_commit_type
1852 pack
$ui_coml -side left
-fill x
1853 pack .vpane.lower.commarea.buffer.header.amend
-side right
1854 pack .vpane.lower.commarea.buffer.header.new
-side right
1856 text
$ui_comm -background white
-borderwidth 1 \
1859 -autoseparators true \
1861 -width 75 -height 9 -wrap none \
1863 -yscrollcommand {.vpane.lower.commarea.buffer.sby
set}
1864 scrollbar .vpane.lower.commarea.buffer.sby \
1865 -command [list
$ui_comm yview
]
1866 pack .vpane.lower.commarea.buffer.header
-side top
-fill x
1867 pack .vpane.lower.commarea.buffer.sby
-side right
-fill y
1868 pack
$ui_comm -side left
-fill y
1869 pack .vpane.lower.commarea.buffer
-side left
-fill y
1871 # -- Commit Message Buffer Context Menu
1873 set ctxm .vpane.lower.commarea.buffer.ctxm
1874 menu
$ctxm -tearoff 0
1877 -command {tk_textCut
$ui_comm}
1880 -command {tk_textCopy
$ui_comm}
1883 -command {tk_textPaste
$ui_comm}
1886 -command {$ui_comm delete sel.first sel.last
}
1889 -label {Select All
} \
1890 -command {focus
$ui_comm;$ui_comm tag add sel
0.0 end
}
1894 $ui_comm tag add sel
0.0 end
1895 tk_textCopy
$ui_comm
1896 $ui_comm tag remove sel
0.0 end
1902 bind_button3
$ui_comm "tk_popup $ctxm %X %Y"
1906 proc trace_current_diff_path
{varname args
} {
1907 global current_diff_path diff_actions file_states
1908 if {$current_diff_path eq
{}} {
1914 set p
$current_diff_path
1915 set s
[mapdesc
[lindex
$file_states($p) 0] $p]
1917 set p
[escape_path
$p]
1921 .vpane.lower.
diff.header.status configure
-text $s
1922 .vpane.lower.
diff.header.
file configure
-text $f
1923 .vpane.lower.
diff.header.path configure
-text $p
1924 foreach w
$diff_actions {
1928 trace add variable current_diff_path
write trace_current_diff_path
1930 frame .vpane.lower.
diff.header
-background gold
1931 label .vpane.lower.
diff.header.status \
1933 -width $max_status_desc \
1936 label .vpane.lower.
diff.header.
file \
1940 label .vpane.lower.
diff.header.path \
1944 pack .vpane.lower.
diff.header.status
-side left
1945 pack .vpane.lower.
diff.header.
file -side left
1946 pack .vpane.lower.
diff.header.path
-fill x
1947 set ctxm .vpane.lower.
diff.header.ctxm
1948 menu
$ctxm -tearoff 0
1956 -- $current_diff_path
1958 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
1959 bind_button3 .vpane.lower.
diff.header.path
"tk_popup $ctxm %X %Y"
1963 frame .vpane.lower.
diff.body
1964 set ui_diff .vpane.lower.
diff.body.t
1965 text
$ui_diff -background white
-borderwidth 0 \
1966 -width 80 -height 15 -wrap none \
1968 -xscrollcommand {.vpane.lower.
diff.body.sbx
set} \
1969 -yscrollcommand {.vpane.lower.
diff.body.sby
set} \
1971 scrollbar .vpane.lower.
diff.body.sbx
-orient horizontal \
1972 -command [list
$ui_diff xview
]
1973 scrollbar .vpane.lower.
diff.body.sby
-orient vertical \
1974 -command [list
$ui_diff yview
]
1975 pack .vpane.lower.
diff.body.sbx
-side bottom
-fill x
1976 pack .vpane.lower.
diff.body.sby
-side right
-fill y
1977 pack
$ui_diff -side left
-fill both
-expand 1
1978 pack .vpane.lower.
diff.header
-side top
-fill x
1979 pack .vpane.lower.
diff.body
-side bottom
-fill both
-expand 1
1981 $ui_diff tag conf d_cr
-elide true
1982 $ui_diff tag conf d_@
-foreground blue
-font font_diffbold
1983 $ui_diff tag conf d_
+ -foreground {#00a000}
1984 $ui_diff tag conf d_-
-foreground red
1986 $ui_diff tag conf d_
++ -foreground {#00a000}
1987 $ui_diff tag conf d_--
-foreground red
1988 $ui_diff tag conf d_
+s \
1989 -foreground {#00a000} \
1990 -background {#e2effa}
1991 $ui_diff tag conf d_-s \
1993 -background {#e2effa}
1994 $ui_diff tag conf d_s
+ \
1995 -foreground {#00a000} \
1997 $ui_diff tag conf d_s- \
2001 $ui_diff tag conf d
<<<<<<< \
2002 -foreground orange \
2004 $ui_diff tag conf d
======= \
2005 -foreground orange \
2007 $ui_diff tag conf d
>>>>>>> \
2008 -foreground orange \
2011 $ui_diff tag raise sel
2013 # -- Diff Body Context Menu
2015 set ctxm .vpane.lower.
diff.body.ctxm
2016 menu
$ctxm -tearoff 0
2019 -command reshow_diff
2020 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2023 -command {tk_textCopy
$ui_diff}
2024 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2026 -label {Select All
} \
2027 -command {focus
$ui_diff;$ui_diff tag add sel
0.0 end
}
2028 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2032 $ui_diff tag add sel
0.0 end
2033 tk_textCopy
$ui_diff
2034 $ui_diff tag remove sel
0.0 end
2036 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2039 -label {Apply
/Reverse Hunk
} \
2040 -command {apply_hunk
$cursorX $cursorY}
2041 set ui_diff_applyhunk
[$ctxm index last
]
2042 lappend diff_actions
[list
$ctxm entryconf
$ui_diff_applyhunk -state]
2045 -label {Decrease Font Size
} \
2046 -command {incr_font_size font_diff
-1}
2047 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2049 -label {Increase Font Size
} \
2050 -command {incr_font_size font_diff
1}
2051 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2054 -label {Show Less Context
} \
2055 -command {if {$repo_config(gui.diffcontext
) >= 1} {
2056 incr repo_config
(gui.diffcontext
) -1
2059 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2061 -label {Show More Context
} \
2062 -command {if {$repo_config(gui.diffcontext
) < 99} {
2063 incr repo_config
(gui.diffcontext
)
2066 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2068 $ctxm add
command -label {Options...
} \
2070 bind_button3
$ui_diff "
2073 if {\$ui_index eq \$current_diff_side} {
2074 $ctxm entryconf $ui_diff_applyhunk -label {Unstage Hunk From Commit}
2076 $ctxm entryconf $ui_diff_applyhunk -label {Stage Hunk For Commit}
2078 tk_popup $ctxm %X %Y
2080 unset ui_diff_applyhunk
2084 label .status
-textvariable ui_status_value \
2089 pack .status
-anchor w
-side bottom
-fill x
2094 set gm
$repo_config(gui.geometry
)
2095 wm geometry .
[lindex
$gm 0]
2096 .vpane sash place
0 \
2097 [lindex
[.vpane sash coord
0] 0] \
2099 .vpane.files sash place
0 \
2101 [lindex
[.vpane.files sash coord
0] 1]
2107 bind $ui_comm <$M1B-Key-Return> {do_commit
;break}
2108 bind $ui_comm <$M1B-Key-i> {do_add_all
;break}
2109 bind $ui_comm <$M1B-Key-I> {do_add_all
;break}
2110 bind $ui_comm <$M1B-Key-x> {tk_textCut
%W
;break}
2111 bind $ui_comm <$M1B-Key-X> {tk_textCut
%W
;break}
2112 bind $ui_comm <$M1B-Key-c> {tk_textCopy
%W
;break}
2113 bind $ui_comm <$M1B-Key-C> {tk_textCopy
%W
;break}
2114 bind $ui_comm <$M1B-Key-v> {tk_textPaste
%W
; %W see insert
; break}
2115 bind $ui_comm <$M1B-Key-V> {tk_textPaste
%W
; %W see insert
; break}
2116 bind $ui_comm <$M1B-Key-a> {%W tag add sel
0.0 end
;break}
2117 bind $ui_comm <$M1B-Key-A> {%W tag add sel
0.0 end
;break}
2119 bind $ui_diff <$M1B-Key-x> {tk_textCopy
%W
;break}
2120 bind $ui_diff <$M1B-Key-X> {tk_textCopy
%W
;break}
2121 bind $ui_diff <$M1B-Key-c> {tk_textCopy
%W
;break}
2122 bind $ui_diff <$M1B-Key-C> {tk_textCopy
%W
;break}
2123 bind $ui_diff <$M1B-Key-v> {break}
2124 bind $ui_diff <$M1B-Key-V> {break}
2125 bind $ui_diff <$M1B-Key-a> {%W tag add sel
0.0 end
;break}
2126 bind $ui_diff <$M1B-Key-A> {%W tag add sel
0.0 end
;break}
2127 bind $ui_diff <Key-Up
> {catch
{%W yview scroll
-1 units
};break}
2128 bind $ui_diff <Key-Down
> {catch
{%W yview scroll
1 units
};break}
2129 bind $ui_diff <Key-Left
> {catch
{%W xview scroll
-1 units
};break}
2130 bind $ui_diff <Key-Right
> {catch
{%W xview scroll
1 units
};break}
2131 bind $ui_diff <Key-k
> {catch
{%W yview scroll
-1 units
};break}
2132 bind $ui_diff <Key-j
> {catch
{%W yview scroll
1 units
};break}
2133 bind $ui_diff <Key-h
> {catch
{%W xview scroll
-1 units
};break}
2134 bind $ui_diff <Key-l
> {catch
{%W xview scroll
1 units
};break}
2135 bind $ui_diff <Control-Key-b
> {catch
{%W yview scroll
-1 pages
};break}
2136 bind $ui_diff <Control-Key-f
> {catch
{%W yview scroll
1 pages
};break}
2137 bind $ui_diff <Button-1
> {focus
%W
}
2139 if {[is_enabled branch
]} {
2140 bind .
<$M1B-Key-n> do_create_branch
2141 bind .
<$M1B-Key-N> do_create_branch
2144 bind all
<Key-F5
> do_rescan
2145 bind all
<$M1B-Key-r> do_rescan
2146 bind all
<$M1B-Key-R> do_rescan
2147 bind .
<$M1B-Key-s> do_signoff
2148 bind .
<$M1B-Key-S> do_signoff
2149 bind .
<$M1B-Key-i> do_add_all
2150 bind .
<$M1B-Key-I> do_add_all
2151 bind .
<$M1B-Key-Return> do_commit
2152 foreach i
[list
$ui_index $ui_workdir] {
2153 bind $i <Button-1
> "toggle_or_diff $i %x %y; break"
2154 bind $i <$M1B-Button-1> "add_one_to_selection $i %x %y; break"
2155 bind $i <Shift-Button-1
> "add_range_to_selection $i %x %y; break"
2159 set file_lists
($ui_index) [list
]
2160 set file_lists
($ui_workdir) [list
]
2162 wm title .
"[appname] ([reponame]) [file normalize [file dirname [gitdir]]]"
2163 focus
-force $ui_comm
2165 # -- Warn the user about environmental problems. Cygwin's Tcl
2166 # does *not* pass its env array onto any processes it spawns.
2167 # This means that git processes get none of our environment.
2172 set msg
"Possible environment issues exist.
2174 The following environment variables are probably
2175 going to be ignored by any Git subprocess run
2179 foreach name
[array names env
] {
2180 switch
-regexp -- $name {
2181 {^GIT_INDEX_FILE$
} -
2182 {^GIT_OBJECT_DIRECTORY$
} -
2183 {^GIT_ALTERNATE_OBJECT_DIRECTORIES$
} -
2185 {^GIT_EXTERNAL_DIFF$
} -
2189 {^GIT_CONFIG_LOCAL$
} -
2190 {^GIT_
(AUTHOR|COMMITTER
)_DATE$
} {
2191 append msg
" - $name\n"
2194 {^GIT_
(AUTHOR|COMMITTER
)_
(NAME|EMAIL
)$
} {
2195 append msg
" - $name\n"
2197 set suggest_user
$name
2201 if {$ignored_env > 0} {
2203 This is due to a known issue with the
2204 Tcl binary distributed by Cygwin."
2206 if {$suggest_user ne
{}} {
2209 A good replacement for $suggest_user
2210 is placing values for the user.name and
2211 user.email settings into your personal
2217 unset ignored_env msg suggest_user name
2220 # -- Only initialize complex UI if we are going to stay running.
2222 if {[is_enabled transport
]} {
2226 populate_branch_menu
2231 # -- Only suggest a gc run if we are going to stay running.
2233 if {[is_enabled multicommit
]} {
2234 set object_limit
2000
2235 if {[is_Windows
]} {set object_limit
200}
2236 regexp
{^
([0-9]+) objects
,} [git count-objects
] _junk objects_current
2237 if {$objects_current >= $object_limit} {
2239 "This repository currently has $objects_current loose objects.
2241 To maintain optimal performance it is strongly recommended that you compress the database when more than $object_limit loose objects exist.
2243 Compress the database now?"] eq
yes} {
2247 unset object_limit _junk objects_current
2250 lock_index begin-read