Created
April 11, 2014 06:19
-
-
Save doylecnn/10443711 to your computer and use it in GitHub Desktop.
windows 上 cygwin 下使用 git difftool 配合beyound compare 3 要用到的辅助脚本
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# !/bin/sh | |
# diff is called by git difftool with 2 parameters: | |
# old-file-path new-file-path | |
# config in .gitconfig: | |
# [diff] | |
# tool = mybc3 | |
# [difftool] | |
# prompt = false | |
# [difftool "mybc3"] | |
# cmd = /cygdrive/c/WINDOWS/diff.sh \"$LOCAL\" \"$REMOTE\" | |
checkFileExists () { | |
local result=1 | |
if [[ -e $1 && $1 != "/dev/null" ]]; then | |
resultString="\e[32m[${1}] is exists\e[m" | |
result=0 | |
else | |
resultString="\e[31m[${1}] is not exists\e[m" | |
fi | |
return $result; | |
} | |
checkFileExists "$1" | |
leftExist=$? | |
leftExistsMessage=$resultString | |
checkFileExists "$2" | |
rightExist=$? | |
rightExistsMessage=$resultString | |
if [[ ($leftExist -eq 0) && ($rightExist -eq 0) ]] ; then | |
left=`cygpath -w "$1"` | |
right=`cygpath -w "$2"` | |
/cygdrive/d/Program\ Files/Beyond\ Compare\ 3/BComp.com "$left" "$right" /qc | |
lastResult=$? | |
if [[ $lastResult -eq 2 ]]; then | |
printf "\e[32m[${right}] Rules-based same\e[m" | |
echo | |
exit 0 | |
elif [[ $lastResult -eq 13 ]]; then | |
printf "\e[31m[${right}] Rules-based differences\e[m" | |
echo | |
else | |
printf "\e[31m[${right}] ${lastResult}\e[m" | |
fi | |
read -p "show diff window?(Y/n)" choice | |
if [[ -z $choice || ($choice != "N" && $choice != "n") ]]; then | |
choice="Y" | |
else | |
choice="N" | |
fi | |
else | |
printf "${leftExistsMessage}" | |
echo | |
printf "${rightExistsMessage}" | |
echo | |
read -p "show diff window?(N/y)" choice | |
if [[ -z $choice || ($choice != "Y" && $choice != "y") ]]; then | |
choice="N" | |
else | |
choice="Y" | |
fi | |
fi | |
echo ----------------- | |
if [[ $choice = "Y" ]]; then | |
/cygdrive/d/Program\ Files/Beyond\ Compare\ 3/BComp.exe "$left" "$right" /ro1 & #|cat | |
sleep 2 | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment