git-gui: Expose the browser as a subcommand.
Some users may find being able to browse around an arbitrary branch to be handy, so we now expose our graphical browser through `git gui browse <committish>`. Yes, I'm being somewhat lazy and making the user give us the name of the branch to browse. They can always enter HEAD. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Feb 16, 2007 at 00:24 UTC
b90d479255d3b47e3604493b58e271cb9cd8dccd
1 file changed
+21
-5
git-gui.sh
+21
-5
@@ -3044,7 +3044,14 @@ proc new_browser {commit} {
3044
global next_browser_id cursor_ptr M1B
3045
global browser_commit browser_status browser_stack browser_path browser_busy
3046
3047
- set w .browser[incr next_browser_id]
3047
+ if {[winfo ismapped .]} {
3048
+ set w .browser[incr next_browser_id]
3049
+ set tl $w
3050
+ toplevel $w
3051
+ } else {
3052
+ set w {}
3053
+ set tl .
3054
+ }
3055
set w_list $w.list.l
3056
set browser_commit($w_list) $commit
3057
set browser_status($w_list) {Starting...}
@@ -3052,7 +3059,6 @@ proc new_browser {commit} {
3059
set browser_path($w_list) $browser_commit($w_list):
3060
set browser_busy($w_list) 1
3061
3055
- toplevel $w
3062
label $w.path -textvariable browser_path($w_list) \
3063
-anchor w \
3064
-justify left \
@@ -3102,8 +3108,8 @@ proc new_browser {commit} {
3108
bind $w_list <Left> break
3109
bind $w_list <Right> break
3110
3105
- bind $w <Visibility> "focus $w"
3106
- bind $w <Destroy> "
3111
+ bind $tl <Visibility> "focus $w"
3112
+ bind $tl <Destroy> "
3113
array unset browser_buffer $w_list
3114
array unset browser_files $w_list
3115
array unset browser_status $w_list
@@ -3112,7 +3118,7 @@ proc new_browser {commit} {
3118
array unset browser_commit $w_list
3119
array unset browser_busy $w_list
3120
"
3115
- wm title $w "[appname] ([reponame]): File Browser"
3121
+ wm title $tl "[appname] ([reponame]): File Browser"
3122
ls_tree $w_list $browser_commit($w_list) {}
3123
}
3124
@@ -5019,6 +5025,7 @@ enable_option transport
5025
switch -- $subcommand {
5026
--version -
5027
version -
5028
+browser -
5029
blame {
5030
disable_option multicommit
5031
disable_option branch
@@ -5359,6 +5366,15 @@ version {
5366
puts "git-gui version $appvers"
5367
exit
5368
}
5369
+browser {
5370
+ if {[llength $argv] != 1} {
5371
+ puts stderr "usage: $argv0 browser commit"
5372
+ exit 1
5373
+ }
5374
+ set current_branch [lindex $argv 0]
5375
+ new_browser $current_branch
5376
+ return
5377
+}
5378
blame {
5379
if {[llength $argv] != 2} {
5380
puts stderr "usage: $argv0 blame commit path"