Skip to content

Commit b90d479

Browse files
committed
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>
1 parent 101e3ae commit b90d479

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

git-gui.sh

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3044,15 +3044,21 @@ proc new_browser {commit} {
30443044
global next_browser_id cursor_ptr M1B
30453045
global browser_commit browser_status browser_stack browser_path browser_busy
30463046

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+
}
30483055
set w_list $w.list.l
30493056
set browser_commit($w_list) $commit
30503057
set browser_status($w_list) {Starting...}
30513058
set browser_stack($w_list) {}
30523059
set browser_path($w_list) $browser_commit($w_list):
30533060
set browser_busy($w_list) 1
30543061

3055-
toplevel $w
30563062
label $w.path -textvariable browser_path($w_list) \
30573063
-anchor w \
30583064
-justify left \
@@ -3102,8 +3108,8 @@ proc new_browser {commit} {
31023108
bind $w_list <Left> break
31033109
bind $w_list <Right> break
31043110

3105-
bind $w <Visibility> "focus $w"
3106-
bind $w <Destroy> "
3111+
bind $tl <Visibility> "focus $w"
3112+
bind $tl <Destroy> "
31073113
array unset browser_buffer $w_list
31083114
array unset browser_files $w_list
31093115
array unset browser_status $w_list
@@ -3112,7 +3118,7 @@ proc new_browser {commit} {
31123118
array unset browser_commit $w_list
31133119
array unset browser_busy $w_list
31143120
"
3115-
wm title $w "[appname] ([reponame]): File Browser"
3121+
wm title $tl "[appname] ([reponame]): File Browser"
31163122
ls_tree $w_list $browser_commit($w_list) {}
31173123
}
31183124

@@ -5019,6 +5025,7 @@ enable_option transport
50195025
switch -- $subcommand {
50205026
--version -
50215027
version -
5028+
browser -
50225029
blame {
50235030
disable_option multicommit
50245031
disable_option branch
@@ -5359,6 +5366,15 @@ version {
53595366
puts "git-gui version $appvers"
53605367
exit
53615368
}
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+
}
53625378
blame {
53635379
if {[llength $argv] != 2} {
53645380
puts stderr "usage: $argv0 blame commit path"

0 commit comments

Comments
 (0)