@matheusbsbs / matheus-bagliano / commits / f7078b4091
Fork 0

git-gui: Allow specifying an initial line for git gui blame.

Add a command-line option to make git gui blame automatically scroll to a specific line in the file. Useful for integration with other tools. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Alexander Gavrilov committed Aug 23, 2008 at 12:32 UTC f7078b40917daa20ea3fa54c7e38766594e4b996
3 files changed +14 -5
git-gui.sh
+11 -2
@@ -2296,10 +2296,15 @@ proc usage {} {
2296 switch -- $subcommand {
2297 browser -
2298 blame {
2299 - set subcommand_args {rev? path}
2299 + if {$subcommand eq "blame"} {
2300 + set subcommand_args {[--line=<num>] rev? path}
2301 + } else {
2302 + set subcommand_args {rev? path}
2303 + }
2304 if {$argv eq {}} usage
2305 set head {}
2306 set path {}
2307 + set jump_spec {}
2308 set is_path 0
2309 foreach a $argv {
2310 if {$is_path || [file exists $_prefix$a]} {
@@ -2313,6 +2318,9 @@ blame {
2318 set path {}
2319 }
2320 set is_path 1
2321 + } elseif {[regexp {^--line=(\d+)$} $a a lnum]} {
2322 + if {$jump_spec ne {} || $head ne {}} usage
2323 + set jump_spec [list $lnum]
2324 } elseif {$head eq {}} {
2325 if {$head ne {}} usage
2326 set head $a
@@ -2344,6 +2352,7 @@ blame {
2352
2353 switch -- $subcommand {
2354 browser {
2355 + if {$jump_spec ne {}} usage
2356 if {$head eq {}} {
2357 if {$path ne {} && [file isdirectory $path]} {
2358 set head $current_branch
@@ -2359,7 +2368,7 @@ blame {
2368 puts stderr [mc "fatal: cannot stat path %s: No such file or directory" $path]
2369 exit 1
2370 }
2362 - blame::new $head $path
2371 + blame::new $head $path $jump_spec
2372 }
2373 }
2374 return
lib/blame.tcl
+2 -2
@@ -58,7 +58,7 @@ field tooltip_t {} ; # Text widget in $tooltip_wm
58 field tooltip_timer {} ; # Current timer event for our tooltip
59 field tooltip_commit {} ; # Commit(s) in tooltip
60
61 -constructor new {i_commit i_path} {
61 +constructor new {i_commit i_path i_jump} {
62 global cursor_ptr
63 variable active_color
64 variable group_colors
@@ -338,7 +338,7 @@ constructor new {i_commit i_path} {
338 wm protocol $top WM_DELETE_WINDOW "destroy $top"
339 bind $top <Destroy> [cb _kill]
340
341 - _load $this {}
341 + _load $this $i_jump
342 }
343
344 method _kill {} {
lib/browser.tcl
+1 -1
@@ -151,7 +151,7 @@ method _enter {} {
151 append p [lindex $n 1]
152 }
153 append p $name
154 - blame::new $browser_commit $p
154 + blame::new $browser_commit $p {}
155 }
156 }
157 }