Skip to content

Commit bc434e8

Browse files
bookgitster
authored andcommitted
cvsimport: allow for multiple -M options
Use Getopt::Long instead of Getopt::Std to handle multiple -M options, for all the cases when having a single custom regex is not enough. Signed-off-by: Philippe Bruhat (BooK) <book@cpan.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent fbbbc36 commit bc434e8

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

git-cvsimport.perl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
use strict;
1717
use warnings;
18-
use Getopt::Std;
18+
use Getopt::Long;
1919
use File::Spec;
2020
use File::Temp qw(tempfile tmpnam);
2121
use File::Path qw(mkpath);
@@ -29,7 +29,7 @@
2929
$SIG{'PIPE'}="IGNORE";
3030
$ENV{'TZ'}="UTC";
3131

32-
our ($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,$opt_P, $opt_s,$opt_m,$opt_M,$opt_A,$opt_S,$opt_L, $opt_a, $opt_r);
32+
our ($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,$opt_P, $opt_s,$opt_m,@opt_M,$opt_A,$opt_S,$opt_L, $opt_a, $opt_r);
3333
my (%conv_author_name, %conv_author_email);
3434

3535
sub usage(;$) {
@@ -112,7 +112,12 @@ sub read_repo_config {
112112

113113
my $opts = "haivmkuo:d:p:r:C:z:s:M:P:A:S:L:";
114114
read_repo_config($opts);
115-
getopts($opts) or usage();
115+
Getopt::Long::Configure( 'no_ignore_case', 'bundling' );
116+
117+
# turn the Getopt::Std specification in a Getopt::Long one,
118+
# with support for multiple -M options
119+
GetOptions( map { s/:/=s/; /M/ ? "$_\@" : $_ } split( /(?!:)/, $opts ) )
120+
or usage();
116121
usage if $opt_h;
117122

118123
if (@ARGV == 0) {
@@ -166,8 +171,8 @@ sub read_repo_config {
166171
if ($opt_m) {
167172
@mergerx = ( qr/\b(?:from|of|merge|merging|merged) ([-\w]+)/i );
168173
}
169-
if ($opt_M) {
170-
push (@mergerx, qr/$opt_M/);
174+
if (@opt_M) {
175+
push (@mergerx, map { qr/$_/ } @opt_M);
171176
}
172177

173178
# Remember UTC of our starting time

0 commit comments

Comments
 (0)