1
0
mirror of https://github.com/TheLocehiliosan/yadm synced 2026-03-02 03:49:29 +00:00

Support for symlinked directories (#17)

This commit is contained in:
Tim Byrne
2016-08-05 16:09:26 -05:00
parent 85abcf981c
commit fa286f0c9d
2 changed files with 18 additions and 7 deletions

21
yadm
View File

@@ -117,16 +117,23 @@ function alt() {
#; loop over all "tracked" files
#; for every file which matches the above regex, create a symlink
last_linked=''
for tracked_file in $(git ls-files | sort); do
tracked_file="$YADM_WORK/$tracked_file"
if [ -e "$tracked_file" ] ; then
if [[ $tracked_file =~ $match ]] ; then
new_link="${BASH_REMATCH[1]}"
debug "Linking $tracked_file to $new_link"
[ -n "$loud" ] && echo "Linking $tracked_file to $new_link"
ln -fs "$tracked_file" "$new_link"
#; process both the path, and it's parent directory
for alt_path in "$tracked_file" "${tracked_file%/*}"; do
if [ -e "$alt_path" ] ; then
if [[ $alt_path =~ $match ]] ; then
if [ "$alt_path" != "$last_linked" ] ; then
new_link="${BASH_REMATCH[1]}"
debug "Linking $alt_path to $new_link"
[ -n "$loud" ] && echo "Linking $alt_path to $new_link"
ln -nfs "$alt_path" "$new_link"
last_linked="$alt_path"
fi
fi
fi
fi
done
done
}