Skip to content

Commit

Permalink
cvsimport: fix relative argument filenames
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Oct 19, 2009
1 parent b142da2 commit f6fdbb6
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions git-cvsimport.perl
Original file line number Diff line number Diff line change
Expand Up @@ -579,10 +579,21 @@ ($)
return $r;
}

my $user_filename_prepend = '';
sub munge_user_filename {
my $name = shift;
return File::Spec->file_name_is_absolute($name) ?
$name :
$user_filename_prepend . $name;
}

-d $git_tree
or mkdir($git_tree,0777)
or die "Could not create $git_tree: $!";
chdir($git_tree);
if ($git_tree ne '.') {
$user_filename_prepend = getwd() . '/';
chdir($git_tree);
}

my $last_branch = "";
my $orig_branch = "";
Expand Down Expand Up @@ -644,7 +655,7 @@ ($)
-f "$git_dir/cvs-authors" and
read_author_info("$git_dir/cvs-authors");
if ($opt_A) {
read_author_info($opt_A);
read_author_info(munge_user_filename($opt_A));
write_author_info("$git_dir/cvs-authors");
}

Expand Down Expand Up @@ -679,7 +690,7 @@ ($)
$? == 0 or die "git-cvsimport: fatal: cvsps reported error\n";
close $cvspsfh;
} else {
$cvspsfile = $opt_P;
$cvspsfile = munge_user_filename($opt_P);
}

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

0 comments on commit f6fdbb6

Please sign in to comment.