From b1cda8cad6b71e3b8c294f2bd9c9a10f9c88299a Mon Sep 17 00:00:00 2001 From: Thomas Koutcher Date: Thu, 7 Mar 2024 20:05:45 +0100 Subject: [PATCH] Update message in the blame view * Show the commit the line came from in the title window. * Show the commit where annotating starts in the status window. --- src/blame.c | 13 ++++++++++--- test/blame/default-test | 8 ++++---- test/blame/initial-diff-test | 2 +- test/blame/revargs-test | 4 ++-- test/blame/start-on-line-test | 2 +- test/blame/stash-test | 6 ++++-- 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/blame.c b/src/blame.c index 785b88d91..b8c094ff7 100644 --- a/src/blame.c +++ b/src/blame.c @@ -234,6 +234,10 @@ blame_read(struct view *view, struct buffer *buf, bool force_stop) update_view_title(view); redraw_view_from(view, 0); } + + if (view->env->ref[0]) + update_status("Start annotating from %s", view->env->ref); + return true; } @@ -355,7 +359,7 @@ blame_go_forward(struct view *view, struct blame *blame, bool parent) const char *filename = parent ? commit->parent_filename : commit->filename; if (!*id && parent) { - report("The selected commit has no parents"); + report("The selected commit has no parents with this file"); return; } @@ -474,10 +478,13 @@ blame_select(struct view *view, struct line *line) if (!commit) return; - if (string_rev_is_null(commit->id)) + if (string_rev_is_null(commit->id)) { string_ncopy(view->env->commit, "HEAD", 4); - else + string_format(view->ref, "%s", commit->filename); + } else { string_copy_rev(view->env->commit, commit->id); + string_format(view->ref, "%s changed %s", commit->id, commit->filename); + } if (strcmp(commit->filename, view->env->file)) string_format(view->env->file_old, "%s", commit->filename); diff --git a/test/blame/default-test b/test/blame/default-test index a7249e55d..1c113449c 100755 --- a/test/blame/default-test +++ b/test/blame/default-test @@ -56,7 +56,7 @@ assert_equals 'blame-default.screen' < AuthorDate: Tue Oct 29 18:46:52 2013 +0100 @@ -101,7 +101,7 @@ assert_equals 'blame-with-diff-no-file-filter.screen' < AuthorDate: Tue Oct 29 18:46:52 2013 +0100 @@ -152,5 +152,5 @@ assert_equals 'blame-parent-of-74537d9.screen' < file git add file + export GIT_AUTHOR_DATE="1486403695" + export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" git commit -m "Initial commit" echo "changed line" > file git stash @@ -40,10 +42,10 @@ EOF assert_equals 'blame1.screen' <