aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Keeping2022-02-13 15:29:06 +0000
committerYigit Sever2023-07-21 03:03:50 +0300
commitbac1c93fc6783194ebdba868d6f5d27f0eb37ca4 (patch)
tree1eec4d99a33425210e803ec7d1711300a161d367
parentea9f614e02559f0166c9e74441f3edf4fe897fe2 (diff)
downloadcgit-bac1c93fc6783194ebdba868d6f5d27f0eb37ca4.tar.gz
cgit-bac1c93fc6783194ebdba868d6f5d27f0eb37ca4.tar.bz2
cgit-bac1c93fc6783194ebdba868d6f5d27f0eb37ca4.zip
ui-blame: add a link to the parent commit in blame
When walking through the history, it is useful to quickly see the same file at the previous revision, so add a link to do this. It would be nice to link to the correct line with an additional fragment, but this requires significantly more work so it can be done as an enhancement later. (ent->s_lno is mostly the right thing, but it is the line number in the post-image of the target commit whereas the link is to the parent of that commit, i.e. the pre-image of the target.) Suggested-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--ui-blame.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/ui-blame.c b/ui-blame.c
index 4adec2b..aedce8d 100644
--- a/ui-blame.c
+++ b/ui-blame.c
@@ -54,6 +54,15 @@ static void emit_blame_entry_hash(struct blame_entry *ent)
54 html("</span>"); 54 html("</span>");
55 free(detail); 55 free(detail);
56 56
57 if (!parse_commit(suspect->commit) && suspect->commit->parents) {
58 struct commit *parent = suspect->commit->parents->item;
59
60 html(" ");
61 cgit_blame_link("^", "Blame the previous revision", NULL,
62 ctx.qry.head, oid_to_hex(&parent->object.oid),
63 suspect->path);
64 }
65
57 while (line++ < ent->num_lines) 66 while (line++ < ent->num_lines)
58 html("\n"); 67 html("\n");
59} 68}