git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Unapplied patches reminder

From
Jeff King <peff@peff.net>
Date
Oct 19, 2009, 06:49 UTC
Message-ID
<20091019064955.GB1457@coredump.intra.peff.net>
In-Reply-To
<7v63aci8id.fsf@alter.siamese.dyndns.org>
On Sun, Oct 18, 2009 at 04:31:54PM -0700, Junio C Hamano wrote:
Show 15 quoted lines
> > From:	Jeff King <peff@peff.net>
> > Subject: Re: [BUG?] git-cvsimport: path to cvspsfile
> > Date:	Wed, 23 Sep 2009 15:14:29 -0400
> > Message-ID: <20090923191428.GA30104@coredump.intra.peff.net>
> >
> >     Bug. The script does a chdir() and then looks at the cvspsfile later. I
> >     think "-A" would have the same problem. Here is a totally untested patch
> >     to address the issue. Johannes, will this is_absolute_path actually work
> >     on Windows? I think The Right Way would be to use
> >     File::Spec::file_name_is_absolute, but I haven't checked whether that is
> >     part of core perl and if so, which version it appeared in.
> 
> My understanding of this is that it is a typical "how about this" that is
> still waiting for a follow-up discussion that will result in an eventual
> solution.

Yep. I got comments from JSixt, but I never got around to re-rolling. Here it is, though still only lightly tested by me (happily, I have not had to touch CVS for a few years).

-- >8 --
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 <peff@peff.net>
---
 git-cvsimport.perl |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index 1ad20ac..a7d215c 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 $!;
-- 
1.6.5.1.121.g1a4d5
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 15 in “Unapplied patches reminder”
  1. Nanako ShiraishiOct 18, 2009
  2. Junio C HamanoOct 18, 2009
  3. Junio C HamanoOct 18, 2009
  4. Heiko VoigtOct 19, 2009
  5. Junio C HamanoOct 18, 2009
  6. Jeff KingOct 19, 2009
  7. Junio C HamanoOct 19, 2009
  8. Junio C HamanoOct 18, 2009
  9. Rolf Bjarne KvingeOct 19, 2009
  10. Per StrandhOct 19, 2009
  11. Junio C HamanoOct 18, 2009
  12. Junio C HamanoOct 18, 2009
  13. Greg PriceDec 7, 2009
  14. Junio C HamanoOct 18, 2009
  15. Junio C HamanoOct 18, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.