realm-js/scripts/git-win-symlink-aliases

39 lines
1.4 KiB
Plaintext
Raw Normal View History

2017-04-03 20:33:12 +00:00
#Based on http://stackoverflow.com/questions/5917249/git-symlinks-in-windows
git config alias.rm-symlink '!__git_rm_symlink(){
git checkout -- "$1"
link=$(echo "$1")
POS=$'\''/'\''
DOS=$'\''\\\\'\''
doslink=${link//$POS/$DOS}
dest=$(dirname "$link")/$(cat "$link")
dosdest=${dest//$POS/$DOS}
if [ -f "$dest" ]; then
rm -f "$link"
cmd //C mklink //H "$doslink" "$dosdest"
elif [ -d "$dest" ]; then
rm -f "$link"
cmd //C mklink //J "$doslink" "$dosdest"
else
echo "ERROR: Something went wrong when processing $1 . . ."
echo " $dest may not actually exist as a valid target."
fi
}; __git_rm_symlink "$1"'
git config alias.rm-symlinks '!__git_rm_symlinks(){
for symlink in $(git ls-files -s | egrep "^120000" | cut -f2); do
git rm-symlink "$symlink"
git update-index --assume-unchanged "$symlink"
done
}; __git_rm_symlinks'
git config alias.checkout-symlinks '!__git_checkout_symlinks(){
POS=$'\''/'\''
DOS=$'\''\\\\'\''
for symlink in $(git ls-files -s | egrep "^120000" | cut -f2); do
git update-index --no-assume-unchanged "$symlink"
dossymlink=${symlink//$POS/$DOS}
cmd //C rmdir //Q "$dossymlink" 2>/dev/null
git checkout -- "$symlink"
echo "Restored git symlink $symlink <<===>> $(cat $symlink)"
done
}; __git_checkout_symlinks'