summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Herland <johan@herland.net>2008-02-11 23:43:41 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-02-27 19:35:09 (GMT)
commit12f0a5ea7dc999bfe06973bf61261fc809c2b2fb (patch)
treee7a83d864a852fe0f177b1ddb242b476d3aedb07
parent9057f0a62c8681bcff8460fec80747a6aa5b43c8 (diff)
downloadgit-12f0a5ea7dc999bfe06973bf61261fc809c2b2fb.zip
git-12f0a5ea7dc999bfe06973bf61261fc809c2b2fb.tar.gz
git-12f0a5ea7dc999bfe06973bf61261fc809c2b2fb.tar.bz2
Fix 'git cvsexportcommit -w $cvsdir ...' when used with relative $GIT_DIR
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xgit-cvsexportcommit.perl11
-rwxr-xr-xt/t9200-git-cvsexportcommit.sh2
2 files changed, 6 insertions, 7 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";
diff --git a/t/t9200-git-cvsexportcommit.sh b/t/t9200-git-cvsexportcommit.sh
index 7e25a39..49d57a8 100755
--- a/t/t9200-git-cvsexportcommit.sh
+++ b/t/t9200-git-cvsexportcommit.sh
@@ -246,7 +246,7 @@ test_expect_success \
;;
esac
-test_expect_failure '-w option should work with relative GIT_DIR' '
+test_expect_success '-w option should work with relative GIT_DIR' '
mkdir W &&
echo foobar >W/file1.txt &&
echo bazzle >W/file2.txt &&