From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS11403 173.228.157.0/24 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from pb-smtp20.pobox.com (pb-smtp20.pobox.com [173.228.157.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 8E4CE1F8C1 for ; Sat, 9 May 2020 18:57:51 +0000 (UTC) Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id DC60CB8182; Sat, 9 May 2020 14:57:50 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:in-reply-to:date:message-id:mime-version:content-type; s=sasl; bh=uKEvJ7bYtmjxiITxgKB+gZpxtj8=; b=ky1QWO1ZAohs4+akFgXu S3+8xoNKT5QcDPaZav3PcaCxWSYnRpAYaRlM/tPaqS9KBYkjvQcWTh3otmIgqlsy p6/WQBFNhZIBwVW/i8KhKSYkCbarDYMFnkoR3E1q/4oo+OOa1cPszjVVc0b5HSHl ZNKZhHJIclEiipnDNURPq5I= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id D4F64B8181; Sat, 9 May 2020 14:57:50 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=kyleam.com; h=from:to:cc:subject:in-reply-to:date:message-id:mime-version:content-type; s=mesmtp; bh=atLLJ1ECMpyxDZDVzTV8u1D6J6+5cdzFYqkyoFH6U/w=; b=eBY246gXKFiZEaGBMOQSyFfSFgV7BnJ8dcQpg1dZ8pLR/fyDNMLmn7UjEOvgHL411/H8Uakw/SUclVFeeQOvUcS3EaHlL2w9qAXUOppoJu/r6JpKmI65+Z+xQBRAi4x5wMeBBE30JskvvNfSfK9Q2f9YQ22X3BCkX2mAHpd7cWw= Received: from localhost (unknown [45.33.91.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp20.pobox.com (Postfix) with ESMTPSA id 46CB8B8180; Sat, 9 May 2020 14:57:48 -0400 (EDT) (envelope-from kyle@kyleam.com) From: Kyle Meyer To: Eric Wong Cc: meta@public-inbox.org Subject: [PATCH] viewdiff: don't increment the reported hunk line number In-Reply-To: <20200509182401.GA20512@dcvr> Date: Sat, 09 May 2020 18:57:46 +0000 Message-ID: <87pnbdc4wl.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: F9A6411A-9226-11EA-9E00-B0405B776F7B-24757444!pb-smtp20.pobox.com List-Id: Eric Wong writes: > I'll probably take this patch, soon, got a commit message? Sure. Thanks. -- >8 -- Subject: [PATCH] viewdiff: don't increment the reported hunk line number For a diff hunk starting at line N, diff_hunk() constructs the link with "#n(N + 1)". This sends the viewer one line below the first context line. Although this is minor and may not even be noticed, there's not an obvious reason to increment the line number, so switch to using the reported value as is. --- lib/PublicInbox/ViewDiff.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/ViewDiff.pm b/lib/PublicInbox/ViewDiff.pm index 6fe9a0d7..536bb9e3 100644 --- a/lib/PublicInbox/ViewDiff.pm +++ b/lib/PublicInbox/ViewDiff.pm @@ -50,12 +50,12 @@ sub diff_hunk ($$$$) { if (defined($spfx) && defined($oid_a) && defined($oid_b)) { my ($n) = ($ca =~ /^-([0-9]+)/); - $n = defined($n) ? do { ++$n; "#n$n" } : ''; + $n = defined($n) ? "#n$n" : ''; $$dst .= qq(@@ {Q}$n">$ca); ($n) = ($cb =~ /^\+([0-9]+)/); - $n = defined($n) ? do { ++$n; "#n$n" } : ''; + $n = defined($n) ? "#n$n" : ''; $$dst .= qq( {Q}$n">$cb @@); } else { $$dst .= "@@ $ca $cb @@"; -- 2.26.1