Skip to content

Commit

Permalink
Use %(file_old) for old filename in the blame view
Browse files Browse the repository at this point in the history
Fixes #1226
  • Loading branch information
koutcher committed Nov 19, 2022
1 parent d8ee5de commit aced133
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,11 @@ blame_select(struct view *view, struct line *line)
else
string_copy_rev(view->env->commit, commit->id);

if (commit->filename)
string_format(view->env->file, "%s", commit->filename);
if (strcmp(commit->filename, view->env->file))
string_format(view->env->file_old, "%s", commit->filename);
else
view->env->file_old[0] = '\0';

view->env->lineno = view->pos.lineno + 1;
}

Expand Down
4 changes: 4 additions & 0 deletions src/diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,8 @@ diff_common_select(struct view *view, struct line *line, const char *changes_msg
const char *old_file = diff_get_pathname(view, header, true);
if (old_file)
string_format(view->env->file_old, "%s", old_file);
else
view->env->file_old[0] = '\0';
string_format(view->env->file, "%s", file);
view->env->lineno = view->env->goto_lineno = 0;
view->env->blob[0] = 0;
Expand All @@ -826,6 +828,8 @@ diff_common_select(struct view *view, struct line *line, const char *changes_msg
const char *old_file = diff_get_pathname(view, line, true);
if (old_file)
string_format(view->env->file_old, "%s", old_file);
else
view->env->file_old[0] = '\0';
if (changes_msg)
string_format(view->ref, "%s to '%s'", changes_msg, file);
string_format(view->env->file, "%s", file);
Expand Down

0 comments on commit aced133

Please sign in to comment.