Since we're about to do a v3.0.0 release, let's bump the version to v3.
Make this change automatically with the following command to avoid any
missed items:
git grep -l github.com/git-lfs/git-lfs/v2 | \
xargs sed -i -e 's!github.com/git-lfs/git-lfs/v2!github.com/git-lfs/git-lfs/v3!g'
When our go.mod file was introduced in commit
114e85c2002091eb415040923d872f8e4a4bc636 in PR #3208, the module
path chosen did not include a trailing /v2 component. However,
the Go modules specification now advises that module paths must
have a "major version suffix" which matches the release version.
We therefore add a /v2 suffix to our module path and all its
instances in import paths.
See also https://golang.org/ref/mod#major-version-suffixes for
details regarding the Go module system's major version suffix rule.
This code path has several 40-based constants. Use the ObjectIDLengths
and ObjectIDRegex variables to parse these values in a way that works
for either SHA-1 or SHA-256.
There are some places in our code that we need to check whether an
object ID is the all-zeros ID. We've had several different pieces of
code to check this, but let's put a single function together to check
this regardless of the hash algorithm in use.
Remove all the other pieces of code which check for this, including a
couple which were not even used.
If a user attempts to force-push over a ref and we don't currently have
the object that the reference currently points to, our pre-push hook
will fail with a message like the following:
ref foo:: Error in git rev-list --stdin --objects --not --remotes=origin --: exit status 128 fatal: bad object 1aabb695d63c4d4afe731ab69573893390526896
This occurs because we pass the existing object name to git rev-list as
something to exclude. Normally, this is a good idea, since it means we
can short-circuit the traversal since we already know what the other
side has. However, in this case, it causes unwanted problems.
What we really want is for Git to just ignore an object if it's bad, and
fortunately the rev-list --ignore-missing object does exactly this, so
let's use it. Note that we must pass it before the --stdin option since
otherwise it has no effect, so move the --stdin option to the end of the
command.
We have an optimization that means we avoid traversing objects that
exist in the remote tracking branches of named remotes. We assume that
the server already has the LFS objects referred to by those Git objects.
However, this doesn't work for URL remotes, since there are no remote
tracking branches for them. Instead, let's make sure that we don't
traverse Git objects that are included in the old value of the ref,
which we know the server must have.
Note that this will not help the case where someone is pushing a new
branch to a URL remote; in that case, the old value is the all-zeros
value and we'll still have to traverse the entire history since we
haven't learned anything about what the server has.