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 proc current-branch
{} {
267 set fd
[open
[gitdir HEAD
] r
]
268 if {[gets
$fd ref
] <16
269 ||
![regsub
{^ref
: refs
/heads
/} $ref {} ref
]} {
276 auto_load tk_optionMenu
277 rename tk_optionMenu real__tkOptionMenu
278 proc tk_optionMenu
{w varName args
} {
279 set m
[eval real__tkOptionMenu
$w $varName $args]
280 $m configure
-font font_ui
281 $w configure
-font font_ui
285 ######################################################################
289 if {{--version} eq
$argv ||
{version
} eq
$argv} {
290 puts
"git-gui version $appvers"
297 if {[catch
{set v
[git
--version]} err
]} {
298 catch
{wm withdraw .
}
299 error_popup
"Cannot determine Git version:
303 [appname] requires Git $req_maj.$req_min or later."
306 if {[regexp
{^git version
(\d
+)\.
(\d
+)} $v _junk act_maj act_min
]} {
307 if {$act_maj < $req_maj
308 ||
($act_maj == $req_maj && $act_min < $req_min)} {
309 catch
{wm withdraw .
}
310 error_popup
"[appname] requires Git $req_maj.$req_min or later.
316 catch
{wm withdraw .
}
317 error_popup
"Cannot parse Git version string:\n\n$v"
320 unset -nocomplain v _junk act_maj act_min req_maj req_min
322 ######################################################################
327 set _gitdir
$env(GIT_DIR
)
331 set _gitdir
[git rev-parse
--git-dir]
332 set _prefix
[git rev-parse
--show-prefix]
334 catch
{wm withdraw .
}
335 error_popup
"Cannot find the git directory:\n\n$err"
338 if {![file isdirectory
$_gitdir] && [is_Cygwin
]} {
339 catch
{set _gitdir
[exec cygpath
--unix $_gitdir]}
341 if {![file isdirectory
$_gitdir]} {
342 catch
{wm withdraw .
}
343 error_popup
"Git directory not found:\n\n$_gitdir"
346 if {[lindex
[file split $_gitdir] end
] ne
{.git
}} {
347 catch
{wm withdraw .
}
348 error_popup
"Cannot use funny .git directory:\n\n$_gitdir"
351 if {[catch
{cd [file dirname $_gitdir]} err
]} {
352 catch
{wm withdraw .
}
353 error_popup
"No working directory [file dirname $_gitdir]:\n\n$err"
356 set _reponame
[lindex
[file split \
357 [file normalize
[file dirname $_gitdir]]] \
360 ######################################################################
364 set current_diff_path
{}
365 set current_diff_side
{}
366 set diff_actions
[list
]
367 set ui_status_value
{Initializing...
}
371 set MERGE_HEAD
[list
]
374 set current_branch
{}
375 set current_diff_path
{}
376 set selected_commit_type new
378 ######################################################################
386 set disable_on_lock
[list
]
387 set index_lock_type none
389 proc lock_index
{type} {
390 global index_lock_type disable_on_lock
392 if {$index_lock_type eq
{none
}} {
393 set index_lock_type
$type
394 foreach w
$disable_on_lock {
395 uplevel
#0 $w disabled
398 } elseif
{$index_lock_type eq
"begin-$type"} {
399 set index_lock_type
$type
405 proc unlock_index
{} {
406 global index_lock_type disable_on_lock
408 set index_lock_type none
409 foreach w
$disable_on_lock {
414 ######################################################################
418 proc repository_state
{ctvar hdvar mhvar
} {
419 global current_branch
420 upvar
$ctvar ct
$hdvar hd
$mhvar mh
424 set current_branch
[current-branch
]
425 if {[catch
{set hd
[git rev-parse
--verify HEAD
]}]} {
431 set merge_head
[gitdir MERGE_HEAD
]
432 if {[file exists
$merge_head]} {
434 set fd_mh
[open
$merge_head r
]
435 while {[gets
$fd_mh line
] >= 0} {
446 global PARENT empty_tree
448 set p
[lindex
$PARENT 0]
452 if {$empty_tree eq
{}} {
453 set empty_tree
[git mktree
<< {}]
458 proc rescan
{after
{honor_trustmtime
1}} {
459 global HEAD PARENT MERGE_HEAD commit_type
460 global ui_index ui_workdir ui_status_value ui_comm
461 global rescan_active file_states
464 if {$rescan_active > 0 ||
![lock_index
read]} return
466 repository_state newType newHEAD newMERGE_HEAD
467 if {[string match amend
* $commit_type]
468 && $newType eq
{normal
}
469 && $newHEAD eq
$HEAD} {
473 set MERGE_HEAD
$newMERGE_HEAD
474 set commit_type
$newType
477 array
unset file_states
479 if {![$ui_comm edit modified
]
480 ||
[string trim
[$ui_comm get
0.0 end
]] eq
{}} {
481 if {[load_message GITGUI_MSG
]} {
482 } elseif
{[load_message MERGE_MSG
]} {
483 } elseif
{[load_message SQUASH_MSG
]} {
486 $ui_comm edit modified false
489 if {[is_enabled branch
]} {
494 if {$honor_trustmtime && $repo_config(gui.trustmtime
) eq
{true
}} {
495 rescan_stage2
{} $after
498 set ui_status_value
{Refreshing
file status...
}
499 set cmd
[list git update-index
]
501 lappend cmd
--unmerged
502 lappend cmd
--ignore-missing
503 lappend cmd
--refresh
504 set fd_rf
[open
"| $cmd" r
]
505 fconfigure
$fd_rf -blocking 0 -translation binary
506 fileevent
$fd_rf readable \
507 [list rescan_stage2
$fd_rf $after]
511 proc rescan_stage2
{fd after
} {
512 global ui_status_value
513 global rescan_active buf_rdi buf_rdf buf_rlo
517 if {![eof
$fd]} return
521 set ls_others
[list | git ls-files
--others -z \
522 --exclude-per-directory=.gitignore
]
523 set info_exclude
[gitdir info exclude
]
524 if {[file readable
$info_exclude]} {
525 lappend ls_others
"--exclude-from=$info_exclude"
533 set ui_status_value
{Scanning
for modified files ...
}
534 set fd_di
[open
"| git diff-index --cached -z [PARENT]" r
]
535 set fd_df
[open
"| git diff-files -z" r
]
536 set fd_lo
[open
$ls_others r
]
538 fconfigure
$fd_di -blocking 0 -translation binary
-encoding binary
539 fconfigure
$fd_df -blocking 0 -translation binary
-encoding binary
540 fconfigure
$fd_lo -blocking 0 -translation binary
-encoding binary
541 fileevent
$fd_di readable
[list read_diff_index
$fd_di $after]
542 fileevent
$fd_df readable
[list read_diff_files
$fd_df $after]
543 fileevent
$fd_lo readable
[list read_ls_others
$fd_lo $after]
546 proc load_message
{file} {
550 if {[file isfile
$f]} {
551 if {[catch
{set fd
[open
$f r
]}]} {
554 set content
[string trim
[read $fd]]
556 regsub
-all -line {[ \r\t]+$
} $content {} content
557 $ui_comm delete
0.0 end
558 $ui_comm insert end
$content
564 proc read_diff_index
{fd after
} {
567 append buf_rdi
[read $fd]
569 set n
[string length
$buf_rdi]
571 set z1
[string first
"\0" $buf_rdi $c]
574 set z2
[string first
"\0" $buf_rdi $z1]
578 set i
[split [string range
$buf_rdi $c [expr {$z1 - 2}]] { }]
579 set p
[string range
$buf_rdi $z1 [expr {$z2 - 1}]]
581 [encoding convertfrom
$p] \
583 [list
[lindex
$i 0] [lindex
$i 2]] \
589 set buf_rdi
[string range
$buf_rdi $c end
]
594 rescan_done
$fd buf_rdi
$after
597 proc read_diff_files
{fd after
} {
600 append buf_rdf
[read $fd]
602 set n
[string length
$buf_rdf]
604 set z1
[string first
"\0" $buf_rdf $c]
607 set z2
[string first
"\0" $buf_rdf $z1]
611 set i
[split [string range
$buf_rdf $c [expr {$z1 - 2}]] { }]
612 set p
[string range
$buf_rdf $z1 [expr {$z2 - 1}]]
614 [encoding convertfrom
$p] \
617 [list
[lindex
$i 0] [lindex
$i 2]]
622 set buf_rdf
[string range
$buf_rdf $c end
]
627 rescan_done
$fd buf_rdf
$after
630 proc read_ls_others
{fd after
} {
633 append buf_rlo
[read $fd]
634 set pck
[split $buf_rlo "\0"]
635 set buf_rlo
[lindex
$pck end
]
636 foreach p
[lrange
$pck 0 end-1
] {
637 merge_state
[encoding convertfrom
$p] ?O
639 rescan_done
$fd buf_rlo
$after
642 proc rescan_done
{fd buf after
} {
643 global rescan_active current_diff_path
644 global file_states repo_config
647 if {![eof
$fd]} return
650 if {[incr rescan_active
-1] > 0} return
655 if {$current_diff_path ne
{}} reshow_diff
659 proc prune_selection
{} {
660 global file_states selected_paths
662 foreach path
[array names selected_paths
] {
663 if {[catch
{set still_here
$file_states($path)}]} {
664 unset selected_paths
($path)
669 ######################################################################
673 proc mapicon
{w state path
} {
676 if {[catch
{set r
$all_icons($state$w)}]} {
677 puts
"error: no icon for $w state={$state} $path"
683 proc mapdesc
{state path
} {
686 if {[catch
{set r
$all_descs($state)}]} {
687 puts
"error: no desc for state={$state} $path"
693 proc escape_path
{path
} {
694 regsub
-all {\\} $path "\\\\" path
695 regsub
-all "\n" $path "\\n" path
699 proc short_path
{path
} {
700 return [escape_path
[lindex
[file split $path] end
]]
704 set null_sha1
[string repeat
0 40]
706 proc merge_state
{path new_state
{head_info
{}} {index_info
{}}} {
707 global file_states next_icon_id null_sha1
709 set s0
[string index
$new_state 0]
710 set s1
[string index
$new_state 1]
712 if {[catch
{set info
$file_states($path)}]} {
714 set icon n
[incr next_icon_id
]
716 set state
[lindex
$info 0]
717 set icon
[lindex
$info 1]
718 if {$head_info eq
{}} {set head_info
[lindex
$info 2]}
719 if {$index_info eq
{}} {set index_info
[lindex
$info 3]}
722 if {$s0 eq
{?
}} {set s0
[string index
$state 0]} \
723 elseif
{$s0 eq
{_
}} {set s0 _
}
725 if {$s1 eq
{?
}} {set s1
[string index
$state 1]} \
726 elseif
{$s1 eq
{_
}} {set s1 _
}
728 if {$s0 eq
{A
} && $s1 eq
{_
} && $head_info eq
{}} {
729 set head_info
[list
0 $null_sha1]
730 } elseif
{$s0 ne
{_
} && [string index
$state 0] eq
{_
}
731 && $head_info eq
{}} {
732 set head_info
$index_info
735 set file_states
($path) [list
$s0$s1 $icon \
736 $head_info $index_info \
741 proc display_file_helper
{w path icon_name old_m new_m
} {
745 set lno
[lsearch
-sorted -exact $file_lists($w) $path]
747 set file_lists
($w) [lreplace
$file_lists($w) $lno $lno]
749 $w conf
-state normal
750 $w delete
$lno.0 [expr {$lno + 1}].0
751 $w conf
-state disabled
753 } elseif
{$old_m eq
{_
} && $new_m ne
{_
}} {
754 lappend file_lists
($w) $path
755 set file_lists
($w) [lsort
-unique $file_lists($w)]
756 set lno
[lsearch
-sorted -exact $file_lists($w) $path]
758 $w conf
-state normal
759 $w image create
$lno.0 \
760 -align center
-padx 5 -pady 1 \
762 -image [mapicon
$w $new_m $path]
763 $w insert
$lno.1 "[escape_path $path]\n"
764 $w conf
-state disabled
765 } elseif
{$old_m ne
$new_m} {
766 $w conf
-state normal
767 $w image conf
$icon_name -image [mapicon
$w $new_m $path]
768 $w conf
-state disabled
772 proc display_file
{path state
} {
773 global file_states selected_paths
774 global ui_index ui_workdir
776 set old_m
[merge_state
$path $state]
777 set s
$file_states($path)
778 set new_m
[lindex
$s 0]
779 set icon_name
[lindex
$s 1]
781 set o
[string index
$old_m 0]
782 set n
[string index
$new_m 0]
789 display_file_helper
$ui_index $path $icon_name $o $n
791 if {[string index
$old_m 0] eq
{U
}} {
794 set o
[string index
$old_m 1]
796 if {[string index
$new_m 0] eq
{U
}} {
799 set n
[string index
$new_m 1]
801 display_file_helper
$ui_workdir $path $icon_name $o $n
803 if {$new_m eq
{__
}} {
804 unset file_states
($path)
805 catch
{unset selected_paths
($path)}
809 proc display_all_files_helper
{w path icon_name m
} {
812 lappend file_lists
($w) $path
813 set lno
[expr {[lindex
[split [$w index end
] .
] 0] - 1}]
814 $w image create end \
815 -align center
-padx 5 -pady 1 \
817 -image [mapicon
$w $m $path]
818 $w insert end
"[escape_path $path]\n"
821 proc display_all_files
{} {
822 global ui_index ui_workdir
823 global file_states file_lists
826 $ui_index conf
-state normal
827 $ui_workdir conf
-state normal
829 $ui_index delete
0.0 end
830 $ui_workdir delete
0.0 end
833 set file_lists
($ui_index) [list
]
834 set file_lists
($ui_workdir) [list
]
836 foreach path
[lsort
[array names file_states
]] {
837 set s
$file_states($path)
839 set icon_name
[lindex
$s 1]
841 set s
[string index
$m 0]
842 if {$s ne
{U
} && $s ne
{_
}} {
843 display_all_files_helper
$ui_index $path \
847 if {[string index
$m 0] eq
{U
}} {
850 set s
[string index
$m 1]
853 display_all_files_helper
$ui_workdir $path \
858 $ui_index conf
-state disabled
859 $ui_workdir conf
-state disabled
862 ######################################################################
867 #define mask_width 14
868 #define mask_height 15
869 static unsigned char mask_bits
[] = {
870 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
871 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
872 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f};
875 image create bitmap file_plain
-background white
-foreground black
-data {
876 #define plain_width 14
877 #define plain_height 15
878 static unsigned char plain_bits
[] = {
879 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
880 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10,
881 0x02, 0x10, 0x02, 0x10, 0xfe, 0x1f};
882 } -maskdata $filemask
884 image create bitmap file_mod
-background white
-foreground blue
-data {
886 #define mod_height 15
887 static unsigned char mod_bits
[] = {
888 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
889 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
890 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
891 } -maskdata $filemask
893 image create bitmap file_fulltick
-background white
-foreground "#007000" -data {
894 #define file_fulltick_width 14
895 #define file_fulltick_height 15
896 static unsigned char file_fulltick_bits
[] = {
897 0xfe, 0x01, 0x02, 0x1a, 0x02, 0x0c, 0x02, 0x0c, 0x02, 0x16, 0x02, 0x16,
898 0x02, 0x13, 0x00, 0x13, 0x86, 0x11, 0x8c, 0x11, 0xd8, 0x10, 0xf2, 0x10,
899 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
900 } -maskdata $filemask
902 image create bitmap file_parttick
-background white
-foreground "#005050" -data {
903 #define parttick_width 14
904 #define parttick_height 15
905 static unsigned char parttick_bits
[] = {
906 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
907 0x7a, 0x14, 0x02, 0x16, 0x02, 0x13, 0x8a, 0x11, 0xda, 0x10, 0x72, 0x10,
908 0x22, 0x10, 0x02, 0x10, 0xfe, 0x1f};
909 } -maskdata $filemask
911 image create bitmap file_question
-background white
-foreground black
-data {
912 #define file_question_width 14
913 #define file_question_height 15
914 static unsigned char file_question_bits
[] = {
915 0xfe, 0x01, 0x02, 0x02, 0xe2, 0x04, 0xf2, 0x09, 0x1a, 0x1b, 0x0a, 0x13,
916 0x82, 0x11, 0xc2, 0x10, 0x62, 0x10, 0x62, 0x10, 0x02, 0x10, 0x62, 0x10,
917 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
918 } -maskdata $filemask
920 image create bitmap file_removed
-background white
-foreground red
-data {
921 #define file_removed_width 14
922 #define file_removed_height 15
923 static unsigned char file_removed_bits
[] = {
924 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
925 0x1a, 0x16, 0x32, 0x13, 0xe2, 0x11, 0xc2, 0x10, 0xe2, 0x11, 0x32, 0x13,
926 0x1a, 0x16, 0x02, 0x10, 0xfe, 0x1f};
927 } -maskdata $filemask
929 image create bitmap file_merge
-background white
-foreground blue
-data {
930 #define file_merge_width 14
931 #define file_merge_height 15
932 static unsigned char file_merge_bits
[] = {
933 0xfe, 0x01, 0x02, 0x03, 0x62, 0x05, 0x62, 0x09, 0x62, 0x1f, 0x62, 0x10,
934 0xfa, 0x11, 0xf2, 0x10, 0x62, 0x10, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
935 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
936 } -maskdata $filemask
939 #define file_width 18
940 #define file_height 18
941 static unsigned char file_bits
[] = {
942 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0x00,
943 0x0c, 0x03, 0x00, 0x04, 0xfe, 0x00, 0x06, 0x80, 0x00, 0xff, 0x9f, 0x00,
944 0x03, 0x98, 0x00, 0x02, 0x90, 0x00, 0x06, 0xb0, 0x00, 0x04, 0xa0, 0x00,
945 0x0c, 0xe0, 0x00, 0x08, 0xc0, 0x00, 0xf8, 0xff, 0x00, 0x00, 0x00, 0x00,
946 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
948 image create bitmap file_dir
-background white
-foreground blue \
949 -data $file_dir_data -maskdata $file_dir_data
952 set file_uplevel_data
{
955 static unsigned char up_bits
[] = {
956 0x80, 0x00, 0xc0, 0x01, 0xe0, 0x03, 0xf0, 0x07, 0xf8, 0x0f, 0xfc, 0x1f,
957 0xfe, 0x3f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
958 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00};
960 image create bitmap file_uplevel
-background white
-foreground red \
961 -data $file_uplevel_data -maskdata $file_uplevel_data
962 unset file_uplevel_data
964 set ui_index .vpane.files.index.list
965 set ui_workdir .vpane.files.workdir.list
967 set all_icons
(_
$ui_index) file_plain
968 set all_icons
(A
$ui_index) file_fulltick
969 set all_icons
(M
$ui_index) file_fulltick
970 set all_icons
(D
$ui_index) file_removed
971 set all_icons
(U
$ui_index) file_merge
973 set all_icons
(_
$ui_workdir) file_plain
974 set all_icons
(M
$ui_workdir) file_mod
975 set all_icons
(D
$ui_workdir) file_question
976 set all_icons
(U
$ui_workdir) file_merge
977 set all_icons
(O
$ui_workdir) file_plain
979 set max_status_desc
0
983 {_M
"Modified, not staged"}
984 {M_
"Staged for commit"}
985 {MM
"Portions staged for commit"}
986 {MD
"Staged for commit, missing"}
988 {_O
"Untracked, not staged"}
989 {A_
"Staged for commit"}
990 {AM
"Portions staged for commit"}
991 {AD
"Staged for commit, missing"}
994 {D_
"Staged for removal"}
995 {DO
"Staged for removal, still present"}
997 {U_
"Requires merge resolution"}
998 {UU
"Requires merge resolution"}
999 {UM
"Requires merge resolution"}
1000 {UD
"Requires merge resolution"}
1002 if {$max_status_desc < [string length
[lindex
$i 1]]} {
1003 set max_status_desc
[string length
[lindex
$i 1]]
1005 set all_descs
([lindex
$i 0]) [lindex
$i 1]
1009 ######################################################################
1013 proc bind_button3
{w cmd
} {
1014 bind $w <Any-Button-3
> $cmd
1016 bind $w <Control-Button-1
> $cmd
1020 proc scrollbar2many
{list mode args
} {
1021 foreach w
$list {eval $w $mode $args}
1024 proc many2scrollbar
{list mode sb top bottom
} {
1025 $sb set $top $bottom
1026 foreach w
$list {$w $mode moveto
$top}
1029 proc incr_font_size
{font
{amt
1}} {
1030 set sz
[font configure
$font -size]
1032 font configure
$font -size $sz
1033 font configure
${font}bold
-size $sz
1036 ######################################################################
1040 set starting_gitk_msg
{Starting gitk... please
wait...
}
1042 proc do_gitk
{revs
} {
1043 global env ui_status_value starting_gitk_msg
1045 # -- Always start gitk through whatever we were loaded with. This
1046 # lets us bypass using shell process on Windows systems.
1048 set cmd
[list
[info nameofexecutable
]]
1049 lappend cmd
[gitexec gitk
]
1055 if {[catch
{eval exec $cmd &} err
]} {
1056 error_popup
"Failed to start gitk:\n\n$err"
1058 set ui_status_value
$starting_gitk_msg
1060 if {$ui_status_value eq
$starting_gitk_msg} {
1061 set ui_status_value
{Ready.
}
1070 global ui_comm is_quitting repo_config commit_type
1072 if {$is_quitting} return
1075 if {[winfo exists
$ui_comm]} {
1076 # -- Stash our current commit buffer.
1078 set save
[gitdir GITGUI_MSG
]
1079 set msg
[string trim
[$ui_comm get
0.0 end
]]
1080 regsub
-all -line {[ \r\t]+$
} $msg {} msg
1081 if {(![string match amend
* $commit_type]
1082 ||
[$ui_comm edit modified
])
1085 set fd
[open
$save w
]
1086 puts
-nonewline $fd $msg
1090 catch
{file delete
$save}
1093 # -- Stash our current window geometry into this repository.
1095 set cfg_geometry
[list
]
1096 lappend cfg_geometry
[wm geometry .
]
1097 lappend cfg_geometry
[lindex
[.vpane sash coord
0] 1]
1098 lappend cfg_geometry
[lindex
[.vpane.files sash coord
0] 0]
1099 if {[catch
{set rc_geometry
$repo_config(gui.geometry
)}]} {
1102 if {$cfg_geometry ne
$rc_geometry} {
1103 catch
{git config gui.geometry
$cfg_geometry}
1111 rescan
{set ui_status_value
{Ready.
}}
1118 proc toggle_or_diff
{w x y
} {
1119 global file_states file_lists current_diff_path ui_index ui_workdir
1120 global last_clicked selected_paths
1122 set pos
[split [$w index @
$x,$y] .
]
1123 set lno
[lindex
$pos 0]
1124 set col [lindex
$pos 1]
1125 set path
[lindex
$file_lists($w) [expr {$lno - 1}]]
1131 set last_clicked
[list
$w $lno]
1132 array
unset selected_paths
1133 $ui_index tag remove in_sel
0.0 end
1134 $ui_workdir tag remove in_sel
0.0 end
1137 if {$current_diff_path eq
$path} {
1138 set after
{reshow_diff
;}
1142 if {$w eq
$ui_index} {
1144 "Unstaging [short_path $path] from commit" \
1146 [concat
$after {set ui_status_value
{Ready.
}}]
1147 } elseif
{$w eq
$ui_workdir} {
1149 "Adding [short_path $path]" \
1151 [concat
$after {set ui_status_value
{Ready.
}}]
1154 show_diff
$path $w $lno
1158 proc add_one_to_selection
{w x y
} {
1159 global file_lists last_clicked selected_paths
1161 set lno
[lindex
[split [$w index @
$x,$y] .
] 0]
1162 set path
[lindex
$file_lists($w) [expr {$lno - 1}]]
1168 if {$last_clicked ne
{}
1169 && [lindex
$last_clicked 0] ne
$w} {
1170 array
unset selected_paths
1171 [lindex
$last_clicked 0] tag remove in_sel
0.0 end
1174 set last_clicked
[list
$w $lno]
1175 if {[catch
{set in_sel
$selected_paths($path)}]} {
1179 unset selected_paths
($path)
1180 $w tag remove in_sel
$lno.0 [expr {$lno + 1}].0
1182 set selected_paths
($path) 1
1183 $w tag add in_sel
$lno.0 [expr {$lno + 1}].0
1187 proc add_range_to_selection
{w x y
} {
1188 global file_lists last_clicked selected_paths
1190 if {[lindex
$last_clicked 0] ne
$w} {
1191 toggle_or_diff
$w $x $y
1195 set lno
[lindex
[split [$w index @
$x,$y] .
] 0]
1196 set lc
[lindex
$last_clicked 1]
1205 foreach path
[lrange
$file_lists($w) \
1206 [expr {$begin - 1}] \
1207 [expr {$end - 1}]] {
1208 set selected_paths
($path) 1
1210 $w tag add in_sel
$begin.0 [expr {$end + 1}].0
1213 ######################################################################
1217 set cursor_ptr arrow
1218 font create font_diff
-family Courier
-size 10
1222 eval font configure font_ui
[font actual
[.dummy cget
-font]]
1226 font create font_uibold
1227 font create font_diffbold
1229 foreach class
{Button Checkbutton Entry Label
1230 Labelframe Listbox Menu Message
1232 option add
*$class.font font_ui
1236 if {[is_Windows
] ||
[is_MacOSX
]} {
1237 option add
*Menu.tearOff
0
1248 proc apply_config
{} {
1249 global repo_config font_descs
1251 foreach option
$font_descs {
1252 set name
[lindex
$option 0]
1253 set font
[lindex
$option 1]
1255 foreach
{cn cv
} $repo_config(gui.
$name) {
1256 font configure
$font $cn $cv
1259 error_popup
"Invalid font specified in gui.$name:\n\n$err"
1261 foreach
{cn cv
} [font configure
$font] {
1262 font configure
${font}bold
$cn $cv
1264 font configure
${font}bold
-weight bold
1268 set default_config
(merge.diffstat
) true
1269 set default_config
(merge.summary
) false
1270 set default_config
(merge.verbosity
) 2
1271 set default_config
(user.name
) {}
1272 set default_config
(user.email
) {}
1274 set default_config
(gui.pruneduringfetch
) false
1275 set default_config
(gui.trustmtime
) false
1276 set default_config
(gui.diffcontext
) 5
1277 set default_config
(gui.newbranchtemplate
) {}
1278 set default_config
(gui.fontui
) [font configure font_ui
]
1279 set default_config
(gui.fontdiff
) [font configure font_diff
]
1281 {fontui font_ui
{Main Font
}}
1282 {fontdiff font_diff
{Diff
/Console Font
}}
1287 ######################################################################
1289 ## feature option selection
1291 if {[regexp
{^git-
(.
+)$
} [appname
] _junk subcommand
]} {
1296 if {$subcommand eq
{gui.sh
}} {
1299 if {$subcommand eq
{gui
} && [llength
$argv] > 0} {
1300 set subcommand
[lindex
$argv 0]
1301 set argv
[lrange
$argv 1 end
]
1304 enable_option multicommit
1305 enable_option branch
1306 enable_option transport
1308 switch
-- $subcommand {
1311 disable_option multicommit
1312 disable_option branch
1313 disable_option transport
1316 enable_option singlecommit
1318 disable_option multicommit
1319 disable_option branch
1320 disable_option transport
1324 ######################################################################
1332 menu .mbar
-tearoff 0
1333 .mbar add cascade
-label Repository
-menu .mbar.repository
1334 .mbar add cascade
-label Edit
-menu .mbar.edit
1335 if {[is_enabled branch
]} {
1336 .mbar add cascade
-label Branch
-menu .mbar.branch
1338 if {[is_enabled multicommit
] ||
[is_enabled singlecommit
]} {
1339 .mbar add cascade
-label Commit
-menu .mbar.commit
1341 if {[is_enabled transport
]} {
1342 .mbar add cascade
-label Merge
-menu .mbar.merge
1343 .mbar add cascade
-label Fetch
-menu .mbar.fetch
1344 .mbar add cascade
-label Push
-menu .mbar.push
1346 . configure
-menu .mbar
1348 # -- Repository Menu
1350 menu .mbar.repository
1352 .mbar.repository add
command \
1353 -label {Browse Current Branch
} \
1354 -command {browser
::new
$current_branch}
1355 trace add variable current_branch
write ".mbar.repository entryconf [.mbar.repository index last] -label \"Browse \$current_branch\" ;#"
1356 .mbar.repository add separator
1358 .mbar.repository add
command \
1359 -label {Visualize Current Branch
} \
1360 -command {do_gitk
$current_branch}
1361 trace add variable current_branch
write ".mbar.repository entryconf [.mbar.repository index last] -label \"Visualize \$current_branch\" ;#"
1362 .mbar.repository add
command \
1363 -label {Visualize All Branches
} \
1364 -command {do_gitk
--all}
1365 .mbar.repository add separator
1367 if {[is_enabled multicommit
]} {
1368 .mbar.repository add
command -label {Database Statistics
} \
1371 .mbar.repository add
command -label {Compress Database
} \
1374 .mbar.repository add
command -label {Verify Database
} \
1375 -command do_fsck_objects
1377 .mbar.repository add separator
1380 .mbar.repository add
command \
1381 -label {Create Desktop Icon
} \
1382 -command do_cygwin_shortcut
1383 } elseif
{[is_Windows
]} {
1384 .mbar.repository add
command \
1385 -label {Create Desktop Icon
} \
1386 -command do_windows_shortcut
1387 } elseif
{[is_MacOSX
]} {
1388 .mbar.repository add
command \
1389 -label {Create Desktop Icon
} \
1390 -command do_macosx_app
1394 .mbar.repository add
command -label Quit \
1401 .mbar.edit add
command -label Undo \
1402 -command {catch
{[focus
] edit undo
}} \
1404 .mbar.edit add
command -label Redo \
1405 -command {catch
{[focus
] edit redo
}} \
1407 .mbar.edit add separator
1408 .mbar.edit add
command -label Cut \
1409 -command {catch
{tk_textCut
[focus
]}} \
1411 .mbar.edit add
command -label Copy \
1412 -command {catch
{tk_textCopy
[focus
]}} \
1414 .mbar.edit add
command -label Paste \
1415 -command {catch
{tk_textPaste
[focus
]; [focus
] see insert
}} \
1417 .mbar.edit add
command -label Delete \
1418 -command {catch
{[focus
] delete sel.first sel.last
}} \
1420 .mbar.edit add separator
1421 .mbar.edit add
command -label {Select All
} \
1422 -command {catch
{[focus
] tag add sel
0.0 end
}} \
1427 if {[is_enabled branch
]} {
1430 .mbar.branch add
command -label {Create...
} \
1431 -command do_create_branch \
1433 lappend disable_on_lock
[list .mbar.branch entryconf \
1434 [.mbar.branch index last
] -state]
1436 .mbar.branch add
command -label {Rename...
} \
1437 -command branch_rename
::dialog
1438 lappend disable_on_lock
[list .mbar.branch entryconf \
1439 [.mbar.branch index last
] -state]
1441 .mbar.branch add
command -label {Delete...
} \
1442 -command do_delete_branch
1443 lappend disable_on_lock
[list .mbar.branch entryconf \
1444 [.mbar.branch index last
] -state]
1446 .mbar.branch add
command -label {Reset...
} \
1447 -command merge
::reset_hard
1448 lappend disable_on_lock
[list .mbar.branch entryconf \
1449 [.mbar.branch index last
] -state]
1454 if {[is_enabled multicommit
] ||
[is_enabled singlecommit
]} {
1457 .mbar.commit add radiobutton \
1458 -label {New Commit
} \
1459 -command do_select_commit_type \
1460 -variable selected_commit_type \
1462 lappend disable_on_lock \
1463 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1465 .mbar.commit add radiobutton \
1466 -label {Amend Last Commit
} \
1467 -command do_select_commit_type \
1468 -variable selected_commit_type \
1470 lappend disable_on_lock \
1471 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1473 .mbar.commit add separator
1475 .mbar.commit add
command -label Rescan \
1476 -command do_rescan \
1478 lappend disable_on_lock \
1479 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1481 .mbar.commit add
command -label {Add To Commit
} \
1482 -command do_add_selection
1483 lappend disable_on_lock \
1484 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1486 .mbar.commit add
command -label {Add Existing To Commit
} \
1487 -command do_add_all \
1489 lappend disable_on_lock \
1490 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1492 .mbar.commit add
command -label {Unstage From Commit
} \
1493 -command do_unstage_selection
1494 lappend disable_on_lock \
1495 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1497 .mbar.commit add
command -label {Revert Changes
} \
1498 -command do_revert_selection
1499 lappend disable_on_lock \
1500 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1502 .mbar.commit add separator
1504 .mbar.commit add
command -label {Sign Off
} \
1505 -command do_signoff \
1508 .mbar.commit add
command -label Commit \
1509 -command do_commit \
1510 -accelerator $M1T-Return
1511 lappend disable_on_lock \
1512 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1517 if {[is_enabled branch
]} {
1519 .mbar.merge add
command -label {Local Merge...
} \
1520 -command merge
::dialog
1521 lappend disable_on_lock \
1522 [list .mbar.merge entryconf
[.mbar.merge index last
] -state]
1523 .mbar.merge add
command -label {Abort Merge...
} \
1524 -command merge
::reset_hard
1525 lappend disable_on_lock \
1526 [list .mbar.merge entryconf
[.mbar.merge index last
] -state]
1532 if {[is_enabled transport
]} {
1536 .mbar.push add
command -label {Push...
} \
1537 -command do_push_anywhere
1538 .mbar.push add
command -label {Delete...
} \
1539 -command remote_branch_delete
::dialog
1543 # -- Apple Menu (Mac OS X only)
1545 .mbar add cascade
-label Apple
-menu .mbar.apple
1548 .mbar.apple add
command -label "About [appname]" \
1550 .mbar.apple add
command -label "Options..." \
1555 .mbar.edit add separator
1556 .mbar.edit add
command -label {Options...
} \
1561 if {[file exists
/usr
/local
/miga
/lib
/gui-miga
]
1562 && [file exists .pvcsrc
]} {
1564 global ui_status_value
1565 if {![lock_index update
]} return
1566 set cmd
[list sh
--login -c "/usr/local/miga/lib/gui-miga \"[pwd]\""]
1567 set miga_fd
[open
"|$cmd" r
]
1568 fconfigure
$miga_fd -blocking 0
1569 fileevent
$miga_fd readable
[list miga_done
$miga_fd]
1570 set ui_status_value
{Running miga...
}
1572 proc miga_done
{fd
} {
1577 rescan
[list
set ui_status_value
{Ready.
}]
1580 .mbar add cascade
-label Tools
-menu .mbar.tools
1582 .mbar.tools add
command -label "Migrate" \
1584 lappend disable_on_lock \
1585 [list .mbar.tools entryconf
[.mbar.tools index last
] -state]
1591 .mbar add cascade
-label Help
-menu .mbar.
help
1595 .mbar.
help add
command -label "About [appname]" \
1600 catch
{set browser
$repo_config(instaweb.browser
)}
1601 set doc_path
[file dirname [gitexec
]]
1602 set doc_path
[file join $doc_path Documentation index.html
]
1605 set doc_path
[exec cygpath
--mixed $doc_path]
1608 if {$browser eq
{}} {
1611 } elseif
{[is_Cygwin
]} {
1612 set program_files
[file dirname [exec cygpath
--windir]]
1613 set program_files
[file join $program_files {Program Files
}]
1614 set firefox
[file join $program_files {Mozilla Firefox
} firefox.exe
]
1615 set ie
[file join $program_files {Internet Explorer
} IEXPLORE.EXE
]
1616 if {[file exists
$firefox]} {
1617 set browser
$firefox
1618 } elseif
{[file exists
$ie]} {
1621 unset program_files firefox ie
1625 if {[file isfile
$doc_path]} {
1626 set doc_url
"file:$doc_path"
1628 set doc_url
{http
://www.kernel.org
/pub
/software
/scm
/git
/docs
/}
1631 if {$browser ne
{}} {
1632 .mbar.
help add
command -label {Online Documentation
} \
1633 -command [list
exec $browser $doc_url &]
1635 unset browser doc_path doc_url
1637 # -- Standard bindings
1639 bind .
<Destroy
> do_quit
1640 bind all
<$M1B-Key-q> do_quit
1641 bind all
<$M1B-Key-Q> do_quit
1642 bind all
<$M1B-Key-w> {destroy
[winfo toplevel
%W
]}
1643 bind all
<$M1B-Key-W> {destroy
[winfo toplevel
%W
]}
1645 set subcommand_args
{}
1647 puts stderr
"usage: $::argv0 $::subcommand $::subcommand_args"
1651 # -- Not a normal commit type invocation? Do that instead!
1653 switch
-- $subcommand {
1655 set subcommand_args
{rev?
}
1656 switch
[llength
$argv] {
1657 0 { set current_branch
[current-branch
] }
1658 1 { set current_branch
[lindex
$argv 0] }
1661 browser
::new
$current_branch
1665 set subcommand_args
{rev? path?
}
1670 if {$is_path ||
[file exists
$_prefix$a]} {
1671 if {$path ne
{}} usage
1674 } elseif
{$a eq
{--}} {
1676 if {$head ne
{}} usage
1681 } elseif
{$head eq
{}} {
1682 if {$head ne
{}} usage
1691 set current_branch
[current-branch
]
1693 set current_branch
$head
1696 if {$path eq
{}} usage
1697 blame
::new
$head $path
1702 if {[llength
$argv] != 0} {
1703 puts
-nonewline stderr
"usage: $argv0"
1704 if {$subcommand ne
{gui
} && [appname
] ne
"git-$subcommand"} {
1705 puts
-nonewline stderr
" $subcommand"
1710 # fall through to setup UI for commits
1713 puts stderr
"usage: $argv0 \[{blame|browser|citool}\]"
1724 -text {Current Branch
:} \
1728 -textvariable current_branch \
1731 pack .branch.l1
-side left
1732 pack .branch.cb
-side left
-fill x
1733 pack .branch
-side top
-fill x
1735 # -- Main Window Layout
1737 panedwindow .vpane
-orient vertical
1738 panedwindow .vpane.files
-orient horizontal
1739 .vpane add .vpane.files
-sticky nsew
-height 100 -width 200
1740 pack .vpane
-anchor n
-side top
-fill both
-expand 1
1742 # -- Index File List
1744 frame .vpane.files.index
-height 100 -width 200
1745 label .vpane.files.index.title
-text {Staged Changes
(Will Be Committed
)} \
1747 text
$ui_index -background white
-borderwidth 0 \
1748 -width 20 -height 10 \
1750 -cursor $cursor_ptr \
1751 -xscrollcommand {.vpane.files.index.sx
set} \
1752 -yscrollcommand {.vpane.files.index.sy
set} \
1754 scrollbar .vpane.files.index.sx
-orient h
-command [list
$ui_index xview
]
1755 scrollbar .vpane.files.index.sy
-orient v
-command [list
$ui_index yview
]
1756 pack .vpane.files.index.title
-side top
-fill x
1757 pack .vpane.files.index.sx
-side bottom
-fill x
1758 pack .vpane.files.index.sy
-side right
-fill y
1759 pack
$ui_index -side left
-fill both
-expand 1
1760 .vpane.files add .vpane.files.index
-sticky nsew
1762 # -- Working Directory File List
1764 frame .vpane.files.workdir
-height 100 -width 200
1765 label .vpane.files.workdir.title
-text {Unstaged Changes
(Will Not Be Committed
)} \
1767 text
$ui_workdir -background white
-borderwidth 0 \
1768 -width 20 -height 10 \
1770 -cursor $cursor_ptr \
1771 -xscrollcommand {.vpane.files.workdir.sx
set} \
1772 -yscrollcommand {.vpane.files.workdir.sy
set} \
1774 scrollbar .vpane.files.workdir.sx
-orient h
-command [list
$ui_workdir xview
]
1775 scrollbar .vpane.files.workdir.sy
-orient v
-command [list
$ui_workdir yview
]
1776 pack .vpane.files.workdir.title
-side top
-fill x
1777 pack .vpane.files.workdir.sx
-side bottom
-fill x
1778 pack .vpane.files.workdir.sy
-side right
-fill y
1779 pack
$ui_workdir -side left
-fill both
-expand 1
1780 .vpane.files add .vpane.files.workdir
-sticky nsew
1782 foreach i
[list
$ui_index $ui_workdir] {
1783 $i tag conf in_diff
-font font_uibold
1784 $i tag conf in_sel \
1785 -background [$i cget
-foreground] \
1786 -foreground [$i cget
-background]
1790 # -- Diff and Commit Area
1792 frame .vpane.lower
-height 300 -width 400
1793 frame .vpane.lower.commarea
1794 frame .vpane.lower.
diff -relief sunken
-borderwidth 1
1795 pack .vpane.lower.commarea
-side top
-fill x
1796 pack .vpane.lower.
diff -side bottom
-fill both
-expand 1
1797 .vpane add .vpane.lower
-sticky nsew
1799 # -- Commit Area Buttons
1801 frame .vpane.lower.commarea.buttons
1802 label .vpane.lower.commarea.buttons.l
-text {} \
1805 pack .vpane.lower.commarea.buttons.l
-side top
-fill x
1806 pack .vpane.lower.commarea.buttons
-side left
-fill y
1808 button .vpane.lower.commarea.buttons.rescan
-text {Rescan
} \
1810 pack .vpane.lower.commarea.buttons.rescan
-side top
-fill x
1811 lappend disable_on_lock \
1812 {.vpane.lower.commarea.buttons.rescan conf
-state}
1814 button .vpane.lower.commarea.buttons.incall
-text {Add Existing
} \
1816 pack .vpane.lower.commarea.buttons.incall
-side top
-fill x
1817 lappend disable_on_lock \
1818 {.vpane.lower.commarea.buttons.incall conf
-state}
1820 button .vpane.lower.commarea.buttons.signoff
-text {Sign Off
} \
1822 pack .vpane.lower.commarea.buttons.signoff
-side top
-fill x
1824 button .vpane.lower.commarea.buttons.commit
-text {Commit
} \
1826 pack .vpane.lower.commarea.buttons.commit
-side top
-fill x
1827 lappend disable_on_lock \
1828 {.vpane.lower.commarea.buttons.commit conf
-state}
1830 # -- Commit Message Buffer
1832 frame .vpane.lower.commarea.buffer
1833 frame .vpane.lower.commarea.buffer.header
1834 set ui_comm .vpane.lower.commarea.buffer.t
1835 set ui_coml .vpane.lower.commarea.buffer.header.l
1836 radiobutton .vpane.lower.commarea.buffer.header.new \
1837 -text {New Commit
} \
1838 -command do_select_commit_type \
1839 -variable selected_commit_type \
1841 lappend disable_on_lock \
1842 [list .vpane.lower.commarea.buffer.header.new conf
-state]
1843 radiobutton .vpane.lower.commarea.buffer.header.amend \
1844 -text {Amend Last Commit
} \
1845 -command do_select_commit_type \
1846 -variable selected_commit_type \
1848 lappend disable_on_lock \
1849 [list .vpane.lower.commarea.buffer.header.amend conf
-state]
1853 proc trace_commit_type
{varname args
} {
1854 global ui_coml commit_type
1855 switch
-glob -- $commit_type {
1856 initial
{set txt
{Initial Commit Message
:}}
1857 amend
{set txt
{Amended Commit Message
:}}
1858 amend-initial
{set txt
{Amended Initial Commit Message
:}}
1859 amend-merge
{set txt
{Amended Merge Commit Message
:}}
1860 merge
{set txt
{Merge Commit Message
:}}
1861 * {set txt
{Commit Message
:}}
1863 $ui_coml conf
-text $txt
1865 trace add variable commit_type
write trace_commit_type
1866 pack
$ui_coml -side left
-fill x
1867 pack .vpane.lower.commarea.buffer.header.amend
-side right
1868 pack .vpane.lower.commarea.buffer.header.new
-side right
1870 text
$ui_comm -background white
-borderwidth 1 \
1873 -autoseparators true \
1875 -width 75 -height 9 -wrap none \
1877 -yscrollcommand {.vpane.lower.commarea.buffer.sby
set}
1878 scrollbar .vpane.lower.commarea.buffer.sby \
1879 -command [list
$ui_comm yview
]
1880 pack .vpane.lower.commarea.buffer.header
-side top
-fill x
1881 pack .vpane.lower.commarea.buffer.sby
-side right
-fill y
1882 pack
$ui_comm -side left
-fill y
1883 pack .vpane.lower.commarea.buffer
-side left
-fill y
1885 # -- Commit Message Buffer Context Menu
1887 set ctxm .vpane.lower.commarea.buffer.ctxm
1888 menu
$ctxm -tearoff 0
1891 -command {tk_textCut
$ui_comm}
1894 -command {tk_textCopy
$ui_comm}
1897 -command {tk_textPaste
$ui_comm}
1900 -command {$ui_comm delete sel.first sel.last
}
1903 -label {Select All
} \
1904 -command {focus
$ui_comm;$ui_comm tag add sel
0.0 end
}
1908 $ui_comm tag add sel
0.0 end
1909 tk_textCopy
$ui_comm
1910 $ui_comm tag remove sel
0.0 end
1916 bind_button3
$ui_comm "tk_popup $ctxm %X %Y"
1920 proc trace_current_diff_path
{varname args
} {
1921 global current_diff_path diff_actions file_states
1922 if {$current_diff_path eq
{}} {
1928 set p
$current_diff_path
1929 set s
[mapdesc
[lindex
$file_states($p) 0] $p]
1931 set p
[escape_path
$p]
1935 .vpane.lower.
diff.header.status configure
-text $s
1936 .vpane.lower.
diff.header.
file configure
-text $f
1937 .vpane.lower.
diff.header.path configure
-text $p
1938 foreach w
$diff_actions {
1942 trace add variable current_diff_path
write trace_current_diff_path
1944 frame .vpane.lower.
diff.header
-background orange
1945 label .vpane.lower.
diff.header.status \
1946 -background orange \
1947 -width $max_status_desc \
1950 label .vpane.lower.
diff.header.
file \
1951 -background orange \
1954 label .vpane.lower.
diff.header.path \
1955 -background orange \
1958 pack .vpane.lower.
diff.header.status
-side left
1959 pack .vpane.lower.
diff.header.
file -side left
1960 pack .vpane.lower.
diff.header.path
-fill x
1961 set ctxm .vpane.lower.
diff.header.ctxm
1962 menu
$ctxm -tearoff 0
1970 -- $current_diff_path
1972 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
1973 bind_button3 .vpane.lower.
diff.header.path
"tk_popup $ctxm %X %Y"
1977 frame .vpane.lower.
diff.body
1978 set ui_diff .vpane.lower.
diff.body.t
1979 text
$ui_diff -background white
-borderwidth 0 \
1980 -width 80 -height 15 -wrap none \
1982 -xscrollcommand {.vpane.lower.
diff.body.sbx
set} \
1983 -yscrollcommand {.vpane.lower.
diff.body.sby
set} \
1985 scrollbar .vpane.lower.
diff.body.sbx
-orient horizontal \
1986 -command [list
$ui_diff xview
]
1987 scrollbar .vpane.lower.
diff.body.sby
-orient vertical \
1988 -command [list
$ui_diff yview
]
1989 pack .vpane.lower.
diff.body.sbx
-side bottom
-fill x
1990 pack .vpane.lower.
diff.body.sby
-side right
-fill y
1991 pack
$ui_diff -side left
-fill both
-expand 1
1992 pack .vpane.lower.
diff.header
-side top
-fill x
1993 pack .vpane.lower.
diff.body
-side bottom
-fill both
-expand 1
1995 $ui_diff tag conf d_cr
-elide true
1996 $ui_diff tag conf d_@
-foreground blue
-font font_diffbold
1997 $ui_diff tag conf d_
+ -foreground {#00a000}
1998 $ui_diff tag conf d_-
-foreground red
2000 $ui_diff tag conf d_
++ -foreground {#00a000}
2001 $ui_diff tag conf d_--
-foreground red
2002 $ui_diff tag conf d_
+s \
2003 -foreground {#00a000} \
2004 -background {#e2effa}
2005 $ui_diff tag conf d_-s \
2007 -background {#e2effa}
2008 $ui_diff tag conf d_s
+ \
2009 -foreground {#00a000} \
2011 $ui_diff tag conf d_s- \
2015 $ui_diff tag conf d
<<<<<<< \
2016 -foreground orange \
2018 $ui_diff tag conf d
======= \
2019 -foreground orange \
2021 $ui_diff tag conf d
>>>>>>> \
2022 -foreground orange \
2025 $ui_diff tag raise sel
2027 # -- Diff Body Context Menu
2029 set ctxm .vpane.lower.
diff.body.ctxm
2030 menu
$ctxm -tearoff 0
2033 -command reshow_diff
2034 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2037 -command {tk_textCopy
$ui_diff}
2038 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2040 -label {Select All
} \
2041 -command {focus
$ui_diff;$ui_diff tag add sel
0.0 end
}
2042 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2046 $ui_diff tag add sel
0.0 end
2047 tk_textCopy
$ui_diff
2048 $ui_diff tag remove sel
0.0 end
2050 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2053 -label {Apply
/Reverse Hunk
} \
2054 -command {apply_hunk
$cursorX $cursorY}
2055 set ui_diff_applyhunk
[$ctxm index last
]
2056 lappend diff_actions
[list
$ctxm entryconf
$ui_diff_applyhunk -state]
2059 -label {Decrease Font Size
} \
2060 -command {incr_font_size font_diff
-1}
2061 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2063 -label {Increase Font Size
} \
2064 -command {incr_font_size font_diff
1}
2065 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2068 -label {Show Less Context
} \
2069 -command {if {$repo_config(gui.diffcontext
) >= 1} {
2070 incr repo_config
(gui.diffcontext
) -1
2073 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2075 -label {Show More Context
} \
2076 -command {if {$repo_config(gui.diffcontext
) < 99} {
2077 incr repo_config
(gui.diffcontext
)
2080 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2082 $ctxm add
command -label {Options...
} \
2084 bind_button3
$ui_diff "
2087 if {\$ui_index eq \$current_diff_side} {
2088 $ctxm entryconf $ui_diff_applyhunk -label {Unstage Hunk From Commit}
2090 $ctxm entryconf $ui_diff_applyhunk -label {Stage Hunk For Commit}
2092 tk_popup $ctxm %X %Y
2094 unset ui_diff_applyhunk
2098 label .status
-textvariable ui_status_value \
2103 pack .status
-anchor w
-side bottom
-fill x
2108 set gm
$repo_config(gui.geometry
)
2109 wm geometry .
[lindex
$gm 0]
2110 .vpane sash place
0 \
2111 [lindex
[.vpane sash coord
0] 0] \
2113 .vpane.files sash place
0 \
2115 [lindex
[.vpane.files sash coord
0] 1]
2121 bind $ui_comm <$M1B-Key-Return> {do_commit
;break}
2122 bind $ui_comm <$M1B-Key-i> {do_add_all
;break}
2123 bind $ui_comm <$M1B-Key-I> {do_add_all
;break}
2124 bind $ui_comm <$M1B-Key-x> {tk_textCut
%W
;break}
2125 bind $ui_comm <$M1B-Key-X> {tk_textCut
%W
;break}
2126 bind $ui_comm <$M1B-Key-c> {tk_textCopy
%W
;break}
2127 bind $ui_comm <$M1B-Key-C> {tk_textCopy
%W
;break}
2128 bind $ui_comm <$M1B-Key-v> {tk_textPaste
%W
; %W see insert
; break}
2129 bind $ui_comm <$M1B-Key-V> {tk_textPaste
%W
; %W see insert
; break}
2130 bind $ui_comm <$M1B-Key-a> {%W tag add sel
0.0 end
;break}
2131 bind $ui_comm <$M1B-Key-A> {%W tag add sel
0.0 end
;break}
2133 bind $ui_diff <$M1B-Key-x> {tk_textCopy
%W
;break}
2134 bind $ui_diff <$M1B-Key-X> {tk_textCopy
%W
;break}
2135 bind $ui_diff <$M1B-Key-c> {tk_textCopy
%W
;break}
2136 bind $ui_diff <$M1B-Key-C> {tk_textCopy
%W
;break}
2137 bind $ui_diff <$M1B-Key-v> {break}
2138 bind $ui_diff <$M1B-Key-V> {break}
2139 bind $ui_diff <$M1B-Key-a> {%W tag add sel
0.0 end
;break}
2140 bind $ui_diff <$M1B-Key-A> {%W tag add sel
0.0 end
;break}
2141 bind $ui_diff <Key-Up
> {catch
{%W yview scroll
-1 units
};break}
2142 bind $ui_diff <Key-Down
> {catch
{%W yview scroll
1 units
};break}
2143 bind $ui_diff <Key-Left
> {catch
{%W xview scroll
-1 units
};break}
2144 bind $ui_diff <Key-Right
> {catch
{%W xview scroll
1 units
};break}
2145 bind $ui_diff <Key-k
> {catch
{%W yview scroll
-1 units
};break}
2146 bind $ui_diff <Key-j
> {catch
{%W yview scroll
1 units
};break}
2147 bind $ui_diff <Key-h
> {catch
{%W xview scroll
-1 units
};break}
2148 bind $ui_diff <Key-l
> {catch
{%W xview scroll
1 units
};break}
2149 bind $ui_diff <Control-Key-b
> {catch
{%W yview scroll
-1 pages
};break}
2150 bind $ui_diff <Control-Key-f
> {catch
{%W yview scroll
1 pages
};break}
2151 bind $ui_diff <Button-1
> {focus
%W
}
2153 if {[is_enabled branch
]} {
2154 bind .
<$M1B-Key-n> do_create_branch
2155 bind .
<$M1B-Key-N> do_create_branch
2158 bind all
<Key-F5
> do_rescan
2159 bind all
<$M1B-Key-r> do_rescan
2160 bind all
<$M1B-Key-R> do_rescan
2161 bind .
<$M1B-Key-s> do_signoff
2162 bind .
<$M1B-Key-S> do_signoff
2163 bind .
<$M1B-Key-i> do_add_all
2164 bind .
<$M1B-Key-I> do_add_all
2165 bind .
<$M1B-Key-Return> do_commit
2166 foreach i
[list
$ui_index $ui_workdir] {
2167 bind $i <Button-1
> "toggle_or_diff $i %x %y; break"
2168 bind $i <$M1B-Button-1> "add_one_to_selection $i %x %y; break"
2169 bind $i <Shift-Button-1
> "add_range_to_selection $i %x %y; break"
2173 set file_lists
($ui_index) [list
]
2174 set file_lists
($ui_workdir) [list
]
2176 wm title .
"[appname] ([reponame]) [file normalize [file dirname [gitdir]]]"
2177 focus
-force $ui_comm
2179 # -- Warn the user about environmental problems. Cygwin's Tcl
2180 # does *not* pass its env array onto any processes it spawns.
2181 # This means that git processes get none of our environment.
2186 set msg
"Possible environment issues exist.
2188 The following environment variables are probably
2189 going to be ignored by any Git subprocess run
2193 foreach name
[array names env
] {
2194 switch
-regexp -- $name {
2195 {^GIT_INDEX_FILE$
} -
2196 {^GIT_OBJECT_DIRECTORY$
} -
2197 {^GIT_ALTERNATE_OBJECT_DIRECTORIES$
} -
2199 {^GIT_EXTERNAL_DIFF$
} -
2203 {^GIT_CONFIG_LOCAL$
} -
2204 {^GIT_
(AUTHOR|COMMITTER
)_DATE$
} {
2205 append msg
" - $name\n"
2208 {^GIT_
(AUTHOR|COMMITTER
)_
(NAME|EMAIL
)$
} {
2209 append msg
" - $name\n"
2211 set suggest_user
$name
2215 if {$ignored_env > 0} {
2217 This is due to a known issue with the
2218 Tcl binary distributed by Cygwin."
2220 if {$suggest_user ne
{}} {
2223 A good replacement for $suggest_user
2224 is placing values for the user.name and
2225 user.email settings into your personal
2231 unset ignored_env msg suggest_user name
2234 # -- Only initialize complex UI if we are going to stay running.
2236 if {[is_enabled transport
]} {
2240 populate_branch_menu
2245 # -- Only suggest a gc run if we are going to stay running.
2247 if {[is_enabled multicommit
]} {
2248 set object_limit
2000
2249 if {[is_Windows
]} {set object_limit
200}
2250 regexp
{^
([0-9]+) objects
,} [git count-objects
] _junk objects_current
2251 if {$objects_current >= $object_limit} {
2253 "This repository currently has $objects_current loose objects.
2255 To maintain optimal performance it is strongly recommended that you compress the database when more than $object_limit loose objects exist.
2257 Compress the database now?"] eq
yes} {
2261 unset object_limit _junk objects_current
2264 lock_index begin-read