maintainer |
---|
pvh |
This is a simple example of a git custom merge driver for automerge. It is derived from https://github.com/Praqma/git-merge-driver but any problems are my own fault.
Included in this repository is a not-very-promising approach to merging text files paired with more canonical .mrg files.
Run example.sh
for a demonstration of the merge driver.
It will create a merge conflict in the repository, causing the merge driver to start and resolve the conflict.
First up is defining the merge driversd.
This is done via local git config. See mergetool-setup.sh
for an example. Unfortunately, each user must run these commands in their own directory.
For more, visit git-scm.com - Git Attributes.
Note that, much like git hooks, the .git/config
file can't be checked in/shared through the repository.
A common way of distributing merge drivers is to check the configuration file in elsewhere and provide a script to copy it to .git/config
.
In this repository, the merge driver is configured in the .gitconfig
file, which is copied to .git/config
by the mergetool-setup.sh
script.
For a successful merge, the merge driver is expected to leave the merge result at %A
's path and exiting with status code 0
.
If the merge went awry, the merge driver can exit with a non-zero status code.
Note: Any tools or scripts called by the merge driver must be available on PATH
.
You configure the file patterns you want the merge driver to be used for in the .gitattributes
file:
*.mrg merge=my-custom-driver