Skip to content

Instantly share code, notes, and snippets.

@elsevers
Last active September 27, 2023 07:39
Show Gist options
  • Save elsevers/11349227 to your computer and use it in GitHub Desktop.
Save elsevers/11349227 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Wrapper script for git mergetool
# This requires the .gitconfig file to have:
# - mergetool entry for "wdiff";
# - mergetool entry for "fw_def";
# 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
WDIFF="\.doc"
if echo "$BASE" | grep -q "$WDIFF"; then
echo "Using merge tool for word file";
CMD=$(git config mergetool.wdiff.cmd)
eval $CMD
else
#checking for additional special merge tool cases
#Finally, the default case:
echo "Using default merge tool";
CMD=$(git config mergetool.fw_def.cmd)
eval $CMD
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment