From d2c91253e64e144d17d0f5a0ce9c72661c43a29c Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 4 Jul 2015 22:01:39 +0100 Subject: dgit: Set up a merge driver for debian/changelog. Closes:#769291. --- debian/changelog | 1 + dgit | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/debian/changelog b/debian/changelog index 49b8777..9e8f572 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 802d791..73184fb 100755 --- 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 () { + 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"; } -- cgit v1.2.3