Skip to content

Instantly share code, notes, and snippets.

@jconst
Created June 10, 2021 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jconst/eb0177729dc7c6cfc4d15fad84e61649 to your computer and use it in GitHub Desktop.
Save jconst/eb0177729dc7c6cfc4d15fad84e61649 to your computer and use it in GitHub Desktop.
merge-wrapper for UnityYAMLMerge
#!/bin/bash
# Wrapper script for git mergetool
# This requires the .gitconfig file to have:
# - mergetool entry for "unityyamlmerge";
# - mergetool entry for "p4mergetool";
# These merge tool entries must both specify the
# cmd field. The command to call this script:
# [mergetool "merge_wrapper"]
# cmd = $HOME/merge-wrapper \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"
# Locate this script in your $HOME
BASE=$1
LOCAL=$2
REMOTE=$3
MERGED=$4
UNITY_EXT="\.unity"
if echo "$BASE" | grep -q "$UNITY_EXT"; then
echo "Using merge tool for unity file";
CMD=$(git config mergetool.unityyamlmerge.cmd)
eval $CMD
else
#checking for additional special merge tool cases
#Finally, the default case:
echo "Using default merge tool";
CMD=$(git config mergetool.p4mergetool.cmd)
eval $CMD
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment