[PATCH] git push pull and clone

Pass Word passwordstore at 89vx.net
Sun Jan 6 06:24:10 CET 2019


This patch adds git pull before commit and push after if a remote exists.

It also adds support for "pass git clone <url>".  (The command "pass 
init" should not be run if you plan to clone.)


diff --git a/src/password-store.sh b/src/password-store.sh
index d89d455..d8f22b6 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -43,7 +43,10 @@ git_commit() {
         local sign=""
         [[ -n $INNER_GIT_DIR ]] || return
         [[ $(git -C "$INNER_GIT_DIR" config --bool --get 
pass.signcommits) == "true" ]] && sign="-S"
+       local remote=$(git -C "$INNER_GIT_DIR" remote -v)
+       [[ "$remote" ]] && git -C "$INNER_GIT_DIR" pull
         git -C "$INNER_GIT_DIR" commit $sign -m "$1"
+       [[ "$remote" ]] && git -C "$INNER_GIT_DIR" push
  }
  yesno() {
         [[ -t 0 ]] || return 0
@@ -641,6 +644,8 @@ cmd_git() {
                 git_add_file .gitattributes "Configure git repository 
for gpg file diff."
                 git -C "$INNER_GIT_DIR" config --local diff.gpg.binary true
                 git -C "$INNER_GIT_DIR" config --local 
diff.gpg.textconv "$GPG -d ${GPG_OPTS[*]}"
+       elif [[ $1 == "clone" ]]; then
+               git "$@" "$PREFIX"
         elif [[ -n $INNER_GIT_DIR ]]; then
                 tmpdir nowarn #Defines $SECURE_TMPDIR. We don't warn, 
because at most, this only copies encrypted files.
                 export TMPDIR="$SECURE_TMPDIR"


More information about the Password-Store mailing list