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 <angavrilov@gmail.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
Alexander Gavrilov committed
Aug 23, 2008 at 12:29 UTC
77aa0ae8d3599b905ceb25db8cc50d6820efb793
1 file changed
+23
gitk
+23
@@ -2214,6 +2214,8 @@ proc makewindow {} {
2214
-command {flist_hl 1}
2215
$flist_menu add command -label [mc "External diff"] \
2216
-command {external_diff}
2217
+ $flist_menu add command -label [mc "Blame parent commit"] \
2218
+ -command {external_blame 1}
2219
}
2220
2221
# Windows sends all mouse wheel events to the current focused window, not
@@ -3021,6 +3023,27 @@ proc external_diff {} {
3023
}
3024
}
3025
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
+
3047
# delete $dir when we see eof on $f (presumably because the child has exited)
3048
proc delete_at_eof {f dir} {
3049
while {[gets $f line] >= 0} {}