AGWA / git-crypt

Transparent file encryption in git
https://www.agwa.name/projects/git-crypt/
GNU General Public License v3.0
8.32k stars 479 forks source link

Add parameter for git-crypt lock to ignore already locked repository #133

Open nickolas-pohilets opened 7 years ago

nickolas-pohilets commented 7 years ago

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.

olivergondza commented 5 years ago

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.

navxio commented 3 years ago

need this

alerque commented 3 years ago

@AGWA Would you accept a fix for this if a PR was put together?

AGWA commented 3 years ago

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