summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Koutcher <thomas.koutcher@online.fr>2022-08-17 20:51:47 +0200
committerThomas Koutcher <thomas.koutcher@online.fr>2022-11-19 17:58:27 +0100
commitaced133adbc334b502a38332bd114b9a20ddb84f (patch)
treef2b9ad2a6a9895b360411ff013ed533152d31a52
parentd8ee5def74db38e57b5fdbf5a8f5fd4391460706 (diff)
Use %(file_old) for old filename in the blame view
Fixes #1226
-rw-r--r--src/blame.c7
-rw-r--r--src/diff.c4
2 files changed, 9 insertions, 2 deletions
diff --git a/src/blame.c b/src/blame.c
index 8da763f8..83025860 100644
--- a/src/blame.c
+++ b/src/blame.c
@@ -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;
}
diff --git a/src/diff.c b/src/diff.c
index 1cb82937..2071c38e 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -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;
@@ -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);