chiark / gitweb /
dgit: Set up a merge driver for debian/changelog. Closes:#769291.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 4 Jul 2015 21:01:39 +0000 (22:01 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 4 Jul 2015 21:16:59 +0000 (22:16 +0100)
debian/changelog
dgit

index 49b8777a7f1cb518cc0e7e7b31267f2b5efd279a..9e8f572946ace82064a3249205c11dada4a009ca 100644 (file)
@@ -97,6 +97,7 @@ dgit (0.23~) unstable; urgency=low
   * For non-Debian distros, debiantag() uses distro name a la DEP-14.
   * dgit: Be more careful about tag updates during fetch: only update
     tags referring to uploads to distro we are trying to fetch from.
+  * dgit: Set up a merge driver for debian/changelog.  Closes:#769291.
 
  --
 
diff --git a/dgit b/dgit
index 802d791fb7504af58a152b3c73d1787df37aa2ba..73184fbd7ff75ea30cebe73ec512fef24e6dfa6a 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -1481,6 +1481,33 @@ sub set_local_git_config ($$) {
     runcmd @git, qw(config), $k, $v;
 }
 
+sub setup_mergechangelogs () {
+    my $driver = 'dpkg-mergechangelogs';
+    my $cb = "merge.$driver";
+    my $attrs = '.git/info/attributes';
+    ensuredir '.git/info';
+
+    open NATTRS, ">", "$attrs.new" or die "$attrs.new $!";
+    if (!open ATTRS, "<", $attrs) {
+       $!==ENOENT or die "$attrs: $!";
+    } else {
+       while (<ATTRS>) {
+           chomp;
+           next if m{^debian/changelog\s};
+           print NATTRS $_, "\n" or die $!;
+       }
+       ATTRS->error and die $!;
+       close ATTRS;
+    }
+    print NATTRS "debian/changelog merge=$driver\n" or die $!;
+    close NATTRS;
+
+    set_local_git_config "$cb.name", 'debian/changelog merge driver';
+    set_local_git_config "$cb.driver", 'dpkg-mergechangelogs -m %O %A %B %A';
+
+    rename "$attrs.new", "$attrs" or die "$attrs: $!";
+}
+
 sub clone ($) {
     my ($dstdir) = @_;
     canonicalise_suite();
@@ -1510,6 +1537,7 @@ sub clone ($) {
        $vcsgiturl =~ s/\s+-b\s+\S+//g;
        runcmd @git, qw(remote add vcs-git), $vcsgiturl;
     }
+    setup_mergechangelogs();
     runcmd @git, qw(reset --hard), lrref();
     printdone "ready for work in $dstdir";
 }