@matheusbsbs / matheus-bagliano / commits / ac74905064
Fork 0

contrib/git-svn: allow rebuild to work on non-linear remote heads

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 <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>

Eric Wong committed Mar 20, 2006 at 20:51 UTC ac7490506418e3ec495775e432b7040a17449fa9
1 file changed +13 -1
contrib/git-svn/git-svn.perl
+13 -1
@@ -850,11 +850,23 @@ sub assert_revision_unknown {
850 }
851 }
852
853 +sub trees_eq {
854 + my ($x, $y) = @_;
855 + my @x = safe_qx('git-cat-file','commit',$x);
856 + my @y = safe_qx('git-cat-file','commit',$y);
857 + if (($y[0] ne $x[0]) || $x[0] !~ /^tree $sha1\n$/
858 + || $y[0] !~ /^tree $sha1\n$/) {
859 + print STDERR "Trees not equal: $y[0] != $x[0]\n";
860 + return 0
861 + }
862 + return 1;
863 +}
864 +
865 sub assert_revision_eq_or_unknown {
866 my ($revno, $commit) = @_;
867 if (-f "$REV_DIR/$revno") {
868 my $current = file_to_s("$REV_DIR/$revno");
857 - if ($commit ne $current) {
869 + if (($commit ne $current) && !trees_eq($commit, $current)) {
870 croak "$REV_DIR/$revno already exists!\n",
871 "current: $current\nexpected: $commit\n";
872 }