mirror of
https://github.com/TheLocehiliosan/yadm
synced 2024-10-27 20:34:27 +00:00
Move logic around assert_private_dirs to be more efficient
This commit is contained in:
parent
46105aae47
commit
cc1993dc14
9
yadm
9
yadm
@ -732,6 +732,8 @@ function clone() {
|
|||||||
rm -rf "$YADM_REPO"
|
rm -rf "$YADM_REPO"
|
||||||
error_out "Clone failed, 'origin/${branch}' does not exist in ${clone_args[0]}"
|
error_out "Clone failed, 'origin/${branch}' does not exist in ${clone_args[0]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [ "$YADM_WORK" = "$HOME" ]; then
|
||||||
debug "Determining if repo tracks private directories"
|
debug "Determining if repo tracks private directories"
|
||||||
for private_dir in .ssh/ .gnupg/; do
|
for private_dir in .ssh/ .gnupg/; do
|
||||||
found_log=$("$GIT_PROGRAM" log -n 1 "origin/${branch}" -- "$private_dir" 2>/dev/null)
|
found_log=$("$GIT_PROGRAM" log -n 1 "origin/${branch}" -- "$private_dir" 2>/dev/null)
|
||||||
@ -740,6 +742,8 @@ function clone() {
|
|||||||
assert_private_dirs "$private_dir"
|
assert_private_dirs "$private_dir"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
[ -n "$DEBUG" ] && display_private_perms "pre-merge"
|
[ -n "$DEBUG" ] && display_private_perms "pre-merge"
|
||||||
debug "Doing an initial merge of origin/${branch}"
|
debug "Doing an initial merge of origin/${branch}"
|
||||||
"$GIT_PROGRAM" merge "origin/${branch}" || {
|
"$GIT_PROGRAM" merge "origin/${branch}" || {
|
||||||
@ -940,10 +944,12 @@ function git_command() {
|
|||||||
# ensure private .ssh and .gnupg directories exist first
|
# ensure private .ssh and .gnupg directories exist first
|
||||||
# TODO: consider restricting this to only commands which modify the work-tree
|
# TODO: consider restricting this to only commands which modify the work-tree
|
||||||
|
|
||||||
|
if [ "$YADM_WORK" = "$HOME" ]; then
|
||||||
auto_private_dirs=$(config --bool yadm.auto-private-dirs)
|
auto_private_dirs=$(config --bool yadm.auto-private-dirs)
|
||||||
if [ "$auto_private_dirs" != "false" ] ; then
|
if [ "$auto_private_dirs" != "false" ] ; then
|
||||||
assert_private_dirs .gnupg/ .ssh/
|
assert_private_dirs .gnupg/ .ssh/
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
CHANGES_POSSIBLE=1
|
CHANGES_POSSIBLE=1
|
||||||
|
|
||||||
@ -1567,9 +1573,6 @@ function invoke_hook() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function assert_private_dirs() {
|
function assert_private_dirs() {
|
||||||
# only assert private dirs if the worktree is the same as $HOME
|
|
||||||
[ "$YADM_WORK" != "$HOME" ] && return
|
|
||||||
|
|
||||||
for private_dir in "$@"; do
|
for private_dir in "$@"; do
|
||||||
if [ ! -d "$YADM_WORK/$private_dir" ]; then
|
if [ ! -d "$YADM_WORK/$private_dir" ]; then
|
||||||
debug "Creating $YADM_WORK/$private_dir"
|
debug "Creating $YADM_WORK/$private_dir"
|
||||||
|
Loading…
Reference in New Issue
Block a user