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: AS3215 2.0.0.0/16 X-Spam-Status: No, score=-3.3 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from out1.migadu.com (out1.migadu.com [IPv6:2001:41d0:2:863f::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id DA7911F5AE for ; Fri, 21 May 2021 04:38:24 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kyleam.com; s=key1; t=1621571900; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=5lR5C4CLj/jFyk2ic1R69xtCD1LLmMXoR+sQyi3bLqc=; b=j30Tt7L14H3MNkw1E93F2nztOKc1s1OjyyQz+EBI3oy518PJwZqv+GxDSezyRML+ZJLo9h hVr5uuR184c0LZ1upVbaaLcZh01ISuHG+CP6xyOAWHiItK1fyLZnDO797o/0gaJd9lHS8T BzQKJ8ufB3wLVM9AWqrZeIT7zO9bF0D3N2VI/QKicrUMB3XjVlASMO4cqfLta2J/Yz+ecV hzpCI581Wd6vadV9voqUSBmPa+8dithy8yFtOo090SryURNNUh4Srxgc4K/Cful7LmjrVi bwaoN+b+hYQJK3rl4F41b5wZe+o85LlFFF9NOcGgBzINEuvKkf0txqGnz8kykw== From: Kyle Meyer To: meta@public-inbox.org Subject: [PATCH] lei rediff: fix construction of git-diff options Date: Fri, 21 May 2021 00:38:16 -0400 Message-Id: <20210521043816.23838-1-kyle@kyleam.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: kyle@kyleam.com List-Id: When generating git-diff options, lei-rediff extracts the single character option from the lei option spec. However, there's no check that the regular expression actually matches, leading to an unintentional git-diff option when there isn't a short option (e.g., --inter-hunk-context=1 maps to the invalid `git diff --color -w1'). Check for a match before trying to extract the single character option. Fixes: cf0c7ce3ce81b5c3 (lei rediff: regenerate diffs from stdin) --- lib/PublicInbox/LeiRediff.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/LeiRediff.pm b/lib/PublicInbox/LeiRediff.pm index 3c8ebe41..2e793df5 100644 --- a/lib/PublicInbox/LeiRediff.pm +++ b/lib/PublicInbox/LeiRediff.pm @@ -108,8 +108,9 @@ EOM push @cmd, '--'.($opt->{color} && !$opt->{'no-color'} ? '' : 'no-'). 'color'; for my $o (@PublicInbox::LEI::diff_opt) { - $o =~ s/\|([a-z0-9])\b//i; # remove single char short option - my $c = $1; + my $c = ''; + # remove single char short option + $o =~ s/\|([a-z0-9])\b//i and $c = $1; if ($o =~ s/=[is]@\z//) { my $v = $opt->{$o} or next; push @cmd, map { $c ? "-$c$_" : "--$o=$_" } @$v; base-commit: 2f720902ed702b64d918165ba21a96dabbeeca26 -- 2.31.1