Commit Graph

17 Commits

Author SHA1 Message Date
Chris Darroch
021a06ec55 commands,t: make import default to saving work
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.
2021-03-26 15:39:22 -07:00
Chris Darroch
b6a32b71d4 t: fix typo and remove unused debugging commands 2021-03-10 20:43:58 -08:00
brian m. carlson
dd463c624f
migrate import: ensure all files end up in .gitattributes
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.
2020-11-23 22:11:09 +00:00
brian m. carlson
4bca2ebdc6
t/t-migrate-import: check for correct missing object
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.
2020-11-23 22:11:09 +00:00
Eli Ribble
5a4f2eb7f9 Add --above parameter to 'migrate import'.
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.
2020-11-05 18:57:25 -08:00
brian m. carlson
9e006ac4e2
Rename default branch in tests to "main"
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'
2020-07-08 15:38:17 +00:00
brian m. carlson
ac0deefef9
git: consider full refspec when determining seen refs
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.
2020-05-18 13:57:29 +00:00
brian m. carlson
c8524d2563
migrate import: set text to unspecified for excluded fields
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.
2020-04-09 17:25:24 +00:00
Taylor Blau
a470c39587
git/githistory/rewriter.go: uncache with mode
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>
2019-06-25 20:56:59 +00:00
brian m. carlson
ff410fa761
githistory: rewrite tags pointing to tags
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.
2019-06-24 19:09:23 +00:00
Taylor Blau
ca4eeba59d commands/command_migrate_import.go: install hooks
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.
2018-09-05 10:50:57 -04:00
Taylor Blau
351c81fc5d Merge branch 'master' into ttaylorr/prove 2018-07-23 11:12:04 -05:00
Taylor Blau
9afae6f6fc Merge branch 'master' into ttaylorr/prove 2018-07-17 12:54:38 -05:00
Taylor Blau
e0ed17dd0f t: move 't-migrate-fixtures.sh' to 'fixtures' 2018-07-11 13:18:25 -05:00
Taylor Blau
f2fd813c9d t: fix more source-ing from the wrong location 2018-07-11 13:18:25 -05:00
Taylor Blau
de9152049c t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
Taylor Blau
219b7e0a3d t: prefix all existing tests with t- 2018-07-09 16:24:25 -05:00