Skip to content

Add merge driver for changelog conflicts - #9436

Open
gbp wants to merge 1 commit into
developfrom
changelog-merge-driver
Open

Add merge driver for changelog conflicts#9436
gbp wants to merge 1 commit into
developfrom
changelog-merge-driver

Conversation

@gbp

@gbp gbp commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

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"

[skip changelog]

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"
@gbp
gbp requested a review from garethrees August 5, 2026 10:51

@garethrees garethrees left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@garethrees

Copy link
Copy Markdown
Member

cc/ @laurentS

@laurentS

laurentS commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Neat! will this break git if I checkout an older branch that does not have the script?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants