List for cgit developers and users
 help / color / mirror / Atom feed
From: john at keeping.me.uk (John Keeping)
Subject: [PATCH] ui-diff: don't link to single file diff stat
Date: Mon, 29 Dec 2014 22:27:55 +0000	[thread overview]
Message-ID: <b8a1e9e7b51aa1fdf2735e38497c02dae9ca8776.1419891898.git.john@keeping.me.uk> (raw)
In-Reply-To: <54A1B513.2000304@kernel.org>

Seeing the diff stat for a single file is pretty useless, so reset the
diff type before generating the links to individual files in the diff
stat so that the links will show a useful diff.

Reported-by: Konstantin Ryabitsev <mricon at kernel.org>
Signed-off-by: John Keeping <john at keeping.me.uk>
---
On Mon, Dec 29, 2014 at 03:09:55PM -0500, Konstantin Ryabitsev wrote:
> On 23/12/14 09:30 PM, Jason A. Donenfeld wrote:
> > Ahh yes, of course -- John has done it, and it's been merged
> > here: ddfaef6bb28e697491b25bff5a7b260d44ce6ccf
> 
> I actually had a chance to try it out now. It looks pretty nice, but has
> an unintended downside in the sense that "dt=2" is sticky. E.g. for a
> link like:
> 
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/diff/?id=v3.19-rc2&id2=v3.19-rc1&dt=2
> 
> This will show the diffstat only, but then if I click on any of the
> files for more details, the "diffstat only" mode persists. The user
> would then need to know to change to "unified" in the dropdown on the
> right to see actual diff contents.
> 
> It's not a bug per se, just wondering if we can improve the user experience.

Something like this, perhaps?

 ui-diff.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/ui-diff.c b/ui-diff.c
index bf2ec57..5b6df1f 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -428,6 +428,16 @@ void cgit_print_diff(const char *new_rev, const char *old_rev,
 	if (show_ctrls)
 		cgit_print_diff_ctrls();
 
+	/*
+	 * Clicking on a link to a file in the diff stat should show a diff
+	 * of the file, showing the diff stat limited to a single file is
+	 * pretty useless.  All links from this point on will be to
+	 * individual files, so we simply reset the difftype in the query
+	 * here to avoid propagating DIFF_STATONLY to the individual files.
+	 */
+	if (difftype == DIFF_STATONLY)
+		ctx.qry.difftype = ctx.cfg.difftype;
+
 	cgit_print_diffstat(old_rev_sha1, new_rev_sha1, prefix);
 
 	if (difftype == DIFF_STATONLY)
-- 
2.2.1.286.gdf3164c



  reply	other threads:[~2014-12-29 22:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-22 15:40 RFE: Show just diff summary mricon
2014-12-24  2:27 ` Jason
2014-12-24  2:30   ` Jason
2014-12-29 20:09     ` mricon
2014-12-29 22:27       ` john [this message]
2014-12-30  9:09         ` [PATCH] ui-diff: don't link to single file diff stat Jason
2014-12-30 14:53           ` mricon

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=b8a1e9e7b51aa1fdf2735e38497c02dae9ca8776.1419891898.git.john@keeping.me.uk \
    --to=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).