Merge pull request #18 from kazhala/dev

Fix migration issue on big dotfile base
pull/25/head
Kevin Zhuang 4 years ago committed by GitHub
commit 504be1c88d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,6 +2,13 @@
Noteble changes are documentated in this file.
## dev
### Fixed
- Fixed the dotbare crash when migrating a dotfile repo with over 100 files [#12](https://github.com/kazhala/dotbare/issues/12)
- Fixed dotbare fbackup crash when using cp command on symlink
## 1.2.1 (09/07/2020)
### Added

@ -45,7 +45,14 @@ function dotbare_backup() {
while IFS= read -r line; do
dir_name=$(dirname "${line}")
[[ ! -d "${DOTBARE_BACKUP}/${dir_name}" ]] && mkdir -p "${DOTBARE_BACKUP}/${dir_name}"
command "${action_command}" -v "${line}" "${DOTBARE_BACKUP}/${line}"
[[ "${action_command}" == "cp" ]] \
&& cp -av "${line}" "${DOTBARE_BACKUP}/${line}" \
&& continue
# Purposly didn't use the -v flag because in finit, error message were
# directed to /dev/null but the cp/mv info will still be printed, causing confusion.
[[ "${action_command}" == "mv" ]] \
&& mv "${line}" "${DOTBARE_BACKUP}/${line}" \
&& echo "${line} -> ${DOTBARE_BACKUP}/${line}"
done <<< "${selected_files}"
exit 0
}

@ -89,9 +89,10 @@ else
[[ ! -d "${DOTBARE_TREE}" ]] && mkdir -p "${DOTBARE_TREE}"
cd "${DOTBARE_TREE}"
git clone --bare "${remote_url}" "${DOTBARE_DIR}"
if ! git --git-dir "${DOTBARE_DIR}" --work-tree "${DOTBARE_TREE}" checkout 2> /dev/null; then
echo "File checkout failed"
echo "Backing up pre-existing dotfiles ..."
set +e
while ! git --git-dir "${DOTBARE_DIR}" --work-tree "${DOTBARE_TREE}" checkout 2> /dev/null; do
echo "Resolving conflicts ..."
git --git-dir "${DOTBARE_DIR}" --work-tree "${DOTBARE_TREE}" checkout 2>&1 \
| awk '{
if ($0 ~ /[\t].*/) {
@ -99,10 +100,14 @@ else
print $0
}
}' \
| xargs -I __ "${mydir}"/fbackup -p __ -m
echo "dotfiles backup succeeded, checkout continue"
git --git-dir "${DOTBARE_DIR}" --work-tree "${DOTBARE_TREE}" checkout
fi
| xargs -I __ "${mydir}"/fbackup -p __ -m 2> /dev/null
if git --git-dir "${DOTBARE_DIR}" --work-tree "${DOTBARE_TREE}" checkout 2> /dev/null; then
echo "All conflicts resolved"
break
fi
done
set -e
git --git-dir "${DOTBARE_DIR}" --work-tree "${DOTBARE_TREE}" \
config --local status.showUntrackedFiles no
echo "File checkout succeeded"

Loading…
Cancel
Save