* [PATCH] cvsimport: allow for multiple -M options
@ 2008-02-21 14:25 Philippe Bruhat (BooK)
2008-02-23 22:51 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Philippe Bruhat (BooK) @ 2008-02-21 14:25 UTC (permalink / raw)
To: git; +Cc: gitster, Philippe Bruhat (BooK)
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.
For example, "merged (\w+)" and "(\w+) merged" can't be easily turned
into a single regular expression capturing the branch name in $1.
Signed-off-by: Philippe Bruhat (BooK) <book@cpan.org>
---
git-cvsimport.perl | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index 3d013a7..f138a01 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -15,7 +15,7 @@
use strict;
use warnings;
-use Getopt::Std;
+use Getopt::Long;
use File::Spec;
use File::Temp qw(tempfile tmpnam);
use File::Path qw(mkpath);
@@ -29,7 +29,7 @@ use IPC::Open2;
$SIG{'PIPE'}="IGNORE";
$ENV{'TZ'}="UTC";
-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);
+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);
my (%conv_author_name, %conv_author_email);
sub usage(;$) {
@@ -112,7 +112,12 @@ sub read_repo_config {
my $opts = "haivmkuo:d:p:r:C:z:s:M:P:A:S:L:";
read_repo_config($opts);
-getopts($opts) or usage();
+Getopt::Long::Configure( 'no_ignore_case' );
+
+# turn the Getopt::Std specification in a Getopt::Long one,
+# with support for multiple -M options
+GetOptions( map { s/:/=s/; /M/ ? "$_\@" : $_ } split( /(?!:)/, $opts ) )
+ or usage();
usage if $opt_h;
if (@ARGV == 0) {
@@ -166,8 +171,8 @@ our @mergerx = ();
if ($opt_m) {
@mergerx = ( qr/\b(?:from|of|merge|merging|merged) ([-\w]+)/i );
}
-if ($opt_M) {
- push (@mergerx, qr/$opt_M/);
+if (@opt_M) {
+ push (@mergerx, map { qr/$_/ } @opt_M);
}
# Remember UTC of our starting time
--
1.5.4.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] cvsimport: allow for multiple -M options
2008-02-21 14:25 [PATCH] cvsimport: allow for multiple -M options Philippe Bruhat (BooK)
@ 2008-02-23 22:51 ` Junio C Hamano
0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2008-02-23 22:51 UTC (permalink / raw)
To: Philippe Bruhat (BooK); +Cc: git
This seems to break t9600.
* expecting success:
cd module-git &&
git config cvsimport.module module &&
git cvsimport -a -z0 &&
git merge origin &&
cd .. &&
git diff module-cvs/tick module-git/tick
Unknown option: z0
Usage: git-cvsimport # fetch/update GIT from CVS
[-o branch-for-HEAD] [-h] [-v] [-d CVSROOT] [-A
author-conv-file]
[-p opts-for-cvsps] [-P file] [-C GIT_repository] [-z
fuzz] [-i] [-k]
[-u] [-s subst] [-a] [-m] [-M regex] [-S regex] [-L
commitlimit]
[-r remote] [CVS_module]
* FAIL 8: cvsimport.module config works
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] cvsimport: allow for multiple -M options
2008-02-28 10:18 ` [PATCH] cvsimport: have default merge regex allow for dashes in the branch name Philippe Bruhat (BooK)
@ 2008-02-28 10:18 ` Philippe Bruhat (BooK)
0 siblings, 0 replies; 3+ messages in thread
From: Philippe Bruhat (BooK) @ 2008-02-28 10:18 UTC (permalink / raw)
To: git; +Cc: gitster, Philippe Bruhat (BooK
From: Philippe Bruhat (BooK <book@cpan.org>
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.
For example, "merged (\w+)" and "(\w+) merged" can't be easily turned
into a single regular expression capturing the branch name in $1.
---
git-cvsimport.perl | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index 3d013a7..f138a01 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -15,7 +15,7 @@
use strict;
use warnings;
-use Getopt::Std;
+use Getopt::Long;
use File::Spec;
use File::Temp qw(tempfile tmpnam);
use File::Path qw(mkpath);
@@ -29,7 +29,7 @@ use IPC::Open2;
$SIG{'PIPE'}="IGNORE";
$ENV{'TZ'}="UTC";
-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);
+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);
my (%conv_author_name, %conv_author_email);
sub usage(;$) {
@@ -112,7 +112,12 @@ sub read_repo_config {
my $opts = "haivmkuo:d:p:r:C:z:s:M:P:A:S:L:";
read_repo_config($opts);
-getopts($opts) or usage();
+Getopt::Long::Configure( 'no_ignore_case' );
+
+# turn the Getopt::Std specification in a Getopt::Long one,
+# with support for multiple -M options
+GetOptions( map { s/:/=s/; /M/ ? "$_\@" : $_ } split( /(?!:)/, $opts ) )
+ or usage();
usage if $opt_h;
if (@ARGV == 0) {
@@ -166,8 +171,8 @@ our @mergerx = ();
if ($opt_m) {
@mergerx = ( qr/\b(?:from|of|merge|merging|merged) ([-\w]+)/i );
}
-if ($opt_M) {
- push (@mergerx, qr/$opt_M/);
+if (@opt_M) {
+ push (@mergerx, map { qr/$_/ } @opt_M);
}
# Remember UTC of our starting time
--
1.5.4.2.187.gfc276
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-02-28 10:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-21 14:25 [PATCH] cvsimport: allow for multiple -M options Philippe Bruhat (BooK)
2008-02-23 22:51 ` Junio C Hamano
-- strict thread matches above, loose matches on Subject: below --
2008-02-28 10:18 Multiple -M options for git-cvsimport Philippe Bruhat (BooK)
2008-02-28 10:18 ` [PATCH] cvsimport: have default merge regex allow for dashes in the branch name Philippe Bruhat (BooK)
2008-02-28 10:18 ` [PATCH] cvsimport: allow for multiple -M options Philippe Bruhat (BooK)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).