git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Mackerras <paulus@samba.org>
To: Alexander Gavrilov <angavrilov@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 3/7] gitk: Allow starting gui blame for a specific line.
Date: Thu, 23 Oct 2008 22:58:58 +1100	[thread overview]
Message-ID: <18688.26370.467724.404768@cargo.ozlabs.ibm.com> (raw)
In-Reply-To: <1223449540-20457-4-git-send-email-angavrilov@gmail.com>

Alexander Gavrilov writes:

> Adds a context menu item to the diff viewer pane that
> calls blame, focusing it on the clicked line. In case
> of combined diffs, it also automatically deduces which
> parent is to be blamed.

I have some comments on this one, but I haven't finished reviewing it
completely, so I may have more... :)

> +proc find_hunk_blamespec {base line} {
> +    global ctext
> +
> +    # Find and parse the hunk header
> +    set s_lix [$ctext search -backwards -regexp ^@@ "$line.0 lineend" $base.0]
> +    if {$s_lix eq {}} return
> +
> +    set s_line [$ctext get $s_lix "$s_lix + 1 lines"]
> +    if {![regexp {^@@@?(( -\d+(,\d+)?)+) \+(\d+)(,\d+)? @@} $s_line \

In fact there can be many @ characters at the beginning of the line;
the number of parents plus one, in fact.  See commit
c465a76af658b443075d6efee1c3131257643020 in the kernel tree for an
example.  I suggest starting with ^@@@* rather than ^@@@?.

> +    # Now scan the lines to determine offset within the hunk
> +    set parent {}
> +    set dline 0
> +    set s_lno [lindex [split $s_lix "."] 0]
> +
> +    for {set i $line} {$i > $s_lno} {incr i -1} {
> +	set c_line [$ctext get $i.0 "$i.0 + 1 lines"]
> +	if {$parent eq {}} {
> +	    # find first preceeding line that belongs to some parent
> +	    for {set j 0} {$j < [llength $old_lines]} {incr j} {
> +		set code [string index $c_line $j]
> +		if {$code ne {-} && $code ne { }} continue
> +		if {$code eq { } && $parent ne {}} continue
> +		set parent $j
> +		if {$code eq {-}} break
> +	    }
> +	}

This part worries me a bit.  If the user clicks on a line where all
the $code values are "+" then I think we should blame the current
commit.  Either that, or we disable the context menu item before
posting it if the user clicks on a line that starts with all "+"
characters (as many "+" as there are parents).

BTW, writing "-" rather than {-} in expressions is more idiomatic.

Paul.

  parent reply	other threads:[~2008-10-23 12:00 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-08  7:05 [PATCH 0/7] gitk: UI enhancements Alexander Gavrilov
2008-10-08  7:05 ` [PATCH 1/7] gitk: Enhance UI popup and accelerator handling Alexander Gavrilov
2008-10-08  7:05   ` [PATCH 2/7] gitk: Allow forcing branch creation if it already exists Alexander Gavrilov
2008-10-08  7:05     ` [PATCH 3/7] gitk: Allow starting gui blame for a specific line Alexander Gavrilov
2008-10-08  7:05       ` [PATCH 4/7] gitk: Fix file list context menu for merge commits Alexander Gavrilov
2008-10-08  7:05         ` [PATCH 5/7] gitk: Make cherry-pick call git-citool on conflicts Alexander Gavrilov
2008-10-08  7:05           ` [PATCH 6/7] gitk: Implement a user-friendly Edit View dialog Alexander Gavrilov
2008-10-08  7:05             ` [PATCH 7/7] gitk: Explicitly position popup windows Alexander Gavrilov
2008-10-21 11:41               ` Paul Mackerras
2008-10-21 12:52                 ` Alexander Gavrilov
2008-10-09  7:42           ` [PATCH 5/7] gitk: Make cherry-pick call git-citool on conflicts Paul Mackerras
2008-10-09  8:24             ` Alexander Gavrilov
2008-10-09 10:57               ` Paul Mackerras
2008-10-21 11:39         ` [PATCH 4/7] gitk: Fix file list context menu for merge commits Paul Mackerras
2008-10-23 11:58       ` Paul Mackerras [this message]
2008-10-24  8:13         ` [PATCH 3/7] gitk: Allow starting gui blame for a specific line Alexander Gavrilov
2008-10-25 11:57           ` Paul Mackerras
2008-10-25 16:45             ` Alexander Gavrilov
2008-10-26  3:58               ` Paul Mackerras
2008-10-21 11:38     ` [PATCH 2/7] gitk: Allow forcing branch creation if it already exists Paul Mackerras
2008-10-09  0:27   ` [PATCH 1/7] gitk: Enhance UI popup and accelerator handling Paul Mackerras
2008-10-09  8:12     ` Alexander Gavrilov
2008-10-09 11:02       ` Paul Mackerras
2008-10-16 21:55   ` Paul Mackerras
2008-10-16 22:08     ` Alexander Gavrilov
2008-10-21 11:35   ` Paul Mackerras

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=18688.26370.467724.404768@cargo.ozlabs.ibm.com \
    --to=paulus@samba.org \
    --cc=angavrilov@gmail.com \
    --cc=git@vger.kernel.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).