On Sun, May 23, 2010 at 03:40:52AM -0400, Jeff King wrote: > Now try "tig blame new". For all of the lines but the first, blaming the > parent gets you the correct "The selected commit has no parents". But > parent-blaming the first line will correctly re-blame using the filename > "old". By the way, there is one minor bug remaining after this patch: > 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); > + select_commit_parent(blame->commit->id, opt_ref) && > + follow_parent_rename(blame->commit->id, opt_ref, > + blame->commit->filename, opt_file)) { > setup_blame_parent_line(view, blame); > open_view(view, REQ_VIEW_BLAME, OPEN_REFRESH); > } We may write some new filename into opt_file in the follow_parent_rename call, but setup_blame_parent_line always diffs the original file. Which means we lose the line position when following a rename. We need to do the equivalent of: git diff -U0 \ opt_ref:opt_file \ blame->commit->id:blame->commit->filename IOW, to blame directly between the two blobs. Sadly, I don't think there is a plumbing command to do this, so we are stuck using regular "git diff", which may have surprises in the config. The patch below works for my simple tests. I think we probably want to be doing this anyway for the multiple-parent case. I didn't test, but I don't think that diff-tree invocation is going to produce any output for a merge commit. diff --git a/tig.c b/tig.c index cfa26ce..4388c2f 100644 --- a/tig.c +++ b/tig.c @@ -5177,15 +5177,21 @@ check_blame_commit(struct blame *blame, bool check_null_id) static void setup_blame_parent_line(struct view *view, struct blame *blame) { + 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); + if (!io_run(&io, diff_tree_argv, NULL, IO_RD)) return; -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html