Fix bug with alternate linked directories
Previously the tracked files were sorted, and then the files and their parent directories were considered for possible alternates. Depending on the length of directories and names of files, inconsistencies would occur because the directory separator (/) would be part of the sorting. To fix this, a unique list of tracked files and their parent directories are sorted into a single list which is processed.
This commit is contained in:
parent
fb1181c8a9
commit
0c6be5e398
1 changed files with 17 additions and 19 deletions
8
yadm
8
yadm
|
@ -181,10 +181,9 @@ function alt() {
|
||||||
for match in $match1 $match2; do
|
for match in $match1 $match2; do
|
||||||
last_linked=''
|
last_linked=''
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
for tracked_file in $("$GIT_PROGRAM" ls-files | sort) "${ENCRYPT_INCLUDE_FILES[@]}"; do
|
# the alt_paths looped over here are a unique sorted list of both files and their immediate parent directory
|
||||||
tracked_file="$YADM_WORK/$tracked_file"
|
for alt_path in $(for tracked in $("$GIT_PROGRAM" ls-files); do printf "%s\n" "$tracked" "${tracked%/*}"; done | sort -u) "${ENCRYPT_INCLUDE_FILES[@]}"; do
|
||||||
# process both the path, and it's parent directory
|
alt_path="$YADM_WORK/$alt_path"
|
||||||
for alt_path in "$tracked_file" "${tracked_file%/*}"; do
|
|
||||||
if [ -e "$alt_path" ] ; then
|
if [ -e "$alt_path" ] ; then
|
||||||
if [[ $alt_path =~ $match ]] ; then
|
if [[ $alt_path =~ $match ]] ; then
|
||||||
if [ "$alt_path" != "$last_linked" ] ; then
|
if [ "$alt_path" != "$last_linked" ] ; then
|
||||||
|
@ -205,7 +204,6 @@ function alt() {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
done
|
|
||||||
|
|
||||||
# loop over all "tracked" files
|
# loop over all "tracked" files
|
||||||
# for every file which is a *##yadm.j2 create a real file
|
# for every file which is a *##yadm.j2 create a real file
|
||||||
|
|
Loading…
Reference in a new issue