<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 18/09/2016 22:15, Lucas Hoffmann
wrote:<br>
</div>
<blockquote cite="mid:147423333927.5414.14002454894792087100@mbp"
type="cite">
<pre wrap="">Quoting Brian Candler (2016-09-18 17:54:21)
</pre>
<blockquote type="cite" style="color: #000000;">
<pre wrap=""><span class="moz-txt-citetags">> </span>Another option I would like to see is to be able to use multiple git
<span class="moz-txt-citetags">> </span>repos within the tree.
</pre>
</blockquote>
<pre wrap="">Did you read my response before yours? Do you know about git
submodules? Maybe they can help you.</pre>
</blockquote>
<p>I didn't have a chance to try it out until now, but now I have.</p>
<p>TL;DR: it doesn't work.</p>
<p>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.<br>
</p>
$ mkdir /tmp/foo /tmp/bar /tmp/baz<br>
<p>$ for i in /tmp/foo /tmp/bar /tmp/baz; do (cd $i && git
init .); done<br>
Initialized empty Git repository in /private/tmp/foo/.git/<br>
Initialized empty Git repository in /private/tmp/bar/.git/<br>
Initialized empty Git repository in /private/tmp/baz/.git/</p>
<p>$ for i in /tmp/foo /tmp/bar /tmp/baz; do (PASSWORD_STORE_DIR=$i
pass init <a class="moz-txt-link-abbreviated" href="mailto:b.candler@pobox.com">b.candler@pobox.com</a>); done<br>
Password store initialized for <a class="moz-txt-link-abbreviated" href="mailto:b.candler@pobox.com">b.candler@pobox.com</a></p>
<p>...</p>
<p>$ PASSWORD_STORE_DIR=/tmp/foo pass edit one<br>
...</p>
<p>$ PASSWORD_STORE_DIR=/tmp/bar pass edit two<br>
...</p>
<p>$ PASSWORD_STORE_DIR=/tmp/baz pass edit three<br>
...</p>
$ PASSWORD_STORE_DIR=/tmp/foo pass one<br>
<p>You need a passphrase to unlock the secret key for<br>
user: "Brian Candler <a class="moz-txt-link-rfc2396E" href="mailto:B.Candler@pobox.com"><B.Candler@pobox.com></a>"<br>
...</p>
<p>ONE<br>
</p>
<p><br>
</p>
<p>OK so far. Now to create a new repo with three submodules:</p>
<p><br>
</p>
<p>$ mkdir /tmp/unified<br>
$ cd /tmp/unified<br>
$ git init .<br>
Initialized empty Git repository in /private/tmp/unified/.git/<br>
$ git submodule add /tmp/foo<br>
Cloning into 'foo'...<br>
done.<br>
$ git submodule add /tmp/bar<br>
Cloning into 'bar'...<br>
done.<br>
$ git submodule add /tmp/baz<br>
Cloning into 'baz'...<br>
done.<br>
$ git commit -m 'Added submodules'<br>
[master (root-commit) c89167a] Added submodules<br>
4 files changed, 12 insertions(+)<br>
create mode 100644 .gitmodules<br>
create mode 160000 bar<br>
create mode 160000 baz<br>
create mode 160000 foo</p>
$ PASSWORD_STORE_DIR=/tmp/unified pass list<br>
Password Store<br>
├── bar<br>
│ └── two<br>
├── baz<br>
│ └── three<br>
└── foo<br>
└── one<br>
$ PASSWORD_STORE_DIR=/tmp/unified pass foo/one<br>
<br>
You need a passphrase to unlock the secret key for<br>
user: "Brian Candler <a class="moz-txt-link-rfc2396E" href="mailto:B.Candler@pobox.com"><B.Candler@pobox.com></a>"<br>
...<br>
<br>
ONE<br>
<br>
<br>
Again no problem: reading a password works fine. But what about when
you want to edit one?<br>
<br>
<br>
$ PASSWORD_STORE_DIR=/tmp/unified pass edit foo/one<br>
<br>
You need a passphrase to unlock the secret key for<br>
user: "Brian Candler <a class="moz-txt-link-rfc2396E" href="mailto:B.Candler@pobox.com"><B.Candler@pobox.com></a>"<br>
2048-bit ELG-E key, ID B4439488, created 2008-06-30 (main key ID
EBF0ECF0)<br>
<br>
<br>
You need a passphrase to unlock the secret key for<br>
user: "Brian Candler <a class="moz-txt-link-rfc2396E" href="mailto:B.Candler@pobox.com"><B.Candler@pobox.com></a>"<br>
2048-bit ELG-E key, ID B4439488, created 2008-06-30 (main key ID
EBF0ECF0)<br>
<br>
<b>fatal: Pathspec '/tmp/unified/foo/one.gpg' is in submodule 'foo'</b><b><br>
</b><br>
<br>
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.<br>
<br>
Checking the status by hand:<br>
<br>
$ cd /tmp/unified<br>
$ git status<br>
On branch master<br>
Changes not staged for commit:<br>
(use "git add <file>..." to update what will be committed)<br>
(use "git checkout -- <file>..." to discard changes in
working directory)<br>
(commit or discard the untracked or modified content in
submodules)<br>
<br>
modified: foo (modified content)<br>
<br>
no changes added to commit (use "git add" and/or "git commit -a")<br>
$ cd /tmp/unified/foo<br>
$ git status<br>
On branch master<br>
Your branch is up-to-date with 'origin/master'.<br>
Changes not staged for commit:<br>
(use "git add <file>..." to update what will be committed)<br>
(use "git checkout -- <file>..." to discard changes in
working directory)<br>
<br>
modified: one.gpg<br>
<br>
no changes added to commit (use "git add" and/or "git commit -a")<br>
<br>
<br>
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:<br>
<br>
$ cd /tmp/unified/foo/<br>
$ git commit -am 'Updated foo'<br>
[master 60e939b] Updated foo<br>
1 file changed, 0 insertions(+), 0 deletions(-)<br>
rewrite one.gpg (100%)<br>
$ cd /tmp/unified/<br>
$ git status<br>
On branch master<br>
Changes not staged for commit:<br>
(use "git add <file>..." to update what will be committed)<br>
(use "git checkout -- <file>..." to discard changes in
working directory)<br>
<br>
modified: foo (new commits)<br>
<br>
no changes added to commit (use "git add" and/or "git commit -a")<br>
$ git commit -am 'Updated unified'<br>
[master 564b675] Updated unified<br>
1 file changed, 1 insertion(+), 1 deletion(-)<br>
<br>
<br>
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.<br>
<br>
(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)<br>
<br>
According to <a class="moz-txt-link-freetext" href="https://git-scm.com/book/en/v2/Git-Tools-Submodules">https://git-scm.com/book/en/v2/Git-Tools-Submodules</a>, I
think this might be possible using the
"--recurse-submodules=on-demand" flag - but password-store doesn't
invoke that.<br>
<br>
Regards,<br>
<br>
Brian.<br>
<br>
</body>
</html>