diff --git a/gocrypt.bash b/gocrypt.bash index 37cf4ae..f0cacfa 100755 --- a/gocrypt.bash +++ b/gocrypt.bash @@ -32,6 +32,10 @@ gocrypt_die() { exit 1 } +_cmd_git() { + [ -d '.git' ] && cmd_git "$@" +} + gocrypt_derive_password() { local data="$1" local key="$2" @@ -94,10 +98,10 @@ gocrypt_init() { echo "# Gocrypt" >> .gitignore echo "gocrypt" >> .gitignore - cmd_git add .gitignore - $needs_passphrase && cmd_git add "$gocrypt_needs_passphrase_marker" - cmd_git add "$gocrypt_dir" - cmd_git commit -m "Initialized encrypted storage for gocrypt plugin" + _cmd_git add .gitignore + $needs_passphrase && _cmd_git add "$gocrypt_needs_passphrase_marker" + _cmd_git add "$gocrypt_dir" + _cmd_git commit -m "Initialized encrypted storage for gocrypt plugin" } gocrypt_open() { @@ -134,8 +138,8 @@ gocrypt_delegate() { # Delegate command to another `pass` instance that manages what is inside of the mountpoint PASSWORD_STORE_DIR="$PWD/$gocrypt_dec_dir" "$PROGRAM" "$@" # Commit if there has been changes due to this operation - cmd_git add "$gocrypt_dir" - cmd_git commit -m "Encrypted pass operation inside gocrypt" "$gocrypt_dir" || echo "No git commit created" + _cmd_git add "$gocrypt_dir" + _cmd_git commit -m "Encrypted pass operation inside gocrypt" "$gocrypt_dir" || echo "No git commit created" } gocrypt_crypt() {