1 |
tl;dr: In app-portage/gentoolkit-0.5.1 there's a new tool I wrote, |
2 |
called merge-driver-ekeyword that can automatically resolve git merge |
3 |
conflicts involving the KEYWORDS=... line in ebuilds. |
4 |
|
5 |
Since the KEYWORDS=... assignment is a single line, git struggles to |
6 |
handle conflicts. When rebasing a series of commits that modify the |
7 |
KEYWORDS=... it's usually easier to throw them away and reapply on the |
8 |
new tree than it is to manually handle conflicts during the rebase. |
9 |
|
10 |
git allows a 'merge driver' program to handle conflicts; this program |
11 |
handles conflicts in the KEYWORDS=... assignment. E.g., given an ebuild |
12 |
with these keywords: |
13 |
|
14 |
KEYWORDS="~alpha amd64 arm arm64 ~hppa ppc ppc64 x86" |
15 |
|
16 |
One developer drops the ~alpha keyword and pushes to gentoo.git, and |
17 |
another developer stabilizes hppa. Without this merge driver, git |
18 |
requires the second developer to manually resolve the conflict which is |
19 |
tedious and prone to mistakes when rebasing a long series of patches. |
20 |
With the custom merge driver, it automatically resolves the conflict. |
21 |
|
22 |
To use the merge driver, configure your gentoo.git as such: |
23 |
|
24 |
gentoo.git/.git/config: |
25 |
|
26 |
[merge "keywords"] |
27 |
name = KEYWORDS merge driver |
28 |
driver = merge-driver-ekeyword %O %A %B %P |
29 |
|
30 |
gentoo.git/.git/info/attributes: |
31 |
|
32 |
*.ebuild merge=keywords |
33 |
|
34 |
With that configured, git merge conflicts on the KEYWORDS=... line will |
35 |
be resolved automatically (e.g. during git pull --rebase). |
36 |
|
37 |
Enjoy! |