[pass] Add 'Change Dir' Functionality

Brian Candler b.candler at pobox.com
Mon Sep 26 14:03:25 CEST 2016


On 18/09/2016 22:15, Lucas Hoffmann wrote:
> Quoting Brian Candler (2016-09-18 17:54:21)
>> >Another option I would like to see is to be able to use multiple git
>> >repos within the tree.
> Did you read my response before yours?  Do you know about git
> submodules?  Maybe they can help you.

I didn't have a chance to try it out until now, but now I have.

TL;DR: it doesn't work.

Long version: let's try it in full. Make three repos, clone them, add 
them to an outer unified repo, and then run password-store in that.

$ mkdir /tmp/foo /tmp/bar /tmp/baz

$ for i in /tmp/foo /tmp/bar /tmp/baz; do (cd $i && git init .); done
Initialized empty Git repository in /private/tmp/foo/.git/
Initialized empty Git repository in /private/tmp/bar/.git/
Initialized empty Git repository in /private/tmp/baz/.git/

$ for i in /tmp/foo /tmp/bar /tmp/baz; do (PASSWORD_STORE_DIR=$i pass 
init b.candler at pobox.com); done
Password store initialized for b.candler at pobox.com

...

$ PASSWORD_STORE_DIR=/tmp/foo pass edit one
...

$ PASSWORD_STORE_DIR=/tmp/bar pass edit two
...

$ PASSWORD_STORE_DIR=/tmp/baz pass edit three
...

$ PASSWORD_STORE_DIR=/tmp/foo pass one

You need a passphrase to unlock the secret key for
user: "Brian Candler <B.Candler at pobox.com>"
...

ONE


OK so far. Now to create a new repo with three submodules:


$ mkdir /tmp/unified
$ cd /tmp/unified
$ git init .
Initialized empty Git repository in /private/tmp/unified/.git/
$ git submodule add /tmp/foo
Cloning into 'foo'...
done.
$ git submodule add /tmp/bar
Cloning into 'bar'...
done.
$ git submodule add /tmp/baz
Cloning into 'baz'...
done.
$ git commit -m 'Added submodules'
[master (root-commit) c89167a] Added submodules
  4 files changed, 12 insertions(+)
  create mode 100644 .gitmodules
  create mode 160000 bar
  create mode 160000 baz
  create mode 160000 foo

$ PASSWORD_STORE_DIR=/tmp/unified pass list
Password Store
├── bar
│   └── two
├── baz
│   └── three
└── foo
     └── one
$ PASSWORD_STORE_DIR=/tmp/unified pass foo/one

You need a passphrase to unlock the secret key for
user: "Brian Candler <B.Candler at pobox.com>"
...

ONE


Again no problem: reading a password works fine. But what about when you 
want to edit one?


$ PASSWORD_STORE_DIR=/tmp/unified pass edit foo/one

You need a passphrase to unlock the secret key for
user: "Brian Candler <B.Candler at pobox.com>"
2048-bit ELG-E key, ID B4439488, created 2008-06-30 (main key ID EBF0ECF0)


You need a passphrase to unlock the secret key for
user: "Brian Candler <B.Candler at pobox.com>"
2048-bit ELG-E key, ID B4439488, created 2008-06-30 (main key ID EBF0ECF0)

*fatal: Pathspec '/tmp/unified/foo/one.gpg' is in submodule 'foo'**
*

So it's broken. My guess is it's trying to do a "git add" from the outer 
repo, when the modified file is in the inner repo.

Checking the status by hand:

$ cd /tmp/unified
$ git status
On branch master
Changes not staged for commit:
   (use "git add <file>..." to update what will be committed)
   (use "git checkout -- <file>..." to discard changes in working directory)
   (commit or discard the untracked or modified content in submodules)

     modified:   foo (modified content)

no changes added to commit (use "git add" and/or "git commit -a")
$ cd /tmp/unified/foo
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
   (use "git add <file>..." to update what will be committed)
   (use "git checkout -- <file>..." to discard changes in working directory)

     modified:   one.gpg

no changes added to commit (use "git add" and/or "git commit -a")


In summary: whatever password-store is doing, it doesn't work with 
submodules. I am able to fix it up by doing commits separately in the 
inner repo and the outer one:

$ cd /tmp/unified/foo/
$ git commit -am 'Updated foo'
[master 60e939b] Updated foo
  1 file changed, 0 insertions(+), 0 deletions(-)
  rewrite one.gpg (100%)
$ cd /tmp/unified/
$ git status
On branch master
Changes not staged for commit:
   (use "git add <file>..." to update what will be committed)
   (use "git checkout -- <file>..." to discard changes in working directory)

     modified:   foo (new commits)

no changes added to commit (use "git add" and/or "git commit -a")
$ git commit -am 'Updated unified'
[master 564b675] Updated unified
  1 file changed, 1 insertion(+), 1 deletion(-)


Note: I have not yet tested "git push"; that would require the target to 
be a bare repo, so the test environment would have to be set up a bit 
differently. But again, I would expect to have to do a "git push" within 
the inner repo, *and* a "git push" within the outer one.

(Actually the outer repo is just holding pointers to the inner ones, so 
it doesn't matter that much. What matters is doing a git push on the 
inner ones)

According to https://git-scm.com/book/en/v2/Git-Tools-Submodules, I 
think this might be possible using the "--recurse-submodules=on-demand" 
flag - but password-store doesn't invoke that.

Regards,

Brian.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20160926/ab1a9a78/attachment.html>


More information about the Password-Store mailing list