@matheusbsbs / matheus-bagliano / commits / 7b85a17b86
Fork 0

git-gui: Abstract out windows platform test to is_Windows proc.

Like the is_MacOSX proc we shouldn't keep repeating the platform test for Windows. Instead abstract the code out into a procedure and use the procedure whenever we need to do something special. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Nov 21, 2006 at 11:57 UTC 7b85a17b86062c87ceebbf70acfbd62e00cd4bac
1 file changed +20 -14
git-gui
+20 -14
@@ -891,14 +891,14 @@ A good commit message has the following format:
891 }
892
893 proc commit_prehook {curHEAD msg} {
894 - global tcl_platform gitdir ui_status_value pch_error
894 + global gitdir ui_status_value pch_error
895 +
896 + set pchook [file join $gitdir hooks pre-commit]
897
898 # On Cygwin [file executable] might lie so we need to ask
899 # the shell if the hook is executable. Yes that's annoying.
898 -
899 - set pchook [file join $gitdir hooks pre-commit]
900 - if {$tcl_platform(platform) eq {windows}
901 - && [file isfile $pchook]} {
900 + #
901 + if {[is_Windows] && [file isfile $pchook]} {
902 set pchook [list sh -c [concat \
903 "if test -x \"$pchook\";" \
904 "then exec \"$pchook\" 2>&1;" \
@@ -948,7 +948,7 @@ proc commit_writetree {curHEAD msg} {
948
949 proc commit_committree {fd_wt curHEAD msg} {
950 global HEAD PARENT MERGE_HEAD commit_type
951 - global single_commit gitdir tcl_platform
951 + global single_commit gitdir
952 global ui_status_value ui_comm selected_commit_type
953 global file_states selected_paths rescan_active
954
@@ -1016,7 +1016,7 @@ proc commit_committree {fd_wt curHEAD msg} {
1016 # -- Run the post-commit hook.
1017 #
1018 set pchook [file join $gitdir hooks post-commit]
1019 - if {$tcl_platform(platform) eq {windows} && [file isfile $pchook]} {
1019 + if {[is_Windows] && [file isfile $pchook]} {
1020 set pchook [list sh -c [concat \
1021 "if test -x \"$pchook\";" \
1022 "then exec \"$pchook\";" \
@@ -1724,6 +1724,14 @@ proc is_MacOSX {} {
1724 return 0
1725 }
1726
1727 +proc is_Windows {} {
1728 + global tcl_platform
1729 + if {$tcl_platform(platform) eq {windows}} {
1730 + return 1
1731 + }
1732 + return 0
1733 +}
1734 +
1735 proc bind_button3 {w cmd} {
1736 bind $w <Any-Button-3> $cmd
1737 if {[is_MacOSX]} {
@@ -1854,12 +1862,10 @@ proc console_init {w} {
1862 }
1863
1864 proc console_exec {w cmd {after {}}} {
1857 - global tcl_platform
1858 -
1865 # -- Windows tosses the enviroment when we exec our child.
1866 # But most users need that so we have to relogin. :-(
1867 #
1862 - if {$tcl_platform(platform) eq {windows}} {
1868 + if {[is_Windows]} {
1869 set cmd [list sh --login -c "cd \"[pwd]\" && [join $cmd { }]"]
1870 }
1871
@@ -1934,7 +1940,7 @@ proc console_read {w fd after} {
1940 set starting_gitk_msg {Please wait... Starting gitk...}
1941
1942 proc do_gitk {} {
1937 - global tcl_platform ui_status_value starting_gitk_msg
1943 + global ui_status_value starting_gitk_msg
1944
1945 set ui_status_value $starting_gitk_msg
1946 after 10000 {
@@ -1943,7 +1949,7 @@ proc do_gitk {} {
1949 }
1950 }
1951
1946 - if {$tcl_platform(platform) eq {windows}} {
1952 + if {[is_Windows]} {
1953 exec sh -c gitk &
1954 } else {
1955 exec gitk &
@@ -2613,7 +2619,7 @@ font create font_diffbold
2619
2620 set M1B M1
2621 set M1T M1
2616 -if {$tcl_platform(platform) eq {windows}} {
2622 +if {[is_Windows]} {
2623 set M1B Control
2624 set M1T Ctrl
2625 } elseif {[is_MacOSX]} {
@@ -2690,7 +2696,7 @@ if {!$single_commit} {
2696
2697 .mbar.repository add separator
2698
2693 - if {$tcl_platform(platform) eq {windows}} {
2699 + if {[is_Windows]} {
2700 .mbar.repository add command \
2701 -label {Create Desktop Icon} \
2702 -command do_windows_shortcut \