#!/usr/bin/env bash --login 

GITEXEC=""
if ! which git > /dev/null; then
	# Gits official installer puts it at /usr/local/git/bin/git so we'll check there 
	# since MAS can't use the profile
	if ! [ -e "/usr/local/git/bin/git" ] ; then
		if which xcrun > /dev/null ; then
			if ! xcrun -find git > /dev/null; then
				echo "Could not locate git. Is it installed?" >&2
				exit 201
			else
				GITEXEC="xcrun git"
			fi
		else
			exit 201
		fi
	else
		GITEXEC="/usr/local/git/bin/git"
	fi
else
	GITEXEC="git"
fi

script_path=`dirname "$0"`

if "${script_path}/check_git-default"; then
	("${script_path}/uninstall_git-default") 2>&1
fi

($GITEXEC config --global --remove-section difftool.Kaleidoscope;
$GITEXEC config --global --remove-section mergetool.Kaleidoscope) 2>&1
# We don't really care if this fails or not

exit 0
