From f6fdbb6804eac72eb0ccff191162a5911bf2b014 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 19 Oct 2009 02:49:55 -0400 Subject: [PATCH] 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 Signed-off-by: Junio C Hamano --- git-cvsimport.perl | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/git-cvsimport.perl b/git-cvsimport.perl index 1ad20ac964..a7d215c8aa 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -579,10 +579,21 @@ sub get_headref ($) { 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 = ""; @@ -644,7 +655,7 @@ unless (-d $git_dir) { -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"); } @@ -679,7 +690,7 @@ unless ($opt_P) { $? == 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 $!; -- 2.11.4.GIT