diff --git a/commands/command_migrate_import.go b/commands/command_migrate_import.go index bf6adaa3..7b1eb161 100644 --- a/commands/command_migrate_import.go +++ b/commands/command_migrate_import.go @@ -18,6 +18,7 @@ import ( "github.com/git-lfs/git-lfs/v3/tasklog" "github.com/git-lfs/git-lfs/v3/tools" "github.com/git-lfs/git-lfs/v3/tools/humanize" + "github.com/git-lfs/git-lfs/v3/tr" "github.com/git-lfs/gitobj/v2" "github.com/spf13/cobra" ) @@ -138,6 +139,12 @@ func migrateImportCommand(cmd *cobra.Command, args []string) { if err != nil { ExitWithError(errors.Wrap(err, "fatal: cannot parse --above=")) } + if above > 0 { + include, exclude := getIncludeExcludeArgs(cmd) + if include != nil || exclude != nil || migrateFixup { + ExitWithError(errors.Errorf(tr.Tr.Get("fatal: cannot use --above with --include, --exclude, --fixup"))) + } + } blobCache := make(map[string]bytes.Buffer) diff --git a/docs/man/git-lfs-migrate.1.ronn b/docs/man/git-lfs-migrate.1.ronn index 3fb5e887..ef481b3c 100644 --- a/docs/man/git-lfs-migrate.1.ronn +++ b/docs/man/git-lfs-migrate.1.ronn @@ -232,7 +232,8 @@ options and these additional ones: * `--above=` Only migrate files whose individual filesize is above the given size. `size` may be specified as a number of bytes, or a number followed by a storage - unit, e.g., "1b", "20 MB", "3 TiB", etc. + unit, e.g., "1b", "20 MB", "3 TiB", etc. This option cannot be used with + the `--include`, `--exclude`, and `--fixup` options. * `--object-map=` Write to `path` a file with the mapping of each rewritten commits. The file diff --git a/t/t-migrate-import.sh b/t/t-migrate-import.sh index 399ede10..8a175c9e 100755 --- a/t/t-migrate-import.sh +++ b/t/t-migrate-import.sh @@ -487,6 +487,22 @@ begin_test "migrate import (above with multiple files)" ) end_test +begin_test "migrate import (above with include or exclude)" +( + set -e + setup_single_local_branch_untracked + + md_main_oid="$(calc_oid "$(git cat-file -p "refs/heads/main:a.md")")" + txt_main_oid="$(calc_oid "$(git cat-file -p "refs/heads/main:a.txt")")" + + git lfs migrate import --above 121B --include "*.md" && exit 1 + git lfs migrate import --above 121B --exclude "*.txt" && exit 1 + git lfs migrate import --above 121B --fixup && exit 1 + true +) +end_test + + begin_test "migrate import (existing .gitattributes)" ( set -e