2024-05-10 18:41:18 +00:00
|
|
|
The [[git-remote-annex|/git-remote-annex]] command allows pushing a git
|
|
|
|
repository to a special remote, and later cloning from it.
|
|
|
|
|
2024-05-07 17:42:12 +00:00
|
|
|
This adds two new key types to git-annex, GITMANIFEST and a GITBUNDLE.
|
2024-04-06 09:28:29 +00:00
|
|
|
|
proof of concent for push to git bundles with MANIFEST
This is a shell script, so not final code, and it does not use git-annex
at all, but it shows how to push to git bundles, listed in a MANIFEST,
the same as the git-remote-annex program will eventually do.
While developing this, I realized that the design needed to be changed
slightly regarding where refs are stored. Since a push can delete a ref
from a remote, storing each newly pushed ref in a bundle won't work,
because deleting a ref would then entail deleting all old bundles and
re-uploading from scratch. So instead, only the refs in the last bundle
listed in the MANIFEST are the active refs. Any refs in prior bundles
are just old refs that were stored previously (a reflog as it were).
That means that, in a situation where two different people are pushing
to the same special remote from different repos, whoever pushes last
wins. Any refs pushed by the other person earlier will be ignored. This
may not be desirable, and git-annex might be able use the git-annex
branch to detect such situations and rescue the refs that got lost. Even
without such a recovery process though, the refs that the other person
thought they pushed will be preserved in their refs/namespaces/mine, so
a pull followed by a push will generally resolve the situation.
Note that the use of refs/namespaces/mine in the bundle is not really
desirable, and it might be worth making a local clone of the repo in
order to set up the refs that will be put in the bundle. Which seems to
be the only way to avoid needing that. But it does need to maintain
the refs/namespaces/mine/ in the git repo in order to remember what refs
have been pushed to the remote before, in order to include them in the
next bundle pushed. A name that includes the remote uuid will be needed
in the final implementation.
Anyway, this shell script seems to fully work, including incremental
pushing, force pushing, and pushes that delete refs.
Sponsored-by: Brett Eisenberg on Patreon
2024-04-25 20:38:34 +00:00
|
|
|
GITMANIFEST--$UUID is the manifest for a git repository stored in the
|
2024-05-20 19:41:09 +00:00
|
|
|
git-annex repository with that UUID. When that is not present,
|
|
|
|
GITMANIFEST--$UUID.bak is a backup copy that can be used instead.
|
2024-04-06 09:28:29 +00:00
|
|
|
|
2024-05-20 19:41:09 +00:00
|
|
|
GITBUNDLE--$UUID-$sha256 is a git bundle.
|
2024-04-06 09:28:29 +00:00
|
|
|
|
|
|
|
# format of the manifest file
|
|
|
|
|
2024-05-06 20:25:55 +00:00
|
|
|
An ordered list of bundle keys, one per line.
|
|
|
|
|
2024-05-13 13:03:43 +00:00
|
|
|
Additionally, there may be bundle keys that are prefixed with "-".
|
|
|
|
These keys are not part of the current content of the git remote
|
|
|
|
and are in the process of being deleted.
|
|
|
|
|
2024-05-06 20:25:55 +00:00
|
|
|
(Lines end with unix `"\n"`, not `"\r\n"`.)
|
2024-04-06 09:28:29 +00:00
|
|
|
|
2024-05-13 15:37:47 +00:00
|
|
|
# exporttree=yes remotes
|
|
|
|
|
|
|
|
In an exporttree=yes remote, the GITMANIFEST and GITBUNDLE objects are
|
|
|
|
stored in the remote, under the `.git/annex/objects/` path.
|
|
|
|
|
2024-05-20 19:41:09 +00:00
|
|
|
# multiple special remotes in the same place
|
2024-04-06 12:30:51 +00:00
|
|
|
|
2024-05-20 19:41:09 +00:00
|
|
|
It's possible for multiple special remotes to point to the same
|
|
|
|
object storage.
|
2024-04-06 12:30:51 +00:00
|
|
|
|
2024-05-10 18:41:18 +00:00
|
|
|
This is why the UUID of the special remote is included in the GITMANIFEST
|
|
|
|
key, and in the annex:: uri.
|
|
|
|
|
|
|
|
# manually cloning from these files
|
|
|
|
|
|
|
|
If you are unable to use git-annex and need to clone a git repository
|
|
|
|
stored in such a special remote, this procedure will work:
|
|
|
|
|
|
|
|
* Find and download the GITMANIFEST
|
|
|
|
* Download each listed GITBUNDLE
|
|
|
|
* `git fetch` from each new bundle in order.
|
|
|
|
(Note that later bundles can update refs from the versions in previous
|
|
|
|
bundles.)
|
|
|
|
|
2024-05-21 14:41:48 +00:00
|
|
|
Note that, if a GITBUNDLE listed in the GITMANIFEST turns out not to exist,
|
|
|
|
a clone should treat this the same as if the GITMANIFEST were empty.
|
|
|
|
bundle objects are deleted when a push is made to the remote that
|
|
|
|
deletes all refs from it, and in a race between such a push and another
|
|
|
|
push of some refs, it is possible for the GITMANIFEST to refer to deleted
|
|
|
|
bundles.
|
|
|
|
|
|
|
|
When the special remote is encrypted, both the names and content of
|
|
|
|
the GITMANIFEST and GITBUNDLE will also be encrypted. To
|
|
|
|
decrypt those manually, see this [[fairly simple shell script using standard tools|tips/Decrypting_files_in_special_remotes_without_git-annex]].
|