X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=git-gui.sh;h=c5f132993295d7f915255071b4005e44003d8c3a;hb=aa252f194b6a32240117ef339631f42842b6d5b4;hp=72673c627ab881731d07b97710eaf030a4420f7a;hpb=f522c9b5ed367172f969397589ae3d686b867ac0;p=git.git diff --git a/git-gui.sh b/git-gui.sh index 72673c627..c5f132993 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -22,13 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA} ###################################################################### ## -## configure our library - -set oguilib {@@GITGUI_LIBDIR@@} -if {[string match @@* $oguilib]} { - set oguilib [file join [file dirname [file normalize $argv0]] lib] -} -set auto_path [concat [list $oguilib] $auto_path] +## enable verbose loading? if {![catch {set _verbose $env(GITGUI_VERBOSE)}]} { unset _verbose @@ -44,6 +38,54 @@ if {![catch {set _verbose $env(GITGUI_VERBOSE)}]} { } } +###################################################################### +## +## configure our library + +set oguilib {@@GITGUI_LIBDIR@@} +set oguirel {@@GITGUI_RELATIVE@@} +if {$oguirel eq {1}} { + set oguilib [file dirname [file dirname [file normalize $argv0]]] + set oguilib [file join $oguilib share git-gui lib] +} elseif {[string match @@* $oguirel]} { + set oguilib [file join [file dirname [file normalize $argv0]] lib] +} + +set idx [file join $oguilib tclIndex] +if {[catch {set fd [open $idx r]} err]} { + catch {wm withdraw .} + tk_messageBox \ + -icon error \ + -type ok \ + -title "git-gui: fatal error" \ + -message $err + exit 1 +} +if {[gets $fd] eq {# Autogenerated by git-gui Makefile}} { + set idx [list] + while {[gets $fd n] >= 0} { + if {$n ne {} && ![string match #* $n]} { + lappend idx $n + } + } +} else { + set idx {} +} +close $fd + +if {$idx ne {}} { + set loaded [list] + foreach p $idx { + if {[lsearch -exact $loaded $p] >= 0} continue + source [file join $oguilib $p] + lappend loaded $p + } + unset loaded p +} else { + set auto_path [concat [list $oguilib] $auto_path] +} +unset -nocomplain oguirel idx fd + ###################################################################### ## ## read only globals @@ -158,6 +200,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 @@ -261,8 +312,14 @@ unset -nocomplain v _junk act_maj act_min req_maj req_min ## ## repository setup -if { [catch {set _gitdir $env(GIT_DIR)}] - && [catch {set _gitdir [git rev-parse --git-dir]} err]} { +if {[catch { + set _gitdir $env(GIT_DIR) + set _prefix {} + }] + && [catch { + set _gitdir [git rev-parse --git-dir] + set _prefix [git rev-parse --show-prefix] + } err]} { catch {wm withdraw .} error_popup "Cannot find the git directory:\n\n$err" exit 1 @@ -1173,15 +1230,16 @@ foreach class {Button Checkbutton Entry Label } unset class -if {[is_Windows]} { - set M1B Control - set M1T Ctrl -} elseif {[is_MacOSX]} { +if {[is_Windows] || [is_MacOSX]} { + option add *Menu.tearOff 0 +} + +if {[is_MacOSX]} { set M1B M1 set M1T Cmd } else { - set M1B M1 - set M1T M1 + set M1B Control + set M1T Ctrl } proc apply_config {} { @@ -1209,6 +1267,7 @@ set default_config(merge.verbosity) 2 set default_config(user.name) {} set default_config(user.email) {} +set default_config(gui.pruneduringfetch) false set default_config(gui.trustmtime) false set default_config(gui.diffcontext) 5 set default_config(gui.newbranchtemplate) {} @@ -1288,7 +1347,7 @@ menu .mbar.repository .mbar.repository add command \ -label {Browse Current Branch} \ - -command {new_browser $current_branch} + -command {browser::new $current_branch} trace add variable current_branch write ".mbar.repository entryconf [.mbar.repository index last] -label \"Browse \$current_branch\" ;#" .mbar.repository add separator @@ -1370,13 +1429,18 @@ 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 \ [.mbar.branch index last] -state] .mbar.branch add command -label {Reset...} \ - -command do_reset_hard + -command merge::reset_hard lappend disable_on_lock [list .mbar.branch entryconf \ [.mbar.branch index last] -state] } @@ -1449,11 +1513,11 @@ if {[is_enabled multicommit] || [is_enabled singlecommit]} { if {[is_enabled branch]} { menu .mbar.merge .mbar.merge add command -label {Local Merge...} \ - -command do_local_merge + -command merge::dialog lappend disable_on_lock \ [list .mbar.merge entryconf [.mbar.merge index last] -state] .mbar.merge add command -label {Abort Merge...} \ - -command do_reset_hard + -command merge::reset_hard lappend disable_on_lock \ [list .mbar.merge entryconf [.mbar.merge index last] -state] @@ -1467,6 +1531,8 @@ if {[is_enabled transport]} { menu .mbar.push .mbar.push add command -label {Push...} \ -command do_push_anywhere + .mbar.push add command -label {Delete...} \ + -command remote_branch_delete::dialog } if {[is_MacOSX]} { @@ -1572,25 +1638,67 @@ bind all <$M1B-Key-Q> do_quit bind all <$M1B-Key-w> {destroy [winfo toplevel %W]} bind all <$M1B-Key-W> {destroy [winfo toplevel %W]} +set subcommand_args {} +proc usage {} { + puts stderr "usage: $::argv0 $::subcommand $::subcommand_args" + exit 1 +} + # -- Not a normal commit type invocation? Do that instead! # switch -- $subcommand { browser { - if {[llength $argv] != 1} { - puts stderr "usage: $argv0 browser commit" - exit 1 + 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] } - set current_branch [lindex $argv 0] - new_browser $current_branch + default usage + } + browser::new $current_branch return } blame { - if {[llength $argv] != 2} { - puts stderr "usage: $argv0 blame commit path" - exit 1 + set subcommand_args {rev? path?} + set head {} + set path {} + set is_path 0 + foreach a $argv { + if {$is_path || [file exists $_prefix$a]} { + if {$path ne {}} usage + set path $_prefix$a + break + } elseif {$a eq {--}} { + if {$path ne {}} { + if {$head ne {}} usage + set head $path + set path {} + } + set is_path 1 + } elseif {$head eq {}} { + if {$head ne {}} usage + set head $a + } else { + usage + } } - set current_branch [lindex $argv 0] - show_blame $current_branch [lindex $argv 1] + unset is_path + + if {$head eq {}} { + set current_branch [git symbolic-ref HEAD] + regsub ^refs/((heads|tags|remotes)/)? \ + $current_branch {} current_branch + } else { + set current_branch $head + } + + if {$path eq {}} usage + blame::new $head $path return } citool - @@ -1638,7 +1746,7 @@ pack .vpane -anchor n -side top -fill both -expand 1 # -- Index File List # frame .vpane.files.index -height 100 -width 200 -label .vpane.files.index.title -text {Changes To Be Committed} \ +label .vpane.files.index.title -text {Staged Changes (Will Be Committed)} \ -background green text $ui_index -background white -borderwidth 0 \ -width 20 -height 10 \ @@ -1658,7 +1766,7 @@ pack $ui_index -side left -fill both -expand 1 # -- Working Directory File List # frame .vpane.files.workdir -height 100 -width 200 -label .vpane.files.workdir.title -text {Changed But Not Updated} \ +label .vpane.files.workdir.title -text {Unstaged Changes (Will Not Be Committed)} \ -background red text $ui_workdir -background white -borderwidth 0 \ -width 20 -height 10 \ @@ -2038,6 +2146,12 @@ bind $ui_diff {catch {%W yview scroll -1 units};break} bind $ui_diff {catch {%W yview scroll 1 units};break} bind $ui_diff {catch {%W xview scroll -1 units};break} bind $ui_diff {catch {%W xview scroll 1 units};break} +bind $ui_diff {catch {%W yview scroll -1 units};break} +bind $ui_diff {catch {%W yview scroll 1 units};break} +bind $ui_diff {catch {%W xview scroll -1 units};break} +bind $ui_diff {catch {%W xview scroll 1 units};break} +bind $ui_diff {catch {%W yview scroll -1 pages};break} +bind $ui_diff {catch {%W yview scroll 1 pages};break} bind $ui_diff {focus %W} if {[is_enabled branch]} {