X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=git-gui.sh;h=0096f4913aa03bada1cfde879478926c5fe9ec06;hb=f8186e92e3399ddd742f2397e802467cabf2849f;hp=d640b143f31510f3a1de41444def5b71f0a47e4e;hpb=f60fdd0eaaaf92882f3e6aeb19bb85482fab6d39;p=git.git diff --git a/git-gui.sh b/git-gui.sh index d640b143f..0096f4913 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1,6 +1,12 @@ #!/bin/sh # Tcl ignores the next line -*- tcl -*- \ -exec wish "$0" -- "$@" + if test "z$*" = zversion \ + || test "z$*" = z--version; \ + then \ + echo 'git-gui version @@GITGUI_VERSION@@'; \ + exit; \ + fi; \ + exec wish "$0" -- "$@" set appvers {@@GITGUI_VERSION@@} set copyright { @@ -20,6 +26,22 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA} +###################################################################### +## +## Tcl/Tk sanity check + +if {[catch {package require Tcl 8.4} err] + || [catch {package require Tk 8.4} err] +} { + catch {wm withdraw .} + tk_messageBox \ + -icon error \ + -type ok \ + -title "git-gui: fatal error" \ + -message $err + exit 1 +} + ###################################################################### ## ## enable verbose loading? @@ -200,6 +222,15 @@ proc is_config_true {name} { } } +proc get_config {name} { + global repo_config + if {[catch {set v $repo_config($name)}]} { + return {} + } else { + return $v + } +} + proc load_config {include_global} { global repo_config global_config default_config @@ -253,6 +284,17 @@ proc git {args} { return [eval exec git $args] } +proc current-branch {} { + set ref {} + set fd [open [gitdir HEAD] r] + if {[gets $fd ref] <16 + || ![regsub {^ref: refs/heads/} $ref {} ref]} { + set ref {} + } + close $fd + return $ref +} + auto_load tk_optionMenu rename tk_optionMenu real__tkOptionMenu proc tk_optionMenu {w varName args} { @@ -266,11 +308,6 @@ proc tk_optionMenu {w varName args} { ## ## version check -if {{--version} eq $argv || {version} eq $argv} { - puts "git-gui version $appvers" - exit -} - set req_maj 1 set req_min 5 @@ -401,15 +438,7 @@ proc repository_state {ctvar hdvar mhvar} { set mh [list] - if {[catch {set current_branch [git symbolic-ref HEAD]}]} { - set current_branch {} - } else { - regsub ^refs/((heads|tags|remotes)/)? \ - $current_branch \ - {} \ - current_branch - } - + set current_branch [current-branch] if {[catch {set hd [git rev-parse --verify HEAD]}]} { set hd {} set ct initial @@ -466,7 +495,8 @@ proc rescan {after {honor_trustmtime 1}} { if {![$ui_comm edit modified] || [string trim [$ui_comm get 0.0 end]] eq {}} { - if {[load_message GITGUI_MSG]} { + if {[string match amend* $commit_type]} { + } elseif {[load_message GITGUI_MSG]} { } elseif {[load_message MERGE_MSG]} { } elseif {[load_message SQUASH_MSG]} { } @@ -1019,6 +1049,7 @@ proc incr_font_size {font {amt 1}} { incr sz $amt font configure $font -size $sz font configure ${font}bold -size $sz + font configure ${font}italic -size $sz } ###################################################################### @@ -1034,15 +1065,17 @@ proc do_gitk {revs} { # lets us bypass using shell process on Windows systems. # set cmd [list [info nameofexecutable]] - lappend cmd [gitexec gitk] + set exe [gitexec gitk] + lappend cmd $exe if {$revs ne {}} { append cmd { } append cmd $revs } - if {[catch {eval exec $cmd &} err]} { - error_popup "Failed to start gitk:\n\n$err" + if {! [file exists $exe]} { + error_popup "Unable to start gitk:\n\n$exe does not exist" } else { + eval exec $cmd & set ui_status_value $starting_gitk_msg after 10000 { if {$ui_status_value eq $starting_gitk_msg} { @@ -1211,12 +1244,14 @@ catch { destroy .dummy } +font create font_uiitalic font create font_uibold font create font_diffbold +font create font_diffitalic foreach class {Button Checkbutton Entry Label Labelframe Listbox Menu Message - Radiobutton Text} { + Radiobutton Spinbox Text} { option add *$class.font font_ui } unset class @@ -1248,11 +1283,14 @@ proc apply_config {} { } foreach {cn cv} [font configure $font] { font configure ${font}bold $cn $cv + font configure ${font}italic $cn $cv } font configure ${font}bold -weight bold + font configure ${font}italic -slant italic } } +set default_config(merge.diffstat) true set default_config(merge.summary) false set default_config(merge.verbosity) 2 set default_config(user.name) {} @@ -1420,6 +1458,11 @@ if {[is_enabled branch]} { lappend disable_on_lock [list .mbar.branch entryconf \ [.mbar.branch index last] -state] + .mbar.branch add command -label {Rename...} \ + -command branch_rename::dialog + lappend disable_on_lock [list .mbar.branch entryconf \ + [.mbar.branch index last] -state] + .mbar.branch add command -label {Delete...} \ -command do_delete_branch lappend disable_on_lock [list .mbar.branch entryconf \ @@ -1516,7 +1559,10 @@ if {[is_enabled transport]} { menu .mbar.push .mbar.push add command -label {Push...} \ - -command do_push_anywhere + -command do_push_anywhere \ + -accelerator $M1T-P + .mbar.push add command -label {Delete...} \ + -command remote_branch_delete::dialog } if {[is_MacOSX]} { @@ -1538,8 +1584,7 @@ if {[is_MacOSX]} { # -- Tools Menu # - if {[file exists /usr/local/miga/lib/gui-miga] - && [file exists .pvcsrc]} { + if {[is_Cygwin] && [file exists /usr/local/miga/lib/gui-miga]} { proc do_miga {} { global ui_status_value if {![lock_index update]} return @@ -1616,7 +1661,7 @@ unset browser doc_path doc_url # -- Standard bindings # -bind . do_quit +wm protocol . WM_DELETE_WINDOW do_quit bind all <$M1B-Key-q> do_quit bind all <$M1B-Key-Q> do_quit bind all <$M1B-Key-w> {destroy [winfo toplevel %W]} @@ -1634,14 +1679,8 @@ switch -- $subcommand { browser { set subcommand_args {rev?} switch [llength $argv] { - 0 { - set current_branch [git symbolic-ref HEAD] - regsub ^refs/((heads|tags|remotes)/)? \ - $current_branch {} current_branch - } - 1 { - set current_branch [lindex $argv 0] - } + 0 { set current_branch [current-branch] } + 1 { set current_branch [lindex $argv 0] } default usage } browser::new $current_branch @@ -1674,9 +1713,7 @@ blame { unset is_path if {$head eq {}} { - set current_branch [git symbolic-ref HEAD] - regsub ^refs/((heads|tags|remotes)/)? \ - $current_branch {} current_branch + set current_branch [current-branch] } else { set current_branch $head } @@ -1731,7 +1768,7 @@ pack .vpane -anchor n -side top -fill both -expand 1 # frame .vpane.files.index -height 100 -width 200 label .vpane.files.index.title -text {Staged Changes (Will Be Committed)} \ - -background green + -background lightgreen text $ui_index -background white -borderwidth 0 \ -width 20 -height 10 \ -wrap none \ @@ -1751,7 +1788,7 @@ pack $ui_index -side left -fill both -expand 1 # frame .vpane.files.workdir -height 100 -width 200 label .vpane.files.workdir.title -text {Unstaged Changes (Will Not Be Committed)} \ - -background red + -background lightsalmon text $ui_workdir -background white -borderwidth 0 \ -width 20 -height 10 \ -wrap none \ @@ -1768,10 +1805,8 @@ pack $ui_workdir -side left -fill both -expand 1 .vpane.files add .vpane.files.workdir -sticky nsew foreach i [list $ui_index $ui_workdir] { - $i tag conf in_diff -font font_uibold - $i tag conf in_sel \ - -background [$i cget -foreground] \ - -foreground [$i cget -background] + $i tag conf in_diff -background lightgray + $i tag conf in_sel -background lightgray } unset i @@ -1815,6 +1850,10 @@ pack .vpane.lower.commarea.buttons.commit -side top -fill x lappend disable_on_lock \ {.vpane.lower.commarea.buttons.commit conf -state} +button .vpane.lower.commarea.buttons.push -text {Push} \ + -command do_push_anywhere +pack .vpane.lower.commarea.buttons.push -side top -fill x + # -- Commit Message Buffer # frame .vpane.lower.commarea.buffer @@ -1929,18 +1968,18 @@ proc trace_current_diff_path {varname args} { } trace add variable current_diff_path write trace_current_diff_path -frame .vpane.lower.diff.header -background orange +frame .vpane.lower.diff.header -background gold label .vpane.lower.diff.header.status \ - -background orange \ + -background gold \ -width $max_status_desc \ -anchor w \ -justify left label .vpane.lower.diff.header.file \ - -background orange \ + -background gold \ -anchor w \ -justify left label .vpane.lower.diff.header.path \ - -background orange \ + -background gold \ -anchor w \ -justify left pack .vpane.lower.diff.header.status -side left @@ -2054,17 +2093,17 @@ lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state] $ctxm add separator $ctxm add command \ -label {Show Less Context} \ - -command {if {$repo_config(gui.diffcontext) >= 2} { + -command {if {$repo_config(gui.diffcontext) >= 1} { incr repo_config(gui.diffcontext) -1 reshow_diff }} lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state] $ctxm add command \ -label {Show More Context} \ - -command { + -command {if {$repo_config(gui.diffcontext) < 99} { incr repo_config(gui.diffcontext) reshow_diff - } + }} lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state] $ctxm add separator $ctxm add command -label {Options...} \ @@ -2142,10 +2181,14 @@ if {[is_enabled branch]} { bind . <$M1B-Key-n> do_create_branch bind . <$M1B-Key-N> do_create_branch } +if {[is_enabled transport]} { + bind . <$M1B-Key-p> do_push_anywhere + bind . <$M1B-Key-P> do_push_anywhere +} -bind all do_rescan -bind all <$M1B-Key-r> do_rescan -bind all <$M1B-Key-R> do_rescan +bind . do_rescan +bind . <$M1B-Key-r> do_rescan +bind . <$M1B-Key-R> do_rescan bind . <$M1B-Key-s> do_signoff bind . <$M1B-Key-S> do_signoff bind . <$M1B-Key-i> do_add_all