From 0455ec0330fd29146d6e16189cc9262566cc566d Mon Sep 17 00:00:00 2001 From: Aaron Crane Date: Sat, 6 Feb 2010 18:26:24 +0000 Subject: cvsimport: new -R option: generate .git/cvs-revisions mapping This option causes the creation or updating of a file mapping CVS (filename, revision number) pairs to Git commit IDs. This is expected to be useful if you have CVS revision numbers stored in commit messages, bug-tracking systems, email archives, and the like. Signed-off-by: Aaron Crane Signed-off-by: Junio C Hamano --- git-cvsimport.perl | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'git-cvsimport.perl') diff --git a/git-cvsimport.perl b/git-cvsimport.perl index 4853bf7a0d..9e03eee458 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -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, $opt_R); my (%conv_author_name, %conv_author_email); sub usage(;$) { @@ -40,7 +40,7 @@ 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] + [-r remote] [-R] [CVS_module] END exit(1); } @@ -110,7 +110,7 @@ sub read_repo_config { } } -my $opts = "haivmkuo:d:p:r:C:z:s:M:P:A:S:L:"; +my $opts = "haivmkuo:d:p:r:C:z:s:M:P:A:S:L:R"; read_repo_config($opts); Getopt::Long::Configure( 'no_ignore_case', 'bundling' ); @@ -659,6 +659,11 @@ if ($opt_A) { write_author_info("$git_dir/cvs-authors"); } +# open .git/cvs-revisions, if requested +open my $revision_map, '>>', "$git_dir/cvs-revisions" + or die "Can't open $git_dir/cvs-revisions for appending: $!\n" + if defined $opt_R; + # # run cvsps into a file unless we are getting @@ -742,7 +747,7 @@ sub write_tree () { } my ($patchset,$date,$author_name,$author_email,$branch,$ancestor,$tag,$logmsg); -my (@old,@new,@skipped,%ignorebranch); +my (@old,@new,@skipped,%ignorebranch,@commit_revisions); # commits that cvsps cannot place anywhere... $ignorebranch{'#CVSPS_NO_BRANCH'} = 1; @@ -825,6 +830,11 @@ sub commit { system('git' , 'update-ref', "$remote/$branch", $cid) == 0 or die "Cannot write branch $branch for update: $!\n"; + if ($revision_map) { + print $revision_map "@$_ $cid\n" for @commit_revisions; + } + @commit_revisions = (); + if ($tag) { my ($xtag) = $tag; $xtag =~ s/\s+\*\*.*$//; # Remove stuff like ** INVALID ** and ** FUNKY ** @@ -959,6 +969,7 @@ while () { push(@skipped, $fn); next; } + push @commit_revisions, [$fn, $rev]; print "Fetching $fn v $rev\n" if $opt_v; my ($tmpname, $size) = $cvs->file($fn,$rev); if ($size == -1) { @@ -981,7 +992,9 @@ while () { unlink($tmpname); } elsif ($state == 9 and /^\s+(.+?):\d+(?:\.\d+)+->(\d+(?:\.\d+)+)\(DEAD\)\s*$/) { my $fn = $1; + my $rev = $2; $fn =~ s#^/+##; + push @commit_revisions, [$fn, $rev]; push(@old,$fn); print "Delete $fn\n" if $opt_v; } elsif ($state == 9 and /^\s*$/) { -- cgit v1.2.3 From d48b28418355ef41a9501eb28a82ec0b69e62a17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Fri, 24 Sep 2010 20:00:52 +0000 Subject: perl: bump the required Perl version to 5.8 from 5.6.[21] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Formalize our dependency on perl 5.8, bumped from 5.6.[12]. We already used the three-arg form of open() which was introduced in 5.6.1, but t/t9700/test.pl explicitly depended on 5.6.2. However git-add--interactive.pl has been failing on the 5.6 line since it was introduced in v1.5.0-rc0~12^2~2 back in 2006 due to this open syntax: sub run_cmd_pipe { my $fh = undef; open($fh, '-|', @_) or die; return <$fh>; } Which when executed dies on "Can't use an undefined value as filehandle reference". Several of our tests also fail on 5.6 (even more when compiled with NO_PERL_MAKEMAKER=1): t2016-checkout-patch.sh t3904-stash-patch.sh t3701-add-interactive.sh t7105-reset-patch.sh t7501-commit.sh t9700-perl-git.sh Our code is bitrotting on 5.6 with no-one interested in fixing it, and pinning us to such an ancient release of Perl is keeping us from using useful features introduced in the 5.8 release. The 5.6 series is now over 10 years old, and the 5.6.2 maintenance release almost 7. 5.8 on the other hand is more than 8 years old. All the modern Unix-like operating systems have now upgraded to it or a later version, and 5.8 packages are available for old IRIX, AIX Solaris and Tru64 systems. Signed-off-by: Ævar Arnfjörð Bjarmason Acked-by: Tor Arntsen Acked-by: Randal L. Schwartz Signed-off-by: Junio C Hamano --- git-cvsimport.perl | 1 + 1 file changed, 1 insertion(+) (limited to 'git-cvsimport.perl') diff --git a/git-cvsimport.perl b/git-cvsimport.perl index 9e03eee458..53869fb644 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -13,6 +13,7 @@ # The head revision is on branch "origin" by default. # You can change that with the '-o' option. +use 5.008; use strict; use warnings; use Getopt::Long; -- cgit v1.2.3 From 3328acedc6104e3d46e8f0d26006d9650092ef3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Fri, 24 Sep 2010 20:00:53 +0000 Subject: perl: use "use warnings" instead of -w MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change the Perl scripts to turn on lexical warnings instead of setting the global $^W variable via the -w switch. The -w sets warnings for all code that interpreter runs, while "use warnings" is lexically scoped. The former is probably not what the authors wanted. As an auxiliary benefit it's now possible to build Git with: PERL_PATH='/usr/bin/env perl' Which would previously result in failures, since "#!/usr/bin/env perl -w" doesn't work as a shebang. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- git-cvsimport.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-cvsimport.perl') diff --git a/git-cvsimport.perl b/git-cvsimport.perl index 53869fb644..249aeaf175 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -1,4 +1,4 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl # This tool is copyright (c) 2005, Matthias Urlichs. # It is released under the Gnu Public License, version 2. -- cgit v1.2.3 From 1bb28d87e1d8897db662f48455d369860758fbdd Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Mon, 18 Oct 2010 15:11:25 +0200 Subject: {cvs,svn}import: use the new 'git read-tree --empty' Since fb1bb96 (read-tree: deprecate syntax without tree-ish args, 2010-09-10) not passing --empty caused a spurious warning that was shown to the user. Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- git-cvsimport.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-cvsimport.perl') diff --git a/git-cvsimport.perl b/git-cvsimport.perl index 9e03eee458..7ab7bbc9ea 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -611,7 +611,7 @@ my %index; # holds filenames of one index per branch unless (-d $git_dir) { system(qw(git init)); die "Cannot init the GIT db at $git_tree: $?\n" if $?; - system(qw(git read-tree)); + system(qw(git read-tree --empty)); die "Cannot init an empty tree: $?\n" if $?; $last_branch = $opt_o; -- cgit v1.2.3 From 549ad6d2f3a7090d6f73f8ebacd5d1db7a0cf90f Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Sun, 28 Nov 2010 20:39:45 +0100 Subject: cvsimport: partial whitespace cleanup in preparation of the config parse patch Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- git-cvsimport.perl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'git-cvsimport.perl') diff --git a/git-cvsimport.perl b/git-cvsimport.perl index 7ab7bbc9ea..bf953543ac 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -90,8 +90,8 @@ sub write_author_info($) { # convert getopts specs for use by git config sub read_repo_config { - # Split the string between characters, unless there is a ':' - # So "abc:de" becomes ["a", "b", "c:", "d", "e"] + # Split the string between characters, unless there is a ':' + # So "abc:de" becomes ["a", "b", "c:", "d", "e"] my @opts = split(/ *(?!:)/, shift); foreach my $o (@opts) { my $key = $o; @@ -99,13 +99,13 @@ sub read_repo_config { my $arg = 'git config'; $arg .= ' --bool' if ($o !~ /:$/); - chomp(my $tmp = `$arg --get cvsimport.$key`); + chomp(my $tmp = `$arg --get cvsimport.$key`); if ($tmp && !($arg =~ /--bool/ && $tmp eq 'false')) { - no strict 'refs'; - my $opt_name = "opt_" . $key; - if (!$$opt_name) { - $$opt_name = $tmp; - } + no strict 'refs'; + my $opt_name = "opt_" . $key; + if (!$$opt_name) { + $$opt_name = $tmp; + } } } } -- cgit v1.2.3 From 60d5985dab5d3c5a283f060414b903778adfd09a Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Wed, 29 Dec 2010 22:55:34 +0100 Subject: cvsimport: handle the parsing of uppercase config options The current code leads to fatal: bad config value for 'cvsimport.r' in .git/config for a standard use case with cvsimport.r set. cvsimport sets internal variables by checking the config for each possible command line option. The problem is that config items are case insensitive, so config.r and config.R are the same. The ugly error is due to that fact that cvsimport expects a bool for -R (and thus config.R) but a remote name for -r (and thus config.r). Fix this by making cvsimport expect long names for uppercase options. config options for cvsimport have been undocumented so far, though present in the code and advertised in several tutorials. So one may read "enhance" for "fix". Similarly, the names for the options are "documented" in the code, waitiing for their lowercase equivalents to be transformed into long config options, as well. Helped-by: Junio C Hamano Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- git-cvsimport.perl | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'git-cvsimport.perl') diff --git a/git-cvsimport.perl b/git-cvsimport.perl index bf953543ac..58f5b11dc2 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -89,6 +89,14 @@ sub write_author_info($) { } # convert getopts specs for use by git config +my %longmap = ( + 'A:' => 'authors-file', + 'M:' => 'merge-regex', + 'P:' => undef, + 'R' => 'track-revisions', + 'S:' => 'ignore-paths', +); + sub read_repo_config { # Split the string between characters, unless there is a ':' # So "abc:de" becomes ["a", "b", "c:", "d", "e"] @@ -98,8 +106,17 @@ sub read_repo_config { $key =~ s/://g; my $arg = 'git config'; $arg .= ' --bool' if ($o !~ /:$/); - - chomp(my $tmp = `$arg --get cvsimport.$key`); + my $ckey = $key; + + if (exists $longmap{$o}) { + # An uppercase option like -R cannot be + # expressed in the configuration, as the + # variable names are downcased. + $ckey = $longmap{$o}; + next if (! defined $ckey); + $ckey =~ s/-//g; + } + chomp(my $tmp = `$arg --get cvsimport.$ckey`); if ($tmp && !($arg =~ /--bool/ && $tmp eq 'false')) { no strict 'refs'; my $opt_name = "opt_" . $key; -- cgit v1.2.3 From e7cad3ccd05461b0defdef86c9d786ab6fb9fe40 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Mon, 31 Jan 2011 20:29:46 +0100 Subject: git-cvsimport.perl: Bail out right away when reading from the server fails If the CVS server is down, this reduced the git-cvsimport output from: ssh: connect to host ijbswa.cvs.sourceforge.net port 22: Connection refused Use of uninitialized value $rep in scalar chomp at /usr/local/libexec/git-core/git-cvsimport line 369. Use of uninitialized value $rep in substitution (s///) at /usr/local/libexec/git-core/git-cvsimport line 370. Expected Valid-requests from server, but got: to the less noisy: ssh: connect to host ijbswa.cvs.sourceforge.net port 22: Connection refused Failed to read from server at /usr/local/libexec/git-core/git-cvsimport line 370. In this case a silent exit() instead of the die() would probably do, but I assume that there could be cases where the connection attempt succeeds, but reading from the server fails for other reasons. Signed-off-by: Fabian Keil Signed-off-by: Junio C Hamano --- git-cvsimport.perl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'git-cvsimport.perl') diff --git a/git-cvsimport.perl b/git-cvsimport.perl index 8e683e5478..bbf327f3e8 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -366,7 +366,9 @@ sub conn { $self->{'socketo'}->write("valid-requests\n"); $self->{'socketo'}->flush(); - chomp(my $rep=$self->readline()); + my $rep=$self->readline(); + die "Failed to read from server" unless defined $rep; + chomp($rep); if ($rep !~ s/^Valid-requests\s*//) { $rep="" unless $rep; die "Expected Valid-requests from server, but got: $rep\n"; -- cgit v1.2.3 From 58fdef0cff5bcf10f2621d00466b33a5b8a39bf7 Mon Sep 17 00:00:00 2001 From: Guy Rouillier Date: Sun, 1 May 2011 01:33:52 -0400 Subject: Look for password in both CVS and CVSNT password files. In conn, if password is not passed on command line, look for a password entry in both the CVS password file and the CVSNT password file. If only one file is found and the requested repository is in that file, or if both files are found but the requested repository is found in only one file, use the password from the single file containing the repository entry. If both files are found and the requested repository is found in both files, then produce an error message. The CVS password file separates tokens with a space character, while the CVSNT password file separates tokens with an equal (=) character. Add a sub find_password_entry that accepts the password file name and a delimiter to eliminate code duplication. Signed-off-by: Guy Rouillier Signed-off-by: Junio C Hamano --- git-cvsimport.perl | 53 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 12 deletions(-) (limited to 'git-cvsimport.perl') diff --git a/git-cvsimport.perl b/git-cvsimport.perl index 8e683e5478..5c012a35d2 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -227,6 +227,31 @@ sub new { return $self; } +sub find_password_entry { + my ($cvspass, @cvsroot) = @_; + my ($file, $delim) = @$cvspass; + my $pass; + local ($_); + + if (open(my $fh, $file)) { + # :pserver:cvs@mea.tmt.tele.fi:/cvsroot/zmailer Ah) { + chomp; + s/^\/\d+\s+//; + my ($w, $p) = split($delim,$_,2); + for my $cvsroot (@cvsroot) { + if ($w eq $cvsroot) { + $pass = $p; + last CVSPASSFILE; + } + } + } + close($fh); + } + return $pass; +} + sub conn { my $self = shift; my $repo = $self->{'fullrep'}; @@ -259,19 +284,23 @@ sub conn { if ($pass) { $pass = $self->_scramble($pass); } else { - open(H,$ENV{'HOME'}."/.cvspass") and do { - # :pserver:cvs@mea.tmt.tele.fi:/cvsroot/zmailer Ah) { - chomp; - s/^\/\d+\s+//; - my ($w,$p) = split(/\s/,$_,2); - if ($w eq $rr or $w eq $rr2) { - $pass = $p; - last; - } + my @cvspass = ([$ENV{'HOME'}."/.cvspass", qr/\s/], + [$ENV{'HOME'}."/.cvs/cvspass", qr/=/]); + my @loc = (); + foreach my $cvspass (@cvspass) { + my $p = find_password_entry($cvspass, $rr, $rr2); + if ($p) { + push @loc, $cvspass->[0]; + $pass = $p; } - }; - $pass = "A" unless $pass; + } + + if (1 < @loc) { + die("Multiple cvs password files have ". + "entries for CVSROOT $opt_d: @loc"); + } elsif (!$pass) { + $pass = "A"; + } } my ($s, $rep); -- cgit v1.2.3