6b5f740a00
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.
32 lines
679 B
Bash
Executable File
32 lines
679 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
. "$(dirname "$0")/testlib.sh"
|
|
|
|
begin_test "repository format version"
|
|
(
|
|
set -e
|
|
|
|
reponame="lfs-repo-version"
|
|
git init $reponame
|
|
cd $reponame
|
|
|
|
[ -z "$(git config --local lfs.repositoryFormatVersion)" ]
|
|
|
|
git lfs track '*.dat'
|
|
|
|
[ "$(git config --local lfs.repositoryFormatVersion)" = "0" ]
|
|
|
|
git config --local lfs.repositoryFormatVersion 1
|
|
|
|
git lfs track '*.bin' >output 2>&1 && exit 1
|
|
cat output
|
|
grep "Unknown repository format version: 1" output
|
|
|
|
git config --local --unset lfs.repositoryFormatVersion
|
|
# Verify that global settings are ignored.
|
|
git config --global lfs.repositoryFormatVersion 1
|
|
|
|
git lfs track '*.bin'
|
|
)
|
|
end_test
|