]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei rediff: fix construction of git-diff options
authorKyle Meyer <kyle@kyleam.com>
Fri, 21 May 2021 04:38:16 +0000 (00:38 -0400)
committerEric Wong <e@80x24.org>
Fri, 21 May 2021 09:44:33 +0000 (09:44 +0000)
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

index 3c8ebe4183f41dc3ed126c38416ec2cc3671f931..2e793df585ae82c9f6419b52848202cb21bc345c 100644 (file)
@@ -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;