Git has supported git worktree for a while. Be nice if pass did. Working directories created with git worktree have a .git file, not a .git directory.
The easy way to apply it is to first fetch it: git fetch https://github.com/lyda/password-store.git git-worktree Then either make a branch to review and then merge it: git checkout -b git-worktree FETCH_HEAD git checkout master git merge git-worktree Or just merge it directly: git merge FETCH_HEAD If extracting from mail files is more fun, a patch follows: >From 3dd1d7cb4669e5469e13c21667a781a93b7ca024 Mon Sep 17 00:00:00 2001 From: Kevin Lyda <[email protected]> Date: Mon, 28 Nov 2016 11:53:08 +0000 Subject: Allow for a git worktree repo. Allow for a git worktree repo. Say you have your password-store as a branch in a project. You can then do this: ```bash git clone git@gitserver:project.git cd project git branch password-store origin/password-store git worktree add ../password-store password-store ``` Now both `project/` and `password-store/` use the same git repo. However `password-store/.git` is a file, not a directory. Arguably `test -e` is too permissive. A properly formatted `.git` file in a worktree working dir will be `^gitdir: /fqpn/project/.git/worktrees/password-store$` and we could check for that. But it seems overkill to me. As it stands pass won't really work with a worktree working dir and this should fix that. --- src/password-store.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/password-store.sh b/src/password-store.sh index 63be840..e0dfc75 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -25,14 +25,14 @@ export GIT_WORK_TREE="${PASSWORD_STORE_GIT:-$PREFIX}" # git_add_file() { - [[ -d $GIT_DIR ]] || return + [[ -e $GIT_DIR ]] || return git add "$1" || return [[ -n $(git status --porcelain "$1") ]] || return git_commit "$2" } git_commit() { local sign="" - [[ -d $GIT_DIR ]] || return + [[ -e $GIT_DIR ]] || return [[ $(git config --bool --get pass.signcommits) == "true" ]] && sign="-S" git commit $sign -m "$1" } @@ -277,7 +277,7 @@ cmd_init() { if [[ $# -eq 1 && -z $1 ]]; then [[ ! -f "$gpg_id" ]] && die "Error: $gpg_id does not exist and so cannot be removed." rm -v -f "$gpg_id" || exit 1 - if [[ -d $GIT_DIR ]]; then + if [[ -e $GIT_DIR ]]; then git rm -qr "$gpg_id" git_commit "Deinitialize ${gpg_id}${id_path:+ ($id_path)}." fi @@ -500,7 +500,7 @@ cmd_delete() { [[ $force -eq 1 ]] || yesno "Are you sure you would like to delete $path?" rm $recursive -f -v "$passfile" - if [[ -d $GIT_DIR && ! -e $passfile ]]; then + if [[ -e $GIT_DIR && ! -e $passfile ]]; then git rm -qr "$passfile" git_commit "Remove $path from store." fi @@ -541,7 +541,7 @@ cmd_copy_move() { mv $interactive -v "$old_path" "$new_path" || exit 1 [[ -e "$new_path" ]] && reencrypt_path "$new_path" - if [[ -d $GIT_DIR && ! -e $old_path ]]; then + if [[ -e $GIT_DIR && ! -e $old_path ]]; then git rm -qr "$old_path" git_add_file "$new_path" "Rename ${1} to ${2}." fi @@ -562,7 +562,7 @@ cmd_git() { git_add_file .gitattributes "Configure git repository for gpg file diff." git config --local diff.gpg.binary true git config --local diff.gpg.textconv "$GPG -d ${GPG_OPTS[*]}" - elif [[ -d $GIT_DIR ]]; then + elif [[ -e $GIT_DIR ]]; then tmpdir nowarn #Defines $SECURE_TMPDIR. We don't warn, because at most, this only copies encrypted files. export TMPDIR="$SECURE_TMPDIR" git "$@" -- 2.10.2 Kevin -- Kevin Lyda Galway, Ireland _______________________________________________ Password-Store mailing list [email protected] https://lists.zx2c4.com/mailman/listinfo/password-store
