Skip to content

Commit 9f9817e

Browse files
author
Junio C Hamano
committed
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
2 parents 2cc06a0 + 061303f commit 9f9817e

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

git-cvsimport.perl

100644100755
Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use warnings;
1818
use Getopt::Std;
1919
use File::Spec;
20-
use File::Temp qw(tempfile);
20+
use File::Temp qw(tempfile tmpnam);
2121
use File::Path qw(mkpath);
2222
use File::Basename qw(basename dirname);
2323
use Time::Local;
@@ -467,13 +467,12 @@ ($$)
467467
$orig_git_index = $ENV{GIT_INDEX_FILE} if exists $ENV{GIT_INDEX_FILE};
468468

469469
my %index; # holds filenames of one index per branch
470-
{ # init with an index for origin
471-
my ($fh, $fn) = tempfile('gitXXXXXX', SUFFIX => '.idx',
472-
DIR => File::Spec->tmpdir());
473-
close ($fh);
474-
$index{$opt_o} = $fn;
475-
}
470+
$index{$opt_o} = tmpnam();
471+
476472
$ENV{GIT_INDEX_FILE} = $index{$opt_o};
473+
system("git-read-tree", $opt_o);
474+
die "read-tree failed: $?\n" if $?;
475+
477476
unless(-d $git_dir) {
478477
system("git-init-db");
479478
die "Cannot init the GIT db at $git_tree: $?\n" if $?;
@@ -502,10 +501,7 @@ ($$)
502501

503502
# populate index
504503
unless ($index{$last_branch}) {
505-
my ($fh, $fn) = tempfile('gitXXXXXX', SUFFIX => '.idx',
506-
DIR => File::Spec->tmpdir());
507-
close ($fh);
508-
$index{$last_branch} = $fn;
504+
$index{$last_branch} = tmpnam();
509505
}
510506
$ENV{GIT_INDEX_FILE} = $index{$last_branch};
511507
system('git-read-tree', $last_branch);
@@ -818,16 +814,26 @@ sub commit {
818814
if(($ancestor || $branch) ne $last_branch) {
819815
print "Switching from $last_branch to $branch\n" if $opt_v;
820816
unless ($index{$branch}) {
821-
my ($fh, $fn) = tempfile('gitXXXXXX', SUFFIX => '.idx',
822-
DIR => File::Spec->tmpdir());
823-
close ($fh);
824-
$index{$branch} = $fn;
817+
$index{$branch} = tmpnam();
825818
$ENV{GIT_INDEX_FILE} = $index{$branch};
826819
system("git-read-tree", $branch);
827820
die "read-tree failed: $?\n" if $?;
828-
} else {
821+
}
822+
# just in case
823+
$ENV{GIT_INDEX_FILE} = $index{$branch};
824+
if ($ancestor) {
825+
print "have ancestor $ancestor" if $opt_v;
826+
system("git-read-tree", $ancestor);
827+
die "read-tree failed: $?\n" if $?;
828+
}
829+
} else {
830+
# just in case
831+
unless ($index{$branch}) {
832+
$index{$branch} = tmpnam();
829833
$ENV{GIT_INDEX_FILE} = $index{$branch};
830-
}
834+
system("git-read-tree", $branch);
835+
die "read-tree failed: $?\n" if $?;
836+
}
831837
}
832838
$last_branch = $branch if $branch ne $last_branch;
833839
$state = 9;

0 commit comments

Comments
 (0)