Hi there, This is how i patched latest version of the pass script to be able to have .git in any of the subdirectories. Patch attached.
HOW: function find_git_dir() gets $passfile path and tries to find first .git directory in all of the subdirectories in the path up to $PREFIX WHEN: function find_git_dir is called from any function that should generate a commit (cmd_insert, cmd_edit, cmd_git) ruza -- e-mail: [email protected] www: http://ruza.eu http://brmlab.cz
--- password-store.sh 2014-11-01 22:57:15.702218124 +0100 +++ /usr/bin/pass 2014-11-03 12:45:21.863203963 +0100 @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usb/bin/env bash # Copyright (C) 2012 - 2014 Jason A. Donenfeld <[email protected]>. All Rights Reserved. # This file is licensed under the GPLv2+. Please see COPYING for more information. @@ -15,12 +15,22 @@ X_SELECTION="${PASSWORD_STORE_X_SELECTION:-clipboard}" CLIP_TIME="${PASSWORD_STORE_CLIP_TIME:-45}" -export GIT_DIR="${PASSWORD_STORE_GIT:-$PREFIX}/.git" -export GIT_WORK_TREE="${PASSWORD_STORE_GIT:-$PREFIX}" - # # BEGIN helper functions # +find_git_dir() { +#cd "$PREFIX/$(dirname $1)" +cd "$(dirname $1)" +while true ;do + PASSWORD_STORE_GIT="$(find $PWD -maxdepth 1 -type d -and -name .git -exec dirname {} \; 2>/dev/null)" + [[ -d $PWD/.git ]] && break + if [[ $PWD == $PREFIX ]];then break;fi + cd .. +done + +export GIT_DIR="${PASSWORD_STORE_GIT:-$PREFIX}/.git" +export GIT_WORK_TREE="${PASSWORD_STORE_GIT:-$PREFIX}" +} git_add_file() { [[ -d $GIT_DIR ]] || return @@ -194,7 +204,6 @@ GETOPT="getopt" SHRED="shred -f -z" -source "$(dirname "$0")/platform/$(uname | cut -d _ -f 1 | tr '[:upper:]' '[:lower:]').sh" 2>/dev/null # PLATFORM_FUNCTION_FILE # # END platform definable @@ -282,6 +291,7 @@ local gpg_id="$PREFIX/$id_path/.gpg-id" + #find_git_dir "$passfile" if [[ $# -eq 1 && -z $1 ]]; then [[ ! -f "$gpg_id" ]] && die "Error: $gpg_id does not exist and so cannot be removed." rm -v -f "$gpg_id" || exit 1 @@ -408,6 +418,7 @@ read -r -p "Enter password for $path: " -e password $GPG -e "${GPG_RECIPIENT_ARGS[@]}" -o "$passfile" "${GPG_OPTS[@]}" <<<"$password" fi + find_git_dir "$passfile" git_add_file "$passfile" "Add given password for $path to store." } @@ -434,6 +445,7 @@ while ! $GPG -e "${GPG_RECIPIENT_ARGS[@]}" -o "$passfile" "${GPG_OPTS[@]}" "$tmp_file"; do yesno "GPG encryption failed. Would you like to try again?" done + find_git_dir "$passfile" git_add_file "$passfile" "$action password for $path using ${EDITOR:-vi}." } @@ -476,6 +488,7 @@ fi local verb="Add" [[ $inplace -eq 1 ]] && verb="Replace" + find_git_dir "$passfile" git_add_file "$passfile" "$verb generated password for ${path}." if [[ $clip -eq 0 ]]; then @@ -508,6 +521,7 @@ [[ $force -eq 1 ]] || yesno "Are you sure you would like to delete $path?" rm $recursive -f -v "$passfile" + find_git_dir "$passfile" if [[ -d $GIT_DIR && ! -e $passfile ]]; then git rm -qr "$passfile" git_commit "Remove $path from store." @@ -561,6 +575,7 @@ } cmd_git() { + find_git_dir "$2" if [[ $1 == "init" ]]; then git "$@" || exit 1 git_add_file "$PREFIX" "Add current contents of password store."
_______________________________________________ Password-Store mailing list [email protected] http://lists.zx2c4.com/mailman/listinfo/password-store
