X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-gui.sh;h=ae22338be353e4ba588948a0778ea8b0b8a1a60e;hb=df6287ecd78206095796512bca80e87cc5a5e33b;hp=335b5f8b67dead27b82488266698f842199dc494;hpb=db7f34d4c54c1162d976be4d1752642c85e063b4;p=git.git diff --git a/git-gui.sh b/git-gui.sh index 335b5f8b6..ae22338be 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -140,7 +140,7 @@ proc load_config {include_global} { array unset global_config if {$include_global} { catch { - set fd_rc [open "| git repo-config --global --list" r] + set fd_rc [open "| git config --global --list" r] while {[gets $fd_rc line] >= 0} { if {[regexp {^([^=]+)=(.*)$} $line line name value]} { if {[is_many_config $name]} { @@ -156,7 +156,7 @@ proc load_config {include_global} { array unset repo_config catch { - set fd_rc [open "| git repo-config --list" r] + set fd_rc [open "| git config --list" r] while {[gets $fd_rc line] >= 0} { if {[regexp {^([^=]+)=(.*)$} $line line name value]} { if {[is_many_config $name]} { @@ -202,14 +202,14 @@ proc save_config {} { set value $global_config_new($name) if {$value ne $global_config($name)} { if {$value eq $default_config($name)} { - catch {exec git repo-config --global --unset $name} + catch {exec git config --global --unset $name} } else { regsub -all "\[{}\]" $value {"} value - exec git repo-config --global $name $value + exec git config --global $name $value } set global_config($name) $value if {$value eq $repo_config($name)} { - catch {exec git repo-config --unset $name} + catch {exec git config --unset $name} set repo_config($name) $value } } @@ -219,10 +219,10 @@ proc save_config {} { set value $repo_config_new($name) if {$value ne $repo_config($name)} { if {$value eq $global_config($name)} { - catch {exec git repo-config --unset $name} + catch {exec git config --unset $name} } else { regsub -all "\[{}\]" $value {"} value - exec git repo-config $name $value + exec git config $name $value } set repo_config($name) $value } @@ -319,16 +319,6 @@ set _reponame [lindex [file split \ [file normalize [file dirname $_gitdir]]] \ end] -enable_option multicommit -enable_option branch -enable_option transport - -if {[appname] eq {git-citool}} { - disable_option multicommit - disable_option branch - disable_option transport -} - ###################################################################### ## ## task management @@ -1307,7 +1297,7 @@ proc commit_committree {fd_wt curHEAD msg} { $ui_comm edit reset $ui_comm edit modified false - if {![is_enabled multicommit]} do_quit + if {[is_enabled singlecommit]} do_quit # -- Update in memory status # @@ -3236,12 +3226,17 @@ proc read_ls_tree {fd w} { proc show_blame {commit path} { global next_browser_id blame_status blame_data - set w .browser[incr next_browser_id] + if {[winfo ismapped .]} { + set w .browser[incr next_browser_id] + set tl $w + toplevel $w + } else { + set w {} + set tl . + } set blame_status($w) {Loading current file content...} set texts [list] - toplevel $w - label $w.path -text "$commit:$path" \ -anchor w \ -justify left \ @@ -3399,12 +3394,12 @@ proc show_blame {commit path} { set blame_data($w,colors) {} - bind $w "focus $w" - bind $w " - array unset blame_status $w + bind $tl "focus $tl" + bind $tl " + array unset blame_status {$w} array unset blame_data $w,* " - wm title $w "[appname] ([reponame]): File Viewer" + wm title $tl "[appname] ([reponame]): File Viewer" set blame_data($w,total_lines) 0 set cmd [list git cat-file blob "$commit:$path"] @@ -3442,7 +3437,9 @@ proc read_blame_catfile {fd w commit path texts w_lno w_file} { lappend cmd $commit -- $path set fd [open "| $cmd" r] fconfigure $fd -blocking 0 -translation lf -encoding binary - fileevent $fd readable "read_blame_incremental $fd $w $texts" + set handler [list read_blame_incremental $fd $w] + append handler " $texts" + fileevent $fd readable $handler } } @@ -4154,7 +4151,7 @@ proc do_quit {} { set rc_geometry {} } if {$cfg_geometry ne $rc_geometry} { - catch {exec git repo-config gui.geometry $cfg_geometry} + catch {exec git config gui.geometry $cfg_geometry} } } @@ -4916,10 +4913,48 @@ set font_descs { load_config 0 apply_config +###################################################################### +## +## feature option selection + +if {[regexp {^git-(.+)$} [appname] _junk subcommand]} { + unset _junk +} else { + set subcommand gui +} +if {$subcommand eq {gui.sh}} { + set subcommand gui +} +if {$subcommand eq {gui} && [llength $argv] > 0} { + set subcommand [lindex $argv 0] + set argv [lrange $argv 1 end] +} + +enable_option multicommit +enable_option branch +enable_option transport + +switch -- $subcommand { +blame { + disable_option multicommit + disable_option branch + disable_option transport +} +citool { + enable_option singlecommit + + disable_option multicommit + disable_option branch + disable_option transport +} +} + ###################################################################### ## ## ui construction +set ui_comm {} + # -- Menu Bar # menu .mbar -tearoff 0 @@ -4928,7 +4963,9 @@ menu .mbar -tearoff 0 if {[is_enabled branch]} { .mbar add cascade -label Branch -menu .mbar.branch } -.mbar add cascade -label Commit -menu .mbar.commit +if {[is_enabled multicommit] || [is_enabled singlecommit]} { + .mbar add cascade -label Commit -menu .mbar.commit +} if {[is_enabled transport]} { .mbar add cascade -label Merge -menu .mbar.merge .mbar add cascade -label Fetch -menu .mbar.fetch @@ -4944,15 +4981,17 @@ menu .mbar.repository -label {Browse Current Branch} \ -command {new_browser $current_branch} \ -font font_ui +trace add variable current_branch write ".mbar.repository entryconf [.mbar.repository index last] -label \"Browse \$current_branch\" ;#" .mbar.repository add separator .mbar.repository add command \ -label {Visualize Current Branch} \ - -command {do_gitk {}} \ + -command {do_gitk $current_branch} \ -font font_ui +trace add variable current_branch write ".mbar.repository entryconf [.mbar.repository index last] -label \"Visualize \$current_branch\" ;#" .mbar.repository add command \ -label {Visualize All Branches} \ - -command {do_gitk {--all}} \ + -command {do_gitk --all} \ -font font_ui .mbar.repository add separator @@ -5049,73 +5088,75 @@ if {[is_enabled branch]} { # -- Commit Menu # -menu .mbar.commit - -.mbar.commit add radiobutton \ - -label {New Commit} \ - -command do_select_commit_type \ - -variable selected_commit_type \ - -value new \ - -font font_ui -lappend disable_on_lock \ - [list .mbar.commit entryconf [.mbar.commit index last] -state] +if {[is_enabled multicommit] || [is_enabled singlecommit]} { + menu .mbar.commit + + .mbar.commit add radiobutton \ + -label {New Commit} \ + -command do_select_commit_type \ + -variable selected_commit_type \ + -value new \ + -font font_ui + lappend disable_on_lock \ + [list .mbar.commit entryconf [.mbar.commit index last] -state] -.mbar.commit add radiobutton \ - -label {Amend Last Commit} \ - -command do_select_commit_type \ - -variable selected_commit_type \ - -value amend \ - -font font_ui -lappend disable_on_lock \ - [list .mbar.commit entryconf [.mbar.commit index last] -state] + .mbar.commit add radiobutton \ + -label {Amend Last Commit} \ + -command do_select_commit_type \ + -variable selected_commit_type \ + -value amend \ + -font font_ui + lappend disable_on_lock \ + [list .mbar.commit entryconf [.mbar.commit index last] -state] -.mbar.commit add separator + .mbar.commit add separator -.mbar.commit add command -label Rescan \ - -command do_rescan \ - -accelerator F5 \ - -font font_ui -lappend disable_on_lock \ - [list .mbar.commit entryconf [.mbar.commit index last] -state] + .mbar.commit add command -label Rescan \ + -command do_rescan \ + -accelerator F5 \ + -font font_ui + lappend disable_on_lock \ + [list .mbar.commit entryconf [.mbar.commit index last] -state] -.mbar.commit add command -label {Add To Commit} \ - -command do_add_selection \ - -font font_ui -lappend disable_on_lock \ - [list .mbar.commit entryconf [.mbar.commit index last] -state] + .mbar.commit add command -label {Add To Commit} \ + -command do_add_selection \ + -font font_ui + lappend disable_on_lock \ + [list .mbar.commit entryconf [.mbar.commit index last] -state] -.mbar.commit add command -label {Add All To Commit} \ - -command do_add_all \ - -accelerator $M1T-I \ - -font font_ui -lappend disable_on_lock \ - [list .mbar.commit entryconf [.mbar.commit index last] -state] + .mbar.commit add command -label {Add Existing To Commit} \ + -command do_add_all \ + -accelerator $M1T-I \ + -font font_ui + lappend disable_on_lock \ + [list .mbar.commit entryconf [.mbar.commit index last] -state] -.mbar.commit add command -label {Unstage From Commit} \ - -command do_unstage_selection \ - -font font_ui -lappend disable_on_lock \ - [list .mbar.commit entryconf [.mbar.commit index last] -state] + .mbar.commit add command -label {Unstage From Commit} \ + -command do_unstage_selection \ + -font font_ui + lappend disable_on_lock \ + [list .mbar.commit entryconf [.mbar.commit index last] -state] -.mbar.commit add command -label {Revert Changes} \ - -command do_revert_selection \ - -font font_ui -lappend disable_on_lock \ - [list .mbar.commit entryconf [.mbar.commit index last] -state] + .mbar.commit add command -label {Revert Changes} \ + -command do_revert_selection \ + -font font_ui + lappend disable_on_lock \ + [list .mbar.commit entryconf [.mbar.commit index last] -state] -.mbar.commit add separator + .mbar.commit add separator -.mbar.commit add command -label {Sign Off} \ - -command do_signoff \ - -accelerator $M1T-S \ - -font font_ui + .mbar.commit add command -label {Sign Off} \ + -command do_signoff \ + -accelerator $M1T-S \ + -font font_ui -.mbar.commit add command -label Commit \ - -command do_commit \ - -accelerator $M1T-Return \ - -font font_ui -lappend disable_on_lock \ - [list .mbar.commit entryconf [.mbar.commit index last] -state] + .mbar.commit add command -label Commit \ + -command do_commit \ + -accelerator $M1T-Return \ + -font font_ui + lappend disable_on_lock \ + [list .mbar.commit entryconf [.mbar.commit index last] -state] +} if {[is_MacOSX]} { # -- Apple Menu (Mac OS X only) @@ -5218,6 +5259,44 @@ if {$browser ne {}} { } unset browser doc_path doc_url +# -- Standard bindings +# +bind . 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]} +bind all <$M1B-Key-W> {destroy [winfo toplevel %W]} + +# -- Not a normal commit type invocation? Do that instead! +# +switch -- $subcommand { +blame { + if {[llength $argv] != 2} { + puts stderr "usage: $argv0 blame commit path" + exit 1 + } + set current_branch [lindex $argv 0] + show_blame $current_branch [lindex $argv 1] + return +} +citool - +gui { + if {[llength $argv] != 0} { + puts -nonewline stderr "usage: $argv0" + if {$subcommand ne {gui} && [appname] ne "git-$subcommand"} { + puts -nonewline stderr " $subcommand" + } + puts stderr {} + exit 1 + } + # fall through to setup UI for commits +} +default { + puts stderr "usage: $argv0 \[{blame|citool}\]" + exit 1 +} +} + # -- Branch Control # frame .branch \ @@ -5344,7 +5423,7 @@ pack .vpane.lower.commarea.buttons.rescan -side top -fill x lappend disable_on_lock \ {.vpane.lower.commarea.buttons.rescan conf -state} -button .vpane.lower.commarea.buttons.incall -text {Add All} \ +button .vpane.lower.commarea.buttons.incall -text {Add Existing} \ -command do_add_all \ -font font_ui pack .vpane.lower.commarea.buttons.incall -side top -fill x @@ -5714,7 +5793,6 @@ if {[is_enabled branch]} { bind . <$M1B-Key-N> do_create_branch } -bind . do_quit bind all do_rescan bind all <$M1B-Key-r> do_rescan bind all <$M1B-Key-R> do_rescan @@ -5723,10 +5801,6 @@ bind . <$M1B-Key-S> do_signoff bind . <$M1B-Key-i> do_add_all bind . <$M1B-Key-I> do_add_all bind . <$M1B-Key-Return> do_commit -bind all <$M1B-Key-q> do_quit -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]} foreach i [list $ui_index $ui_workdir] { bind $i "toggle_or_diff $i %x %y; break" bind $i <$M1B-Button-1> "add_one_to_selection $i %x %y; break"