chiark / gitweb /
dgit: Do not introduce duplicate origs in .changes files
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 26 Jun 2018 23:16:29 +0000 (00:16 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 26 Jun 2018 23:59:22 +0000 (00:59 +0100)
The .dsc and .changes matching code contained roughly
   $fieldbody =~ / \Q$item\E\n/m
but this is wrong when the $fieldbody matches $item in its last line,
and there is no trailing newline (as would be usual).  This code
is obviouslu confused because m affects only ^ $ which don't appear
in the regexp.  Change these to / \Q$item\E$/m which is what ought
to have been, and probably was, intended.

In one case we are trying to delete a line.  In that case we need to
remove the leading newline.  The field body always starts with a
newline so the use of \n rather than ^ is fine.

Closes:#869146.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
debian/changelog
dgit

index 0dc301413eb06e1e707536ed7d9a6b69ab61655f..4a0883ca8ab83ceb485b666b483f6797455f791f 100644 (file)
@@ -1,6 +1,8 @@
 dgit (5.3~) unstable; urgency=medium
 
   Bugfixes:
 dgit (5.3~) unstable; urgency=medium
 
   Bugfixes:
+  * dgit: Do not introduce duplicate origs in .changes files,
+    eg if the .changes already has that orig.  Closes:#869146.
   * Honour GIT_REFLOG_ACTION everywhere.  Closes:#901935.
   * git-debrebase new-upstream: Provide better reflog entries
     by setting GIT_REFLOG_ACTION.  Closes:#901925.
   * Honour GIT_REFLOG_ACTION everywhere.  Closes:#901935.
   * git-debrebase new-upstream: Provide better reflog entries
     by setting GIT_REFLOG_ACTION.  Closes:#901925.
diff --git a/dgit b/dgit
index bbfaea1ec6fe326a3f8f0a6022bc06453b607c55..d18cc73b000be7b6fefafb869f900d940e5bda09 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -1975,12 +1975,12 @@ END
            if ($found_same) {
                # in archive, delete from .changes if it's there
                $changed{$file} = "removed" if
            if ($found_same) {
                # in archive, delete from .changes if it's there
                $changed{$file} = "removed" if
-                   $changes->{$fname} =~ s/^.* \Q$file\E$(?:)\n//m;
-           } elsif ($changes->{$fname} =~ m/^.* \Q$file\E$(?:)\n/m) {
+                   $changes->{$fname} =~ s/\n.* \Q$file\E$(?:)$//m;
+           } elsif ($changes->{$fname} =~ m/^.* \Q$file\E$(?:)$/m) {
                # not in archive, but it's here in the .changes
            } else {
                my $dsc_data = getfield $dsc, $fname;
                # not in archive, but it's here in the .changes
            } else {
                my $dsc_data = getfield $dsc, $fname;
-               $dsc_data =~ m/^(.* \Q$file\E$)\n/m or die "$dsc_data $file ?";
+               $dsc_data =~ m/^(.* \Q$file\E$)$/m or die "$dsc_data $file ?";
                my $extra = $1;
                $extra =~ s/ \d+ /$&$placementinfo /
                    or die "$fname $extra >$dsc_data< ?"
                my $extra = $1;
                $extra =~ s/ \d+ /$&$placementinfo /
                    or die "$fname $extra >$dsc_data< ?"