elasticdog / transcrypt

transparently encrypt files within a git repository
MIT License
1.43k stars 102 forks source link

.git/crypt/transcrypt: line 245: GIT_REFLOG_ACTION: unbound variable #150

Closed ZhymabekRoman closed 1 year ago

ZhymabekRoman commented 1 year ago

Thank you for making transcrypt! When applying a stash with the git stash pop command, this error appears:

.git/crypt/transcrypt: line 245: GIT_REFLOG_ACTION: unbound variable

transcrypt version: https://github.com/elasticdog/transcrypt/commit/e08c3595e6ec57bc448e50401cb7ed845d866419 git version: 2.30.2

jmurty commented 1 year ago

Hi @ZhymabekRoman I haven't been able to reproduce this error with some basic testing of git stash and git stash pop but in commit bcc46694 I have applied a potential fix to the one place Transcrypt refers to GIT_REFLOG_ACTION.

Can you test the latest version on the main branch and confirm whether it fixes the unbound variable error for you?

ZhymabekRoman commented 1 year ago

@jmurty, Thanks for reply!

I haven't been able to reproduce this error with some basic testing

I think it's because I forgot to mention Auto-merging during the git stash.

Full command output with latest transcrypt version:

roman@debian:~/Obsidian$ git stash pop
*** WARNING : deprecated key derivation used.
Using -iter or -pbkdf2 would be better.
.git/crypt/transcrypt: line 267: THEIRS_LABEL: unbound variable
Auto-merging diary/.obsidian/plugins/recent-files-obsidian/data.json
CONFLICT (content): Merge conflict in diary/.obsidian/plugins/recent-files-obsidian/data.json
The stash entry is kept in case you need it again.
jmurty commented 1 year ago

Hi @ZhymabekRoman thanks for that clarification. I think I've fixed it properly now in commit 155808d9, can you please re-test to confirm?

To be clear for anyone following along, or reading this later, this bug was triggered when you:

If the further changes are staged, git will try to merge the stash content instead of failing with the usual error: Your local changes to the following files would be overwritten by merge error.

Despite using git for years, I didn't know that staging file changes would trigger auto-merge behaviour when applying a stash with changes to the same file. Hat tip to https://stackoverflow.com/a/16613814 for teaching me this.

ZhymabekRoman commented 1 year ago

@jmurty, I tested the latest version of transcrypt and everything seems to work perfectly! Thank you!