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 ## enable verbose loading?
27 if {![catch
{set _verbose
$env(GITGUI_VERBOSE
)}]} {
29 rename auto_load real__auto_load
30 proc auto_load
{name args
} {
31 puts stderr
"auto_load $name"
32 return [uplevel
1 real__auto_load
$name $args]
34 rename
source real__source
36 puts stderr
"source $name"
37 uplevel
1 real__source
$name
41 ######################################################################
43 ## configure our library
45 set oguilib
{@@GITGUI_LIBDIR@@
}
46 set oguirel
{@@GITGUI_RELATIVE@@
}
47 if {$oguirel eq
{1}} {
48 set oguilib
[file dirname [file dirname [file normalize
$argv0]]]
49 set oguilib
[file join $oguilib share git-gui lib
]
50 } elseif
{[string match @@
* $oguirel]} {
51 set oguilib
[file join [file dirname [file normalize
$argv0]] lib
]
54 set idx
[file join $oguilib tclIndex
]
55 if {[catch
{set fd
[open
$idx r
]} err
]} {
60 -title "git-gui: fatal error" \
64 if {[gets
$fd] eq
{# Autogenerated by git-gui Makefile}} {
66 while {[gets
$fd n
] >= 0} {
67 if {$n ne
{} && ![string match
#* $n]} {
79 if {[lsearch
-exact $loaded $p] >= 0} continue
80 source [file join $oguilib $p]
85 set auto_path
[concat
[list
$oguilib] $auto_path]
87 unset -nocomplain oguirel idx fd
89 ######################################################################
93 set _appname
[lindex
[file split $argv0] end
]
109 return [eval [concat
[list
file join $_gitdir] $args]]
112 proc gitexec
{args
} {
114 if {$_gitexec eq
{}} {
115 if {[catch
{set _gitexec
[git
--exec-path]} err
]} {
116 error
"Git not installed?\n\n$err"
122 return [eval [concat
[list
file join $_gitexec] $args]]
131 global tcl_platform tk_library
132 if {[tk windowingsystem
] eq
{aqua
}} {
140 if {$tcl_platform(platform
) eq
{windows
}} {
147 global tcl_platform _iscygwin
148 if {$_iscygwin eq
{}} {
149 if {$tcl_platform(platform
) eq
{windows
}} {
150 if {[catch
{set p
[exec cygpath
--windir]} err
]} {
162 proc is_enabled
{option
} {
163 global enabled_options
164 if {[catch
{set on
$enabled_options($option)}]} {return 0}
168 proc enable_option
{option
} {
169 global enabled_options
170 set enabled_options
($option) 1
173 proc disable_option
{option
} {
174 global enabled_options
175 set enabled_options
($option) 0
178 ######################################################################
182 proc is_many_config
{name
} {
183 switch
-glob -- $name {
192 proc is_config_true
{name
} {
194 if {[catch
{set v
$repo_config($name)}]} {
196 } elseif
{$v eq
{true
} ||
$v eq
{1} ||
$v eq
{yes}} {
203 proc get_config
{name
} {
205 if {[catch
{set v
$repo_config($name)}]} {
212 proc load_config
{include_global
} {
213 global repo_config global_config default_config
215 array
unset global_config
216 if {$include_global} {
218 set fd_rc
[open
"| git config --global --list" r
]
219 while {[gets
$fd_rc line
] >= 0} {
220 if {[regexp
{^
([^
=]+)=(.
*)$
} $line line name value
]} {
221 if {[is_many_config
$name]} {
222 lappend global_config
($name) $value
224 set global_config
($name) $value
232 array
unset repo_config
234 set fd_rc
[open
"| git config --list" r
]
235 while {[gets
$fd_rc line
] >= 0} {
236 if {[regexp
{^
([^
=]+)=(.
*)$
} $line line name value
]} {
237 if {[is_many_config
$name]} {
238 lappend repo_config
($name) $value
240 set repo_config
($name) $value
247 foreach name
[array names default_config
] {
248 if {[catch
{set v
$global_config($name)}]} {
249 set global_config
($name) $default_config($name)
251 if {[catch
{set v
$repo_config($name)}]} {
252 set repo_config
($name) $default_config($name)
257 ######################################################################
262 return [eval exec git
$args]
265 auto_load tk_optionMenu
266 rename tk_optionMenu real__tkOptionMenu
267 proc tk_optionMenu
{w varName args
} {
268 set m
[eval real__tkOptionMenu
$w $varName $args]
269 $m configure
-font font_ui
270 $w configure
-font font_ui
274 ######################################################################
278 if {{--version} eq
$argv ||
{version
} eq
$argv} {
279 puts
"git-gui version $appvers"
286 if {[catch
{set v
[git
--version]} err
]} {
287 catch
{wm withdraw .
}
288 error_popup
"Cannot determine Git version:
292 [appname] requires Git $req_maj.$req_min or later."
295 if {[regexp
{^git version
(\d
+)\.
(\d
+)} $v _junk act_maj act_min
]} {
296 if {$act_maj < $req_maj
297 ||
($act_maj == $req_maj && $act_min < $req_min)} {
298 catch
{wm withdraw .
}
299 error_popup
"[appname] requires Git $req_maj.$req_min or later.
305 catch
{wm withdraw .
}
306 error_popup
"Cannot parse Git version string:\n\n$v"
309 unset -nocomplain v _junk act_maj act_min req_maj req_min
311 ######################################################################
316 set _gitdir
$env(GIT_DIR
)
320 set _gitdir
[git rev-parse
--git-dir]
321 set _prefix
[git rev-parse
--show-prefix]
323 catch
{wm withdraw .
}
324 error_popup
"Cannot find the git directory:\n\n$err"
327 if {![file isdirectory
$_gitdir] && [is_Cygwin
]} {
328 catch
{set _gitdir
[exec cygpath
--unix $_gitdir]}
330 if {![file isdirectory
$_gitdir]} {
331 catch
{wm withdraw .
}
332 error_popup
"Git directory not found:\n\n$_gitdir"
335 if {[lindex
[file split $_gitdir] end
] ne
{.git
}} {
336 catch
{wm withdraw .
}
337 error_popup
"Cannot use funny .git directory:\n\n$_gitdir"
340 if {[catch
{cd [file dirname $_gitdir]} err
]} {
341 catch
{wm withdraw .
}
342 error_popup
"No working directory [file dirname $_gitdir]:\n\n$err"
345 set _reponame
[lindex
[file split \
346 [file normalize
[file dirname $_gitdir]]] \
349 ######################################################################
353 set current_diff_path
{}
354 set current_diff_side
{}
355 set diff_actions
[list
]
356 set ui_status_value
{Initializing...
}
360 set MERGE_HEAD
[list
]
363 set current_branch
{}
364 set current_diff_path
{}
365 set selected_commit_type new
367 ######################################################################
375 set disable_on_lock
[list
]
376 set index_lock_type none
378 proc lock_index
{type} {
379 global index_lock_type disable_on_lock
381 if {$index_lock_type eq
{none
}} {
382 set index_lock_type
$type
383 foreach w
$disable_on_lock {
384 uplevel
#0 $w disabled
387 } elseif
{$index_lock_type eq
"begin-$type"} {
388 set index_lock_type
$type
394 proc unlock_index
{} {
395 global index_lock_type disable_on_lock
397 set index_lock_type none
398 foreach w
$disable_on_lock {
403 ######################################################################
407 proc repository_state
{ctvar hdvar mhvar
} {
408 global current_branch
409 upvar
$ctvar ct
$hdvar hd
$mhvar mh
413 if {[catch
{set current_branch
[git symbolic-ref HEAD
]}]} {
414 set current_branch
{}
416 regsub ^refs
/((heads|tags|remotes
)/)? \
422 if {[catch
{set hd
[git rev-parse
--verify HEAD
]}]} {
428 set merge_head
[gitdir MERGE_HEAD
]
429 if {[file exists
$merge_head]} {
431 set fd_mh
[open
$merge_head r
]
432 while {[gets
$fd_mh line
] >= 0} {
443 global PARENT empty_tree
445 set p
[lindex
$PARENT 0]
449 if {$empty_tree eq
{}} {
450 set empty_tree
[git mktree
<< {}]
455 proc rescan
{after
{honor_trustmtime
1}} {
456 global HEAD PARENT MERGE_HEAD commit_type
457 global ui_index ui_workdir ui_status_value ui_comm
458 global rescan_active file_states
461 if {$rescan_active > 0 ||
![lock_index
read]} return
463 repository_state newType newHEAD newMERGE_HEAD
464 if {[string match amend
* $commit_type]
465 && $newType eq
{normal
}
466 && $newHEAD eq
$HEAD} {
470 set MERGE_HEAD
$newMERGE_HEAD
471 set commit_type
$newType
474 array
unset file_states
476 if {![$ui_comm edit modified
]
477 ||
[string trim
[$ui_comm get
0.0 end
]] eq
{}} {
478 if {[load_message GITGUI_MSG
]} {
479 } elseif
{[load_message MERGE_MSG
]} {
480 } elseif
{[load_message SQUASH_MSG
]} {
483 $ui_comm edit modified false
486 if {[is_enabled branch
]} {
491 if {$honor_trustmtime && $repo_config(gui.trustmtime
) eq
{true
}} {
492 rescan_stage2
{} $after
495 set ui_status_value
{Refreshing
file status...
}
496 set cmd
[list git update-index
]
498 lappend cmd
--unmerged
499 lappend cmd
--ignore-missing
500 lappend cmd
--refresh
501 set fd_rf
[open
"| $cmd" r
]
502 fconfigure
$fd_rf -blocking 0 -translation binary
503 fileevent
$fd_rf readable \
504 [list rescan_stage2
$fd_rf $after]
508 proc rescan_stage2
{fd after
} {
509 global ui_status_value
510 global rescan_active buf_rdi buf_rdf buf_rlo
514 if {![eof
$fd]} return
518 set ls_others
[list | git ls-files
--others -z \
519 --exclude-per-directory=.gitignore
]
520 set info_exclude
[gitdir info exclude
]
521 if {[file readable
$info_exclude]} {
522 lappend ls_others
"--exclude-from=$info_exclude"
530 set ui_status_value
{Scanning
for modified files ...
}
531 set fd_di
[open
"| git diff-index --cached -z [PARENT]" r
]
532 set fd_df
[open
"| git diff-files -z" r
]
533 set fd_lo
[open
$ls_others r
]
535 fconfigure
$fd_di -blocking 0 -translation binary
-encoding binary
536 fconfigure
$fd_df -blocking 0 -translation binary
-encoding binary
537 fconfigure
$fd_lo -blocking 0 -translation binary
-encoding binary
538 fileevent
$fd_di readable
[list read_diff_index
$fd_di $after]
539 fileevent
$fd_df readable
[list read_diff_files
$fd_df $after]
540 fileevent
$fd_lo readable
[list read_ls_others
$fd_lo $after]
543 proc load_message
{file} {
547 if {[file isfile
$f]} {
548 if {[catch
{set fd
[open
$f r
]}]} {
551 set content
[string trim
[read $fd]]
553 regsub
-all -line {[ \r\t]+$
} $content {} content
554 $ui_comm delete
0.0 end
555 $ui_comm insert end
$content
561 proc read_diff_index
{fd after
} {
564 append buf_rdi
[read $fd]
566 set n
[string length
$buf_rdi]
568 set z1
[string first
"\0" $buf_rdi $c]
571 set z2
[string first
"\0" $buf_rdi $z1]
575 set i
[split [string range
$buf_rdi $c [expr {$z1 - 2}]] { }]
576 set p
[string range
$buf_rdi $z1 [expr {$z2 - 1}]]
578 [encoding convertfrom
$p] \
580 [list
[lindex
$i 0] [lindex
$i 2]] \
586 set buf_rdi
[string range
$buf_rdi $c end
]
591 rescan_done
$fd buf_rdi
$after
594 proc read_diff_files
{fd after
} {
597 append buf_rdf
[read $fd]
599 set n
[string length
$buf_rdf]
601 set z1
[string first
"\0" $buf_rdf $c]
604 set z2
[string first
"\0" $buf_rdf $z1]
608 set i
[split [string range
$buf_rdf $c [expr {$z1 - 2}]] { }]
609 set p
[string range
$buf_rdf $z1 [expr {$z2 - 1}]]
611 [encoding convertfrom
$p] \
614 [list
[lindex
$i 0] [lindex
$i 2]]
619 set buf_rdf
[string range
$buf_rdf $c end
]
624 rescan_done
$fd buf_rdf
$after
627 proc read_ls_others
{fd after
} {
630 append buf_rlo
[read $fd]
631 set pck
[split $buf_rlo "\0"]
632 set buf_rlo
[lindex
$pck end
]
633 foreach p
[lrange
$pck 0 end-1
] {
634 merge_state
[encoding convertfrom
$p] ?O
636 rescan_done
$fd buf_rlo
$after
639 proc rescan_done
{fd buf after
} {
640 global rescan_active current_diff_path
641 global file_states repo_config
644 if {![eof
$fd]} return
647 if {[incr rescan_active
-1] > 0} return
652 if {$current_diff_path ne
{}} reshow_diff
656 proc prune_selection
{} {
657 global file_states selected_paths
659 foreach path
[array names selected_paths
] {
660 if {[catch
{set still_here
$file_states($path)}]} {
661 unset selected_paths
($path)
666 ######################################################################
670 proc mapicon
{w state path
} {
673 if {[catch
{set r
$all_icons($state$w)}]} {
674 puts
"error: no icon for $w state={$state} $path"
680 proc mapdesc
{state path
} {
683 if {[catch
{set r
$all_descs($state)}]} {
684 puts
"error: no desc for state={$state} $path"
690 proc escape_path
{path
} {
691 regsub
-all {\\} $path "\\\\" path
692 regsub
-all "\n" $path "\\n" path
696 proc short_path
{path
} {
697 return [escape_path
[lindex
[file split $path] end
]]
701 set null_sha1
[string repeat
0 40]
703 proc merge_state
{path new_state
{head_info
{}} {index_info
{}}} {
704 global file_states next_icon_id null_sha1
706 set s0
[string index
$new_state 0]
707 set s1
[string index
$new_state 1]
709 if {[catch
{set info
$file_states($path)}]} {
711 set icon n
[incr next_icon_id
]
713 set state
[lindex
$info 0]
714 set icon
[lindex
$info 1]
715 if {$head_info eq
{}} {set head_info
[lindex
$info 2]}
716 if {$index_info eq
{}} {set index_info
[lindex
$info 3]}
719 if {$s0 eq
{?
}} {set s0
[string index
$state 0]} \
720 elseif
{$s0 eq
{_
}} {set s0 _
}
722 if {$s1 eq
{?
}} {set s1
[string index
$state 1]} \
723 elseif
{$s1 eq
{_
}} {set s1 _
}
725 if {$s0 eq
{A
} && $s1 eq
{_
} && $head_info eq
{}} {
726 set head_info
[list
0 $null_sha1]
727 } elseif
{$s0 ne
{_
} && [string index
$state 0] eq
{_
}
728 && $head_info eq
{}} {
729 set head_info
$index_info
732 set file_states
($path) [list
$s0$s1 $icon \
733 $head_info $index_info \
738 proc display_file_helper
{w path icon_name old_m new_m
} {
742 set lno
[lsearch
-sorted -exact $file_lists($w) $path]
744 set file_lists
($w) [lreplace
$file_lists($w) $lno $lno]
746 $w conf
-state normal
747 $w delete
$lno.0 [expr {$lno + 1}].0
748 $w conf
-state disabled
750 } elseif
{$old_m eq
{_
} && $new_m ne
{_
}} {
751 lappend file_lists
($w) $path
752 set file_lists
($w) [lsort
-unique $file_lists($w)]
753 set lno
[lsearch
-sorted -exact $file_lists($w) $path]
755 $w conf
-state normal
756 $w image create
$lno.0 \
757 -align center
-padx 5 -pady 1 \
759 -image [mapicon
$w $new_m $path]
760 $w insert
$lno.1 "[escape_path $path]\n"
761 $w conf
-state disabled
762 } elseif
{$old_m ne
$new_m} {
763 $w conf
-state normal
764 $w image conf
$icon_name -image [mapicon
$w $new_m $path]
765 $w conf
-state disabled
769 proc display_file
{path state
} {
770 global file_states selected_paths
771 global ui_index ui_workdir
773 set old_m
[merge_state
$path $state]
774 set s
$file_states($path)
775 set new_m
[lindex
$s 0]
776 set icon_name
[lindex
$s 1]
778 set o
[string index
$old_m 0]
779 set n
[string index
$new_m 0]
786 display_file_helper
$ui_index $path $icon_name $o $n
788 if {[string index
$old_m 0] eq
{U
}} {
791 set o
[string index
$old_m 1]
793 if {[string index
$new_m 0] eq
{U
}} {
796 set n
[string index
$new_m 1]
798 display_file_helper
$ui_workdir $path $icon_name $o $n
800 if {$new_m eq
{__
}} {
801 unset file_states
($path)
802 catch
{unset selected_paths
($path)}
806 proc display_all_files_helper
{w path icon_name m
} {
809 lappend file_lists
($w) $path
810 set lno
[expr {[lindex
[split [$w index end
] .
] 0] - 1}]
811 $w image create end \
812 -align center
-padx 5 -pady 1 \
814 -image [mapicon
$w $m $path]
815 $w insert end
"[escape_path $path]\n"
818 proc display_all_files
{} {
819 global ui_index ui_workdir
820 global file_states file_lists
823 $ui_index conf
-state normal
824 $ui_workdir conf
-state normal
826 $ui_index delete
0.0 end
827 $ui_workdir delete
0.0 end
830 set file_lists
($ui_index) [list
]
831 set file_lists
($ui_workdir) [list
]
833 foreach path
[lsort
[array names file_states
]] {
834 set s
$file_states($path)
836 set icon_name
[lindex
$s 1]
838 set s
[string index
$m 0]
839 if {$s ne
{U
} && $s ne
{_
}} {
840 display_all_files_helper
$ui_index $path \
844 if {[string index
$m 0] eq
{U
}} {
847 set s
[string index
$m 1]
850 display_all_files_helper
$ui_workdir $path \
855 $ui_index conf
-state disabled
856 $ui_workdir conf
-state disabled
859 ######################################################################
864 #define mask_width 14
865 #define mask_height 15
866 static unsigned char mask_bits
[] = {
867 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
868 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
869 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f};
872 image create bitmap file_plain
-background white
-foreground black
-data {
873 #define plain_width 14
874 #define plain_height 15
875 static unsigned char plain_bits
[] = {
876 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
877 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10,
878 0x02, 0x10, 0x02, 0x10, 0xfe, 0x1f};
879 } -maskdata $filemask
881 image create bitmap file_mod
-background white
-foreground blue
-data {
883 #define mod_height 15
884 static unsigned char mod_bits
[] = {
885 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
886 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
887 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
888 } -maskdata $filemask
890 image create bitmap file_fulltick
-background white
-foreground "#007000" -data {
891 #define file_fulltick_width 14
892 #define file_fulltick_height 15
893 static unsigned char file_fulltick_bits
[] = {
894 0xfe, 0x01, 0x02, 0x1a, 0x02, 0x0c, 0x02, 0x0c, 0x02, 0x16, 0x02, 0x16,
895 0x02, 0x13, 0x00, 0x13, 0x86, 0x11, 0x8c, 0x11, 0xd8, 0x10, 0xf2, 0x10,
896 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
897 } -maskdata $filemask
899 image create bitmap file_parttick
-background white
-foreground "#005050" -data {
900 #define parttick_width 14
901 #define parttick_height 15
902 static unsigned char parttick_bits
[] = {
903 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
904 0x7a, 0x14, 0x02, 0x16, 0x02, 0x13, 0x8a, 0x11, 0xda, 0x10, 0x72, 0x10,
905 0x22, 0x10, 0x02, 0x10, 0xfe, 0x1f};
906 } -maskdata $filemask
908 image create bitmap file_question
-background white
-foreground black
-data {
909 #define file_question_width 14
910 #define file_question_height 15
911 static unsigned char file_question_bits
[] = {
912 0xfe, 0x01, 0x02, 0x02, 0xe2, 0x04, 0xf2, 0x09, 0x1a, 0x1b, 0x0a, 0x13,
913 0x82, 0x11, 0xc2, 0x10, 0x62, 0x10, 0x62, 0x10, 0x02, 0x10, 0x62, 0x10,
914 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
915 } -maskdata $filemask
917 image create bitmap file_removed
-background white
-foreground red
-data {
918 #define file_removed_width 14
919 #define file_removed_height 15
920 static unsigned char file_removed_bits
[] = {
921 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
922 0x1a, 0x16, 0x32, 0x13, 0xe2, 0x11, 0xc2, 0x10, 0xe2, 0x11, 0x32, 0x13,
923 0x1a, 0x16, 0x02, 0x10, 0xfe, 0x1f};
924 } -maskdata $filemask
926 image create bitmap file_merge
-background white
-foreground blue
-data {
927 #define file_merge_width 14
928 #define file_merge_height 15
929 static unsigned char file_merge_bits
[] = {
930 0xfe, 0x01, 0x02, 0x03, 0x62, 0x05, 0x62, 0x09, 0x62, 0x1f, 0x62, 0x10,
931 0xfa, 0x11, 0xf2, 0x10, 0x62, 0x10, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
932 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
933 } -maskdata $filemask
936 #define file_width 18
937 #define file_height 18
938 static unsigned char file_bits
[] = {
939 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0x00,
940 0x0c, 0x03, 0x00, 0x04, 0xfe, 0x00, 0x06, 0x80, 0x00, 0xff, 0x9f, 0x00,
941 0x03, 0x98, 0x00, 0x02, 0x90, 0x00, 0x06, 0xb0, 0x00, 0x04, 0xa0, 0x00,
942 0x0c, 0xe0, 0x00, 0x08, 0xc0, 0x00, 0xf8, 0xff, 0x00, 0x00, 0x00, 0x00,
943 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
945 image create bitmap file_dir
-background white
-foreground blue \
946 -data $file_dir_data -maskdata $file_dir_data
949 set file_uplevel_data
{
952 static unsigned char up_bits
[] = {
953 0x80, 0x00, 0xc0, 0x01, 0xe0, 0x03, 0xf0, 0x07, 0xf8, 0x0f, 0xfc, 0x1f,
954 0xfe, 0x3f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
955 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00};
957 image create bitmap file_uplevel
-background white
-foreground red \
958 -data $file_uplevel_data -maskdata $file_uplevel_data
959 unset file_uplevel_data
961 set ui_index .vpane.files.index.list
962 set ui_workdir .vpane.files.workdir.list
964 set all_icons
(_
$ui_index) file_plain
965 set all_icons
(A
$ui_index) file_fulltick
966 set all_icons
(M
$ui_index) file_fulltick
967 set all_icons
(D
$ui_index) file_removed
968 set all_icons
(U
$ui_index) file_merge
970 set all_icons
(_
$ui_workdir) file_plain
971 set all_icons
(M
$ui_workdir) file_mod
972 set all_icons
(D
$ui_workdir) file_question
973 set all_icons
(U
$ui_workdir) file_merge
974 set all_icons
(O
$ui_workdir) file_plain
976 set max_status_desc
0
980 {_M
"Modified, not staged"}
981 {M_
"Staged for commit"}
982 {MM
"Portions staged for commit"}
983 {MD
"Staged for commit, missing"}
985 {_O
"Untracked, not staged"}
986 {A_
"Staged for commit"}
987 {AM
"Portions staged for commit"}
988 {AD
"Staged for commit, missing"}
991 {D_
"Staged for removal"}
992 {DO
"Staged for removal, still present"}
994 {U_
"Requires merge resolution"}
995 {UU
"Requires merge resolution"}
996 {UM
"Requires merge resolution"}
997 {UD
"Requires merge resolution"}
999 if {$max_status_desc < [string length
[lindex
$i 1]]} {
1000 set max_status_desc
[string length
[lindex
$i 1]]
1002 set all_descs
([lindex
$i 0]) [lindex
$i 1]
1006 ######################################################################
1010 proc bind_button3
{w cmd
} {
1011 bind $w <Any-Button-3
> $cmd
1013 bind $w <Control-Button-1
> $cmd
1017 proc scrollbar2many
{list mode args
} {
1018 foreach w
$list {eval $w $mode $args}
1021 proc many2scrollbar
{list mode sb top bottom
} {
1022 $sb set $top $bottom
1023 foreach w
$list {$w $mode moveto
$top}
1026 proc incr_font_size
{font
{amt
1}} {
1027 set sz
[font configure
$font -size]
1029 font configure
$font -size $sz
1030 font configure
${font}bold
-size $sz
1033 ######################################################################
1037 set starting_gitk_msg
{Starting gitk... please
wait...
}
1039 proc do_gitk
{revs
} {
1040 global env ui_status_value starting_gitk_msg
1042 # -- Always start gitk through whatever we were loaded with. This
1043 # lets us bypass using shell process on Windows systems.
1045 set cmd
[list
[info nameofexecutable
]]
1046 lappend cmd
[gitexec gitk
]
1052 if {[catch
{eval exec $cmd &} err
]} {
1053 error_popup
"Failed to start gitk:\n\n$err"
1055 set ui_status_value
$starting_gitk_msg
1057 if {$ui_status_value eq
$starting_gitk_msg} {
1058 set ui_status_value
{Ready.
}
1067 global ui_comm is_quitting repo_config commit_type
1069 if {$is_quitting} return
1072 if {[winfo exists
$ui_comm]} {
1073 # -- Stash our current commit buffer.
1075 set save
[gitdir GITGUI_MSG
]
1076 set msg
[string trim
[$ui_comm get
0.0 end
]]
1077 regsub
-all -line {[ \r\t]+$
} $msg {} msg
1078 if {(![string match amend
* $commit_type]
1079 ||
[$ui_comm edit modified
])
1082 set fd
[open
$save w
]
1083 puts
-nonewline $fd $msg
1087 catch
{file delete
$save}
1090 # -- Stash our current window geometry into this repository.
1092 set cfg_geometry
[list
]
1093 lappend cfg_geometry
[wm geometry .
]
1094 lappend cfg_geometry
[lindex
[.vpane sash coord
0] 1]
1095 lappend cfg_geometry
[lindex
[.vpane.files sash coord
0] 0]
1096 if {[catch
{set rc_geometry
$repo_config(gui.geometry
)}]} {
1099 if {$cfg_geometry ne
$rc_geometry} {
1100 catch
{git config gui.geometry
$cfg_geometry}
1108 rescan
{set ui_status_value
{Ready.
}}
1115 proc toggle_or_diff
{w x y
} {
1116 global file_states file_lists current_diff_path ui_index ui_workdir
1117 global last_clicked selected_paths
1119 set pos
[split [$w index @
$x,$y] .
]
1120 set lno
[lindex
$pos 0]
1121 set col [lindex
$pos 1]
1122 set path
[lindex
$file_lists($w) [expr {$lno - 1}]]
1128 set last_clicked
[list
$w $lno]
1129 array
unset selected_paths
1130 $ui_index tag remove in_sel
0.0 end
1131 $ui_workdir tag remove in_sel
0.0 end
1134 if {$current_diff_path eq
$path} {
1135 set after
{reshow_diff
;}
1139 if {$w eq
$ui_index} {
1141 "Unstaging [short_path $path] from commit" \
1143 [concat
$after {set ui_status_value
{Ready.
}}]
1144 } elseif
{$w eq
$ui_workdir} {
1146 "Adding [short_path $path]" \
1148 [concat
$after {set ui_status_value
{Ready.
}}]
1151 show_diff
$path $w $lno
1155 proc add_one_to_selection
{w x y
} {
1156 global file_lists last_clicked selected_paths
1158 set lno
[lindex
[split [$w index @
$x,$y] .
] 0]
1159 set path
[lindex
$file_lists($w) [expr {$lno - 1}]]
1165 if {$last_clicked ne
{}
1166 && [lindex
$last_clicked 0] ne
$w} {
1167 array
unset selected_paths
1168 [lindex
$last_clicked 0] tag remove in_sel
0.0 end
1171 set last_clicked
[list
$w $lno]
1172 if {[catch
{set in_sel
$selected_paths($path)}]} {
1176 unset selected_paths
($path)
1177 $w tag remove in_sel
$lno.0 [expr {$lno + 1}].0
1179 set selected_paths
($path) 1
1180 $w tag add in_sel
$lno.0 [expr {$lno + 1}].0
1184 proc add_range_to_selection
{w x y
} {
1185 global file_lists last_clicked selected_paths
1187 if {[lindex
$last_clicked 0] ne
$w} {
1188 toggle_or_diff
$w $x $y
1192 set lno
[lindex
[split [$w index @
$x,$y] .
] 0]
1193 set lc
[lindex
$last_clicked 1]
1202 foreach path
[lrange
$file_lists($w) \
1203 [expr {$begin - 1}] \
1204 [expr {$end - 1}]] {
1205 set selected_paths
($path) 1
1207 $w tag add in_sel
$begin.0 [expr {$end + 1}].0
1210 ######################################################################
1214 set cursor_ptr arrow
1215 font create font_diff
-family Courier
-size 10
1219 eval font configure font_ui
[font actual
[.dummy cget
-font]]
1223 font create font_uibold
1224 font create font_diffbold
1226 foreach class
{Button Checkbutton Entry Label
1227 Labelframe Listbox Menu Message
1229 option add
*$class.font font_ui
1233 if {[is_Windows
] ||
[is_MacOSX
]} {
1234 option add
*Menu.tearOff
0
1245 proc apply_config
{} {
1246 global repo_config font_descs
1248 foreach option
$font_descs {
1249 set name
[lindex
$option 0]
1250 set font
[lindex
$option 1]
1252 foreach
{cn cv
} $repo_config(gui.
$name) {
1253 font configure
$font $cn $cv
1256 error_popup
"Invalid font specified in gui.$name:\n\n$err"
1258 foreach
{cn cv
} [font configure
$font] {
1259 font configure
${font}bold
$cn $cv
1261 font configure
${font}bold
-weight bold
1265 set default_config
(merge.diffstat
) true
1266 set default_config
(merge.summary
) false
1267 set default_config
(merge.verbosity
) 2
1268 set default_config
(user.name
) {}
1269 set default_config
(user.email
) {}
1271 set default_config
(gui.pruneduringfetch
) false
1272 set default_config
(gui.trustmtime
) false
1273 set default_config
(gui.diffcontext
) 5
1274 set default_config
(gui.newbranchtemplate
) {}
1275 set default_config
(gui.fontui
) [font configure font_ui
]
1276 set default_config
(gui.fontdiff
) [font configure font_diff
]
1278 {fontui font_ui
{Main Font
}}
1279 {fontdiff font_diff
{Diff
/Console Font
}}
1284 ######################################################################
1286 ## feature option selection
1288 if {[regexp
{^git-
(.
+)$
} [appname
] _junk subcommand
]} {
1293 if {$subcommand eq
{gui.sh
}} {
1296 if {$subcommand eq
{gui
} && [llength
$argv] > 0} {
1297 set subcommand
[lindex
$argv 0]
1298 set argv
[lrange
$argv 1 end
]
1301 enable_option multicommit
1302 enable_option branch
1303 enable_option transport
1305 switch
-- $subcommand {
1308 disable_option multicommit
1309 disable_option branch
1310 disable_option transport
1313 enable_option singlecommit
1315 disable_option multicommit
1316 disable_option branch
1317 disable_option transport
1321 ######################################################################
1329 menu .mbar
-tearoff 0
1330 .mbar add cascade
-label Repository
-menu .mbar.repository
1331 .mbar add cascade
-label Edit
-menu .mbar.edit
1332 if {[is_enabled branch
]} {
1333 .mbar add cascade
-label Branch
-menu .mbar.branch
1335 if {[is_enabled multicommit
] ||
[is_enabled singlecommit
]} {
1336 .mbar add cascade
-label Commit
-menu .mbar.commit
1338 if {[is_enabled transport
]} {
1339 .mbar add cascade
-label Merge
-menu .mbar.merge
1340 .mbar add cascade
-label Fetch
-menu .mbar.fetch
1341 .mbar add cascade
-label Push
-menu .mbar.push
1343 . configure
-menu .mbar
1345 # -- Repository Menu
1347 menu .mbar.repository
1349 .mbar.repository add
command \
1350 -label {Browse Current Branch
} \
1351 -command {browser
::new
$current_branch}
1352 trace add variable current_branch
write ".mbar.repository entryconf [.mbar.repository index last] -label \"Browse \$current_branch\" ;#"
1353 .mbar.repository add separator
1355 .mbar.repository add
command \
1356 -label {Visualize Current Branch
} \
1357 -command {do_gitk
$current_branch}
1358 trace add variable current_branch
write ".mbar.repository entryconf [.mbar.repository index last] -label \"Visualize \$current_branch\" ;#"
1359 .mbar.repository add
command \
1360 -label {Visualize All Branches
} \
1361 -command {do_gitk
--all}
1362 .mbar.repository add separator
1364 if {[is_enabled multicommit
]} {
1365 .mbar.repository add
command -label {Database Statistics
} \
1368 .mbar.repository add
command -label {Compress Database
} \
1371 .mbar.repository add
command -label {Verify Database
} \
1372 -command do_fsck_objects
1374 .mbar.repository add separator
1377 .mbar.repository add
command \
1378 -label {Create Desktop Icon
} \
1379 -command do_cygwin_shortcut
1380 } elseif
{[is_Windows
]} {
1381 .mbar.repository add
command \
1382 -label {Create Desktop Icon
} \
1383 -command do_windows_shortcut
1384 } elseif
{[is_MacOSX
]} {
1385 .mbar.repository add
command \
1386 -label {Create Desktop Icon
} \
1387 -command do_macosx_app
1391 .mbar.repository add
command -label Quit \
1398 .mbar.edit add
command -label Undo \
1399 -command {catch
{[focus
] edit undo
}} \
1401 .mbar.edit add
command -label Redo \
1402 -command {catch
{[focus
] edit redo
}} \
1404 .mbar.edit add separator
1405 .mbar.edit add
command -label Cut \
1406 -command {catch
{tk_textCut
[focus
]}} \
1408 .mbar.edit add
command -label Copy \
1409 -command {catch
{tk_textCopy
[focus
]}} \
1411 .mbar.edit add
command -label Paste \
1412 -command {catch
{tk_textPaste
[focus
]; [focus
] see insert
}} \
1414 .mbar.edit add
command -label Delete \
1415 -command {catch
{[focus
] delete sel.first sel.last
}} \
1417 .mbar.edit add separator
1418 .mbar.edit add
command -label {Select All
} \
1419 -command {catch
{[focus
] tag add sel
0.0 end
}} \
1424 if {[is_enabled branch
]} {
1427 .mbar.branch add
command -label {Create...
} \
1428 -command do_create_branch \
1430 lappend disable_on_lock
[list .mbar.branch entryconf \
1431 [.mbar.branch index last
] -state]
1433 .mbar.branch add
command -label {Rename...
} \
1434 -command branch_rename
::dialog
1435 lappend disable_on_lock
[list .mbar.branch entryconf \
1436 [.mbar.branch index last
] -state]
1438 .mbar.branch add
command -label {Delete...
} \
1439 -command do_delete_branch
1440 lappend disable_on_lock
[list .mbar.branch entryconf \
1441 [.mbar.branch index last
] -state]
1443 .mbar.branch add
command -label {Reset...
} \
1444 -command merge
::reset_hard
1445 lappend disable_on_lock
[list .mbar.branch entryconf \
1446 [.mbar.branch index last
] -state]
1451 if {[is_enabled multicommit
] ||
[is_enabled singlecommit
]} {
1454 .mbar.commit add radiobutton \
1455 -label {New Commit
} \
1456 -command do_select_commit_type \
1457 -variable selected_commit_type \
1459 lappend disable_on_lock \
1460 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1462 .mbar.commit add radiobutton \
1463 -label {Amend Last Commit
} \
1464 -command do_select_commit_type \
1465 -variable selected_commit_type \
1467 lappend disable_on_lock \
1468 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1470 .mbar.commit add separator
1472 .mbar.commit add
command -label Rescan \
1473 -command do_rescan \
1475 lappend disable_on_lock \
1476 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1478 .mbar.commit add
command -label {Add To Commit
} \
1479 -command do_add_selection
1480 lappend disable_on_lock \
1481 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1483 .mbar.commit add
command -label {Add Existing To Commit
} \
1484 -command do_add_all \
1486 lappend disable_on_lock \
1487 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1489 .mbar.commit add
command -label {Unstage From Commit
} \
1490 -command do_unstage_selection
1491 lappend disable_on_lock \
1492 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1494 .mbar.commit add
command -label {Revert Changes
} \
1495 -command do_revert_selection
1496 lappend disable_on_lock \
1497 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1499 .mbar.commit add separator
1501 .mbar.commit add
command -label {Sign Off
} \
1502 -command do_signoff \
1505 .mbar.commit add
command -label Commit \
1506 -command do_commit \
1507 -accelerator $M1T-Return
1508 lappend disable_on_lock \
1509 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1514 if {[is_enabled branch
]} {
1516 .mbar.merge add
command -label {Local Merge...
} \
1517 -command merge
::dialog
1518 lappend disable_on_lock \
1519 [list .mbar.merge entryconf
[.mbar.merge index last
] -state]
1520 .mbar.merge add
command -label {Abort Merge...
} \
1521 -command merge
::reset_hard
1522 lappend disable_on_lock \
1523 [list .mbar.merge entryconf
[.mbar.merge index last
] -state]
1529 if {[is_enabled transport
]} {
1533 .mbar.push add
command -label {Push...
} \
1534 -command do_push_anywhere
1535 .mbar.push add
command -label {Delete...
} \
1536 -command remote_branch_delete
::dialog
1540 # -- Apple Menu (Mac OS X only)
1542 .mbar add cascade
-label Apple
-menu .mbar.apple
1545 .mbar.apple add
command -label "About [appname]" \
1547 .mbar.apple add
command -label "Options..." \
1552 .mbar.edit add separator
1553 .mbar.edit add
command -label {Options...
} \
1558 if {[file exists
/usr
/local
/miga
/lib
/gui-miga
]
1559 && [file exists .pvcsrc
]} {
1561 global ui_status_value
1562 if {![lock_index update
]} return
1563 set cmd
[list sh
--login -c "/usr/local/miga/lib/gui-miga \"[pwd]\""]
1564 set miga_fd
[open
"|$cmd" r
]
1565 fconfigure
$miga_fd -blocking 0
1566 fileevent
$miga_fd readable
[list miga_done
$miga_fd]
1567 set ui_status_value
{Running miga...
}
1569 proc miga_done
{fd
} {
1574 rescan
[list
set ui_status_value
{Ready.
}]
1577 .mbar add cascade
-label Tools
-menu .mbar.tools
1579 .mbar.tools add
command -label "Migrate" \
1581 lappend disable_on_lock \
1582 [list .mbar.tools entryconf
[.mbar.tools index last
] -state]
1588 .mbar add cascade
-label Help
-menu .mbar.
help
1592 .mbar.
help add
command -label "About [appname]" \
1597 catch
{set browser
$repo_config(instaweb.browser
)}
1598 set doc_path
[file dirname [gitexec
]]
1599 set doc_path
[file join $doc_path Documentation index.html
]
1602 set doc_path
[exec cygpath
--mixed $doc_path]
1605 if {$browser eq
{}} {
1608 } elseif
{[is_Cygwin
]} {
1609 set program_files
[file dirname [exec cygpath
--windir]]
1610 set program_files
[file join $program_files {Program Files
}]
1611 set firefox
[file join $program_files {Mozilla Firefox
} firefox.exe
]
1612 set ie
[file join $program_files {Internet Explorer
} IEXPLORE.EXE
]
1613 if {[file exists
$firefox]} {
1614 set browser
$firefox
1615 } elseif
{[file exists
$ie]} {
1618 unset program_files firefox ie
1622 if {[file isfile
$doc_path]} {
1623 set doc_url
"file:$doc_path"
1625 set doc_url
{http
://www.kernel.org
/pub
/software
/scm
/git
/docs
/}
1628 if {$browser ne
{}} {
1629 .mbar.
help add
command -label {Online Documentation
} \
1630 -command [list
exec $browser $doc_url &]
1632 unset browser doc_path doc_url
1634 # -- Standard bindings
1636 bind .
<Destroy
> do_quit
1637 bind all
<$M1B-Key-q> do_quit
1638 bind all
<$M1B-Key-Q> do_quit
1639 bind all
<$M1B-Key-w> {destroy
[winfo toplevel
%W
]}
1640 bind all
<$M1B-Key-W> {destroy
[winfo toplevel
%W
]}
1642 set subcommand_args
{}
1644 puts stderr
"usage: $::argv0 $::subcommand $::subcommand_args"
1648 # -- Not a normal commit type invocation? Do that instead!
1650 switch
-- $subcommand {
1652 set subcommand_args
{rev?
}
1653 switch
[llength
$argv] {
1655 set current_branch
[git symbolic-ref HEAD
]
1656 regsub ^refs
/((heads|tags|remotes
)/)? \
1657 $current_branch {} current_branch
1660 set current_branch
[lindex
$argv 0]
1664 browser
::new
$current_branch
1668 set subcommand_args
{rev? path?
}
1673 if {$is_path ||
[file exists
$_prefix$a]} {
1674 if {$path ne
{}} usage
1677 } elseif
{$a eq
{--}} {
1679 if {$head ne
{}} usage
1684 } elseif
{$head eq
{}} {
1685 if {$head ne
{}} usage
1694 set current_branch
[git symbolic-ref HEAD
]
1695 regsub ^refs
/((heads|tags|remotes
)/)? \
1696 $current_branch {} current_branch
1698 set current_branch
$head
1701 if {$path eq
{}} usage
1702 blame
::new
$head $path
1707 if {[llength
$argv] != 0} {
1708 puts
-nonewline stderr
"usage: $argv0"
1709 if {$subcommand ne
{gui
} && [appname
] ne
"git-$subcommand"} {
1710 puts
-nonewline stderr
" $subcommand"
1715 # fall through to setup UI for commits
1718 puts stderr
"usage: $argv0 \[{blame|browser|citool}\]"
1729 -text {Current Branch
:} \
1733 -textvariable current_branch \
1736 pack .branch.l1
-side left
1737 pack .branch.cb
-side left
-fill x
1738 pack .branch
-side top
-fill x
1740 # -- Main Window Layout
1742 panedwindow .vpane
-orient vertical
1743 panedwindow .vpane.files
-orient horizontal
1744 .vpane add .vpane.files
-sticky nsew
-height 100 -width 200
1745 pack .vpane
-anchor n
-side top
-fill both
-expand 1
1747 # -- Index File List
1749 frame .vpane.files.index
-height 100 -width 200
1750 label .vpane.files.index.title
-text {Staged Changes
(Will Be Committed
)} \
1752 text
$ui_index -background white
-borderwidth 0 \
1753 -width 20 -height 10 \
1755 -cursor $cursor_ptr \
1756 -xscrollcommand {.vpane.files.index.sx
set} \
1757 -yscrollcommand {.vpane.files.index.sy
set} \
1759 scrollbar .vpane.files.index.sx
-orient h
-command [list
$ui_index xview
]
1760 scrollbar .vpane.files.index.sy
-orient v
-command [list
$ui_index yview
]
1761 pack .vpane.files.index.title
-side top
-fill x
1762 pack .vpane.files.index.sx
-side bottom
-fill x
1763 pack .vpane.files.index.sy
-side right
-fill y
1764 pack
$ui_index -side left
-fill both
-expand 1
1765 .vpane.files add .vpane.files.index
-sticky nsew
1767 # -- Working Directory File List
1769 frame .vpane.files.workdir
-height 100 -width 200
1770 label .vpane.files.workdir.title
-text {Unstaged Changes
(Will Not Be Committed
)} \
1772 text
$ui_workdir -background white
-borderwidth 0 \
1773 -width 20 -height 10 \
1775 -cursor $cursor_ptr \
1776 -xscrollcommand {.vpane.files.workdir.sx
set} \
1777 -yscrollcommand {.vpane.files.workdir.sy
set} \
1779 scrollbar .vpane.files.workdir.sx
-orient h
-command [list
$ui_workdir xview
]
1780 scrollbar .vpane.files.workdir.sy
-orient v
-command [list
$ui_workdir yview
]
1781 pack .vpane.files.workdir.title
-side top
-fill x
1782 pack .vpane.files.workdir.sx
-side bottom
-fill x
1783 pack .vpane.files.workdir.sy
-side right
-fill y
1784 pack
$ui_workdir -side left
-fill both
-expand 1
1785 .vpane.files add .vpane.files.workdir
-sticky nsew
1787 foreach i
[list
$ui_index $ui_workdir] {
1788 $i tag conf in_diff
-font font_uibold
1789 $i tag conf in_sel \
1790 -background [$i cget
-foreground] \
1791 -foreground [$i cget
-background]
1795 # -- Diff and Commit Area
1797 frame .vpane.lower
-height 300 -width 400
1798 frame .vpane.lower.commarea
1799 frame .vpane.lower.
diff -relief sunken
-borderwidth 1
1800 pack .vpane.lower.commarea
-side top
-fill x
1801 pack .vpane.lower.
diff -side bottom
-fill both
-expand 1
1802 .vpane add .vpane.lower
-sticky nsew
1804 # -- Commit Area Buttons
1806 frame .vpane.lower.commarea.buttons
1807 label .vpane.lower.commarea.buttons.l
-text {} \
1810 pack .vpane.lower.commarea.buttons.l
-side top
-fill x
1811 pack .vpane.lower.commarea.buttons
-side left
-fill y
1813 button .vpane.lower.commarea.buttons.rescan
-text {Rescan
} \
1815 pack .vpane.lower.commarea.buttons.rescan
-side top
-fill x
1816 lappend disable_on_lock \
1817 {.vpane.lower.commarea.buttons.rescan conf
-state}
1819 button .vpane.lower.commarea.buttons.incall
-text {Add Existing
} \
1821 pack .vpane.lower.commarea.buttons.incall
-side top
-fill x
1822 lappend disable_on_lock \
1823 {.vpane.lower.commarea.buttons.incall conf
-state}
1825 button .vpane.lower.commarea.buttons.signoff
-text {Sign Off
} \
1827 pack .vpane.lower.commarea.buttons.signoff
-side top
-fill x
1829 button .vpane.lower.commarea.buttons.commit
-text {Commit
} \
1831 pack .vpane.lower.commarea.buttons.commit
-side top
-fill x
1832 lappend disable_on_lock \
1833 {.vpane.lower.commarea.buttons.commit conf
-state}
1835 # -- Commit Message Buffer
1837 frame .vpane.lower.commarea.buffer
1838 frame .vpane.lower.commarea.buffer.header
1839 set ui_comm .vpane.lower.commarea.buffer.t
1840 set ui_coml .vpane.lower.commarea.buffer.header.l
1841 radiobutton .vpane.lower.commarea.buffer.header.new \
1842 -text {New Commit
} \
1843 -command do_select_commit_type \
1844 -variable selected_commit_type \
1846 lappend disable_on_lock \
1847 [list .vpane.lower.commarea.buffer.header.new conf
-state]
1848 radiobutton .vpane.lower.commarea.buffer.header.amend \
1849 -text {Amend Last Commit
} \
1850 -command do_select_commit_type \
1851 -variable selected_commit_type \
1853 lappend disable_on_lock \
1854 [list .vpane.lower.commarea.buffer.header.amend conf
-state]
1858 proc trace_commit_type
{varname args
} {
1859 global ui_coml commit_type
1860 switch
-glob -- $commit_type {
1861 initial
{set txt
{Initial Commit Message
:}}
1862 amend
{set txt
{Amended Commit Message
:}}
1863 amend-initial
{set txt
{Amended Initial Commit Message
:}}
1864 amend-merge
{set txt
{Amended Merge Commit Message
:}}
1865 merge
{set txt
{Merge Commit Message
:}}
1866 * {set txt
{Commit Message
:}}
1868 $ui_coml conf
-text $txt
1870 trace add variable commit_type
write trace_commit_type
1871 pack
$ui_coml -side left
-fill x
1872 pack .vpane.lower.commarea.buffer.header.amend
-side right
1873 pack .vpane.lower.commarea.buffer.header.new
-side right
1875 text
$ui_comm -background white
-borderwidth 1 \
1878 -autoseparators true \
1880 -width 75 -height 9 -wrap none \
1882 -yscrollcommand {.vpane.lower.commarea.buffer.sby
set}
1883 scrollbar .vpane.lower.commarea.buffer.sby \
1884 -command [list
$ui_comm yview
]
1885 pack .vpane.lower.commarea.buffer.header
-side top
-fill x
1886 pack .vpane.lower.commarea.buffer.sby
-side right
-fill y
1887 pack
$ui_comm -side left
-fill y
1888 pack .vpane.lower.commarea.buffer
-side left
-fill y
1890 # -- Commit Message Buffer Context Menu
1892 set ctxm .vpane.lower.commarea.buffer.ctxm
1893 menu
$ctxm -tearoff 0
1896 -command {tk_textCut
$ui_comm}
1899 -command {tk_textCopy
$ui_comm}
1902 -command {tk_textPaste
$ui_comm}
1905 -command {$ui_comm delete sel.first sel.last
}
1908 -label {Select All
} \
1909 -command {focus
$ui_comm;$ui_comm tag add sel
0.0 end
}
1913 $ui_comm tag add sel
0.0 end
1914 tk_textCopy
$ui_comm
1915 $ui_comm tag remove sel
0.0 end
1921 bind_button3
$ui_comm "tk_popup $ctxm %X %Y"
1925 proc trace_current_diff_path
{varname args
} {
1926 global current_diff_path diff_actions file_states
1927 if {$current_diff_path eq
{}} {
1933 set p
$current_diff_path
1934 set s
[mapdesc
[lindex
$file_states($p) 0] $p]
1936 set p
[escape_path
$p]
1940 .vpane.lower.
diff.header.status configure
-text $s
1941 .vpane.lower.
diff.header.
file configure
-text $f
1942 .vpane.lower.
diff.header.path configure
-text $p
1943 foreach w
$diff_actions {
1947 trace add variable current_diff_path
write trace_current_diff_path
1949 frame .vpane.lower.
diff.header
-background orange
1950 label .vpane.lower.
diff.header.status \
1951 -background orange \
1952 -width $max_status_desc \
1955 label .vpane.lower.
diff.header.
file \
1956 -background orange \
1959 label .vpane.lower.
diff.header.path \
1960 -background orange \
1963 pack .vpane.lower.
diff.header.status
-side left
1964 pack .vpane.lower.
diff.header.
file -side left
1965 pack .vpane.lower.
diff.header.path
-fill x
1966 set ctxm .vpane.lower.
diff.header.ctxm
1967 menu
$ctxm -tearoff 0
1975 -- $current_diff_path
1977 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
1978 bind_button3 .vpane.lower.
diff.header.path
"tk_popup $ctxm %X %Y"
1982 frame .vpane.lower.
diff.body
1983 set ui_diff .vpane.lower.
diff.body.t
1984 text
$ui_diff -background white
-borderwidth 0 \
1985 -width 80 -height 15 -wrap none \
1987 -xscrollcommand {.vpane.lower.
diff.body.sbx
set} \
1988 -yscrollcommand {.vpane.lower.
diff.body.sby
set} \
1990 scrollbar .vpane.lower.
diff.body.sbx
-orient horizontal \
1991 -command [list
$ui_diff xview
]
1992 scrollbar .vpane.lower.
diff.body.sby
-orient vertical \
1993 -command [list
$ui_diff yview
]
1994 pack .vpane.lower.
diff.body.sbx
-side bottom
-fill x
1995 pack .vpane.lower.
diff.body.sby
-side right
-fill y
1996 pack
$ui_diff -side left
-fill both
-expand 1
1997 pack .vpane.lower.
diff.header
-side top
-fill x
1998 pack .vpane.lower.
diff.body
-side bottom
-fill both
-expand 1
2000 $ui_diff tag conf d_cr
-elide true
2001 $ui_diff tag conf d_@
-foreground blue
-font font_diffbold
2002 $ui_diff tag conf d_
+ -foreground {#00a000}
2003 $ui_diff tag conf d_-
-foreground red
2005 $ui_diff tag conf d_
++ -foreground {#00a000}
2006 $ui_diff tag conf d_--
-foreground red
2007 $ui_diff tag conf d_
+s \
2008 -foreground {#00a000} \
2009 -background {#e2effa}
2010 $ui_diff tag conf d_-s \
2012 -background {#e2effa}
2013 $ui_diff tag conf d_s
+ \
2014 -foreground {#00a000} \
2016 $ui_diff tag conf d_s- \
2020 $ui_diff tag conf d
<<<<<<< \
2021 -foreground orange \
2023 $ui_diff tag conf d
======= \
2024 -foreground orange \
2026 $ui_diff tag conf d
>>>>>>> \
2027 -foreground orange \
2030 $ui_diff tag raise sel
2032 # -- Diff Body Context Menu
2034 set ctxm .vpane.lower.
diff.body.ctxm
2035 menu
$ctxm -tearoff 0
2038 -command reshow_diff
2039 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2042 -command {tk_textCopy
$ui_diff}
2043 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2045 -label {Select All
} \
2046 -command {focus
$ui_diff;$ui_diff tag add sel
0.0 end
}
2047 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2051 $ui_diff tag add sel
0.0 end
2052 tk_textCopy
$ui_diff
2053 $ui_diff tag remove sel
0.0 end
2055 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2058 -label {Apply
/Reverse Hunk
} \
2059 -command {apply_hunk
$cursorX $cursorY}
2060 set ui_diff_applyhunk
[$ctxm index last
]
2061 lappend diff_actions
[list
$ctxm entryconf
$ui_diff_applyhunk -state]
2064 -label {Decrease Font Size
} \
2065 -command {incr_font_size font_diff
-1}
2066 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2068 -label {Increase Font Size
} \
2069 -command {incr_font_size font_diff
1}
2070 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2073 -label {Show Less Context
} \
2074 -command {if {$repo_config(gui.diffcontext
) >= 2} {
2075 incr repo_config
(gui.diffcontext
) -1
2078 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2080 -label {Show More Context
} \
2082 incr repo_config
(gui.diffcontext
)
2085 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2087 $ctxm add
command -label {Options...
} \
2089 bind_button3
$ui_diff "
2092 if {\$ui_index eq \$current_diff_side} {
2093 $ctxm entryconf $ui_diff_applyhunk -label {Unstage Hunk From Commit}
2095 $ctxm entryconf $ui_diff_applyhunk -label {Stage Hunk For Commit}
2097 tk_popup $ctxm %X %Y
2099 unset ui_diff_applyhunk
2103 label .status
-textvariable ui_status_value \
2108 pack .status
-anchor w
-side bottom
-fill x
2113 set gm
$repo_config(gui.geometry
)
2114 wm geometry .
[lindex
$gm 0]
2115 .vpane sash place
0 \
2116 [lindex
[.vpane sash coord
0] 0] \
2118 .vpane.files sash place
0 \
2120 [lindex
[.vpane.files sash coord
0] 1]
2126 bind $ui_comm <$M1B-Key-Return> {do_commit
;break}
2127 bind $ui_comm <$M1B-Key-i> {do_add_all
;break}
2128 bind $ui_comm <$M1B-Key-I> {do_add_all
;break}
2129 bind $ui_comm <$M1B-Key-x> {tk_textCut
%W
;break}
2130 bind $ui_comm <$M1B-Key-X> {tk_textCut
%W
;break}
2131 bind $ui_comm <$M1B-Key-c> {tk_textCopy
%W
;break}
2132 bind $ui_comm <$M1B-Key-C> {tk_textCopy
%W
;break}
2133 bind $ui_comm <$M1B-Key-v> {tk_textPaste
%W
; %W see insert
; break}
2134 bind $ui_comm <$M1B-Key-V> {tk_textPaste
%W
; %W see insert
; break}
2135 bind $ui_comm <$M1B-Key-a> {%W tag add sel
0.0 end
;break}
2136 bind $ui_comm <$M1B-Key-A> {%W tag add sel
0.0 end
;break}
2138 bind $ui_diff <$M1B-Key-x> {tk_textCopy
%W
;break}
2139 bind $ui_diff <$M1B-Key-X> {tk_textCopy
%W
;break}
2140 bind $ui_diff <$M1B-Key-c> {tk_textCopy
%W
;break}
2141 bind $ui_diff <$M1B-Key-C> {tk_textCopy
%W
;break}
2142 bind $ui_diff <$M1B-Key-v> {break}
2143 bind $ui_diff <$M1B-Key-V> {break}
2144 bind $ui_diff <$M1B-Key-a> {%W tag add sel
0.0 end
;break}
2145 bind $ui_diff <$M1B-Key-A> {%W tag add sel
0.0 end
;break}
2146 bind $ui_diff <Key-Up
> {catch
{%W yview scroll
-1 units
};break}
2147 bind $ui_diff <Key-Down
> {catch
{%W yview scroll
1 units
};break}
2148 bind $ui_diff <Key-Left
> {catch
{%W xview scroll
-1 units
};break}
2149 bind $ui_diff <Key-Right
> {catch
{%W xview scroll
1 units
};break}
2150 bind $ui_diff <Key-k
> {catch
{%W yview scroll
-1 units
};break}
2151 bind $ui_diff <Key-j
> {catch
{%W yview scroll
1 units
};break}
2152 bind $ui_diff <Key-h
> {catch
{%W xview scroll
-1 units
};break}
2153 bind $ui_diff <Key-l
> {catch
{%W xview scroll
1 units
};break}
2154 bind $ui_diff <Control-Key-b
> {catch
{%W yview scroll
-1 pages
};break}
2155 bind $ui_diff <Control-Key-f
> {catch
{%W yview scroll
1 pages
};break}
2156 bind $ui_diff <Button-1
> {focus
%W
}
2158 if {[is_enabled branch
]} {
2159 bind .
<$M1B-Key-n> do_create_branch
2160 bind .
<$M1B-Key-N> do_create_branch
2163 bind all
<Key-F5
> do_rescan
2164 bind all
<$M1B-Key-r> do_rescan
2165 bind all
<$M1B-Key-R> do_rescan
2166 bind .
<$M1B-Key-s> do_signoff
2167 bind .
<$M1B-Key-S> do_signoff
2168 bind .
<$M1B-Key-i> do_add_all
2169 bind .
<$M1B-Key-I> do_add_all
2170 bind .
<$M1B-Key-Return> do_commit
2171 foreach i
[list
$ui_index $ui_workdir] {
2172 bind $i <Button-1
> "toggle_or_diff $i %x %y; break"
2173 bind $i <$M1B-Button-1> "add_one_to_selection $i %x %y; break"
2174 bind $i <Shift-Button-1
> "add_range_to_selection $i %x %y; break"
2178 set file_lists
($ui_index) [list
]
2179 set file_lists
($ui_workdir) [list
]
2181 wm title .
"[appname] ([reponame]) [file normalize [file dirname [gitdir]]]"
2182 focus
-force $ui_comm
2184 # -- Warn the user about environmental problems. Cygwin's Tcl
2185 # does *not* pass its env array onto any processes it spawns.
2186 # This means that git processes get none of our environment.
2191 set msg
"Possible environment issues exist.
2193 The following environment variables are probably
2194 going to be ignored by any Git subprocess run
2198 foreach name
[array names env
] {
2199 switch
-regexp -- $name {
2200 {^GIT_INDEX_FILE$
} -
2201 {^GIT_OBJECT_DIRECTORY$
} -
2202 {^GIT_ALTERNATE_OBJECT_DIRECTORIES$
} -
2204 {^GIT_EXTERNAL_DIFF$
} -
2208 {^GIT_CONFIG_LOCAL$
} -
2209 {^GIT_
(AUTHOR|COMMITTER
)_DATE$
} {
2210 append msg
" - $name\n"
2213 {^GIT_
(AUTHOR|COMMITTER
)_
(NAME|EMAIL
)$
} {
2214 append msg
" - $name\n"
2216 set suggest_user
$name
2220 if {$ignored_env > 0} {
2222 This is due to a known issue with the
2223 Tcl binary distributed by Cygwin."
2225 if {$suggest_user ne
{}} {
2228 A good replacement for $suggest_user
2229 is placing values for the user.name and
2230 user.email settings into your personal
2236 unset ignored_env msg suggest_user name
2239 # -- Only initialize complex UI if we are going to stay running.
2241 if {[is_enabled transport
]} {
2245 populate_branch_menu
2250 # -- Only suggest a gc run if we are going to stay running.
2252 if {[is_enabled multicommit
]} {
2253 set object_limit
2000
2254 if {[is_Windows
]} {set object_limit
200}
2255 regexp
{^
([0-9]+) objects
,} [git count-objects
] _junk objects_current
2256 if {$objects_current >= $object_limit} {
2258 "This repository currently has $objects_current loose objects.
2260 To maintain optimal performance it is strongly recommended that you compress the database when more than $object_limit loose objects exist.
2262 Compress the database now?"] eq
yes} {
2266 unset object_limit _junk objects_current
2269 lock_index begin-read