We update the prompt to be more explicit when the import
(or export) migration commands notice a "dirty" working
tree with uncommitted changes, and we also revise the
default action in this case to be to exit early and
preserve the work in progress.
h/t bk2204 for the suggested revisions.
Currently, if we have a file and it contains an extension, we'll add
that extension to the list of paths that should be placed in
.gitattributes. However, if the file does not contain an extension, it
won't be listed at all. As a result, we may convert a file flagged by
the --above option but never cause Git to filter it properly.
Let's fix this by writing an attribute into the repository with the path
relative to the root if we don't contain an extension. This means that
people can store typical Unix binaries, which lack extensions, as LFS
files more easily.
It was clearly intended that we be checking for a pointer not to exist
with the contents of a.txt, not a.md, at this point. This passes either
way because the file isn't a pointer at all and therefore doesn't match
anything, but it's better to check for the proper thing regardless.
The purpose is to allow users to tell git-lfs to migrate
all files over a particular threshold without having to determine
the various paths and patterns that would. This is very useful
for large code bases with inconsistent history of adding large
files in different places. This option makes it possible to
supply `git-lfs migrate import --everything --above=1Mb` and
have git-lfs do the convenient thing and rewrite history.
Currently, our default branch in tests is "master". This is the Git
default, but the Git default will likely change in the future, so it
makes sense to update our testsuite to be explicit about the branch
name. We'll ensure this continues by building against older versions of
Git as well as newer versions.
We use "main" for the new branch name, since that's the proposed value
upstream.
This commit was made entirely by automated means using the following
command:
git grep -l master t | xargs sed -i -e 's/master/main/g'
We avoid rewriting references that we've already seen, since in some
cases we will need to order references to properly handle tags pointing
to tags. However, we use ref.Name for this, which is the short name,
not the full refspec. Consequently, if we've already seen a ref with
the same short name (e.g., a branch when we're processing a tag), we end
up skipping the second ref.
This is not what we want, so let's use the full refspec when populating
the set of items we've already seen.
When we specify the --exclude option to git lfs migrate import to
exclude certain patterns, we currently specify the files as text.
However, in many cases, the files are not text, so it doesn't make sense
to set them that way.
Let's set the text attribute to unspecified instead and let Git
automatically figure out whether the file should be treated as text or
binary. That's at least less likely to result in silent breakage and
will likely be less surprising to the user.
When we rewrite a blob, we cache certain data based on the file name and
the old object ID. However, we don't consider the mode, so if we have
two identical blobs with the same relative name but different modes,
we'll write the mode we first saw into all subsequent blobs.
Fix this by copying the mode across from the existing blob when we
rewrite the new blob.
Co-authored-by: brian m. carlson <bk2204@github.com>
When rewriting history, we've ignored tags pointing to other tags. This
leads to problems for folks that are trying to shrink the size of their
repository, since they may still have tags that point to the old
history. Add additional handling for tags pointing to tags, recursively
rewriting the inner tags until we reach a commit.
When migrating a repository to use Git LFS for the first time, a user is
also required to run 'git lfs install' inside of their newly-migrated
repository, lest they are unable to push.
This is due to the fact that 'git lfs install' writes
.git/hooks/pre-push, which Git invokes, in turn invoking Git LFS to push
Git LFS objects to the remote before sending Git objects.
Without this, we will push only plain-text pointer files, which puts the
pusher at risk of loosing data, or failing any provider-specific
verification/integrity checks.
So, let's run installHooks() to place hooks in the right place, which
makes the following command sequence possible:
$ git lfs migrate import ...
$ git push --all
Let's avoid running this in 'git lfs migrate info' and 'git lfs migrate
export', since neither require it.