2 # Tcl ignores the next line -*- tcl -*- \
3 if test "z$*" = zversion \
4 ||
test "z$*" = z--version
; \
6 echo 'git-gui version @@GITGUI_VERSION@@'; \
11 set appvers
{@@GITGUI_VERSION@@
}
13 Copyright ©
2006, 2007 Shawn Pearce
, et. al.
15 This program is free software
; you can redistribute it and
/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation
; either version
2 of the License
, or
18 (at your option
) any later version.
20 This program is distributed
in the hope that it will be useful
,
21 but WITHOUT ANY WARRANTY
; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License
for more details.
25 You should have received a copy of the GNU General Public License
26 along with this program
; if not
, write to the Free Software
27 Foundation
, Inc.
, 59 Temple Place
, Suite
330, Boston
, MA
02111-1307 USA
}
29 ######################################################################
31 ## Tcl/Tk sanity check
33 if {[catch
{package require Tcl
8.4} err
]
34 ||
[catch
{package require Tk
8.4} err
]
40 -title "git-gui: fatal error" \
45 ######################################################################
47 ## enable verbose loading?
49 if {![catch
{set _verbose
$env(GITGUI_VERBOSE
)}]} {
51 rename auto_load real__auto_load
52 proc auto_load
{name args
} {
53 puts stderr
"auto_load $name"
54 return [uplevel
1 real__auto_load
$name $args]
56 rename
source real__source
58 puts stderr
"source $name"
59 uplevel
1 real__source
$name
63 ######################################################################
65 ## configure our library
67 set oguilib
{@@GITGUI_LIBDIR@@
}
68 set oguirel
{@@GITGUI_RELATIVE@@
}
69 if {$oguirel eq
{1}} {
70 set oguilib
[file dirname [file dirname [file normalize
$argv0]]]
71 set oguilib
[file join $oguilib share git-gui lib
]
72 } elseif
{[string match @@
* $oguirel]} {
73 set oguilib
[file join [file dirname [file normalize
$argv0]] lib
]
76 set idx
[file join $oguilib tclIndex
]
77 if {[catch
{set fd
[open
$idx r
]} err
]} {
82 -title "git-gui: fatal error" \
86 if {[gets
$fd] eq
{# Autogenerated by git-gui Makefile}} {
88 while {[gets
$fd n
] >= 0} {
89 if {$n ne
{} && ![string match
#* $n]} {
101 if {[lsearch
-exact $loaded $p] >= 0} continue
102 source [file join $oguilib $p]
107 set auto_path
[concat
[list
$oguilib] $auto_path]
109 unset -nocomplain oguirel idx fd
111 ######################################################################
115 set _appname
[lindex
[file split $argv0] end
]
131 return [eval [concat
[list
file join $_gitdir] $args]]
134 proc gitexec
{args
} {
136 if {$_gitexec eq
{}} {
137 if {[catch
{set _gitexec
[git
--exec-path]} err
]} {
138 error
"Git not installed?\n\n$err"
144 return [eval [concat
[list
file join $_gitexec] $args]]
153 global tcl_platform tk_library
154 if {[tk windowingsystem
] eq
{aqua
}} {
162 if {$tcl_platform(platform
) eq
{windows
}} {
169 global tcl_platform _iscygwin
170 if {$_iscygwin eq
{}} {
171 if {$tcl_platform(platform
) eq
{windows
}} {
172 if {[catch
{set p
[exec cygpath
--windir]} err
]} {
184 proc is_enabled
{option
} {
185 global enabled_options
186 if {[catch
{set on
$enabled_options($option)}]} {return 0}
190 proc enable_option
{option
} {
191 global enabled_options
192 set enabled_options
($option) 1
195 proc disable_option
{option
} {
196 global enabled_options
197 set enabled_options
($option) 0
200 ######################################################################
204 proc is_many_config
{name
} {
205 switch
-glob -- $name {
214 proc is_config_true
{name
} {
216 if {[catch
{set v
$repo_config($name)}]} {
218 } elseif
{$v eq
{true
} ||
$v eq
{1} ||
$v eq
{yes}} {
225 proc get_config
{name
} {
227 if {[catch
{set v
$repo_config($name)}]} {
234 proc load_config
{include_global
} {
235 global repo_config global_config default_config
237 array
unset global_config
238 if {$include_global} {
240 set fd_rc
[open
"| git config --global --list" r
]
241 while {[gets
$fd_rc line
] >= 0} {
242 if {[regexp
{^
([^
=]+)=(.
*)$
} $line line name value
]} {
243 if {[is_many_config
$name]} {
244 lappend global_config
($name) $value
246 set global_config
($name) $value
254 array
unset repo_config
256 set fd_rc
[open
"| git config --list" r
]
257 while {[gets
$fd_rc line
] >= 0} {
258 if {[regexp
{^
([^
=]+)=(.
*)$
} $line line name value
]} {
259 if {[is_many_config
$name]} {
260 lappend repo_config
($name) $value
262 set repo_config
($name) $value
269 foreach name
[array names default_config
] {
270 if {[catch
{set v
$global_config($name)}]} {
271 set global_config
($name) $default_config($name)
273 if {[catch
{set v
$repo_config($name)}]} {
274 set repo_config
($name) $default_config($name)
279 ######################################################################
284 return [eval exec git
$args]
287 proc current-branch
{} {
289 set fd
[open
[gitdir HEAD
] r
]
290 if {[gets
$fd ref
] <16
291 ||
![regsub
{^ref
: refs
/heads
/} $ref {} ref
]} {
298 auto_load tk_optionMenu
299 rename tk_optionMenu real__tkOptionMenu
300 proc tk_optionMenu
{w varName args
} {
301 set m
[eval real__tkOptionMenu
$w $varName $args]
302 $m configure
-font font_ui
303 $w configure
-font font_ui
307 ######################################################################
314 if {[catch
{set v
[git
--version]} err
]} {
315 catch
{wm withdraw .
}
316 error_popup
"Cannot determine Git version:
320 [appname] requires Git $req_maj.$req_min or later."
323 if {[regexp
{^git version
(\d
+)\.
(\d
+)} $v _junk act_maj act_min
]} {
324 if {$act_maj < $req_maj
325 ||
($act_maj == $req_maj && $act_min < $req_min)} {
326 catch
{wm withdraw .
}
327 error_popup
"[appname] requires Git $req_maj.$req_min or later.
333 catch
{wm withdraw .
}
334 error_popup
"Cannot parse Git version string:\n\n$v"
337 unset -nocomplain v _junk act_maj act_min req_maj req_min
339 ######################################################################
344 set _gitdir
$env(GIT_DIR
)
348 set _gitdir
[git rev-parse
--git-dir]
349 set _prefix
[git rev-parse
--show-prefix]
351 catch
{wm withdraw .
}
352 error_popup
"Cannot find the git directory:\n\n$err"
355 if {![file isdirectory
$_gitdir] && [is_Cygwin
]} {
356 catch
{set _gitdir
[exec cygpath
--unix $_gitdir]}
358 if {![file isdirectory
$_gitdir]} {
359 catch
{wm withdraw .
}
360 error_popup
"Git directory not found:\n\n$_gitdir"
363 if {[lindex
[file split $_gitdir] end
] ne
{.git
}} {
364 catch
{wm withdraw .
}
365 error_popup
"Cannot use funny .git directory:\n\n$_gitdir"
368 if {[catch
{cd [file dirname $_gitdir]} err
]} {
369 catch
{wm withdraw .
}
370 error_popup
"No working directory [file dirname $_gitdir]:\n\n$err"
373 set _reponame
[lindex
[file split \
374 [file normalize
[file dirname $_gitdir]]] \
377 ######################################################################
381 set current_diff_path
{}
382 set current_diff_side
{}
383 set diff_actions
[list
]
384 set ui_status_value
{Initializing...
}
388 set MERGE_HEAD
[list
]
391 set current_branch
{}
392 set current_diff_path
{}
393 set selected_commit_type new
395 ######################################################################
403 set disable_on_lock
[list
]
404 set index_lock_type none
406 proc lock_index
{type} {
407 global index_lock_type disable_on_lock
409 if {$index_lock_type eq
{none
}} {
410 set index_lock_type
$type
411 foreach w
$disable_on_lock {
412 uplevel
#0 $w disabled
415 } elseif
{$index_lock_type eq
"begin-$type"} {
416 set index_lock_type
$type
422 proc unlock_index
{} {
423 global index_lock_type disable_on_lock
425 set index_lock_type none
426 foreach w
$disable_on_lock {
431 ######################################################################
435 proc repository_state
{ctvar hdvar mhvar
} {
436 global current_branch
437 upvar
$ctvar ct
$hdvar hd
$mhvar mh
441 set current_branch
[current-branch
]
442 if {[catch
{set hd
[git rev-parse
--verify HEAD
]}]} {
448 set merge_head
[gitdir MERGE_HEAD
]
449 if {[file exists
$merge_head]} {
451 set fd_mh
[open
$merge_head r
]
452 while {[gets
$fd_mh line
] >= 0} {
463 global PARENT empty_tree
465 set p
[lindex
$PARENT 0]
469 if {$empty_tree eq
{}} {
470 set empty_tree
[git mktree
<< {}]
475 proc rescan
{after
{honor_trustmtime
1}} {
476 global HEAD PARENT MERGE_HEAD commit_type
477 global ui_index ui_workdir ui_status_value ui_comm
478 global rescan_active file_states
481 if {$rescan_active > 0 ||
![lock_index
read]} return
483 repository_state newType newHEAD newMERGE_HEAD
484 if {[string match amend
* $commit_type]
485 && $newType eq
{normal
}
486 && $newHEAD eq
$HEAD} {
490 set MERGE_HEAD
$newMERGE_HEAD
491 set commit_type
$newType
494 array
unset file_states
496 if {![$ui_comm edit modified
]
497 ||
[string trim
[$ui_comm get
0.0 end
]] eq
{}} {
498 if {[string match amend
* $commit_type]} {
499 } elseif
{[load_message GITGUI_MSG
]} {
500 } elseif
{[load_message MERGE_MSG
]} {
501 } elseif
{[load_message SQUASH_MSG
]} {
504 $ui_comm edit modified false
507 if {[is_enabled branch
]} {
512 if {$honor_trustmtime && $repo_config(gui.trustmtime
) eq
{true
}} {
513 rescan_stage2
{} $after
516 set ui_status_value
{Refreshing
file status...
}
517 set cmd
[list git update-index
]
519 lappend cmd
--unmerged
520 lappend cmd
--ignore-missing
521 lappend cmd
--refresh
522 set fd_rf
[open
"| $cmd" r
]
523 fconfigure
$fd_rf -blocking 0 -translation binary
524 fileevent
$fd_rf readable \
525 [list rescan_stage2
$fd_rf $after]
529 proc rescan_stage2
{fd after
} {
530 global ui_status_value
531 global rescan_active buf_rdi buf_rdf buf_rlo
535 if {![eof
$fd]} return
539 set ls_others
[list | git ls-files
--others -z \
540 --exclude-per-directory=.gitignore
]
541 set info_exclude
[gitdir info exclude
]
542 if {[file readable
$info_exclude]} {
543 lappend ls_others
"--exclude-from=$info_exclude"
551 set ui_status_value
{Scanning
for modified files ...
}
552 set fd_di
[open
"| git diff-index --cached -z [PARENT]" r
]
553 set fd_df
[open
"| git diff-files -z" r
]
554 set fd_lo
[open
$ls_others r
]
556 fconfigure
$fd_di -blocking 0 -translation binary
-encoding binary
557 fconfigure
$fd_df -blocking 0 -translation binary
-encoding binary
558 fconfigure
$fd_lo -blocking 0 -translation binary
-encoding binary
559 fileevent
$fd_di readable
[list read_diff_index
$fd_di $after]
560 fileevent
$fd_df readable
[list read_diff_files
$fd_df $after]
561 fileevent
$fd_lo readable
[list read_ls_others
$fd_lo $after]
564 proc load_message
{file} {
568 if {[file isfile
$f]} {
569 if {[catch
{set fd
[open
$f r
]}]} {
572 set content
[string trim
[read $fd]]
574 regsub
-all -line {[ \r\t]+$
} $content {} content
575 $ui_comm delete
0.0 end
576 $ui_comm insert end
$content
582 proc read_diff_index
{fd after
} {
585 append buf_rdi
[read $fd]
587 set n
[string length
$buf_rdi]
589 set z1
[string first
"\0" $buf_rdi $c]
592 set z2
[string first
"\0" $buf_rdi $z1]
596 set i
[split [string range
$buf_rdi $c [expr {$z1 - 2}]] { }]
597 set p
[string range
$buf_rdi $z1 [expr {$z2 - 1}]]
599 [encoding convertfrom
$p] \
601 [list
[lindex
$i 0] [lindex
$i 2]] \
607 set buf_rdi
[string range
$buf_rdi $c end
]
612 rescan_done
$fd buf_rdi
$after
615 proc read_diff_files
{fd after
} {
618 append buf_rdf
[read $fd]
620 set n
[string length
$buf_rdf]
622 set z1
[string first
"\0" $buf_rdf $c]
625 set z2
[string first
"\0" $buf_rdf $z1]
629 set i
[split [string range
$buf_rdf $c [expr {$z1 - 2}]] { }]
630 set p
[string range
$buf_rdf $z1 [expr {$z2 - 1}]]
632 [encoding convertfrom
$p] \
635 [list
[lindex
$i 0] [lindex
$i 2]]
640 set buf_rdf
[string range
$buf_rdf $c end
]
645 rescan_done
$fd buf_rdf
$after
648 proc read_ls_others
{fd after
} {
651 append buf_rlo
[read $fd]
652 set pck
[split $buf_rlo "\0"]
653 set buf_rlo
[lindex
$pck end
]
654 foreach p
[lrange
$pck 0 end-1
] {
655 merge_state
[encoding convertfrom
$p] ?O
657 rescan_done
$fd buf_rlo
$after
660 proc rescan_done
{fd buf after
} {
661 global rescan_active current_diff_path
662 global file_states repo_config
665 if {![eof
$fd]} return
668 if {[incr rescan_active
-1] > 0} return
673 if {$current_diff_path ne
{}} reshow_diff
677 proc prune_selection
{} {
678 global file_states selected_paths
680 foreach path
[array names selected_paths
] {
681 if {[catch
{set still_here
$file_states($path)}]} {
682 unset selected_paths
($path)
687 ######################################################################
691 proc mapicon
{w state path
} {
694 if {[catch
{set r
$all_icons($state$w)}]} {
695 puts
"error: no icon for $w state={$state} $path"
701 proc mapdesc
{state path
} {
704 if {[catch
{set r
$all_descs($state)}]} {
705 puts
"error: no desc for state={$state} $path"
711 proc escape_path
{path
} {
712 regsub
-all {\\} $path "\\\\" path
713 regsub
-all "\n" $path "\\n" path
717 proc short_path
{path
} {
718 return [escape_path
[lindex
[file split $path] end
]]
722 set null_sha1
[string repeat
0 40]
724 proc merge_state
{path new_state
{head_info
{}} {index_info
{}}} {
725 global file_states next_icon_id null_sha1
727 set s0
[string index
$new_state 0]
728 set s1
[string index
$new_state 1]
730 if {[catch
{set info
$file_states($path)}]} {
732 set icon n
[incr next_icon_id
]
734 set state
[lindex
$info 0]
735 set icon
[lindex
$info 1]
736 if {$head_info eq
{}} {set head_info
[lindex
$info 2]}
737 if {$index_info eq
{}} {set index_info
[lindex
$info 3]}
740 if {$s0 eq
{?
}} {set s0
[string index
$state 0]} \
741 elseif
{$s0 eq
{_
}} {set s0 _
}
743 if {$s1 eq
{?
}} {set s1
[string index
$state 1]} \
744 elseif
{$s1 eq
{_
}} {set s1 _
}
746 if {$s0 eq
{A
} && $s1 eq
{_
} && $head_info eq
{}} {
747 set head_info
[list
0 $null_sha1]
748 } elseif
{$s0 ne
{_
} && [string index
$state 0] eq
{_
}
749 && $head_info eq
{}} {
750 set head_info
$index_info
753 set file_states
($path) [list
$s0$s1 $icon \
754 $head_info $index_info \
759 proc display_file_helper
{w path icon_name old_m new_m
} {
763 set lno
[lsearch
-sorted -exact $file_lists($w) $path]
765 set file_lists
($w) [lreplace
$file_lists($w) $lno $lno]
767 $w conf
-state normal
768 $w delete
$lno.0 [expr {$lno + 1}].0
769 $w conf
-state disabled
771 } elseif
{$old_m eq
{_
} && $new_m ne
{_
}} {
772 lappend file_lists
($w) $path
773 set file_lists
($w) [lsort
-unique $file_lists($w)]
774 set lno
[lsearch
-sorted -exact $file_lists($w) $path]
776 $w conf
-state normal
777 $w image create
$lno.0 \
778 -align center
-padx 5 -pady 1 \
780 -image [mapicon
$w $new_m $path]
781 $w insert
$lno.1 "[escape_path $path]\n"
782 $w conf
-state disabled
783 } elseif
{$old_m ne
$new_m} {
784 $w conf
-state normal
785 $w image conf
$icon_name -image [mapicon
$w $new_m $path]
786 $w conf
-state disabled
790 proc display_file
{path state
} {
791 global file_states selected_paths
792 global ui_index ui_workdir
794 set old_m
[merge_state
$path $state]
795 set s
$file_states($path)
796 set new_m
[lindex
$s 0]
797 set icon_name
[lindex
$s 1]
799 set o
[string index
$old_m 0]
800 set n
[string index
$new_m 0]
807 display_file_helper
$ui_index $path $icon_name $o $n
809 if {[string index
$old_m 0] eq
{U
}} {
812 set o
[string index
$old_m 1]
814 if {[string index
$new_m 0] eq
{U
}} {
817 set n
[string index
$new_m 1]
819 display_file_helper
$ui_workdir $path $icon_name $o $n
821 if {$new_m eq
{__
}} {
822 unset file_states
($path)
823 catch
{unset selected_paths
($path)}
827 proc display_all_files_helper
{w path icon_name m
} {
830 lappend file_lists
($w) $path
831 set lno
[expr {[lindex
[split [$w index end
] .
] 0] - 1}]
832 $w image create end \
833 -align center
-padx 5 -pady 1 \
835 -image [mapicon
$w $m $path]
836 $w insert end
"[escape_path $path]\n"
839 proc display_all_files
{} {
840 global ui_index ui_workdir
841 global file_states file_lists
844 $ui_index conf
-state normal
845 $ui_workdir conf
-state normal
847 $ui_index delete
0.0 end
848 $ui_workdir delete
0.0 end
851 set file_lists
($ui_index) [list
]
852 set file_lists
($ui_workdir) [list
]
854 foreach path
[lsort
[array names file_states
]] {
855 set s
$file_states($path)
857 set icon_name
[lindex
$s 1]
859 set s
[string index
$m 0]
860 if {$s ne
{U
} && $s ne
{_
}} {
861 display_all_files_helper
$ui_index $path \
865 if {[string index
$m 0] eq
{U
}} {
868 set s
[string index
$m 1]
871 display_all_files_helper
$ui_workdir $path \
876 $ui_index conf
-state disabled
877 $ui_workdir conf
-state disabled
880 ######################################################################
885 #define mask_width 14
886 #define mask_height 15
887 static unsigned char mask_bits
[] = {
888 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
889 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
890 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f};
893 image create bitmap file_plain
-background white
-foreground black
-data {
894 #define plain_width 14
895 #define plain_height 15
896 static unsigned char plain_bits
[] = {
897 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
898 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10,
899 0x02, 0x10, 0x02, 0x10, 0xfe, 0x1f};
900 } -maskdata $filemask
902 image create bitmap file_mod
-background white
-foreground blue
-data {
904 #define mod_height 15
905 static unsigned char mod_bits
[] = {
906 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
907 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
908 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
909 } -maskdata $filemask
911 image create bitmap file_fulltick
-background white
-foreground "#007000" -data {
912 #define file_fulltick_width 14
913 #define file_fulltick_height 15
914 static unsigned char file_fulltick_bits
[] = {
915 0xfe, 0x01, 0x02, 0x1a, 0x02, 0x0c, 0x02, 0x0c, 0x02, 0x16, 0x02, 0x16,
916 0x02, 0x13, 0x00, 0x13, 0x86, 0x11, 0x8c, 0x11, 0xd8, 0x10, 0xf2, 0x10,
917 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
918 } -maskdata $filemask
920 image create bitmap file_parttick
-background white
-foreground "#005050" -data {
921 #define parttick_width 14
922 #define parttick_height 15
923 static unsigned char parttick_bits
[] = {
924 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
925 0x7a, 0x14, 0x02, 0x16, 0x02, 0x13, 0x8a, 0x11, 0xda, 0x10, 0x72, 0x10,
926 0x22, 0x10, 0x02, 0x10, 0xfe, 0x1f};
927 } -maskdata $filemask
929 image create bitmap file_question
-background white
-foreground black
-data {
930 #define file_question_width 14
931 #define file_question_height 15
932 static unsigned char file_question_bits
[] = {
933 0xfe, 0x01, 0x02, 0x02, 0xe2, 0x04, 0xf2, 0x09, 0x1a, 0x1b, 0x0a, 0x13,
934 0x82, 0x11, 0xc2, 0x10, 0x62, 0x10, 0x62, 0x10, 0x02, 0x10, 0x62, 0x10,
935 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
936 } -maskdata $filemask
938 image create bitmap file_removed
-background white
-foreground red
-data {
939 #define file_removed_width 14
940 #define file_removed_height 15
941 static unsigned char file_removed_bits
[] = {
942 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
943 0x1a, 0x16, 0x32, 0x13, 0xe2, 0x11, 0xc2, 0x10, 0xe2, 0x11, 0x32, 0x13,
944 0x1a, 0x16, 0x02, 0x10, 0xfe, 0x1f};
945 } -maskdata $filemask
947 image create bitmap file_merge
-background white
-foreground blue
-data {
948 #define file_merge_width 14
949 #define file_merge_height 15
950 static unsigned char file_merge_bits
[] = {
951 0xfe, 0x01, 0x02, 0x03, 0x62, 0x05, 0x62, 0x09, 0x62, 0x1f, 0x62, 0x10,
952 0xfa, 0x11, 0xf2, 0x10, 0x62, 0x10, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
953 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
954 } -maskdata $filemask
957 #define file_width 18
958 #define file_height 18
959 static unsigned char file_bits
[] = {
960 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0x00,
961 0x0c, 0x03, 0x00, 0x04, 0xfe, 0x00, 0x06, 0x80, 0x00, 0xff, 0x9f, 0x00,
962 0x03, 0x98, 0x00, 0x02, 0x90, 0x00, 0x06, 0xb0, 0x00, 0x04, 0xa0, 0x00,
963 0x0c, 0xe0, 0x00, 0x08, 0xc0, 0x00, 0xf8, 0xff, 0x00, 0x00, 0x00, 0x00,
964 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
966 image create bitmap file_dir
-background white
-foreground blue \
967 -data $file_dir_data -maskdata $file_dir_data
970 set file_uplevel_data
{
973 static unsigned char up_bits
[] = {
974 0x80, 0x00, 0xc0, 0x01, 0xe0, 0x03, 0xf0, 0x07, 0xf8, 0x0f, 0xfc, 0x1f,
975 0xfe, 0x3f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
976 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00};
978 image create bitmap file_uplevel
-background white
-foreground red \
979 -data $file_uplevel_data -maskdata $file_uplevel_data
980 unset file_uplevel_data
982 set ui_index .vpane.files.index.list
983 set ui_workdir .vpane.files.workdir.list
985 set all_icons
(_
$ui_index) file_plain
986 set all_icons
(A
$ui_index) file_fulltick
987 set all_icons
(M
$ui_index) file_fulltick
988 set all_icons
(D
$ui_index) file_removed
989 set all_icons
(U
$ui_index) file_merge
991 set all_icons
(_
$ui_workdir) file_plain
992 set all_icons
(M
$ui_workdir) file_mod
993 set all_icons
(D
$ui_workdir) file_question
994 set all_icons
(U
$ui_workdir) file_merge
995 set all_icons
(O
$ui_workdir) file_plain
997 set max_status_desc
0
1001 {_M
"Modified, not staged"}
1002 {M_
"Staged for commit"}
1003 {MM
"Portions staged for commit"}
1004 {MD
"Staged for commit, missing"}
1006 {_O
"Untracked, not staged"}
1007 {A_
"Staged for commit"}
1008 {AM
"Portions staged for commit"}
1009 {AD
"Staged for commit, missing"}
1012 {D_
"Staged for removal"}
1013 {DO
"Staged for removal, still present"}
1015 {U_
"Requires merge resolution"}
1016 {UU
"Requires merge resolution"}
1017 {UM
"Requires merge resolution"}
1018 {UD
"Requires merge resolution"}
1020 if {$max_status_desc < [string length
[lindex
$i 1]]} {
1021 set max_status_desc
[string length
[lindex
$i 1]]
1023 set all_descs
([lindex
$i 0]) [lindex
$i 1]
1027 ######################################################################
1031 proc bind_button3
{w cmd
} {
1032 bind $w <Any-Button-3
> $cmd
1034 bind $w <Control-Button-1
> $cmd
1038 proc scrollbar2many
{list mode args
} {
1039 foreach w
$list {eval $w $mode $args}
1042 proc many2scrollbar
{list mode sb top bottom
} {
1043 $sb set $top $bottom
1044 foreach w
$list {$w $mode moveto
$top}
1047 proc incr_font_size
{font
{amt
1}} {
1048 set sz
[font configure
$font -size]
1050 font configure
$font -size $sz
1051 font configure
${font}bold
-size $sz
1052 font configure
${font}italic
-size $sz
1055 ######################################################################
1059 set starting_gitk_msg
{Starting gitk... please
wait...
}
1061 proc do_gitk
{revs
} {
1062 global env ui_status_value starting_gitk_msg
1064 # -- Always start gitk through whatever we were loaded with. This
1065 # lets us bypass using shell process on Windows systems.
1067 set cmd
[list
[info nameofexecutable
]]
1068 lappend cmd
[gitexec gitk
]
1074 if {[catch
{eval exec $cmd &} err
]} {
1075 error_popup
"Failed to start gitk:\n\n$err"
1077 set ui_status_value
$starting_gitk_msg
1079 if {$ui_status_value eq
$starting_gitk_msg} {
1080 set ui_status_value
{Ready.
}
1089 global ui_comm is_quitting repo_config commit_type
1091 if {$is_quitting} return
1094 if {[winfo exists
$ui_comm]} {
1095 # -- Stash our current commit buffer.
1097 set save
[gitdir GITGUI_MSG
]
1098 set msg
[string trim
[$ui_comm get
0.0 end
]]
1099 regsub
-all -line {[ \r\t]+$
} $msg {} msg
1100 if {(![string match amend
* $commit_type]
1101 ||
[$ui_comm edit modified
])
1104 set fd
[open
$save w
]
1105 puts
-nonewline $fd $msg
1109 catch
{file delete
$save}
1112 # -- Stash our current window geometry into this repository.
1114 set cfg_geometry
[list
]
1115 lappend cfg_geometry
[wm geometry .
]
1116 lappend cfg_geometry
[lindex
[.vpane sash coord
0] 1]
1117 lappend cfg_geometry
[lindex
[.vpane.files sash coord
0] 0]
1118 if {[catch
{set rc_geometry
$repo_config(gui.geometry
)}]} {
1121 if {$cfg_geometry ne
$rc_geometry} {
1122 catch
{git config gui.geometry
$cfg_geometry}
1130 rescan
{set ui_status_value
{Ready.
}}
1137 proc toggle_or_diff
{w x y
} {
1138 global file_states file_lists current_diff_path ui_index ui_workdir
1139 global last_clicked selected_paths
1141 set pos
[split [$w index @
$x,$y] .
]
1142 set lno
[lindex
$pos 0]
1143 set col [lindex
$pos 1]
1144 set path
[lindex
$file_lists($w) [expr {$lno - 1}]]
1150 set last_clicked
[list
$w $lno]
1151 array
unset selected_paths
1152 $ui_index tag remove in_sel
0.0 end
1153 $ui_workdir tag remove in_sel
0.0 end
1156 if {$current_diff_path eq
$path} {
1157 set after
{reshow_diff
;}
1161 if {$w eq
$ui_index} {
1163 "Unstaging [short_path $path] from commit" \
1165 [concat
$after {set ui_status_value
{Ready.
}}]
1166 } elseif
{$w eq
$ui_workdir} {
1168 "Adding [short_path $path]" \
1170 [concat
$after {set ui_status_value
{Ready.
}}]
1173 show_diff
$path $w $lno
1177 proc add_one_to_selection
{w x y
} {
1178 global file_lists last_clicked selected_paths
1180 set lno
[lindex
[split [$w index @
$x,$y] .
] 0]
1181 set path
[lindex
$file_lists($w) [expr {$lno - 1}]]
1187 if {$last_clicked ne
{}
1188 && [lindex
$last_clicked 0] ne
$w} {
1189 array
unset selected_paths
1190 [lindex
$last_clicked 0] tag remove in_sel
0.0 end
1193 set last_clicked
[list
$w $lno]
1194 if {[catch
{set in_sel
$selected_paths($path)}]} {
1198 unset selected_paths
($path)
1199 $w tag remove in_sel
$lno.0 [expr {$lno + 1}].0
1201 set selected_paths
($path) 1
1202 $w tag add in_sel
$lno.0 [expr {$lno + 1}].0
1206 proc add_range_to_selection
{w x y
} {
1207 global file_lists last_clicked selected_paths
1209 if {[lindex
$last_clicked 0] ne
$w} {
1210 toggle_or_diff
$w $x $y
1214 set lno
[lindex
[split [$w index @
$x,$y] .
] 0]
1215 set lc
[lindex
$last_clicked 1]
1224 foreach path
[lrange
$file_lists($w) \
1225 [expr {$begin - 1}] \
1226 [expr {$end - 1}]] {
1227 set selected_paths
($path) 1
1229 $w tag add in_sel
$begin.0 [expr {$end + 1}].0
1232 ######################################################################
1236 set cursor_ptr arrow
1237 font create font_diff
-family Courier
-size 10
1241 eval font configure font_ui
[font actual
[.dummy cget
-font]]
1245 font create font_uiitalic
1246 font create font_uibold
1247 font create font_diffbold
1248 font create font_diffitalic
1250 foreach class
{Button Checkbutton Entry Label
1251 Labelframe Listbox Menu Message
1252 Radiobutton Spinbox Text
} {
1253 option add
*$class.font font_ui
1257 if {[is_Windows
] ||
[is_MacOSX
]} {
1258 option add
*Menu.tearOff
0
1269 proc apply_config
{} {
1270 global repo_config font_descs
1272 foreach option
$font_descs {
1273 set name
[lindex
$option 0]
1274 set font
[lindex
$option 1]
1276 foreach
{cn cv
} $repo_config(gui.
$name) {
1277 font configure
$font $cn $cv
1280 error_popup
"Invalid font specified in gui.$name:\n\n$err"
1282 foreach
{cn cv
} [font configure
$font] {
1283 font configure
${font}bold
$cn $cv
1284 font configure
${font}italic
$cn $cv
1286 font configure
${font}bold
-weight bold
1287 font configure
${font}italic
-slant italic
1291 set default_config
(merge.diffstat
) true
1292 set default_config
(merge.summary
) false
1293 set default_config
(merge.verbosity
) 2
1294 set default_config
(user.name
) {}
1295 set default_config
(user.email
) {}
1297 set default_config
(gui.pruneduringfetch
) false
1298 set default_config
(gui.trustmtime
) false
1299 set default_config
(gui.diffcontext
) 5
1300 set default_config
(gui.newbranchtemplate
) {}
1301 set default_config
(gui.fontui
) [font configure font_ui
]
1302 set default_config
(gui.fontdiff
) [font configure font_diff
]
1304 {fontui font_ui
{Main Font
}}
1305 {fontdiff font_diff
{Diff
/Console Font
}}
1310 ######################################################################
1312 ## feature option selection
1314 if {[regexp
{^git-
(.
+)$
} [appname
] _junk subcommand
]} {
1319 if {$subcommand eq
{gui.sh
}} {
1322 if {$subcommand eq
{gui
} && [llength
$argv] > 0} {
1323 set subcommand
[lindex
$argv 0]
1324 set argv
[lrange
$argv 1 end
]
1327 enable_option multicommit
1328 enable_option branch
1329 enable_option transport
1331 switch
-- $subcommand {
1334 disable_option multicommit
1335 disable_option branch
1336 disable_option transport
1339 enable_option singlecommit
1341 disable_option multicommit
1342 disable_option branch
1343 disable_option transport
1347 ######################################################################
1355 menu .mbar
-tearoff 0
1356 .mbar add cascade
-label Repository
-menu .mbar.repository
1357 .mbar add cascade
-label Edit
-menu .mbar.edit
1358 if {[is_enabled branch
]} {
1359 .mbar add cascade
-label Branch
-menu .mbar.branch
1361 if {[is_enabled multicommit
] ||
[is_enabled singlecommit
]} {
1362 .mbar add cascade
-label Commit
-menu .mbar.commit
1364 if {[is_enabled transport
]} {
1365 .mbar add cascade
-label Merge
-menu .mbar.merge
1366 .mbar add cascade
-label Fetch
-menu .mbar.fetch
1367 .mbar add cascade
-label Push
-menu .mbar.push
1369 . configure
-menu .mbar
1371 # -- Repository Menu
1373 menu .mbar.repository
1375 .mbar.repository add
command \
1376 -label {Browse Current Branch
} \
1377 -command {browser
::new
$current_branch}
1378 trace add variable current_branch
write ".mbar.repository entryconf [.mbar.repository index last] -label \"Browse \$current_branch\" ;#"
1379 .mbar.repository add separator
1381 .mbar.repository add
command \
1382 -label {Visualize Current Branch
} \
1383 -command {do_gitk
$current_branch}
1384 trace add variable current_branch
write ".mbar.repository entryconf [.mbar.repository index last] -label \"Visualize \$current_branch\" ;#"
1385 .mbar.repository add
command \
1386 -label {Visualize All Branches
} \
1387 -command {do_gitk
--all}
1388 .mbar.repository add separator
1390 if {[is_enabled multicommit
]} {
1391 .mbar.repository add
command -label {Database Statistics
} \
1394 .mbar.repository add
command -label {Compress Database
} \
1397 .mbar.repository add
command -label {Verify Database
} \
1398 -command do_fsck_objects
1400 .mbar.repository add separator
1403 .mbar.repository add
command \
1404 -label {Create Desktop Icon
} \
1405 -command do_cygwin_shortcut
1406 } elseif
{[is_Windows
]} {
1407 .mbar.repository add
command \
1408 -label {Create Desktop Icon
} \
1409 -command do_windows_shortcut
1410 } elseif
{[is_MacOSX
]} {
1411 .mbar.repository add
command \
1412 -label {Create Desktop Icon
} \
1413 -command do_macosx_app
1417 .mbar.repository add
command -label Quit \
1424 .mbar.edit add
command -label Undo \
1425 -command {catch
{[focus
] edit undo
}} \
1427 .mbar.edit add
command -label Redo \
1428 -command {catch
{[focus
] edit redo
}} \
1430 .mbar.edit add separator
1431 .mbar.edit add
command -label Cut \
1432 -command {catch
{tk_textCut
[focus
]}} \
1434 .mbar.edit add
command -label Copy \
1435 -command {catch
{tk_textCopy
[focus
]}} \
1437 .mbar.edit add
command -label Paste \
1438 -command {catch
{tk_textPaste
[focus
]; [focus
] see insert
}} \
1440 .mbar.edit add
command -label Delete \
1441 -command {catch
{[focus
] delete sel.first sel.last
}} \
1443 .mbar.edit add separator
1444 .mbar.edit add
command -label {Select All
} \
1445 -command {catch
{[focus
] tag add sel
0.0 end
}} \
1450 if {[is_enabled branch
]} {
1453 .mbar.branch add
command -label {Create...
} \
1454 -command do_create_branch \
1456 lappend disable_on_lock
[list .mbar.branch entryconf \
1457 [.mbar.branch index last
] -state]
1459 .mbar.branch add
command -label {Rename...
} \
1460 -command branch_rename
::dialog
1461 lappend disable_on_lock
[list .mbar.branch entryconf \
1462 [.mbar.branch index last
] -state]
1464 .mbar.branch add
command -label {Delete...
} \
1465 -command do_delete_branch
1466 lappend disable_on_lock
[list .mbar.branch entryconf \
1467 [.mbar.branch index last
] -state]
1469 .mbar.branch add
command -label {Reset...
} \
1470 -command merge
::reset_hard
1471 lappend disable_on_lock
[list .mbar.branch entryconf \
1472 [.mbar.branch index last
] -state]
1477 if {[is_enabled multicommit
] ||
[is_enabled singlecommit
]} {
1480 .mbar.commit add radiobutton \
1481 -label {New Commit
} \
1482 -command do_select_commit_type \
1483 -variable selected_commit_type \
1485 lappend disable_on_lock \
1486 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1488 .mbar.commit add radiobutton \
1489 -label {Amend Last Commit
} \
1490 -command do_select_commit_type \
1491 -variable selected_commit_type \
1493 lappend disable_on_lock \
1494 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1496 .mbar.commit add separator
1498 .mbar.commit add
command -label Rescan \
1499 -command do_rescan \
1501 lappend disable_on_lock \
1502 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1504 .mbar.commit add
command -label {Add To Commit
} \
1505 -command do_add_selection
1506 lappend disable_on_lock \
1507 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1509 .mbar.commit add
command -label {Add Existing To Commit
} \
1510 -command do_add_all \
1512 lappend disable_on_lock \
1513 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1515 .mbar.commit add
command -label {Unstage From Commit
} \
1516 -command do_unstage_selection
1517 lappend disable_on_lock \
1518 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1520 .mbar.commit add
command -label {Revert Changes
} \
1521 -command do_revert_selection
1522 lappend disable_on_lock \
1523 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1525 .mbar.commit add separator
1527 .mbar.commit add
command -label {Sign Off
} \
1528 -command do_signoff \
1531 .mbar.commit add
command -label Commit \
1532 -command do_commit \
1533 -accelerator $M1T-Return
1534 lappend disable_on_lock \
1535 [list .mbar.commit entryconf
[.mbar.commit index last
] -state]
1540 if {[is_enabled branch
]} {
1542 .mbar.merge add
command -label {Local Merge...
} \
1543 -command merge
::dialog
1544 lappend disable_on_lock \
1545 [list .mbar.merge entryconf
[.mbar.merge index last
] -state]
1546 .mbar.merge add
command -label {Abort Merge...
} \
1547 -command merge
::reset_hard
1548 lappend disable_on_lock \
1549 [list .mbar.merge entryconf
[.mbar.merge index last
] -state]
1555 if {[is_enabled transport
]} {
1559 .mbar.push add
command -label {Push...
} \
1560 -command do_push_anywhere
1561 .mbar.push add
command -label {Delete...
} \
1562 -command remote_branch_delete
::dialog
1566 # -- Apple Menu (Mac OS X only)
1568 .mbar add cascade
-label Apple
-menu .mbar.apple
1571 .mbar.apple add
command -label "About [appname]" \
1573 .mbar.apple add
command -label "Options..." \
1578 .mbar.edit add separator
1579 .mbar.edit add
command -label {Options...
} \
1584 if {[is_Cygwin
] && [file exists
/usr
/local
/miga
/lib
/gui-miga
]} {
1586 global ui_status_value
1587 if {![lock_index update
]} return
1588 set cmd
[list sh
--login -c "/usr/local/miga/lib/gui-miga \"[pwd]\""]
1589 set miga_fd
[open
"|$cmd" r
]
1590 fconfigure
$miga_fd -blocking 0
1591 fileevent
$miga_fd readable
[list miga_done
$miga_fd]
1592 set ui_status_value
{Running miga...
}
1594 proc miga_done
{fd
} {
1599 rescan
[list
set ui_status_value
{Ready.
}]
1602 .mbar add cascade
-label Tools
-menu .mbar.tools
1604 .mbar.tools add
command -label "Migrate" \
1606 lappend disable_on_lock \
1607 [list .mbar.tools entryconf
[.mbar.tools index last
] -state]
1613 .mbar add cascade
-label Help
-menu .mbar.
help
1617 .mbar.
help add
command -label "About [appname]" \
1622 catch
{set browser
$repo_config(instaweb.browser
)}
1623 set doc_path
[file dirname [gitexec
]]
1624 set doc_path
[file join $doc_path Documentation index.html
]
1627 set doc_path
[exec cygpath
--mixed $doc_path]
1630 if {$browser eq
{}} {
1633 } elseif
{[is_Cygwin
]} {
1634 set program_files
[file dirname [exec cygpath
--windir]]
1635 set program_files
[file join $program_files {Program Files
}]
1636 set firefox
[file join $program_files {Mozilla Firefox
} firefox.exe
]
1637 set ie
[file join $program_files {Internet Explorer
} IEXPLORE.EXE
]
1638 if {[file exists
$firefox]} {
1639 set browser
$firefox
1640 } elseif
{[file exists
$ie]} {
1643 unset program_files firefox ie
1647 if {[file isfile
$doc_path]} {
1648 set doc_url
"file:$doc_path"
1650 set doc_url
{http
://www.kernel.org
/pub
/software
/scm
/git
/docs
/}
1653 if {$browser ne
{}} {
1654 .mbar.
help add
command -label {Online Documentation
} \
1655 -command [list
exec $browser $doc_url &]
1657 unset browser doc_path doc_url
1659 # -- Standard bindings
1661 wm protocol . WM_DELETE_WINDOW do_quit
1662 bind all
<$M1B-Key-q> do_quit
1663 bind all
<$M1B-Key-Q> do_quit
1664 bind all
<$M1B-Key-w> {destroy
[winfo toplevel
%W
]}
1665 bind all
<$M1B-Key-W> {destroy
[winfo toplevel
%W
]}
1667 set subcommand_args
{}
1669 puts stderr
"usage: $::argv0 $::subcommand $::subcommand_args"
1673 # -- Not a normal commit type invocation? Do that instead!
1675 switch
-- $subcommand {
1677 set subcommand_args
{rev?
}
1678 switch
[llength
$argv] {
1679 0 { set current_branch
[current-branch
] }
1680 1 { set current_branch
[lindex
$argv 0] }
1683 browser
::new
$current_branch
1687 set subcommand_args
{rev? path?
}
1692 if {$is_path ||
[file exists
$_prefix$a]} {
1693 if {$path ne
{}} usage
1696 } elseif
{$a eq
{--}} {
1698 if {$head ne
{}} usage
1703 } elseif
{$head eq
{}} {
1704 if {$head ne
{}} usage
1713 set current_branch
[current-branch
]
1715 set current_branch
$head
1718 if {$path eq
{}} usage
1719 blame
::new
$head $path
1724 if {[llength
$argv] != 0} {
1725 puts
-nonewline stderr
"usage: $argv0"
1726 if {$subcommand ne
{gui
} && [appname
] ne
"git-$subcommand"} {
1727 puts
-nonewline stderr
" $subcommand"
1732 # fall through to setup UI for commits
1735 puts stderr
"usage: $argv0 \[{blame|browser|citool}\]"
1746 -text {Current Branch
:} \
1750 -textvariable current_branch \
1753 pack .branch.l1
-side left
1754 pack .branch.cb
-side left
-fill x
1755 pack .branch
-side top
-fill x
1757 # -- Main Window Layout
1759 panedwindow .vpane
-orient vertical
1760 panedwindow .vpane.files
-orient horizontal
1761 .vpane add .vpane.files
-sticky nsew
-height 100 -width 200
1762 pack .vpane
-anchor n
-side top
-fill both
-expand 1
1764 # -- Index File List
1766 frame .vpane.files.index
-height 100 -width 200
1767 label .vpane.files.index.title
-text {Staged Changes
(Will Be Committed
)} \
1768 -background lightgreen
1769 text
$ui_index -background white
-borderwidth 0 \
1770 -width 20 -height 10 \
1772 -cursor $cursor_ptr \
1773 -xscrollcommand {.vpane.files.index.sx
set} \
1774 -yscrollcommand {.vpane.files.index.sy
set} \
1776 scrollbar .vpane.files.index.sx
-orient h
-command [list
$ui_index xview
]
1777 scrollbar .vpane.files.index.sy
-orient v
-command [list
$ui_index yview
]
1778 pack .vpane.files.index.title
-side top
-fill x
1779 pack .vpane.files.index.sx
-side bottom
-fill x
1780 pack .vpane.files.index.sy
-side right
-fill y
1781 pack
$ui_index -side left
-fill both
-expand 1
1782 .vpane.files add .vpane.files.index
-sticky nsew
1784 # -- Working Directory File List
1786 frame .vpane.files.workdir
-height 100 -width 200
1787 label .vpane.files.workdir.title
-text {Unstaged Changes
(Will Not Be Committed
)} \
1788 -background lightsalmon
1789 text
$ui_workdir -background white
-borderwidth 0 \
1790 -width 20 -height 10 \
1792 -cursor $cursor_ptr \
1793 -xscrollcommand {.vpane.files.workdir.sx
set} \
1794 -yscrollcommand {.vpane.files.workdir.sy
set} \
1796 scrollbar .vpane.files.workdir.sx
-orient h
-command [list
$ui_workdir xview
]
1797 scrollbar .vpane.files.workdir.sy
-orient v
-command [list
$ui_workdir yview
]
1798 pack .vpane.files.workdir.title
-side top
-fill x
1799 pack .vpane.files.workdir.sx
-side bottom
-fill x
1800 pack .vpane.files.workdir.sy
-side right
-fill y
1801 pack
$ui_workdir -side left
-fill both
-expand 1
1802 .vpane.files add .vpane.files.workdir
-sticky nsew
1804 foreach i
[list
$ui_index $ui_workdir] {
1805 $i tag conf in_diff
-background lightgray
1806 $i tag conf in_sel
-background lightgray
1810 # -- Diff and Commit Area
1812 frame .vpane.lower
-height 300 -width 400
1813 frame .vpane.lower.commarea
1814 frame .vpane.lower.
diff -relief sunken
-borderwidth 1
1815 pack .vpane.lower.commarea
-side top
-fill x
1816 pack .vpane.lower.
diff -side bottom
-fill both
-expand 1
1817 .vpane add .vpane.lower
-sticky nsew
1819 # -- Commit Area Buttons
1821 frame .vpane.lower.commarea.buttons
1822 label .vpane.lower.commarea.buttons.l
-text {} \
1825 pack .vpane.lower.commarea.buttons.l
-side top
-fill x
1826 pack .vpane.lower.commarea.buttons
-side left
-fill y
1828 button .vpane.lower.commarea.buttons.rescan
-text {Rescan
} \
1830 pack .vpane.lower.commarea.buttons.rescan
-side top
-fill x
1831 lappend disable_on_lock \
1832 {.vpane.lower.commarea.buttons.rescan conf
-state}
1834 button .vpane.lower.commarea.buttons.incall
-text {Add Existing
} \
1836 pack .vpane.lower.commarea.buttons.incall
-side top
-fill x
1837 lappend disable_on_lock \
1838 {.vpane.lower.commarea.buttons.incall conf
-state}
1840 button .vpane.lower.commarea.buttons.signoff
-text {Sign Off
} \
1842 pack .vpane.lower.commarea.buttons.signoff
-side top
-fill x
1844 button .vpane.lower.commarea.buttons.commit
-text {Commit
} \
1846 pack .vpane.lower.commarea.buttons.commit
-side top
-fill x
1847 lappend disable_on_lock \
1848 {.vpane.lower.commarea.buttons.commit conf
-state}
1850 # -- Commit Message Buffer
1852 frame .vpane.lower.commarea.buffer
1853 frame .vpane.lower.commarea.buffer.header
1854 set ui_comm .vpane.lower.commarea.buffer.t
1855 set ui_coml .vpane.lower.commarea.buffer.header.l
1856 radiobutton .vpane.lower.commarea.buffer.header.new \
1857 -text {New Commit
} \
1858 -command do_select_commit_type \
1859 -variable selected_commit_type \
1861 lappend disable_on_lock \
1862 [list .vpane.lower.commarea.buffer.header.new conf
-state]
1863 radiobutton .vpane.lower.commarea.buffer.header.amend \
1864 -text {Amend Last Commit
} \
1865 -command do_select_commit_type \
1866 -variable selected_commit_type \
1868 lappend disable_on_lock \
1869 [list .vpane.lower.commarea.buffer.header.amend conf
-state]
1873 proc trace_commit_type
{varname args
} {
1874 global ui_coml commit_type
1875 switch
-glob -- $commit_type {
1876 initial
{set txt
{Initial Commit Message
:}}
1877 amend
{set txt
{Amended Commit Message
:}}
1878 amend-initial
{set txt
{Amended Initial Commit Message
:}}
1879 amend-merge
{set txt
{Amended Merge Commit Message
:}}
1880 merge
{set txt
{Merge Commit Message
:}}
1881 * {set txt
{Commit Message
:}}
1883 $ui_coml conf
-text $txt
1885 trace add variable commit_type
write trace_commit_type
1886 pack
$ui_coml -side left
-fill x
1887 pack .vpane.lower.commarea.buffer.header.amend
-side right
1888 pack .vpane.lower.commarea.buffer.header.new
-side right
1890 text
$ui_comm -background white
-borderwidth 1 \
1893 -autoseparators true \
1895 -width 75 -height 9 -wrap none \
1897 -yscrollcommand {.vpane.lower.commarea.buffer.sby
set}
1898 scrollbar .vpane.lower.commarea.buffer.sby \
1899 -command [list
$ui_comm yview
]
1900 pack .vpane.lower.commarea.buffer.header
-side top
-fill x
1901 pack .vpane.lower.commarea.buffer.sby
-side right
-fill y
1902 pack
$ui_comm -side left
-fill y
1903 pack .vpane.lower.commarea.buffer
-side left
-fill y
1905 # -- Commit Message Buffer Context Menu
1907 set ctxm .vpane.lower.commarea.buffer.ctxm
1908 menu
$ctxm -tearoff 0
1911 -command {tk_textCut
$ui_comm}
1914 -command {tk_textCopy
$ui_comm}
1917 -command {tk_textPaste
$ui_comm}
1920 -command {$ui_comm delete sel.first sel.last
}
1923 -label {Select All
} \
1924 -command {focus
$ui_comm;$ui_comm tag add sel
0.0 end
}
1928 $ui_comm tag add sel
0.0 end
1929 tk_textCopy
$ui_comm
1930 $ui_comm tag remove sel
0.0 end
1936 bind_button3
$ui_comm "tk_popup $ctxm %X %Y"
1940 proc trace_current_diff_path
{varname args
} {
1941 global current_diff_path diff_actions file_states
1942 if {$current_diff_path eq
{}} {
1948 set p
$current_diff_path
1949 set s
[mapdesc
[lindex
$file_states($p) 0] $p]
1951 set p
[escape_path
$p]
1955 .vpane.lower.
diff.header.status configure
-text $s
1956 .vpane.lower.
diff.header.
file configure
-text $f
1957 .vpane.lower.
diff.header.path configure
-text $p
1958 foreach w
$diff_actions {
1962 trace add variable current_diff_path
write trace_current_diff_path
1964 frame .vpane.lower.
diff.header
-background gold
1965 label .vpane.lower.
diff.header.status \
1967 -width $max_status_desc \
1970 label .vpane.lower.
diff.header.
file \
1974 label .vpane.lower.
diff.header.path \
1978 pack .vpane.lower.
diff.header.status
-side left
1979 pack .vpane.lower.
diff.header.
file -side left
1980 pack .vpane.lower.
diff.header.path
-fill x
1981 set ctxm .vpane.lower.
diff.header.ctxm
1982 menu
$ctxm -tearoff 0
1990 -- $current_diff_path
1992 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
1993 bind_button3 .vpane.lower.
diff.header.path
"tk_popup $ctxm %X %Y"
1997 frame .vpane.lower.
diff.body
1998 set ui_diff .vpane.lower.
diff.body.t
1999 text
$ui_diff -background white
-borderwidth 0 \
2000 -width 80 -height 15 -wrap none \
2002 -xscrollcommand {.vpane.lower.
diff.body.sbx
set} \
2003 -yscrollcommand {.vpane.lower.
diff.body.sby
set} \
2005 scrollbar .vpane.lower.
diff.body.sbx
-orient horizontal \
2006 -command [list
$ui_diff xview
]
2007 scrollbar .vpane.lower.
diff.body.sby
-orient vertical \
2008 -command [list
$ui_diff yview
]
2009 pack .vpane.lower.
diff.body.sbx
-side bottom
-fill x
2010 pack .vpane.lower.
diff.body.sby
-side right
-fill y
2011 pack
$ui_diff -side left
-fill both
-expand 1
2012 pack .vpane.lower.
diff.header
-side top
-fill x
2013 pack .vpane.lower.
diff.body
-side bottom
-fill both
-expand 1
2015 $ui_diff tag conf d_cr
-elide true
2016 $ui_diff tag conf d_@
-foreground blue
-font font_diffbold
2017 $ui_diff tag conf d_
+ -foreground {#00a000}
2018 $ui_diff tag conf d_-
-foreground red
2020 $ui_diff tag conf d_
++ -foreground {#00a000}
2021 $ui_diff tag conf d_--
-foreground red
2022 $ui_diff tag conf d_
+s \
2023 -foreground {#00a000} \
2024 -background {#e2effa}
2025 $ui_diff tag conf d_-s \
2027 -background {#e2effa}
2028 $ui_diff tag conf d_s
+ \
2029 -foreground {#00a000} \
2031 $ui_diff tag conf d_s- \
2035 $ui_diff tag conf d
<<<<<<< \
2036 -foreground orange \
2038 $ui_diff tag conf d
======= \
2039 -foreground orange \
2041 $ui_diff tag conf d
>>>>>>> \
2042 -foreground orange \
2045 $ui_diff tag raise sel
2047 # -- Diff Body Context Menu
2049 set ctxm .vpane.lower.
diff.body.ctxm
2050 menu
$ctxm -tearoff 0
2053 -command reshow_diff
2054 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2057 -command {tk_textCopy
$ui_diff}
2058 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2060 -label {Select All
} \
2061 -command {focus
$ui_diff;$ui_diff tag add sel
0.0 end
}
2062 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2066 $ui_diff tag add sel
0.0 end
2067 tk_textCopy
$ui_diff
2068 $ui_diff tag remove sel
0.0 end
2070 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2073 -label {Apply
/Reverse Hunk
} \
2074 -command {apply_hunk
$cursorX $cursorY}
2075 set ui_diff_applyhunk
[$ctxm index last
]
2076 lappend diff_actions
[list
$ctxm entryconf
$ui_diff_applyhunk -state]
2079 -label {Decrease Font Size
} \
2080 -command {incr_font_size font_diff
-1}
2081 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2083 -label {Increase Font Size
} \
2084 -command {incr_font_size font_diff
1}
2085 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2088 -label {Show Less Context
} \
2089 -command {if {$repo_config(gui.diffcontext
) >= 1} {
2090 incr repo_config
(gui.diffcontext
) -1
2093 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2095 -label {Show More Context
} \
2096 -command {if {$repo_config(gui.diffcontext
) < 99} {
2097 incr repo_config
(gui.diffcontext
)
2100 lappend diff_actions
[list
$ctxm entryconf
[$ctxm index last
] -state]
2102 $ctxm add
command -label {Options...
} \
2104 bind_button3
$ui_diff "
2107 if {\$ui_index eq \$current_diff_side} {
2108 $ctxm entryconf $ui_diff_applyhunk -label {Unstage Hunk From Commit}
2110 $ctxm entryconf $ui_diff_applyhunk -label {Stage Hunk For Commit}
2112 tk_popup $ctxm %X %Y
2114 unset ui_diff_applyhunk
2118 label .status
-textvariable ui_status_value \
2123 pack .status
-anchor w
-side bottom
-fill x
2128 set gm
$repo_config(gui.geometry
)
2129 wm geometry .
[lindex
$gm 0]
2130 .vpane sash place
0 \
2131 [lindex
[.vpane sash coord
0] 0] \
2133 .vpane.files sash place
0 \
2135 [lindex
[.vpane.files sash coord
0] 1]
2141 bind $ui_comm <$M1B-Key-Return> {do_commit
;break}
2142 bind $ui_comm <$M1B-Key-i> {do_add_all
;break}
2143 bind $ui_comm <$M1B-Key-I> {do_add_all
;break}
2144 bind $ui_comm <$M1B-Key-x> {tk_textCut
%W
;break}
2145 bind $ui_comm <$M1B-Key-X> {tk_textCut
%W
;break}
2146 bind $ui_comm <$M1B-Key-c> {tk_textCopy
%W
;break}
2147 bind $ui_comm <$M1B-Key-C> {tk_textCopy
%W
;break}
2148 bind $ui_comm <$M1B-Key-v> {tk_textPaste
%W
; %W see insert
; break}
2149 bind $ui_comm <$M1B-Key-V> {tk_textPaste
%W
; %W see insert
; break}
2150 bind $ui_comm <$M1B-Key-a> {%W tag add sel
0.0 end
;break}
2151 bind $ui_comm <$M1B-Key-A> {%W tag add sel
0.0 end
;break}
2153 bind $ui_diff <$M1B-Key-x> {tk_textCopy
%W
;break}
2154 bind $ui_diff <$M1B-Key-X> {tk_textCopy
%W
;break}
2155 bind $ui_diff <$M1B-Key-c> {tk_textCopy
%W
;break}
2156 bind $ui_diff <$M1B-Key-C> {tk_textCopy
%W
;break}
2157 bind $ui_diff <$M1B-Key-v> {break}
2158 bind $ui_diff <$M1B-Key-V> {break}
2159 bind $ui_diff <$M1B-Key-a> {%W tag add sel
0.0 end
;break}
2160 bind $ui_diff <$M1B-Key-A> {%W tag add sel
0.0 end
;break}
2161 bind $ui_diff <Key-Up
> {catch
{%W yview scroll
-1 units
};break}
2162 bind $ui_diff <Key-Down
> {catch
{%W yview scroll
1 units
};break}
2163 bind $ui_diff <Key-Left
> {catch
{%W xview scroll
-1 units
};break}
2164 bind $ui_diff <Key-Right
> {catch
{%W xview scroll
1 units
};break}
2165 bind $ui_diff <Key-k
> {catch
{%W yview scroll
-1 units
};break}
2166 bind $ui_diff <Key-j
> {catch
{%W yview scroll
1 units
};break}
2167 bind $ui_diff <Key-h
> {catch
{%W xview scroll
-1 units
};break}
2168 bind $ui_diff <Key-l
> {catch
{%W xview scroll
1 units
};break}
2169 bind $ui_diff <Control-Key-b
> {catch
{%W yview scroll
-1 pages
};break}
2170 bind $ui_diff <Control-Key-f
> {catch
{%W yview scroll
1 pages
};break}
2171 bind $ui_diff <Button-1
> {focus
%W
}
2173 if {[is_enabled branch
]} {
2174 bind .
<$M1B-Key-n> do_create_branch
2175 bind .
<$M1B-Key-N> do_create_branch
2178 bind all
<Key-F5
> do_rescan
2179 bind all
<$M1B-Key-r> do_rescan
2180 bind all
<$M1B-Key-R> do_rescan
2181 bind .
<$M1B-Key-s> do_signoff
2182 bind .
<$M1B-Key-S> do_signoff
2183 bind .
<$M1B-Key-i> do_add_all
2184 bind .
<$M1B-Key-I> do_add_all
2185 bind .
<$M1B-Key-Return> do_commit
2186 foreach i
[list
$ui_index $ui_workdir] {
2187 bind $i <Button-1
> "toggle_or_diff $i %x %y; break"
2188 bind $i <$M1B-Button-1> "add_one_to_selection $i %x %y; break"
2189 bind $i <Shift-Button-1
> "add_range_to_selection $i %x %y; break"
2193 set file_lists
($ui_index) [list
]
2194 set file_lists
($ui_workdir) [list
]
2196 wm title .
"[appname] ([reponame]) [file normalize [file dirname [gitdir]]]"
2197 focus
-force $ui_comm
2199 # -- Warn the user about environmental problems. Cygwin's Tcl
2200 # does *not* pass its env array onto any processes it spawns.
2201 # This means that git processes get none of our environment.
2206 set msg
"Possible environment issues exist.
2208 The following environment variables are probably
2209 going to be ignored by any Git subprocess run
2213 foreach name
[array names env
] {
2214 switch
-regexp -- $name {
2215 {^GIT_INDEX_FILE$
} -
2216 {^GIT_OBJECT_DIRECTORY$
} -
2217 {^GIT_ALTERNATE_OBJECT_DIRECTORIES$
} -
2219 {^GIT_EXTERNAL_DIFF$
} -
2223 {^GIT_CONFIG_LOCAL$
} -
2224 {^GIT_
(AUTHOR|COMMITTER
)_DATE$
} {
2225 append msg
" - $name\n"
2228 {^GIT_
(AUTHOR|COMMITTER
)_
(NAME|EMAIL
)$
} {
2229 append msg
" - $name\n"
2231 set suggest_user
$name
2235 if {$ignored_env > 0} {
2237 This is due to a known issue with the
2238 Tcl binary distributed by Cygwin."
2240 if {$suggest_user ne
{}} {
2243 A good replacement for $suggest_user
2244 is placing values for the user.name and
2245 user.email settings into your personal
2251 unset ignored_env msg suggest_user name
2254 # -- Only initialize complex UI if we are going to stay running.
2256 if {[is_enabled transport
]} {
2260 populate_branch_menu
2265 # -- Only suggest a gc run if we are going to stay running.
2267 if {[is_enabled multicommit
]} {
2268 set object_limit
2000
2269 if {[is_Windows
]} {set object_limit
200}
2270 regexp
{^
([0-9]+) objects
,} [git count-objects
] _junk objects_current
2271 if {$objects_current >= $object_limit} {
2273 "This repository currently has $objects_current loose objects.
2275 To maintain optimal performance it is strongly recommended that you compress the database when more than $object_limit loose objects exist.
2277 Compress the database now?"] eq
yes} {
2281 unset object_limit _junk objects_current
2284 lock_index begin-read