user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] lei rediff: fix construction of git-diff options
@ 2021-05-21  4:38 Kyle Meyer
  2021-05-21  9:52 ` Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Kyle Meyer @ 2021-05-21  4:38 UTC (permalink / raw)
  To: meta

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] lei rediff: fix construction of git-diff options
  2021-05-21  4:38 [PATCH] lei rediff: fix construction of git-diff options Kyle Meyer
@ 2021-05-21  9:52 ` Eric Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2021-05-21  9:52 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: meta

Kyle Meyer <kyle@kyleam.com> wrote:
> 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)

Oops :x   Spending years in another language corrupted my
mind to believe $1 gets clobbered on failed matches;
but that's not the case for Perl.

An unrelated patch I'm working on had the same problem :x

Anyways, pushed as commit 3c1d0da4d0608b5a87371e602a911964d7c1498c
Thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-21  9:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-21  4:38 [PATCH] lei rediff: fix construction of git-diff options Kyle Meyer
2021-05-21  9:52 ` Eric Wong

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.mail.public-inbox.meta
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.mail.public-inbox.meta
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git