{"thread":{"id":"21039","subject":"[BUG?] git-cvsimport: path to cvspsfile","startedAt":"2009-09-23T18:27:56Z","lastAt":"2009-09-24T06:11:14Z","messageCount":4,"participants":["Kacper Kornet","Jeff King","Johannes Sixt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"123682","messageId":"20090923182756.GA12430@onyx.camk.edu.pl","threadId":"21039","inReplyTo":null,"subject":"[BUG?] git-cvsimport: path to cvspsfile","fromName":"Kacper Kornet","fromEmail":"kornet@camk.edu.pl","sentAt":"2009-09-23T18:27:56Z","receivedAt":"2009-09-23T18:27:56Z","isPatch":false,"sender":{"key":"kornet@camk.edu.pl","avatar":null},"body":"Hi,\n\nWhen I use:\n\ngit cvs-import -C <dir> -P <cvspsfile>\n\nit looks for <cvpsfile> relative to <dir>, not the working directory.\nIs it a bug or a feature?\n\nBest wishes,\n-- \n  Kacper\n"},{"id":"123683","messageId":"20090923191428.GA30104@coredump.intra.peff.net","threadId":"21039","inReplyTo":"20090923182756.GA12430@onyx.camk.edu.pl","subject":"Re: [BUG?] git-cvsimport: path to cvspsfile","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-09-23T19:14:29Z","receivedAt":"2009-09-23T19:14:29Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Sep 23, 2009 at 08:27:56PM +0200, Kacper Kornet wrote:\n\n> When I use:\n> \n> git cvs-import -C <dir> -P <cvspsfile>\n> \n> it looks for <cvpsfile> relative to <dir>, not the working directory.\n> Is it a bug or a feature?\n\nBug. The script does a chdir() and then looks at the cvspsfile later. I\nthink \"-A\" would have the same problem. Here is a totally untested patch\nto address the issue. Johannes, will this is_absolute_path actually work\non Windows? I think The Right Way would be to use\nFile::Spec::file_name_is_absolute, but I haven't checked whether that is\npart of core perl and if so, which version it appeared in.\n\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex 1ad20ac..08a30ec 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -579,10 +579,26 @@ sub get_headref ($) {\n \treturn $r;\n }\n \n+sub is_absolute_path {\n+\tlocal $_ = shift;\n+\treturn m{^/};\n+}\n+\n+my $user_filename_prepend = '';\n+sub munge_user_filename {\n+\tmy $name = shift;\n+\treturn is_absolute_path($name) ?\n+\t\t$name :\n+\t\t$user_filename_prepend . $name;\n+}\n+\n -d $git_tree\n \tor mkdir($git_tree,0777)\n \tor die \"Could not create $git_tree: $!\";\n-chdir($git_tree);\n+if ($git_tree ne '.') {\n+\t$user_filename_prepend = getwd() . '/';\n+\tchdir($git_tree);\n+}\n \n my $last_branch = \"\";\n my $orig_branch = \"\";\n@@ -644,7 +660,7 @@ unless (-d $git_dir) {\n -f \"$git_dir/cvs-authors\" and\n   read_author_info(\"$git_dir/cvs-authors\");\n if ($opt_A) {\n-\tread_author_info($opt_A);\n+\tread_author_info(munge_user_filename($opt_A));\n \twrite_author_info(\"$git_dir/cvs-authors\");\n }\n \n@@ -679,7 +695,7 @@ unless ($opt_P) {\n \t$? == 0 or die \"git-cvsimport: fatal: cvsps reported error\\n\";\n \tclose $cvspsfh;\n } else {\n-\t$cvspsfile = $opt_P;\n+\t$cvspsfile = munge_user_filename($opt_P);\n }\n \n open(CVS, \"<$cvspsfile\") or die $!;\n"},{"id":"123712","messageId":"4ABB0ACF.5040508@viscovery.net","threadId":"21039","inReplyTo":"20090923191428.GA30104@coredump.intra.peff.net","subject":"Re: [BUG?] git-cvsimport: path to cvspsfile","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-09-24T05:59:43Z","receivedAt":"2009-09-24T05:59:43Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Jeff King schrieb:\n> Bug. The script does a chdir() and then looks at the cvspsfile later. I\n> think \"-A\" would have the same problem. Here is a totally untested patch\n> to address the issue. Johannes, will this is_absolute_path actually work\n> on Windows? I think The Right Way would be to use\n> File::Spec::file_name_is_absolute, but I haven't checked whether that is\n> part of core perl and if so, which version it appeared in.\n\nWe have File::Spec::file_name_is_absolute in the msysgit installation. I\nsuggest you use it. It sounds like a very basic feature, and I'd be\nsurprised if it were not part of core perl.\n\n-- Hannes\n"},{"id":"123714","messageId":"20090924061114.GB24694@coredump.intra.peff.net","threadId":"21039","inReplyTo":"4ABB0ACF.5040508@viscovery.net","subject":"Re: [BUG?] git-cvsimport: path to cvspsfile","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-09-24T06:11:14Z","receivedAt":"2009-09-24T06:11:14Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Sep 24, 2009 at 07:59:43AM +0200, Johannes Sixt wrote:\n\n> Jeff King schrieb:\n> > Bug. The script does a chdir() and then looks at the cvspsfile later. I\n> > think \"-A\" would have the same problem. Here is a totally untested patch\n> > to address the issue. Johannes, will this is_absolute_path actually work\n> > on Windows? I think The Right Way would be to use\n> > File::Spec::file_name_is_absolute, but I haven't checked whether that is\n> > part of core perl and if so, which version it appeared in.\n> \n> We have File::Spec::file_name_is_absolute in the msysgit installation. I\n> suggest you use it. It sounds like a very basic feature, and I'd be\n> surprised if it were not part of core perl.\n\nLooks like File::Spec at least goes back to perl 5.004, and we are\nalready using it. I'll assume file_name_is_absolute has been there a\nwhile, then. Thanks.\n\n-Peff\n"}]}