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: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 261381F453; Mon, 4 Feb 2019 11:49:22 +0000 (UTC) Date: Mon, 4 Feb 2019 11:49:22 +0000 From: Eric Wong To: SZEDER =?utf-8?B?R8OhYm9y?= Cc: meta@public-inbox.org Subject: [PATCH] viewdiff: group path match to not be confused by "/dev/null" Message-ID: <20190204114922.GA5127@dcvr> References: <20190204105454.GG10587@szeder.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190204105454.GG10587@szeder.dev> List-Id: SZEDER Gábor wrote: > Hi, > > First of all, thanks you very much for adding syntax highlighting for > patch emails, it's fantastic! You're welcome, but it's clearly a work-in-progress :) > However, I noticed that a patch I recently sent to the Git mailing > list got bogus syntax highlighting, as the added line is colored as > removed: > > https://public-inbox.org/git/20190202163421.19686-1-szeder.dev@gmail.com/ > > Perhaps the '>' shell redirection operator causes troubles? I clicked > around in the list archives, and sure enough found other occurrance of > this bug, that also seems to suggest that a '>' might be problematic > only when it's on the first added line: Not the '>', it was actually "/dev/null" :x The following seems to work: ---------8<-------- Subject: [PATCH] viewdiff: group path match to not be confused by "/dev/null" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Leaving out parentheses caused transitions to state="del" or state="add" to be misidentified. cf. https://public-inbox.org/meta/20190204105454.GG10587@szeder.dev/ Reported-by: SZEDER Gábor --- 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 c818203..a773e38 100644 --- a/lib/PublicInbox/ViewDiff.pm +++ b/lib/PublicInbox/ViewDiff.pm @@ -190,8 +190,8 @@ sub flush_diff ($$$) { $$dst .= ''; $state = DSTATE_CTX; $$dst .= to_html($linkify, $s); - } elsif ($s =~ m!^--- $PATH_A! || - $s =~ m!^\+{3} $PATH_B!) { + } elsif ($s =~ m!^--- (?:$PATH_A)! || + $s =~ m!^\+{3} (?:$PATH_B)!) { # color only (no oid link) if missing dctx->{oid_*} $state <= DSTATE_STAT and to_state($dst, $state, DSTATE_HEAD); -- EW