chiark / gitweb /
dgit: importing: Better handle commas in changelog maintainer fields
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 5 Feb 2017 15:22:32 +0000 (15:22 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 5 Feb 2017 20:46:47 +0000 (20:46 +0000)
Some maintainers have written commas in the maintainer field of their
changelog entries.  Such changelog entries could not be imported.

clogp_authline had code to replace multiple maintainers (which are
hypothetical right now) into just the first, but that trips on these
maintainers with commas.

Ultimately we should expect that the Maintainer: field from
dpkg-parsechangelog is in (a subset of) RFC5322 recipient field
format.  In that format, any commas would need to be quoted.

So:

If the Maintainer field from dpkg-parsechangelog has a comma which has
no @ or " before it, then we consider it a single old-school
comma-containing maintainer.  If it were intended as multiple
maintainers, then the first maintainer has no email address.  Not
coping properly with that very-hypothetical future seems OK.  We
simply delete the comma, so that the things we record in the git
history are more conservative.

If there is a " we leave things untouched in the hope that this is a
single address, albeit with some quoting.  The alternative would be to
try to use a full RFC5322 parser.  That's quite a risky change.

Perhaps we will revisit this after stretch.

For now this Closes:#852661.

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

index 4e3ecdcbcc8b6802a820a000acac967a46f64c9a..226920129ea3e055cd30fdf137a664bcc2c19b23 100644 (file)
@@ -6,6 +6,8 @@ dgit (3.10~) unstable; urgency=medium
   * dgit: Strip initial newline from Changes line from dpkg-parsechangelog
     so as to avoid blank line in commit messages.  Closes:#853093.
   * dgit: Do not fail when run with detached HEAD.  Closes:#853022.
   * dgit: Strip initial newline from Changes line from dpkg-parsechangelog
     so as to avoid blank line in commit messages.  Closes:#853093.
   * dgit: Do not fail when run with detached HEAD.  Closes:#853022.
+  * dgit: Be much better about commas in maintainer changelog names.
+    Closes:#852661.
 
   Test suite:
   * quilt-useremail: New test for user config copying (#853085).
 
   Test suite:
   * quilt-useremail: New test for user config copying (#853085).
diff --git a/dgit b/dgit
index 724dba10ef557e79a9ad2ebb1ec47ccb5f82f917..6b1201e7aee73dbc46cdcaa89b3c0b72987f49ce 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -1995,7 +1995,14 @@ sub make_commit_text ($) {
 sub clogp_authline ($) {
     my ($clogp) = @_;
     my $author = getfield $clogp, 'Maintainer';
 sub clogp_authline ($) {
     my ($clogp) = @_;
     my $author = getfield $clogp, 'Maintainer';
-    $author =~ s#,.*##ms;
+    if ($author =~ m/^[^"\@]+\,/) {
+       # single entry Maintainer field with unquoted comma
+       $author = ($& =~ y/,//rd).$'; # strip the comma
+    }
+    # git wants a single author; any remaining commas in $author
+    # are by now preceded by @ (or ").  It seems safer to punt on
+    # "..." for now rather than attempting to dequote or something.
+    $author =~ s#,.*##ms unless $author =~ m/"/;
     my $date = cmdoutput qw(date), '+%s %z', qw(-d), getfield($clogp,'Date');
     my $authline = "$author $date";
     $authline =~ m/$git_authline_re/o or
     my $date = cmdoutput qw(date), '+%s %z', qw(-d), getfield($clogp,'Date');
     my $authline = "$author $date";
     $authline =~ m/$git_authline_re/o or