Skip to content

Commit

Permalink
bin/merge-driver-ekeyword: Look for KEYWORDS changes in upstream commit
Browse files Browse the repository at this point in the history
Previously we only looked for changes to the KEYWORDS= line in our local
commit being rebased. If it contained no changes to KEYWORDS= then the
merge-driver gave up.

However our local patch may conflict with an upstream patch that changed
KEYWORDS.

In that case, we can look for changes to the KEYWORDS= line in the other
patch and try to apply its change to ours.

This happened in gentoo.git commits

2c5cd6c4e004 ("sys-fs/squashfs-tools-ng: Stabilize 1.3.0 amd64, #930693")
7129c2e4e5f3 ("sys-fs/squashfs-tools-ng: run elibtoolize in non-live ebuild")

leading to a rebase mistake in the latter (later fixed by commit
7579afbd4aa1 ("sys-fs/squashfs-tools-ng: stabilize 1.3.0 for amd64")).

With this patch applied, the merge conflicts are automatically resolved
between the two commits regardless of which is "ours" vs "theirs".

Signed-off-by: Matt Turner <[email protected]>
  • Loading branch information
mattst88 committed May 25, 2024
1 parent 6b6fa78 commit a667d93
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions bin/merge-driver-ekeyword
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python3
#
# Copyright 2020-2023 Gentoo Authors
# Copyright 2020-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2 or later

"""
Expand Down Expand Up @@ -119,12 +119,16 @@ def main(argv: Sequence[str]) -> int:
B = argv[3] # %B - filename of the other branch's version
P = argv[4] # %P - original path of the file

# Get changes from %O to %B
changes = keyword_changes(O, B)
if changes:
# Apply O -> B changes to A
# Get changes to KEYWORDS= from %O to %B
if changes := keyword_changes(O, B):
# Apply %O -> %B changes to %A
result = apply_keyword_changes(A, P, changes)
sys.exit(result)
# Get changes to KEYWORDS= from %O to %A
elif changes := keyword_changes(O, A):
# Apply %O -> %A changes to %B
result = apply_keyword_changes(B, P, changes)
sys.exit(result)
else:
try:
os.execlp("git", "git", "merge-file", "-L", "HEAD", "-L", "base", "-L", "ours", A, O, B)
Expand Down

0 comments on commit a667d93

Please sign in to comment.