ifcurl/forgejo/server-config/gitconfig-ifcmerge
Bruno Postle 8e474f2629 gitconfig-ifcmerge: use --prioritise-local correctly per merge direction
ifcmerge defaults to preserving remote IDs; --prioritise-local preserves local
IDs instead.  For Forgejo merge commits, %A is main (local) so ifcmerge_ours
(--prioritise-local) is the right driver — main's IDs are preserved and the
PR branch is renumbered.  For developer rebases from main, %B is main (remote)
so the plain ifcmerge driver (no flag) preserves main's IDs by default.

Update /etc/gitattributes to use ifcmerge_ours for server-side merges, and
update README with a direction table clarifying which driver to use when.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 07:41:49 +01:00

43 lines
1.8 KiB
Text

# Add to /etc/gitconfig on the Forgejo server.
#
# IMPORTANT: also set core.attributesFile so that bare repositories pick up
# the merge driver. Committed per-repo .gitattributes files are NOT read by
# git merge-tree --write-tree in bare-repo context.
#
# [core]
# attributesFile = /etc/gitattributes
#
# and put "*.ifc merge=ifcmerge" in /etc/gitattributes (see gitattributes
# in this directory).
#
# How the merge drivers work
# --------------------------
# The invariant: step-IDs in main/master must never be renumbered, because
# existing cross-references depend on them. ifcmerge always renumbers the
# "remote" side by default; --prioritise-local reverses this and renumbers
# the "remote" side instead. The correct driver depends on which branch is
# checked out when the merge happens:
#
# ifcmerge — use when local (%A) is a working/PR branch and
# remote (%B) is main/master. Default behaviour
# preserves remote (main) IDs.
# e.g. rebasing or updating a PR branch from main.
#
# ifcmerge_ours — use when local (%A) is main/master and remote (%B)
# is a working/PR branch. --prioritise-local preserves
# local (main) IDs.
# e.g. Forgejo "Merge commit" button (standard PR merge).
#
# Use the "Merge commit" strategy in Forgejo (not rebase or squash) so that
# %A is always the base branch — ifcmerge_ours is then the correct driver.
[core]
attributesFile = /etc/gitattributes
[merge "ifcmerge"]
name = IFC merge driver (merging from main into working branch)
driver = ifcmerge %O %A %B %A
[merge "ifcmerge_ours"]
name = IFC merge driver (merging PR branch into main)
driver = ifcmerge --prioritise-local %O %A %B %A