summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-06-26 21:35:33 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-06-26 21:35:33 (GMT)
commit9f9817e34a2cdead809854a0b3b2c93969663402 (patch)
tree75138a3b7a2f643211f1a36e2e64541eda86199e
parent2cc06a0500b4b69e8563f76c42306e36b1f0aabf (diff)
parent061303f0b50a648db8e0af23791fc56181f6bf93 (diff)
downloadgit-9f9817e34a2cdead809854a0b3b2c93969663402.zip
git-9f9817e34a2cdead809854a0b3b2c93969663402.tar.gz
git-9f9817e34a2cdead809854a0b3b2c93969663402.tar.bz2
Merge branch 'ml/cvsimport'
* ml/cvsimport: cvsimport: always set $ENV{GIT_INDEX_FILE} to $index{$branch} cvsimport: setup indexes correctly for ancestors and incremental imports
-rwxr-xr-x[-rw-r--r--]git-cvsimport.perl40
1 files changed, 23 insertions, 17 deletions
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index f3daa6c..50f5d96 100644..100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -17,7 +17,7 @@ use strict;
use warnings;
use Getopt::Std;
use File::Spec;
-use File::Temp qw(tempfile);
+use File::Temp qw(tempfile tmpnam);
use File::Path qw(mkpath);
use File::Basename qw(basename dirname);
use Time::Local;
@@ -467,13 +467,12 @@ my $orig_git_index;
$orig_git_index = $ENV{GIT_INDEX_FILE} if exists $ENV{GIT_INDEX_FILE};
my %index; # holds filenames of one index per branch
-{ # init with an index for origin
- my ($fh, $fn) = tempfile('gitXXXXXX', SUFFIX => '.idx',
- DIR => File::Spec->tmpdir());
- close ($fh);
- $index{$opt_o} = $fn;
-}
+$index{$opt_o} = tmpnam();
+
$ENV{GIT_INDEX_FILE} = $index{$opt_o};
+system("git-read-tree", $opt_o);
+die "read-tree failed: $?\n" if $?;
+
unless(-d $git_dir) {
system("git-init-db");
die "Cannot init the GIT db at $git_tree: $?\n" if $?;
@@ -502,10 +501,7 @@ unless(-d $git_dir) {
# populate index
unless ($index{$last_branch}) {
- my ($fh, $fn) = tempfile('gitXXXXXX', SUFFIX => '.idx',
- DIR => File::Spec->tmpdir());
- close ($fh);
- $index{$last_branch} = $fn;
+ $index{$last_branch} = tmpnam();
}
$ENV{GIT_INDEX_FILE} = $index{$last_branch};
system('git-read-tree', $last_branch);
@@ -818,16 +814,26 @@ while(<CVS>) {
if(($ancestor || $branch) ne $last_branch) {
print "Switching from $last_branch to $branch\n" if $opt_v;
unless ($index{$branch}) {
- my ($fh, $fn) = tempfile('gitXXXXXX', SUFFIX => '.idx',
- DIR => File::Spec->tmpdir());
- close ($fh);
- $index{$branch} = $fn;
+ $index{$branch} = tmpnam();
$ENV{GIT_INDEX_FILE} = $index{$branch};
system("git-read-tree", $branch);
die "read-tree failed: $?\n" if $?;
- } else {
+ }
+ # just in case
+ $ENV{GIT_INDEX_FILE} = $index{$branch};
+ if ($ancestor) {
+ print "have ancestor $ancestor" if $opt_v;
+ system("git-read-tree", $ancestor);
+ die "read-tree failed: $?\n" if $?;
+ }
+ } else {
+ # just in case
+ unless ($index{$branch}) {
+ $index{$branch} = tmpnam();
$ENV{GIT_INDEX_FILE} = $index{$branch};
- }
+ system("git-read-tree", $branch);
+ die "read-tree failed: $?\n" if $?;
+ }
}
$last_branch = $branch if $branch ne $last_branch;
$state = 9;