Browse Source

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>
maint
Alexander Gavrilov 16 years ago committed by Shawn O. Pearce
parent
commit
f7078b4091
  1. 11
      git-gui.sh
  2. 4
      lib/blame.tcl
  3. 2
      lib/browser.tcl

11
git-gui.sh

@ -2296,10 +2296,15 @@ proc usage {} {
switch -- $subcommand { switch -- $subcommand {
browser - browser -
blame { blame {
if {$subcommand eq "blame"} {
set subcommand_args {[--line=<num>] rev? path}
} else {
set subcommand_args {rev? path} set subcommand_args {rev? path}
}
if {$argv eq {}} usage if {$argv eq {}} usage
set head {} set head {}
set path {} set path {}
set jump_spec {}
set is_path 0 set is_path 0
foreach a $argv { foreach a $argv {
if {$is_path || [file exists $_prefix$a]} { if {$is_path || [file exists $_prefix$a]} {
@ -2313,6 +2318,9 @@ blame {
set path {} set path {}
} }
set is_path 1 set is_path 1
} elseif {[regexp {^--line=(\d+)$} $a a lnum]} {
if {$jump_spec ne {} || $head ne {}} usage
set jump_spec [list $lnum]
} elseif {$head eq {}} { } elseif {$head eq {}} {
if {$head ne {}} usage if {$head ne {}} usage
set head $a set head $a
@ -2344,6 +2352,7 @@ blame {


switch -- $subcommand { switch -- $subcommand {
browser { browser {
if {$jump_spec ne {}} usage
if {$head eq {}} { if {$head eq {}} {
if {$path ne {} && [file isdirectory $path]} { if {$path ne {} && [file isdirectory $path]} {
set head $current_branch set head $current_branch
@ -2359,7 +2368,7 @@ blame {
puts stderr [mc "fatal: cannot stat path %s: No such file or directory" $path] puts stderr [mc "fatal: cannot stat path %s: No such file or directory" $path]
exit 1 exit 1
} }
blame::new $head $path blame::new $head $path $jump_spec
} }
} }
return return

4
lib/blame.tcl

@ -58,7 +58,7 @@ field tooltip_t {} ; # Text widget in $tooltip_wm
field tooltip_timer {} ; # Current timer event for our tooltip field tooltip_timer {} ; # Current timer event for our tooltip
field tooltip_commit {} ; # Commit(s) in tooltip field tooltip_commit {} ; # Commit(s) in tooltip


constructor new {i_commit i_path} { constructor new {i_commit i_path i_jump} {
global cursor_ptr global cursor_ptr
variable active_color variable active_color
variable group_colors variable group_colors
@ -338,7 +338,7 @@ constructor new {i_commit i_path} {
wm protocol $top WM_DELETE_WINDOW "destroy $top" wm protocol $top WM_DELETE_WINDOW "destroy $top"
bind $top <Destroy> [cb _kill] bind $top <Destroy> [cb _kill]


_load $this {} _load $this $i_jump
} }


method _kill {} { method _kill {} {

2
lib/browser.tcl

@ -151,7 +151,7 @@ method _enter {} {
append p [lindex $n 1] append p [lindex $n 1]
} }
append p $name append p $name
blame::new $browser_commit $p blame::new $browser_commit $p {}
} }
} }
} }

Loading…
Cancel
Save