Skip to content

Commit

Permalink
Start blame on the commit passed to a "tig show" commandline
Browse files Browse the repository at this point in the history
Fixes the first issue described in #1127 (comment)
  • Loading branch information
krobelus committed Jul 24, 2021
1 parent 529182c commit b99ba09
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
8 changes: 8 additions & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Release notes
=============

master
------

Improvements:

Bug fixes:
- Start blame on the commit passed to a `tig show` commandline (#1135).

tig-2.5.4
---------

Expand Down
14 changes: 9 additions & 5 deletions src/diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,8 @@ diff_trace_origin(struct view *view, struct line *line)
int chunk_marker = line->type == LINE_DIFF_DEL ? '-' : '+';
unsigned long lineno = 0;
const char *file = NULL;
char ref[SIZEOF_REF];
const char *ref = view->vid;
char blame_ref[SIZEOF_REF];
struct blame_header header;
struct blame_commit commit;

Expand Down Expand Up @@ -686,18 +687,21 @@ diff_trace_origin(struct view *view, struct line *line)
}
}

// HACK-ish: we cannot use is_initial_view here, because view->argv is already set.
if (!view->prev && opt_rev_args)
ref = opt_rev_args[0];
if (chunk_marker == '+')
string_copy(ref, view->vid);
string_copy(blame_ref, ref);
else
string_format(ref, "%s^", view->vid);
string_format(blame_ref, "%s^", ref);

if (string_rev_is_null(ref)) {
if (string_rev_is_null(blame_ref)) {
string_ncopy(view->env->file, file, strlen(file));
string_copy(view->env->ref, "");
view->env->goto_lineno = lineno - 1;

} else {
if (!diff_blame_line(ref, file, lineno, &header, &commit)) {
if (!diff_blame_line(blame_ref, file, lineno, &header, &commit)) {
report("Failed to read blame data");
return REQ_NONE;
}
Expand Down

0 comments on commit b99ba09

Please sign in to comment.