git-crypt
git-crypt copied to clipboard
Add parameter for git-crypt lock to ignore already locked repository
I'm writing a BASH script that operates on some data stored inside an encrypted repo, and I want to ensure that repo is locked when the script finishes regardless of anything. So, I'm setting a BASH trap that locks the repo, but in case of normal flow, I'm also locking repo earlier.
Currently git-crypt lock in the trap fails with error message Error: this repository is already locked. and exit code 1.
Would be nice to have a parameter to make git-crypt lock to behave like mkdir -p - if the repository is already locked, just do nothing and exit with code 0.
This is indeed desired. I see it would change the current command semantics but it makes sense to me to get both lock and unlock to behave idempotently.
need this
@AGWA Would you accept a fix for this if a PR was put together?
Yup, I'd accept a PR. I'm thinking we should call it --if-unlocked with no short option. Since this will be used primarily in scripts rather than on the command line, it's better to be descriptive than short.
E.g. git lock --if-unlocked