Skip to content

LFS repository format version - #4552

Merged
bk2204 merged 2 commits into
git-lfs:mainfrom
bk2204:repo-format-version
Jul 21, 2021
Merged

bk2204 merged 2 commits into
git-lfs:mainfrom
bk2204:repo-format-version

Conversation

@bk2204

@bk2204 bk2204 commented Jul 19, 2021 •

Copy link
Copy Markdown
Member

We've had several proposals to change how data is stored on disk, such as by compressing files when stored inside the .git directory. Unfortunately, those proposals are incompatible with how data is stored now and we would likely break older clients if we implemented them.

To make it possible for us to implement them in the future, let's do what Git does and add support for a repository format version. We read the configuration option lfs.repositoryFormatVersion from the local configuration, and if it is nonzero, we exit with an error. We also assume that if the value is not set, then it is implicitly 0 and set it if possible. We ignore any errors when writing to allow working with read-only repositories in the limited circumstances where that can be valuable.

The plan in the future is to support repository format v1, which, like Git's, will be the same but for a set of lfs.repositoryextension.* keys which denote extensions. Such extensions will be ignored in v0, but will be mandatory to understand in v1; unknown keys will cause Git LFS to abort. The implementation of this functionality is left to the future, however.

In addition, make sure we set up the repositories where appropriate so that all major subsystems set the proper value.

Fixes #4533

@bk2204
bk2204 force-pushed the repo-format-version branch from 3353d3a to b6cf6f8 Compare July 19, 2021 20:45
@bk2204
bk2204 marked this pull request as ready for review July 20, 2021 20:26
@bk2204
bk2204 requested a review from a team July 20, 2021 20:26
bk2204 added 2 commits July 21, 2021 13:28
The smudge, clean, and filter-process commands all operate on the
contents of the repository, since they all expect to read or write files
into the LFS store in the repository.  As a result, let's call
setupRepository to verify that we are, in fact, in a repository and if
not, produce an error message.
We've had several proposals to change how data is stored on disk, such
as by compressing files when stored inside the .git directory.
Unfortunately, those proposals are incompatible with how data is stored
now and we would likely break older clients if we implemented them.

To make it possible for us to implement them in the future, let's do
what Git does and add support for a repository format version.  We read
the configuration option lfs.repositoryFormatVersion from the local
configuration, and if it is nonzero, we exit with an error.  We also
assume that if the value is not set, then it is implicitly 0 and set it
if possible.  We ignore any errors when writing to allow working with
read-only repositories in the limited circumstances where that can be
valuable.

The plan in the future is to support repository format v1, which, like
Git's, will be the same but for a set of lfs.repositoryextension.* keys
which denote extensions.  Such extensions will be ignored in v0, but
will be mandatory to understand in v1; unknown keys will cause Git LFS
to abort.  The implementation of this functionality is left to the
future, however.
@bk2204
bk2204 force-pushed the repo-format-version branch from b6cf6f8 to 6b5f740 Compare July 21, 2021 13:29

@chrisd8088 chrisd8088 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment thread t/t-repo-format.sh
git config --local lfs.repositoryFormatVersion 1

git lfs track '*.bin' >output 2>&1 && exit 1
cat output

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing the cat is here in case of test failure, so it's a bit easier to debug what went wrong -- similar to the one in t/t-locks.sh discussed in #4446 (comment).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's exactly the case.

@bk2204
bk2204 merged commit 7f81e7c into git-lfs:main Jul 21, 2021
@bk2204
bk2204 deleted the repo-format-version branch July 21, 2021 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement an LFS repository format version

2 participants