@matheusbsbs / matheus-bagliano / commits / 258871d305
Fork 0

git-gui: Select subcommands like git does.

If we are invoked as `git-foo`, then we should run the `foo` subcommand, as the user has made some sort of link from `git-foo` to our actual program code. So we should honor their request. If we are invoked as `git-gui foo`, the user has not made a link (or did, but is not using it right now) so we should execute the `foo` subcommand. We now can start the single commit UI mode via `git-citool` and also through `git gui citool`. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Feb 8, 2007 at 19:41 UTC 258871d3058a3117d204009b7173bf8c7df2414d
1 file changed +35 -13
git-gui.sh
+35 -13
@@ -4917,20 +4917,32 @@ apply_config
4917 ##
4918 ## feature option selection
4919
4920 +if {[regexp {^git-(.+)$} [appname] _junk subcommand]} {
4921 + unset _junk
4922 +} else {
4923 + set subcommand gui
4924 +}
4925 +if {$subcommand eq {gui.sh}} {
4926 + set subcommand gui
4927 +}
4928 +if {$subcommand eq {gui} && [llength $argv] > 0} {
4929 + set subcommand [lindex $argv 0]
4930 + set argv [lrange $argv 1 end]
4931 +}
4932 +
4933 enable_option multicommit
4934 enable_option branch
4935 enable_option transport
4936
4924 -if {[appname] eq {git-citool}} {
4925 - enable_option singlecommit
4926 -
4937 +switch -- $subcommand {
4938 +blame {
4939 disable_option multicommit
4940 disable_option branch
4941 disable_option transport
4942 }
4943 +citool {
4944 + enable_option singlecommit
4945
4932 -switch -- [lindex $argv 0] {
4933 -blame {
4946 disable_option multicommit
4947 disable_option branch
4948 disable_option transport
@@ -5257,20 +5269,30 @@ bind all <$M1B-Key-W> {destroy [winfo toplevel %W]}
5269
5270 # -- Not a normal commit type invocation? Do that instead!
5271 #
5260 -switch -- [lindex $argv 0] {
5272 +switch -- $subcommand {
5273 blame {
5262 - if {[llength $argv] == 3} {
5263 - set current_branch [lindex $argv 1]
5264 - show_blame $current_branch [lindex $argv 2]
5265 - return
5266 - } else {
5274 + if {[llength $argv] != 2} {
5275 puts stderr "usage: $argv0 blame commit path"
5276 exit 1
5277 }
5278 + set current_branch [lindex $argv 0]
5279 + show_blame $current_branch [lindex $argv 1]
5280 + return
5281 +}
5282 +citool -
5283 +gui {
5284 + if {[llength $argv] != 0} {
5285 + puts -nonewline stderr "usage: $argv0"
5286 + if {$subcommand ne {gui} && [appname] ne "git-$subcommand"} {
5287 + puts -nonewline stderr " $subcommand"
5288 + }
5289 + puts stderr {}
5290 + exit 1
5291 + }
5292 + # fall through to setup UI for commits
5293 }
5271 -{} {}
5294 default {
5273 - puts stderr "usage: $argv0 \[{blame}\]"
5295 + puts stderr "usage: $argv0 \[{blame|citool}\]"
5296 exit 1
5297 }
5298 }