1
0
Fork 0
mirror of synced 2024-12-22 06:31:07 -05:00

Set YADM_WORK within configure_paths

This commit is contained in:
Tim Byrne 2019-12-12 08:00:10 -06:00
parent 18e5fcfacc
commit 46105aae47
No known key found for this signature in database
GPG key ID: 14DB4FC2465A4B12
2 changed files with 15 additions and 12 deletions

View file

@ -186,6 +186,8 @@ def run_parse_encrypt(
export YADM_ENCRYPT
GIT_DIR={paths.repo}
export GIT_DIR
YADM_WORK={paths.work}
export YADM_WORK
{parse_cmd}
export ENCRYPT_INCLUDE_FILES
export PARSE_ENCRYPT_SHORT

25
yadm
View file

@ -833,8 +833,6 @@ function decrypt() {
require_gpg
require_archive
YADM_WORK=$(unix_path "$("$GIT_PROGRAM" config core.worktree)")
if [ "$DO_LIST" = "YES" ] ; then
tar_option="t"
else
@ -919,7 +917,7 @@ function enter() {
shell_cmd=('-c' "$*")
fi
GIT_WORK_TREE=$(unix_path "$("$GIT_PROGRAM" config core.worktree)")
GIT_WORK_TREE="$YADM_WORK"
export GIT_WORK_TREE
[ "${#shell_cmd[@]}" -eq 0 ] && echo "Entering yadm repo"
@ -1454,6 +1452,13 @@ function configure_paths() {
GIT_DIR=$(mixed_path "$YADM_REPO")
export GIT_DIR
# obtain YADM_WORK from repo if it exists
if [ -d "$GIT_DIR" ]; then
local work
work=$(unix_path "$("$GIT_PROGRAM" config core.worktree)")
[ -n "$work" ] && YADM_WORK="$work"
fi
}
function configure_repo() {
@ -1536,12 +1541,11 @@ function invoke_hook() {
debug "Invoking hook: $hook_command"
# expose some internal data to all hooks
work=$(unix_path "$("$GIT_PROGRAM" config core.worktree)")
YADM_HOOK_COMMAND=$HOOK_COMMAND
YADM_HOOK_EXIT=$exit_status
YADM_HOOK_FULL_COMMAND=$FULL_COMMAND
YADM_HOOK_REPO=$YADM_REPO
YADM_HOOK_WORK=$work
YADM_HOOK_WORK=$YADM_WORK
export YADM_HOOK_COMMAND
export YADM_HOOK_EXIT
export YADM_HOOK_FULL_COMMAND
@ -1563,16 +1567,14 @@ function invoke_hook() {
}
function assert_private_dirs() {
work=$(unix_path "$("$GIT_PROGRAM" config core.worktree)")
# only assert private dirs if the worktree is the same as $HOME
[ "$work" != "$HOME" ] && return
[ "$YADM_WORK" != "$HOME" ] && return
for private_dir in "$@"; do
if [ ! -d "$work/$private_dir" ]; then
debug "Creating $work/$private_dir"
if [ ! -d "$YADM_WORK/$private_dir" ]; then
debug "Creating $YADM_WORK/$private_dir"
#shellcheck disable=SC2174
mkdir -m 0700 -p "$work/$private_dir" &> /dev/null
mkdir -m 0700 -p "$YADM_WORK/$private_dir" &> /dev/null
fi
done
}
@ -1593,7 +1595,6 @@ function display_private_perms() {
}
function cd_work() {
YADM_WORK=$(unix_path "$("$GIT_PROGRAM" config core.worktree)")
cd "$YADM_WORK" || {
debug "$1 not processed, unable to cd to $YADM_WORK"
return 1