3 git-merge-changelog - git merge driver for GNU ChangeLog files
7 The default merge driver of 'git' B<always> produces conflicts when
8 pulling public modifications into a privately modified ChangeLog file.
9 This is because ChangeLog files are always modified at the top; the
10 default merge driver has no clue how to deal with this. Furthermore
11 the conflicts are presented with more E<lt>E<lt>E<lt>E<lt> ==== E<gt>E<gt>E<gt>E<gt> markers than
12 necessary; this is because the default merge driver makes pointless
13 efforts to look at the individual line changes inside a ChangeLog entry.
15 This program serves as a 'git' merge driver that avoids these problems.
21 It produces no conflict when ChangeLog entries have been inserted
22 at the top both in the public and in the private modification. It
23 puts the privately added entries above the publicly added entries.
27 It respects the structure of ChangeLog files: entries are not split
28 into lines but kept together.
32 It also handles the case of small modifications of past ChangeLog
33 entries, or of removed ChangeLog entries: they are merged as one
38 Conflicts are presented at the top of the file, rather than where
39 they occurred, so that the user will see them immediately. (Unlike
40 for source code written in some programming language, conflict markers
41 that are located several hundreds lines from the top will not cause
42 any syntax error and therefore would be likely to remain unnoticed.)
52 Add to .git/config of the checkout (or to your $HOME/.gitconfig) the
55 [merge "merge-changelog"]
56 name = GNU-style ChangeLog merge driver
57 driver = /usr/bin/git-merge-changelog %O %A %B
61 In every directory that contains a ChangeLog file, add a file
62 '.gitattributes' with this line:
64 ChangeLog merge=merge-changelog
66 (See "man 5 gitattributes" for more info.)
76 Install the 'extmerge' bzr plug-in listed at
77 L<http://doc.bazaar.canonical.com/plugins/en/index.html>
78 L<http://wiki.bazaar.canonical.com/BzrPlugins>
82 Add to your $HOME/.bazaar/bazaar.conf the line
84 external_merge = git-merge-changelog %b %T %o
88 Then, to merge a conflict in a ChangeLog file, use
90 $ bzr extmerge ChangeLog
100 Add to your $HOME/.hgrc the lines
103 ChangeLog = git-merge-changelog
106 git-merge-changelog.executable = /usr/bin/git-merge-changelog
107 git-merge-changelog.args = $base $local $other
109 See L<http://www.selenic.com/mercurial/hgrc.5.html> section B<merge-tools>
114 =head2 Use as an alternative to 'diff3':
116 git-merge-changelog performs the same role as "diff3 -m", just with
119 $ git-merge-changelog %O %A %B
125 =head2 Calling convention:
127 A merge driver is called with three filename arguments:
133 %O = The common ancestor of %A and %B.
137 %A = The file's contents from the "current branch".
141 %B = The file's contents from the "other branch"; this is the contents
146 In case of a "git stash apply" or of an upstream pull (e.g. from a subsystem
147 maintainer to a central maintainer) or of a downstream pull with --rebase:
153 %A = The file's newest pulled contents; modified by other committers.
157 %B = The user's newest copy of the file; modified by the user.
161 In case of a downstream pull (e.g. from a central repository to the user)
162 or of an upstream pull with --rebase:
168 %A = The user's newest copy of the file; modified by the user.
172 %B = The file's newest pulled contents; modified by other committers.
176 It should write its merged output into file %A. It can also echo some
177 remarks to stdout. It should exit with return code 0 if the merge could
178 be resolved cleanly, or with non-zero return code if there were conflicts.
182 The structure of a ChangeLog file: It consists of ChangeLog entries. A
183 ChangeLog entry starts at a line following a blank line and that starts with
184 a non-whitespace character, or at the beginning of a file.
185 The merge driver works as follows: It reads the three files into memory and
186 dissects them into ChangeLog entries. It then finds the differences between
187 %O and %B. They are classified as:
193 removals (some consecutive entries removed),
197 changes (some consecutive entries removed, some consecutive entries added),
201 additions (some consecutive entries added).
205 The driver then attempts to apply the changes to %A.
206 To this effect, it first computes a correspondence between the entries in %O
207 and the entries in %A, using fuzzy string matching to still identify changed
214 Removals are applied one by one. If the entry is present in %A, at any
215 position, it is removed. If not, the removal is marked as a conflict.
219 Additions at the top of %B are applied at the top of %A.
223 Additions between entry x and entry y (y may be the file end) in %B are
224 applied between entry x and entry y in %A (if they still exist and are
225 still consecutive in %A), otherwise the additions are marked as a
230 Changes are categorized into "simple changes":
233 added_entry ... added_entry modified_entry1 ... modified_entryn,
234 where the correspondence between entry_i and modified_entry_i is still
235 clear; and "big changes": these are all the rest. Simple changes at the
236 top of %B are applied by putting the added entries at the top of %A. The
237 changes in simple changes are applied one by one; possibly leading to
238 single-entry conflicts. Big changes are applied en bloc, possibly
239 leading to conflicts spanning multiple entries.
243 Conflicts are output at the top of the file and cause an exit status of 1.
253 The git-merge-changelog author and maintainer is Bruno Haible.
255 This man page was adapted by Ian Beckwith from the comments at the top
256 of git-merge-changelog.c.
260 git-merge-changelog is part of the GNU gnulib project.
262 Gnulib home page: L<http://www.gnu.org/software/gnulib/>
266 Copyright (C) 2008-2010 Bruno Haible E<lt>bruno@clisp.orgE<gt>
268 This program is free software: you can redistribute it and/or modify
269 it under the terms of the GNU General Public License as published by
270 the Free Software Foundation; either version 2 of the License, or
271 (at your option) any later version.
273 This program is distributed in the hope that it will be useful,
274 but WITHOUT ANY WARRANTY; without even the implied warranty of
275 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
276 GNU General Public License for more details.
278 You should have received a copy of the GNU General Public License
279 along with this program. If not, see L<http://www.gnu.org/licenses/>