Skip to content

Commit

Permalink
contrib/git-svn: allow rebuild to work on non-linear remote heads
Browse files Browse the repository at this point in the history
Because committing back to an SVN repository from different
machines can result in different lineages, two different
repositories running git-svn can result in different commit
SHA1s (but of the same tree).  Sometimes trees that are tracked
independently are merged together (usually via children),
resulting in non-unique git-svn-id: lines in rev-list.

Signed-off-by: Eric Wong <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
Eric Wong authored and Junio C Hamano committed Mar 21, 2006
1 parent a3c57c9 commit ac74905
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion contrib/git-svn/git-svn.perl
Original file line number Diff line number Diff line change
Expand Up @@ -850,11 +850,23 @@ sub assert_revision_unknown {
}
}

sub trees_eq {
my ($x, $y) = @_;
my @x = safe_qx('git-cat-file','commit',$x);
my @y = safe_qx('git-cat-file','commit',$y);
if (($y[0] ne $x[0]) || $x[0] !~ /^tree $sha1\n$/
|| $y[0] !~ /^tree $sha1\n$/) {
print STDERR "Trees not equal: $y[0] != $x[0]\n";
return 0
}
return 1;
}

sub assert_revision_eq_or_unknown {
my ($revno, $commit) = @_;
if (-f "$REV_DIR/$revno") {
my $current = file_to_s("$REV_DIR/$revno");
if ($commit ne $current) {
if (($commit ne $current) && !trees_eq($commit, $current)) {
croak "$REV_DIR/$revno already exists!\n",
"current: $current\nexpected: $commit\n";
}
Expand Down

0 comments on commit ac74905

Please sign in to comment.