Re: [PATCH] Fix 'git cvsexportcommit -w $cvsdir ...' when used with relative $GIT_DIR
- From
Robin Rosenberg <robin.rosenberg.lists@dewire.com>
- Date
- Feb 11, 2008, 20:58 UTC
- Message-ID
- <200802112158.16830.robin.rosenberg.lists@dewire.com>
- In-Reply-To
- <200802110228.05233.johan@herland.net>
måndagen den 11 februari 2008 skrev Johan Herland:
> 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 with "fatal: Not a git repository".
[...]
Show 7 quoted lines
> 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
> + # Oops no GIT_DIR set. Figure out for ourselvesThat's not an "Oops". It's perfectly normal not to have GIT_DIR set.
Show 11 quoted lines
> my $gd =`git-rev-parse --git-dir`;
> chomp($gd);
> - if ($gd eq '.git') {
> - my $wd = `pwd`;Kopia
> - chomp($wd);
> - $gd = $wd."/.git" ;
> - }
> + $ENV{GIT_DIR} = $gd;
> + }
> + unless ($ENV{GIT_DIR} =~ m[^/]) {
> + # GIT_DIR is relative. Prepend $PWDHmm. C:/foo? You should probably use rel2abs in the File::Spec module.
-- robin