chiark / gitweb /
git-debrebase: convert-from-*: snag on discarding comments in series
[dgit.git] / git-debrebase
index 4a705854c1581754e6eea4c69b1c672ea83b8ea7..5fabfd6762e7a3d407521cafe17047ad5bb242e0 100755 (executable)
@@ -232,12 +232,13 @@ sub trees_diff_walk ($$$;$) {
     # $x and $y are as for get_tree
     # where $name, $ix, $iy are $name and $info from get_tree
     # opts are   all       call even for names same in both
+    #            recurse   call even for names same in both
     my $opts = shift @_ if @_>=4;
     my ($x,$y,$call) = @_;
     my $all = $opts->{all};
     return if !$all and $x eq $y;
-    my @x = get_tree $x;
-    my @y = get_tree $y;
+    my @x = get_tree $x, 0, $opts->{recurse};
+    my @y = get_tree $y, 0, $opts->{recurse};
     printdebug "trees_diff_walk(..$x,$y..) ".Dumper(\@x,\@y)
        if $debuglevel >= 3;
     while (@x || @y) {
@@ -309,13 +310,16 @@ sub get_differs ($$) {
 
            my $xp = $ix && "$xd/patches";
            my $yp = $iy && "$yd/patches";
-           trees_diff_walk $xp, $yp, sub {
+           trees_diff_walk { recurse=>1 }, $xp, $yp, sub {
                my ($n,$ix,$iy) = @_;
 
                # analyse difference in debian/patches
 
                my $ok;
-               if ($n !~ m/\.series$/s && !$ix && $plain->($iy)) {
+               if ($n =~ m{/$}s) {
+                   # we are recursing; directories may appear and disappear
+                   $ok = 1;
+               } elsif ($n !~ m/\.series$/s && !$ix && $plain->($iy)) {
                    $ok = 1;
                } elsif ($n eq 'series' && $plain->($ix) && $plain->($iy)) {
                    my $x_s = (git_cat_file "$xp/series", 'blob');
@@ -2445,7 +2449,14 @@ sub check_series_has_all_patches ($) {
        [qw(blob missing)];
     $series //= '';
     my %series;
+    our $comments_snagged;
     foreach my $f (grep /\S/, grep {!m/^\s\#/} split /\n/, $series) {
+       if ($f =~ m/^\s*\#/) {
+           snag 'series-comments',
+               "$seriesfn contains comments, which will be discarded"
+               unless $comments_snagged++;
+           next;
+       }
        fail "patch $f repeated in $seriesfn !" if $series{$f}++;
     }
     foreach my $patchfile (get_tree "$head:debian/patches", 1,1) {