Use git hook to re-initialize a subdirectory

Chris Coutinho chrisbcoutinho at gmail.com
Thu Mar 15 18:50:08 CET 2018


Hello,

I have a subdirectory in my pass-store to allow some passwords to be
decrypted by multiple users. I do this using the `pass init -p
<subdirectory> <user1> <user2> ...`

I would like to create a git hook that re-initializes if a change occurs in
this directory, but I'm having trouble making this work. My thinking is
that this needs to be a 'post-commit' hook because I think I want a change
in the subdirectory (i.e. `pass insert <subdirectory/blah`) to cause a
re-encryption. The issue is that I'm getting stuck in an infinite loop
because a re-encryption causes a commit, which I would only like to do once.

```
SUBDIR=<mysubdirectory>
echo "=== About to execute
if"

if git show --name-only | grep "^$SUBDIR

then

    echo "=== Running
pass..."

    pass init -p $SUBDIR $(cat
$HOME/.password-store/$SUBDIR/.gpg-id)
    echo "=== Done running
pass..."

    exit
0

fi

echo "=== Finished if"
```

This doesn't work because it goes into an infinite loop. Every
initialization launches a new commit, and I don't think I can bypass the
hook using the git commit --no-verify flag.

Are there any ideas here?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20180315/9bd29cc9/attachment.html>


More information about the Password-Store mailing list