Skip to content

Commit f6fdbb6

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b142da2 commit f6fdbb6

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

git-cvsimport.perl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,10 +579,21 @@ ($)
579579
return $r;
580580
}
581581

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+
582590
-d $git_tree
583591
or mkdir($git_tree,0777)
584592
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+
}
586597

587598
my $last_branch = "";
588599
my $orig_branch = "";
@@ -644,7 +655,7 @@ ($)
644655
-f "$git_dir/cvs-authors" and
645656
read_author_info("$git_dir/cvs-authors");
646657
if ($opt_A) {
647-
read_author_info($opt_A);
658+
read_author_info(munge_user_filename($opt_A));
648659
write_author_info("$git_dir/cvs-authors");
649660
}
650661

@@ -679,7 +690,7 @@ ($)
679690
$? == 0 or die "git-cvsimport: fatal: cvsps reported error\n";
680691
close $cvspsfh;
681692
} else {
682-
$cvspsfile = $opt_P;
693+
$cvspsfile = munge_user_filename($opt_P);
683694
}
684695

685696
open(CVS, "<$cvspsfile") or die $!;

0 commit comments

Comments
 (0)