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

[PATCH] Fix 'git cvsexportcommit -w $cvsdir ...' when used with relative $GIT_DIR

From
Johan Herland <johan@herland.net>
Date
Feb 11, 2008, 23:43 UTC
Message-ID
<200802120043.41610.johan@herland.net>
In-Reply-To
<200802112158.16830.robin.rosenberg.lists@dewire.com>

When using the '-w $cvsdir' option to cvsexportcommit, it will chdir into $cvsdir before executing several other git commands. If $GIT_DIR is set to a relative path (e.g. '.'), the git commands executed by cvsexportcommit will naturally fail.

Therefore, ensure that $GIT_DIR is absolute before the chdir to $cvsdir.
Signed-off-by: Johan Herland <johan@herland.net>
---
On Monday 11 February 2008, Robin Rosenberg wrote:
Show 5 quoted lines
> måndagen den 11 februari 2008 skrev Johan Herland:
> > -		# Remember where our GIT_DIR is before changing to CVS checkout
> > +		# Oops no GIT_DIR set. Figure out for ourselves
> 
> That's not an "Oops". It's perfectly normal not to have GIT_DIR set.
Of course not. Fixed.
> > +	unless ($ENV{GIT_DIR} =~ m[^/]) {
> 
> Hmm. C:/foo? You should probably use rel2abs in the File::Spec 
> module.
Thanks. Fixed.
Have fun! :)
...Johan
 git-cvsexportcommit.perl |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl
index d2e50c3..2a8ad1e 100755
--- a/git-cvsexportcommit.perl
+++ b/git-cvsexportcommit.perl
@@ -5,6 +5,7 @@ use Getopt::Std;
 use File::Temp qw(tempdir);
 use Data::Dumper;
 use File::Basename qw(basename dirname);
+use File::Spec;
 
 our ($opt_h, $opt_P, $opt_p, $opt_v, $opt_c, $opt_f, $opt_a, $opt_m, $opt_d, $opt_u, $opt_w);
 
@@ -15,17 +16,15 @@ $opt_h && usage();
 die "Need at least one commit identifier!" unless @ARGV;
 
 if ($opt_w) {
+	# Remember where GIT_DIR is before changing to CVS checkout
 	unless ($ENV{GIT_DIR}) {
-		# Remember where our GIT_DIR is before changing to CVS checkout
+		# No GIT_DIR set. Figure it out for ourselves
 		my $gd =`git-rev-parse --git-dir`;
 		chomp($gd);
-		if ($gd eq '.git') {
-			my $wd = `pwd`;
-			chomp($wd);
-			$gd = $wd."/.git"	;
-		}
 		$ENV{GIT_DIR} = $gd;
 	}
+	# Make sure GIT_DIR is absolute
+	$ENV{GIT_DIR} = File::Spec->rel2abs($ENV{GIT_DIR});
 
 	if (! -d $opt_w."/CVS" ) {
 		die "$opt_w is not a CVS checkout";
-- 
1.5.4.2.g41ac4
Previous: Robin RosenbergNext: Robin Rosenberg
Message 4 of 8 in “Fix 'git cvsexportcommit -w $cvsdir ...' when used with relative $GIT_DIR”
  1. Fix 'git cvsexportcommit -w $cvsdir ...' when used with relative $GIT_DIRJohan Herland, Feb 11, 2008
  2. Junio C HamanoFeb 11, 2008
  3. Robin RosenbergFeb 11, 2008
  4. Fix 'git cvsexportcommit -w $cvsdir ...' when used with relative $GIT_DIRJohan Herland, Feb 11, 2008
  5. Robin RosenbergFeb 12, 2008
  6. Add testcase for 'git cvsexportcommit -w $cvsdir ...' with relative $GIT_DIRJohan Herland, Feb 13, 2008
  7. Junio C HamanoFeb 13, 2008
  8. Jakub NarebskiFeb 13, 2008

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.