Skip to content

Commit 77aa0ae

Browse files
angavrilovpaulusmack
authored andcommitted
gitk: Add menu item for calling git gui blame
This adds a new item to the file list popup menu, that calls git gui blame for the selected file, starting with the first parent of the current commit. Signed-off-by: Alexander Gavrilov <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent 39816d6 commit 77aa0ae

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

gitk

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,6 +2214,8 @@ proc makewindow {} {
22142214
-command {flist_hl 1}
22152215
$flist_menu add command -label [mc "External diff"] \
22162216
-command {external_diff}
2217+
$flist_menu add command -label [mc "Blame parent commit"] \
2218+
-command {external_blame 1}
22172219
}
22182220

22192221
# Windows sends all mouse wheel events to the current focused window, not
@@ -3021,6 +3023,27 @@ proc external_diff {} {
30213023
}
30223024
}
30233025

3026+
proc external_blame {parent_idx} {
3027+
global flist_menu_file
3028+
global nullid nullid2
3029+
global parentlist selectedline currentid
3030+
3031+
if {$parent_idx > 0} {
3032+
set base_commit [lindex $parentlist $selectedline [expr {$parent_idx-1}]]
3033+
} else {
3034+
set base_commit $currentid
3035+
}
3036+
3037+
if {$base_commit eq {} || $base_commit eq $nullid || $base_commit eq $nullid2} {
3038+
error_popup [mc "No such commit"]
3039+
return
3040+
}
3041+
3042+
if {[catch {exec git gui blame $base_commit $flist_menu_file &} err]} {
3043+
error_popup [mc "git gui blame: command failed: $err"]
3044+
}
3045+
}
3046+
30243047
# delete $dir when we see eof on $f (presumably because the child has exited)
30253048
proc delete_at_eof {f dir} {
30263049
while {[gets $f line] >= 0} {}

0 commit comments

Comments
 (0)