summaryrefslogtreecommitdiff
path: root/yadm
diff options
context:
space:
mode:
authorTim Byrne <sultan@locehilios.com>2019-12-12 08:09:00 -0600
committerTim Byrne <sultan@locehilios.com>2019-12-12 08:09:30 -0600
commitcc1993dc14a04b8522b5acde23b4ad2443d4e91e (patch)
treeff798fc17d7c7bf35273885aa437cc3d51ea7c21 /yadm
parent46105aae47c1c895cf9178e3adebaa46315aec73 (diff)
Move logic around assert_private_dirs to be more efficient
Diffstat (limited to 'yadm')
-rwxr-xr-xyadm31
1 files changed, 17 insertions, 14 deletions
diff --git a/yadm b/yadm
index 4db275f..e398822 100755
--- a/yadm
+++ b/yadm
@@ -732,14 +732,18 @@ function clone() {
rm -rf "$YADM_REPO"
error_out "Clone failed, 'origin/${branch}' does not exist in ${clone_args[0]}"
}
- debug "Determining if repo tracks private directories"
- for private_dir in .ssh/ .gnupg/; do
- found_log=$("$GIT_PROGRAM" log -n 1 "origin/${branch}" -- "$private_dir" 2>/dev/null)
- if [ -n "$found_log" ]; then
- debug "Private directory $private_dir is tracked by repo"
- assert_private_dirs "$private_dir"
- fi
- done
+
+ if [ "$YADM_WORK" = "$HOME" ]; then
+ debug "Determining if repo tracks private directories"
+ for private_dir in .ssh/ .gnupg/; do
+ found_log=$("$GIT_PROGRAM" log -n 1 "origin/${branch}" -- "$private_dir" 2>/dev/null)
+ if [ -n "$found_log" ]; then
+ debug "Private directory $private_dir is tracked by repo"
+ assert_private_dirs "$private_dir"
+ fi
+ done
+ fi
+
[ -n "$DEBUG" ] && display_private_perms "pre-merge"
debug "Doing an initial merge of origin/${branch}"
"$GIT_PROGRAM" merge "origin/${branch}" || {
@@ -940,9 +944,11 @@ function git_command() {
# ensure private .ssh and .gnupg directories exist first
# TODO: consider restricting this to only commands which modify the work-tree
- auto_private_dirs=$(config --bool yadm.auto-private-dirs)
- if [ "$auto_private_dirs" != "false" ] ; then
- assert_private_dirs .gnupg/ .ssh/
+ if [ "$YADM_WORK" = "$HOME" ]; then
+ auto_private_dirs=$(config --bool yadm.auto-private-dirs)
+ if [ "$auto_private_dirs" != "false" ] ; then
+ assert_private_dirs .gnupg/ .ssh/
+ fi
fi
CHANGES_POSSIBLE=1
@@ -1567,9 +1573,6 @@ function invoke_hook() {
}
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
if [ ! -d "$YADM_WORK/$private_dir" ]; then
debug "Creating $YADM_WORK/$private_dir"