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>
Philippe Bruhat (BooK committed
Feb 28, 2008 at 11:18 UTC
bc434e829c6f1757d2761c50e06a28278dc2f2c7
1 file changed
+10
-5
git-cvsimport.perl
+10
-5
@@ -15,7 +15,7 @@
15
16
use strict;
17
use warnings;
18
-use Getopt::Std;
18
+use Getopt::Long;
19
use File::Spec;
20
use File::Temp qw(tempfile tmpnam);
21
use File::Path qw(mkpath);
@@ -29,7 +29,7 @@ use IPC::Open2;
29
$SIG{'PIPE'}="IGNORE";
30
$ENV{'TZ'}="UTC";
31
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);
33
my (%conv_author_name, %conv_author_email);
34
35
sub usage(;$) {
@@ -112,7 +112,12 @@ sub read_repo_config {
112
113
my $opts = "haivmkuo:d:p:r:C:z:s:M:P:A:S:L:";
114
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();
121
usage if $opt_h;
122
123
if (@ARGV == 0) {
@@ -166,8 +171,8 @@ our @mergerx = ();
171
if ($opt_m) {
172
@mergerx = ( qr/\b(?:from|of|merge|merging|merged) ([-\w]+)/i );
173
}
169
-if ($opt_M) {
170
- push (@mergerx, qr/$opt_M/);
174
+if (@opt_M) {
175
+ push (@mergerx, map { qr/$_/ } @opt_M);
176
}
177
178
# Remember UTC of our starting time