Skip to content

Commit

Permalink
Fix 'git cvsexportcommit -w $cvsdir ...' when used with relative $GIT…
Browse files Browse the repository at this point in the history
…_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>
  • Loading branch information
Johan Herland authored and Junio C Hamano committed Feb 27, 2008
1 parent 9057f0a commit 12f0a5e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions git-cvsexportcommit.perl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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);

Expand All @@ -15,17 +16,15 @@
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";
Expand Down
2 changes: 1 addition & 1 deletion t/t9200-git-cvsexportcommit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down

0 comments on commit 12f0a5e

Please sign in to comment.