git-svn: remember to check for clean indices on globbed refs, too
Also, warn about dirty indices and avoid an unncessary write-tree call if the index is clean. Signed-off-by: Eric Wong <normalperson@yhbt.net>
Eric Wong committed
Feb 14, 2007 at 16:29 UTC
e8d120bd5a7e09b24c6fa2245cf429e3411028ee
1 file changed
+8
-7
git-svn.perl
+8
-7
@@ -1269,10 +1269,11 @@ sub assert_index_clean {
1269
my $x = command_oneline('write-tree');
1270
my ($y) = (command(qw/cat-file commit/, $treeish) =~
1271
/^tree ($::sha1)/mo);
1272
- if ($y ne $x) {
1273
- unlink $self->{index} or croak $!;
1274
- command_noisy('read-tree', $treeish);
1275
- }
1272
+ return if $y eq $x;
1273
+
1274
+ warn "Index mismatch: $y != $x\nrereading $treeish\n";
1275
+ unlink $self->{index} or die "unlink $self->{index}: $!\n";
1276
+ command_noisy('read-tree', $treeish);
1277
$x = command_oneline('write-tree');
1278
if ($y ne $x) {
1279
::fatal "trees ($treeish) $y != $x\n",
@@ -2755,9 +2756,6 @@ sub gs_fetch_loop_common {
2756
my $common_max = scalar @$gsv;
2757
2758
foreach my $gs (@$gsv) {
2758
- if (my $last_commit = $gs->last_commit) {
2759
- $gs->assert_index_clean($last_commit);
2760
- }
2759
my @tmp = split m#/#, $gs->{path};
2760
my $p = '';
2761
foreach (@tmp) {
@@ -2833,6 +2831,9 @@ sub gs_fetch_loop_common {
2831
}
2832
next unless $gs->match_paths($paths, $r);
2833
$gs->{logged_rev_props} = $logged;
2834
+ if (my $last_commit = $gs->last_commit) {
2835
+ $gs->assert_index_clean($last_commit);
2836
+ }
2837
my $log_entry = $gs->do_fetch($paths, $r);
2838
if ($log_entry) {
2839
$gs->do_git_commit($log_entry);