From: Alexander Gavrilov <angavrilov@gmail.com>
To: git@vger.kernel.org
Cc: Paul Mackerras <paulus@samba.org>,
"Shawn O. Pearce" <spearce@spearce.org>,
Junio C Hamano <gitster@pobox.com>
Subject: [PATCH (GITK,GIT-GUI,DOCS) 4/7] git-gui: Support passing blame to a parent commit.
Date: Sat, 23 Aug 2008 12:30:51 +0400 [thread overview]
Message-ID: <200808231230.51693.angavrilov@gmail.com> (raw)
In-Reply-To: <200808231230.00397.angavrilov@gmail.com>
Add a context menu item that switches the view to the
parent of the commit under cursor. It is useful to see
how the file looked before the change, and find older
changes in the same lines.
Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
---
lib/blame.tcl | 48 ++++++++++++++++++++++++++++++++++++++----------
1 files changed, 38 insertions(+), 10 deletions(-)
diff --git a/lib/blame.tcl b/lib/blame.tcl
index d6c56e8..8b555a1 100644
--- a/lib/blame.tcl
+++ b/lib/blame.tcl
@@ -262,6 +262,9 @@ constructor new {i_commit i_path} {
$w.ctxm add command \
-label [mc "Show History Context"] \
-command [cb _gitkcommit]
+ $w.ctxm add command \
+ -label [mc "Blame Parent Commit"] \
+ -command [cb _blameparent]
foreach i $w_columns {
for {set g 0} {$g < [llength $group_colors]} {incr g} {
@@ -790,19 +793,27 @@ method _load_commit {cur_w cur_d pos} {
set lno [lindex [split [$cur_w index $pos] .] 0]
set dat [lindex $line_data $lno]
if {$dat ne {}} {
- lappend history [list \
- $commit $path \
- $highlight_column \
- $highlight_line \
- [lindex [$w_file xview] 0] \
- [lindex [$w_file yview] 0] \
- ]
- set commit [lindex $dat 0]
- set path [lindex $dat 1]
- _load $this [list [lindex $dat 2]]
+ _load_new_commit $this \
+ [lindex $dat 0] \
+ [lindex $dat 1] \
+ [list [lindex $dat 2]]
}
}
+method _load_new_commit {new_commit new_path jump} {
+ lappend history [list \
+ $commit $path \
+ $highlight_column \
+ $highlight_line \
+ [lindex [$w_file xview] 0] \
+ [lindex [$w_file yview] 0] \
+ ]
+
+ set commit $new_commit
+ set path $new_path
+ _load $this $jump
+}
+
method _showcommit {cur_w lno} {
global repo_config
variable active_color
@@ -969,6 +980,23 @@ method _gitkcommit {} {
}
}
+method _blameparent {} {
+ set dat [_get_click_amov_info $this]
+ if {$dat ne {}} {
+ set cmit [lindex $dat 0]
+
+ if {[catch {set cparent [git rev-parse --verify "$cmit^"]}]} {
+ error_popup [strcat [mc "Cannot find parent commit:"] "\n\n$err"]
+ return;
+ }
+
+ _load_new_commit $this \
+ $cparent \
+ [lindex $dat 1] \
+ [list [lindex $dat 2]]
+ }
+}
+
method _show_tooltip {cur_w pos} {
if {$tooltip_wm ne {}} {
_open_tooltip $this $cur_w
--
1.6.0.rc2
next prev parent reply other threads:[~2008-08-23 8:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-23 8:25 [PATCH (GITK,GIT-GUI,DOCS) 0/7] Improve gui blame and gitk integration Alexander Gavrilov
2008-08-23 8:27 ` [PATCH (GITK,GIT-GUI,DOCS) 1/7] gitk: Allow overriding the default commit Alexander Gavrilov
2008-08-23 8:29 ` [PATCH (GITK,GIT-GUI,DOCS) 2/7] gitk: Support calling git gui blame from gitk Alexander Gavrilov
2008-08-26 10:27 ` Paul Mackerras
2008-08-26 12:10 ` Johannes Sixt
2008-08-26 10:13 ` [PATCH (GITK,GIT-GUI,DOCS) 1/7] gitk: Allow overriding the default commit Paul Mackerras
2008-08-23 8:30 ` [PATCH (GITK,GIT-GUI,DOCS) 3/7] git-gui: Support starting gitk from Gui Blame Alexander Gavrilov
2008-08-23 8:30 ` Alexander Gavrilov [this message]
2008-08-23 8:31 ` [PATCH (GITK,GIT-GUI,DOCS) 5/7] git-gui: Better positioning in Blame Parent Commit Alexander Gavrilov
2008-08-23 8:32 ` [PATCH (GITK,GIT-GUI,DOCS) 6/7] git-gui: Allow specifying an initial line for git gui blame Alexander Gavrilov
2008-08-25 5:06 ` [PATCH (GITK,GIT-GUI,DOCS) 3/7] git-gui: Support starting gitk from Gui Blame Shawn O. Pearce
2008-08-23 8:33 ` [PATCH (GITK,GIT-GUI,DOCS) 7/7] Document new options of gui tools Alexander Gavrilov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200808231230.51693.angavrilov@gmail.com \
--to=angavrilov@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=paulus@samba.org \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).