Merge driver consists of three things:
1. .gitattributes definition that tells which files to process with which driver
2. Section in git/config that maps the logical merge driver name to a concrete script on a disk
3. The actual script files(s) - PHP or Bash impl in our case
It's a bit tricky because:
- .gitattributes is committed in the repo. The paths must therefore be relative.
- git/config is not committed in the repo so it must be created dynamically on actions
like activating VersionPress or restoring / cloning a site. Furthermore, the paths
must be absolute because Git's cwd can be different.
- We need cross-platform scripts so we detect the OS and install the correct driver.
The driver impl can be forced using the $driver parameter.
public static installMergeDriver ( string $rootDir, string $pluginDir, string $vpdbDir, string $driver = self::DRIVER_AUTO ) | ||
$rootDir | string | Where to install the driver |
$pluginDir | string | Path to VersionPress (plugin) - used to look up templates and merge drivers |
$vpdbDir | string | Location of the VPDB dir (where the INI files are) |
$driver | string | DRIVER_BASH | DRIVER_PHP | DRIVER_AUTO (default; will use PHP driver for Windows, Bash otherwise) |