1
0
Fork 0
mirror of synced 2024-12-30 09:49:29 -05: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
No known key found for this signature in database
GPG key ID: 6CBE24C2FD8CF76E
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
}

4
yadm.1
View file

@ -356,6 +356,10 @@ If running on a Solaris server, the link use the default "##" version:
If no "##" version exists and no files match the current OS/HOSTNAME/USER, then no link will be created.
Links are also created for directories named this way, as long as they have at least one
.B yadm
managed file within them.
OS is determined by running
.BR uname\ -s ,
HOSTNAME by running