[PATCH 2/2] Fix deinit of empty subfolder
Timm Fitschen
mail at timmfitschen.de
Mon Jun 1 00:04:14 UTC 2026
This fixes the cmd_init function:
1. Note: `git rm -rq some/dir/.gpgid` deletes the .gpgid file and also
all empty parent directories. If this deletes the `$INNER_GIT_DIR`
(because empty) the subsequent `git_commit` fails. The fix resets the
`$INNER_GIT_DIR` by calling `set_git` again which will traverse the
directory tree to the next existing parent.
2. Check if `$PREFIX/$id_path` exists before calling `reencrypt_path`.
If it doesn't exist, there is nothing to be reencrypted.
---
src/password-store.sh | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/password-store.sh b/src/password-store.sh
index 22e818f..5038647 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -340,6 +340,7 @@ cmd_init() {
rm -v -f "$gpg_id" || exit 1
if [[ -n $INNER_GIT_DIR ]]; then
git -C "$INNER_GIT_DIR" rm -qr "$gpg_id"
+ set_git "$PREFIX/$id_path"
git_commit "Deinitialize ${gpg_id}${id_path:+ ($id_path)}."
fi
rmdir -p "${gpg_id%/*}" 2>/dev/null
@@ -361,8 +362,10 @@ cmd_init() {
fi
fi
- reencrypt_path "$PREFIX/$id_path"
- git_add_file "$PREFIX/$id_path" "Reencrypt password store using new GPG id ${id_print%, }${id_path:+ ($id_path)}."
+ [ -e "$PREFIX/$id_path" ] && {
+ reencrypt_path "$PREFIX/$id_path"
+ git_add_file "$PREFIX/$id_path" "Reencrypt password store using new GPG id ${id_print%, }${id_path:+ ($id_path)}."
+ }
}
cmd_show() {
--
2.49.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 902 bytes
Desc: not available
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20260601/a08838c2/attachment.sig>
More information about the Password-Store
mailing list