git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Jonas Fonseca <fonseca@diku.dk>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Improve parent blame to detect renames by using the previous information
Date: Sun, 6 Jun 2010 18:35:45 -0400	[thread overview]
Message-ID: <20100606223545.GA11424@coredump.intra.peff.net> (raw)
In-Reply-To: <1275767765-8509-1-git-send-email-fonseca@diku.dk>

On Sat, Jun 05, 2010 at 03:56:05PM -0400, Jonas Fonseca wrote:

>  I finally got some more time to dig around this. What if we simply uses
>  the information given by the porcelain output's previous line? It
>  handles your simple test case, and navigating in the tig repository. It
>  also makes it possible to delete a lot of code.

Yes, I think that is the right way to go. The whole time I was doing the
other patches, I kept thinking that we had something like this in the
blame output, but when I looked I couldn't find it (which I can't see
how I would manage now, it's quite obvious to see).

So I think it does the right thing, and I see you also included my fix:

> +	char from[SIZEOF_REF + SIZEOF_STR];
> +	char to[SIZEOF_REF + SIZEOF_STR];
>  	const char *diff_tree_argv[] = {
> -		"git", "diff-tree", "-U0", blame->commit->id,
> -			"--", blame->commit->filename, NULL
> +		"git", "diff", "--no-textconv", "--no-extdiff", "--no-color",
> +			"-U0", from, to, "--", NULL
>  	};
>  	struct io io;
>  	int parent_lineno = -1;
>  	int blamed_lineno = -1;
>  	char *line;
>  
> +	snprintf(from, sizeof(from), "%s:%s", opt_ref, opt_file);
> +	snprintf(to, sizeof(to), "%s:%s", blame->commit->id,
> +		 blame->commit->filename);
> +

to handle the line-jumping properly.

One minor bug:

> @@ -5204,10 +5148,13 @@ blame_request(struct view *view, enum request request, struct line *line)
>  		break;
>  
>  	case REQ_PARENT:
> -		if (check_blame_commit(blame, TRUE) &&
> -		    select_commit_parent(blame->commit->id, opt_ref,
> -					 blame->commit->filename)) {
> -			string_copy(opt_file, blame->commit->filename);
> +		if (!check_blame_commit(blame, TRUE))
> +			break;
> +		if (!*blame->commit->parent_id) {
> +			report("The selected commit has no parents");
> +		} else {
> +			string_copy_rev(opt_ref, blame->commit->parent_id);
> +			string_copy_rev(opt_file, blame->commit->parent_filename);

This second string_copy_rev should be a string_ncopy, shouldn't it?

-Peff

  parent reply	other threads:[~2010-06-06 22:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-10  8:55 [tig PATCH] fix off-by-one on parent selection Jeff King
2010-05-22 17:19 ` Jonas Fonseca
2010-05-23  7:40   ` Jeff King
2010-05-23  7:55     ` Jeff King
2010-06-05 19:56       ` [PATCH] Improve parent blame to detect renames by using the previous information Jonas Fonseca
2010-06-05 19:57         ` [TIG PATCH] " Jonas Fonseca
2010-06-06 22:35         ` Jeff King [this message]
2010-06-09 16:10           ` [PATCH] " Jonas Fonseca
2010-06-10  2:23           ` Jonas Fonseca

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100606223545.GA11424@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=fonseca@diku.dk \
    --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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).