fix(finit): fix the crash when migrating large dotfile repo. Closes #12

pull/18/head
Kevin Zhuang 4 years ago
parent f8f577f24a
commit c7880075dd

@ -2,6 +2,12 @@
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)
## 1.2.1 (09/07/2020)
### Added

@ -45,7 +45,10 @@ 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}"
command "${action_command}" "${line}" "${DOTBARE_BACKUP}/${line}"
# Purposly didn't use the -v flag above because in finit, error message were
# directed to /dev/null but the move info will still be printed, causing confusion.
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