@matheusbsbs / matheus-bagliano / commits / 85d2d59760
Fork 0

git-gui: Allow browser subcommand to start in subdirectory

Like our blame subcommand the browser subcommand now accepts both a revision and a path, just a revision or just a path. This way the user can start the subcommand on any branch, or on any subtree. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Jul 18, 2007 at 00:53 UTC 85d2d59760e5de7f288109cb278eb91da0d5f9bf
2 files changed +27 -29
git-gui.sh
+20 -26
@@ -1976,27 +1976,7 @@ proc usage {} {
1976 # -- Not a normal commit type invocation? Do that instead!
1977 #
1978 switch -- $subcommand {
1979 -browser {
1980 - set subcommand_args {rev?}
1981 - switch [llength $argv] {
1982 - 0 { load_current_branch }
1983 - 1 {
1984 - set current_branch [lindex $argv 0]
1985 - if {[regexp {^[0-9a-f]{1,39}$} $current_branch]} {
1986 - if {[catch {
1987 - set current_branch \
1988 - [git rev-parse --verify $current_branch]
1989 - } err]} {
1990 - puts stderr $err
1991 - exit 1
1992 - }
1993 - }
1994 - }
1995 - default usage
1996 - }
1997 - browser::new $current_branch
1998 - return
1999 -}
1979 +browser -
1980 blame {
1981 set subcommand_args {rev? path}
1982 if {$argv eq {}} usage
@@ -2044,12 +2024,26 @@ blame {
2024 set current_branch $head
2025 }
2026
2047 - if {$head eq {} && ![file exists $path]} {
2048 - puts stderr "fatal: cannot stat path $path: No such file or directory"
2049 - exit 1
2027 + switch -- $subcommand {
2028 + browser {
2029 + if {$head eq {}} {
2030 + if {$path ne {} && [file isdirectory $path]} {
2031 + set head $current_branch
2032 + } else {
2033 + set head $path
2034 + set path {}
2035 + }
2036 + }
2037 + browser::new $head $path
2038 + }
2039 + blame {
2040 + if {$head eq {} && ![file exists $path]} {
2041 + puts stderr "fatal: cannot stat path $path: No such file or directory"
2042 + exit 1
2043 + }
2044 + blame::new $head $path
2045 + }
2046 }
2051 -
2052 - blame::new $head $path
2047 return
2048 }
2049 citool -
lib/browser.tcl
+7 -3
@@ -13,13 +13,13 @@ field browser_busy 1
13
14 field ls_buf {}; # Buffered record output from ls-tree
15
16 -constructor new {commit} {
16 +constructor new {commit {path {}}} {
17 global cursor_ptr M1B
18 make_toplevel top w
19 wm title $top "[appname] ([reponame]): File Browser"
20
21 set browser_commit $commit
22 - set browser_path $browser_commit:
22 + set browser_path $browser_commit:$path
23
24 label $w.path \
25 -textvariable @browser_path \
@@ -73,7 +73,11 @@ constructor new {commit} {
73
74 bind $w_list <Visibility> [list focus $w_list]
75 set w $w_list
76 - _ls $this $browser_commit
76 + if {$path ne {}} {
77 + _ls $this $browser_commit:$path $path
78 + } else {
79 + _ls $this $browser_commit $path
80 + }
81 return $this
82 }
83