Consolidate cd to YADM_WORK
This commit is contained in:
parent
c24906ec10
commit
d411db9f6f
1 changed files with 14 additions and 28 deletions
42
yadm
42
yadm
|
@ -162,12 +162,7 @@ function alt() {
|
||||||
match1="^(.+)##(()|$match_system|$match_system\.$match_host|$match_system\.$match_host\.$match_user)$"
|
match1="^(.+)##(()|$match_system|$match_system\.$match_host|$match_system\.$match_host\.$match_user)$"
|
||||||
match2="^(.+)##($match_class|$match_class\.$match_system|$match_class\.$match_system\.$match_host|$match_class\.$match_system\.$match_host\.$match_user)$"
|
match2="^(.+)##($match_class|$match_class\.$match_system|$match_class\.$match_system\.$match_host|$match_class\.$match_system\.$match_host\.$match_user)$"
|
||||||
|
|
||||||
#; process relative to YADM_WORK
|
cd_work "Alternates" || return
|
||||||
YADM_WORK=$(unix_path "$("$GIT_PROGRAM" config core.worktree)")
|
|
||||||
cd "$YADM_WORK" || {
|
|
||||||
debug "Alternates not processed, unable to cd to $YADM_WORK"
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
#; only be noisy if the "alt" command was run directly
|
#; only be noisy if the "alt" command was run directly
|
||||||
[ "$YADM_COMMAND" = "alt" ] && loud="YES"
|
[ "$YADM_COMMAND" = "alt" ] && loud="YES"
|
||||||
|
@ -423,12 +418,7 @@ function encrypt() {
|
||||||
require_encrypt
|
require_encrypt
|
||||||
parse_encrypt
|
parse_encrypt
|
||||||
|
|
||||||
#; process relative to YADM_WORK
|
cd_work "Encryption" || return
|
||||||
YADM_WORK=$(unix_path "$("$GIT_PROGRAM" config core.worktree)")
|
|
||||||
cd "$YADM_WORK" || {
|
|
||||||
debug "Encryption not processed, unable to cd to $YADM_WORK"
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
#; Build gpg options for gpg
|
#; Build gpg options for gpg
|
||||||
GPG_KEY="$(config yadm.gpg-recipient)"
|
GPG_KEY="$(config yadm.gpg-recipient)"
|
||||||
|
@ -640,11 +630,7 @@ function list() {
|
||||||
|
|
||||||
#; process relative to YADM_WORK when --all is specified
|
#; process relative to YADM_WORK when --all is specified
|
||||||
if [ -n "$LIST_ALL" ] ; then
|
if [ -n "$LIST_ALL" ] ; then
|
||||||
YADM_WORK=$(unix_path "$("$GIT_PROGRAM" config core.worktree)")
|
cd_work "List" || return
|
||||||
cd "$YADM_WORK" || {
|
|
||||||
debug "List not processed, unable to cd to $YADM_WORK"
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#; list tracked files
|
#; list tracked files
|
||||||
|
@ -658,12 +644,7 @@ function perms() {
|
||||||
|
|
||||||
#; TODO: prevent repeats in the files changed
|
#; TODO: prevent repeats in the files changed
|
||||||
|
|
||||||
#; process relative to YADM_WORK
|
cd_work "Perms" || return
|
||||||
YADM_WORK=$(unix_path "$("$GIT_PROGRAM" config core.worktree)")
|
|
||||||
cd "$YADM_WORK" || {
|
|
||||||
debug "Perms not processed, unable to cd to $YADM_WORK"
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
GLOBS=()
|
GLOBS=()
|
||||||
|
|
||||||
|
@ -917,6 +898,15 @@ function display_private_perms() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
function parse_encrypt() {
|
function parse_encrypt() {
|
||||||
if [ "$ENCRYPT_INCLUDE_FILES" != "unparsed" ]; then
|
if [ "$ENCRYPT_INCLUDE_FILES" != "unparsed" ]; then
|
||||||
#shellcheck disable=SC2034
|
#shellcheck disable=SC2034
|
||||||
|
@ -927,11 +917,7 @@ function parse_encrypt() {
|
||||||
ENCRYPT_INCLUDE_FILES=()
|
ENCRYPT_INCLUDE_FILES=()
|
||||||
ENCRYPT_EXCLUDE_FILES=()
|
ENCRYPT_EXCLUDE_FILES=()
|
||||||
|
|
||||||
YADM_WORK=$(unix_path "$("$GIT_PROGRAM" config core.worktree)")
|
cd_work "Parsing encrypt" || return
|
||||||
cd "$YADM_WORK" || {
|
|
||||||
debug "Parsing encrypt not processed, unable to cd to $YADM_WORK"
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
exclude_pattern="^!(.+)"
|
exclude_pattern="^!(.+)"
|
||||||
if [ -f "$YADM_ENCRYPT" ] ; then
|
if [ -f "$YADM_ENCRYPT" ] ; then
|
||||||
|
|
Loading…
Reference in a new issue