From mail at timmfitschen.de Mon Jun 1 00:03:22 2026 From: mail at timmfitschen.de (Timm Fitschen) Date: Mon, 1 Jun 2026 02:03:22 +0200 Subject: [PATCH 1/2] Add failing test: deinit an empty subfolder Message-ID: The test basically calls pass init -p some/dir $KEY1 and then pass init -p some/dir "" which should remove the `some/dir/.gpgid` file and empty parent directories and commit everything to git. However, both `git` and `find` complain about "No such file or directory" which is a false positive error and also leaves uncommitted changes in the git repository. --- tests/t0300-reencryption.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/t0300-reencryption.sh b/tests/t0300-reencryption.sh index 3c88987..08dfc97 100755 --- a/tests/t0300-reencryption.sh +++ b/tests/t0300-reencryption.sh @@ -106,4 +106,12 @@ test_expect_success 'Git picked up all changes throughout' ' [[ -z $(git status --porcelain 2>&1) ]] ' +test_expect_success 'Deinit empty subfolder' ' + "$PASS" init -p some/subfolder $KEY1 &> /dev/null && + stderr="$("$PASS" init -p some/subfolder "" 2>&1 1> /dev/null )" && + echo "$stderr" && + [[ ! "$stderr" =~ "No such file or directory" ]] && + [[ -z $(git status --porcelain 2>&1) ]] +' + test_done -- 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: From mail at timmfitschen.de Mon Jun 1 00:04:14 2026 From: mail at timmfitschen.de (Timm Fitschen) Date: Mon, 1 Jun 2026 02:04:14 +0200 Subject: [PATCH 2/2] Fix deinit of empty subfolder Message-ID: <54bpw35zccpoarpswz6rjz6sv352bbumuvamkjprk6ofqae3n4@lc2n5xwrysif> 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: