Add merge driver for changelog conflicts - #9436
Open
gbp wants to merge 1 commit into
Open
Conversation
Merging branches into develop almost always conflicts in doc/CHANGES.md, because every branch adds its entries to the top of the same section. The conflicts are easily solved: both sides want to keep their entries, and the newest ones belong at the top. Add script/merge-changelog, which resolves those conflicts by keeping both sides of each conflict block, placing "theirs" (the branch being merged) before "ours" (the target branch). It runs as a git merge driver, and .gitattributes associates it with doc/CHANGES.md. The driver first attempts a standard three-way merge and only strips markers when that fails. If any markers survive it exits non-zero, so genuine conflicts still stop the merge for manual resolution. Registering the driver is a one-time step per clone: git config merge.changelog.name "Changelog merge driver" git config merge.changelog.driver "script/merge-changelog %A %O %B"
garethrees
approved these changes
Aug 7, 2026
garethrees
left a comment
Member
There was a problem hiding this comment.
Well TIL. Magic! 🪄
Haven't set it up or run but happy if you are. Will set it up and report any problems as new issues.
Member
|
cc/ @laurentS |
Collaborator
|
Neat! will this break git if I checkout an older branch that does not have the script? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merging branches into develop almost always conflicts in doc/CHANGES.md, because every branch adds its entries to the top of the same section.
The conflicts are easily solved: both sides want to keep their entries, and the newest ones belong at the top.
Add script/merge-changelog, which resolves those conflicts by keeping both sides of each conflict block, placing "theirs" (the branch being merged) before "ours" (the target branch). It runs as a git merge driver, and .gitattributes associates it with doc/CHANGES.md.
The driver first attempts a standard three-way merge and only strips markers when that fails. If any markers survive it exits non-zero, so genuine conflicts still stop the merge for manual resolution.
Registering the driver is a one-time step per clone:
[skip changelog]