List for cgit developers and users
 help / color / mirror / Atom feed
From: John Keeping <john@keeping.me.uk>
To: cgit@lists.zx2c4.com
Cc: John Keeping <john@keeping.me.uk>,
	Alejandro Colomar <alx.manpages@gmail.com>
Subject: [PATCH] blame: add a link to the parent commit
Date: Sun, 13 Feb 2022 15:29:06 +0000	[thread overview]
Message-ID: <5fe03939a1254f65961ea211ce5bd51bdc1e3895.1644766088.git.john@keeping.me.uk> (raw)

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>
---
 ui-blame.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/ui-blame.c b/ui-blame.c
index 03136f7..3b0bcad 100644
--- a/ui-blame.c
+++ b/ui-blame.c
@@ -54,6 +54,15 @@ static void emit_blame_entry_hash(struct blame_entry *ent)
 	html("</span>");
 	free(detail);
 
+	if (!parse_commit(suspect->commit) && suspect->commit->parents) {
+		struct commit *parent = suspect->commit->parents->item;
+
+		html(" ");
+		cgit_blame_link("^", "Blame the previous revision", NULL,
+				ctx.qry.head, oid_to_hex(&parent->object.oid),
+				suspect->path);
+	}
+
 	while (line++ < ent->num_lines)
 		html("\n");
 }
-- 
2.35.1


                 reply	other threads:[~2022-02-13 15:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5fe03939a1254f65961ea211ce5bd51bdc1e3895.1644766088.git.john@keeping.me.uk \
    --to=john@keeping.me.uk \
    --cc=alx.manpages@gmail.com \
    --cc=cgit@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).