summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 795c7c0)
raw | patch | inline | side by side (parent: 795c7c0)
author | Jeff King <peff@peff.net> | |
Wed, 28 Nov 2007 18:56:11 +0000 (13:56 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 28 Nov 2007 22:38:06 +0000 (14:38 -0800) |
Previously, if refs were packed, git-cvsimport would assume
that particular refs did not exist. This could lead to, for
example, overwriting previous 'origin' commits that were
packed.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
that particular refs did not exist. This could lead to, for
example, overwriting previous 'origin' commits that were
packed.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-cvsimport.perl | patch | blob | history | |
t/t9600-cvsimport.sh | patch | blob | history |
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index e4bc2b54f68930df217751975e32b4224f8d765c..a7a7d8f44df7b65f493d5a12fe3c7051f2c4b4a9 100755 (executable)
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
return $s =~ /^[a-f0-9]{40}$/;
}
-sub get_headref ($$) {
- my $name = shift;
- my $git_dir = shift;
-
- my $f = "$git_dir/$remote/$name";
- if (open(my $fh, $f)) {
- chomp(my $r = <$fh>);
- is_sha1($r) or die "Cannot get head id for $name ($r): $!";
- return $r;
- }
- die "unable to open $f: $!" unless $! == POSIX::ENOENT;
- return undef;
+sub get_headref ($) {
+ my $name = shift;
+ my $r = `git rev-parse --verify '$name' 2>/dev/null`;
+ return undef unless $? == 0;
+ chomp $r;
+ return $r;
}
-d $git_tree
$ignorebranch{'#CVSPS_NO_BRANCH'} = 1;
sub commit {
- if ($branch eq $opt_o && !$index{branch} && !get_headref($branch, $git_dir)) {
+ if ($branch eq $opt_o && !$index{branch} &&
+ !get_headref("$remote/$branch")) {
# looks like an initial commit
# use the index primed by git-init
$ENV{GIT_INDEX_FILE} = "$git_dir/index";
update_index(@old, @new);
@old = @new = ();
my $tree = write_tree();
- my $parent = get_headref($last_branch, $git_dir);
+ my $parent = get_headref("$remote/$last_branch");
print "Parent ID " . ($parent ? $parent : "(empty)") . "\n" if $opt_v;
my @commit_args;
foreach my $rx (@mergerx) {
next unless $logmsg =~ $rx && $1;
my $mparent = $1 eq 'HEAD' ? $opt_o : $1;
- if (my $sha1 = get_headref($mparent, $git_dir)) {
+ if (my $sha1 = get_headref("$remote/$mparent")) {
push @commit_args, '-p', $mparent;
print "Merge parent branch: $mparent\n" if $opt_v;
}
diff --git a/t/t9600-cvsimport.sh b/t/t9600-cvsimport.sh
index 1ee06bb3863956ea5566558ef00ec18a2de357b1..3338d447c5b7b43ac274e6966ee693611f5e8056 100755 (executable)
--- a/t/t9600-cvsimport.sh
+++ b/t/t9600-cvsimport.sh
'
+test_expect_success 'pack refs' 'cd module-git && git gc && cd ..'
+
test_expect_success 'update cvs module' '
cd module-cvs &&