1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
|
=head1 NAME
git-merge-changelog - git merge driver for GNU ChangeLog files
=head1 DESCRIPTION
The default merge driver of 'git' B<always> produces conflicts when
pulling public modifications into a privately modified ChangeLog file.
This is because ChangeLog files are always modified at the top; the
default merge driver has no clue how to deal with this. Furthermore
the conflicts are presented with more E<lt>E<lt>E<lt>E<lt> ==== E<gt>E<gt>E<gt>E<gt> markers than
necessary; this is because the default merge driver makes pointless
efforts to look at the individual line changes inside a ChangeLog entry.
This program serves as a 'git' merge driver that avoids these problems.
=over 4
=item Z<>1.
It produces no conflict when ChangeLog entries have been inserted
at the top both in the public and in the private modification. It
puts the privately added entries above the publicly added entries.
=item Z<>2.
It respects the structure of ChangeLog files: entries are not split
into lines but kept together.
=item Z<>3.
It also handles the case of small modifications of past ChangeLog
entries, or of removed ChangeLog entries: they are merged as one
would expect it.
=item Z<>4.
Conflicts are presented at the top of the file, rather than where
they occurred, so that the user will see them immediately. (Unlike
for source code written in some programming language, conflict markers
that are located several hundreds lines from the top will not cause
any syntax error and therefore would be likely to remain unnoticed.)
=back
=head2 For git users:
=over 4
=item -
Add to .git/config of the checkout (or to your $HOME/.gitconfig) the
lines
[merge "merge-changelog"]
name = GNU-style ChangeLog merge driver
driver = /usr/bin/git-merge-changelog %O %A %B
=item -
In every directory that contains a ChangeLog file, add a file
'.gitattributes' with this line:
ChangeLog merge=merge-changelog
(See "man 5 gitattributes" for more info.)
=back
=head2 For bzr users:
=over 4
=item -
Install the 'extmerge' bzr plug-in listed at
L<http://doc.bazaar.canonical.com/plugins/en/index.html>
L<http://wiki.bazaar.canonical.com/BzrPlugins>
=item -
Add to your $HOME/.bazaar/bazaar.conf the line
external_merge = git-merge-changelog %b %T %o
=item -
Then, to merge a conflict in a ChangeLog file, use
$ bzr extmerge ChangeLog
=back
=head2 For hg users:
=over 4
=item -
Add to your $HOME/.hgrc the lines
[merge-patterns]
ChangeLog = git-merge-changelog
[merge-tools]
git-merge-changelog.executable = /usr/bin/git-merge-changelog
git-merge-changelog.args = $base $local $other
See L<http://www.selenic.com/mercurial/hgrc.5.html> section B<merge-tools>
for reference.
=back
=head2 Use as an alternative to 'diff3':
git-merge-changelog performs the same role as "diff3 -m", just with
reordered arguments:
$ git-merge-changelog %O %A %B
is comparable to
$ diff3 -m %A %O %B
=head2 Calling convention:
A merge driver is called with three filename arguments:
=over 4
=item Z<>1.
%O = The common ancestor of %A and %B.
=item Z<>2.
%A = The file's contents from the "current branch".
=item Z<>3.
%B = The file's contents from the "other branch"; this is the contents
being merged in.
=back
In case of a "git stash apply" or of an upstream pull (e.g. from a subsystem
maintainer to a central maintainer) or of a downstream pull with --rebase:
=over 4
=item Z<>2.
%A = The file's newest pulled contents; modified by other committers.
=item Z<>3.
%B = The user's newest copy of the file; modified by the user.
=back
In case of a downstream pull (e.g. from a central repository to the user)
or of an upstream pull with --rebase:
=over 4
=item Z<>2.
%A = The user's newest copy of the file; modified by the user.
=item Z<>3.
%B = The file's newest pulled contents; modified by other committers.
=back
It should write its merged output into file %A. It can also echo some
remarks to stdout. It should exit with return code 0 if the merge could
be resolved cleanly, or with non-zero return code if there were conflicts.
=head2 How it works:
The structure of a ChangeLog file: It consists of ChangeLog entries. A
ChangeLog entry starts at a line following a blank line and that starts with
a non-whitespace character, or at the beginning of a file.
The merge driver works as follows: It reads the three files into memory and
dissects them into ChangeLog entries. It then finds the differences between
%O and %B. They are classified as:
=over 4
=item -
removals (some consecutive entries removed),
=item -
changes (some consecutive entries removed, some consecutive entries added),
=item -
additions (some consecutive entries added).
=back
The driver then attempts to apply the changes to %A.
To this effect, it first computes a correspondence between the entries in %O
and the entries in %A, using fuzzy string matching to still identify changed
entries.
=over 4
=item -
Removals are applied one by one. If the entry is present in %A, at any
position, it is removed. If not, the removal is marked as a conflict.
=item -
Additions at the top of %B are applied at the top of %A.
=item -
Additions between entry x and entry y (y may be the file end) in %B are
applied between entry x and entry y in %A (if they still exist and are
still consecutive in %A), otherwise the additions are marked as a
conflict.
=item -
Changes are categorized into "simple changes":
entry1 ... entryn
are mapped to
added_entry ... added_entry modified_entry1 ... modified_entryn,
where the correspondence between entry_i and modified_entry_i is still
clear; and "big changes": these are all the rest. Simple changes at the
top of %B are applied by putting the added entries at the top of %A. The
changes in simple changes are applied one by one; possibly leading to
single-entry conflicts. Big changes are applied en bloc, possibly
leading to conflicts spanning multiple entries.
=item -
Conflicts are output at the top of the file and cause an exit status of 1.
=back
=head1 SEE ALSO
git(1), git-merge(1)
=head1 AUTHOR
The git-merge-changelog author and maintainer is Bruno Haible.
This man page was adapted by Ian Beckwith from the comments at the top
of git-merge-changelog.c.
=head1 AVAILABILITY
git-merge-changelog is part of the GNU gnulib project.
Gnulib home page: L<http://www.gnu.org/software/gnulib/>
=head1 COPYRIGHT
Copyright (C) 2008-2010 Bruno Haible E<lt>bruno@clisp.orgE<gt>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see L<http://www.gnu.org/licenses/>
=cut
|