Skip to content

Commit

Permalink
cvsimport: setup indexes correctly for ancestors and incremental imports
Browse files Browse the repository at this point in the history
Two bugs had slipped in the "keep one index per branch during import"
patch. Both incremental imports and new branches would see an
empty tree for their initial commit. Now we cover all the relevant
cases, checking whether we actually need to setup the index before
preparing the actual commit, and doing it.

Signed-off-by: Martin Langhoff <martin@catalyst.net.nz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Martin Langhoff authored and Junio C Hamano committed Jun 24, 2006
1 parent acb7014 commit 7ccd900
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions git-cvsimport.perl
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
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;
Expand Down Expand Up @@ -467,12 +467,8 @@ ($$)
$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};
unless(-d $git_dir) {
system("git-init-db");
Expand Down Expand Up @@ -502,10 +498,7 @@ ($$)

# 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);
Expand Down Expand Up @@ -818,16 +811,28 @@ sub commit {
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);
}
if ($ancestor) {
system("git-read-tree", $ancestor);
die "read-tree failed: $?\n" if $?;
} else {
unless ($index{$branch}) {
$index{$branch} = tmpnam();
$ENV{GIT_INDEX_FILE} = $index{$branch};
system("git-read-tree", $branch);
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;
Expand Down

0 comments on commit 7ccd900

Please sign in to comment.