cvsimport: fix relative argument filenames
One of the first things that cvsimport does is chdir to the newly created git repo. This means that any filenames given to us on the command line will be looked up relative to the git repo directory. This is probably not what the user expects, so let's remember and prepend the original directory for relative filenames. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Oct 19, 2009 at 02:49 UTC
f6fdbb6804eac72eb0ccff191162a5911bf2b014
1 file changed
+14
-3
git-cvsimport.perl
+14
-3
@@ -579,10 +579,21 @@ sub get_headref ($) {
579
return $r;
580
}
581
582
+my $user_filename_prepend = '';
583
+sub munge_user_filename {
584
+ my $name = shift;
585
+ return File::Spec->file_name_is_absolute($name) ?
586
+ $name :
587
+ $user_filename_prepend . $name;
588
+}
589
+
590
-d $git_tree
591
or mkdir($git_tree,0777)
592
or die "Could not create $git_tree: $!";
585
-chdir($git_tree);
593
+if ($git_tree ne '.') {
594
+ $user_filename_prepend = getwd() . '/';
595
+ chdir($git_tree);
596
+}
597
598
my $last_branch = "";
599
my $orig_branch = "";
@@ -644,7 +655,7 @@ unless (-d $git_dir) {
655
-f "$git_dir/cvs-authors" and
656
read_author_info("$git_dir/cvs-authors");
657
if ($opt_A) {
647
- read_author_info($opt_A);
658
+ read_author_info(munge_user_filename($opt_A));
659
write_author_info("$git_dir/cvs-authors");
660
}
661
@@ -679,7 +690,7 @@ unless ($opt_P) {
690
$? == 0 or die "git-cvsimport: fatal: cvsps reported error\n";
691
close $cvspsfh;
692
} else {
682
- $cvspsfile = $opt_P;
693
+ $cvspsfile = munge_user_filename($opt_P);
694
}
695
696
open(CVS, "<$cvspsfile") or die $!;