f54c58f0df
Do not populate the keys database with associated files, because a bare repo has no working tree, and so it does not make sense to populate it. Queries of associated files in the keys database always return empty lists in a bare repo, even if it's somehow populated. One way it could be populated is if a user converts a non-bare repo to a bare repo. Note that Git.Config.isBare does a string comparison, so this is not free! But, that string comparison is very small compared to a sqlite query. Sponsored-by: Erik Bjäreholt on Patreon
58 lines
3.1 KiB
Markdown
58 lines
3.1 KiB
Markdown
I am working with a bare repository to transfer two keys from a custom backend to and from a special remote. This seems to be working fine.
|
|
|
|
In order to be able to make use of export remotes (exporttree=yes), I need to be able to specific a tree to be exported. For technical reasons, I want to keep using a bare repository, and use a `hash-object`, `update-index`, and `write-tree` manually in order to create a tree. The Python code snippet that does this looks like this:
|
|
|
|
```
|
|
for key, prefix, fname in (
|
|
# the prefixes are constant hashdir-lower
|
|
(RepoAnnexGitRemote.refs_key, 'a11/1c8', '.datalad/dotgit/refs'),
|
|
(RepoAnnexGitRemote.repo_export_key, '6b2/c13',
|
|
'.datalad/dotgit/repo-export.zip')):
|
|
# create a blob for the annex link
|
|
out = repo._git_runner.run(
|
|
['git', 'hash-object', '-w', '--stdin'],
|
|
stdin=bytes(
|
|
f'../../.git/annex/objects/{prefix}/{key}/{key}', 'utf-8'),
|
|
protocol=StdOutCapture)
|
|
linkhash = out['stdout'].strip()
|
|
# place link into a tree
|
|
out = repo._git_runner.run(
|
|
['git', 'update-index', '--add', '--cacheinfo', '120000',
|
|
linkhash, fname],
|
|
protocol=StdOutCapture)
|
|
# write the complete tree, and return ID
|
|
out = repo._git_runner.run(
|
|
['git', 'write-tree'],
|
|
protocol=StdOutCapture)
|
|
exporttree = out['stdout'].strip()
|
|
```
|
|
|
|
It essentially creates the two blobs for the annex links, puts them together in a tree, and writes it to the repo.
|
|
|
|
However, after this code ran, git-annex is not longer operating properly in the bare repo:
|
|
|
|
```
|
|
% git annex drop --all
|
|
fatal: relative path syntax can't be used outside working tree
|
|
fatal: relative path syntax can't be used outside working tree
|
|
fatal: relative path syntax can't be used outside working tree
|
|
fatal: relative path syntax can't be used outside working tree
|
|
fatal: relative path syntax can't be used outside working tree
|
|
fatal: relative path syntax can't be used outside working tree
|
|
fatal: relative path syntax can't be used outside working tree
|
|
fatal: relative path syntax can't be used outside working tree
|
|
fatal: relative path syntax can't be used outside working tree
|
|
fatal: relative path syntax can't be used outside working tree
|
|
fatal: relative path syntax can't be used outside working tree
|
|
git-annex: fd:21: Data.ByteString.hGetLine: end of file
|
|
```
|
|
|
|
(fatal error messages are from cat-file batch calls inside)
|
|
|
|
When I comment this code out, everything goes back to normal. It seems to makes no difference whether I follow the problematic code up with a `commit-tree` and `update-ref` to actually have the mainline branch point to a commit with that tree. It also seems to make no difference, when I explicitly `setpresentkey <key> <here> 0`.
|
|
|
|
AFAICS this creates the same records as if I would have done this in a regular worktree using high-level git-annex tooling. Other git-annex commands like `fsck` seem to be working fine. If a create a branch with that tree, also `findref` seems to be working properly.
|
|
|
|
Is this a bug, or am I doing something wrong? Thanks in advance for your time!
|
|
|
|
> [[fixed|done]] --[[Joey]]
|