2017-06-09 23:52:56 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# assert_ref_unmoved ensures that the previous and current SHA1 of a given ref
|
|
|
|
# is equal by string comparison:
|
|
|
|
#
|
|
|
|
# assert_ref_unmoved "HEAD" "$previous_sha" "$current_sha"
|
|
|
|
#
|
|
|
|
# If the two are unequal (the ref has moved), a message is printed to stderr and
|
|
|
|
# the program exits.
|
|
|
|
assert_ref_unmoved() {
|
|
|
|
local name="$1"
|
|
|
|
local prev_sha="$2"
|
|
|
|
local current_sha="$3"
|
|
|
|
|
|
|
|
if [ "$prev_sha" != "$current_sha" ]; then
|
|
|
|
echo >&2 "$name should not have moved (from: $prev_sha, to: $current_sha)"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-04-14 09:47:20 +00:00
|
|
|
# setup_local_branch_with_gitattrs creates a repository as follows:
|
2017-06-26 17:27:21 +00:00
|
|
|
#
|
|
|
|
# A---B
|
|
|
|
# \
|
2020-06-29 16:18:57 +00:00
|
|
|
# refs/heads/main
|
2017-06-26 17:27:21 +00:00
|
|
|
#
|
|
|
|
# - Commit 'A' has 120, in a.txt, and a corresponding entry in .gitattributes.
|
|
|
|
setup_local_branch_with_gitattrs() {
|
|
|
|
set -e
|
|
|
|
|
2022-01-23 23:41:30 +00:00
|
|
|
reponame="migrate-single-local-branch-with-attrs"
|
2017-06-26 17:27:21 +00:00
|
|
|
|
|
|
|
remove_and_create_local_repo "$reponame"
|
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 120 > a.txt
|
|
|
|
|
|
|
|
git add a.txt
|
|
|
|
git commit -m "initial commit"
|
|
|
|
|
|
|
|
git lfs track "*.txt"
|
|
|
|
git lfs track "*.other"
|
|
|
|
|
|
|
|
git add .gitattributes
|
|
|
|
git commit -m "add .gitattributes"
|
|
|
|
}
|
|
|
|
|
2018-05-26 00:11:14 +00:00
|
|
|
# setup_local_branch_with_nested_gitattrs creates a repository as follows:
|
|
|
|
#
|
|
|
|
# A---B
|
|
|
|
# \
|
2020-06-29 16:18:57 +00:00
|
|
|
# refs/heads/main
|
2018-05-26 00:11:14 +00:00
|
|
|
#
|
|
|
|
# - Commit 'A' has 120, in a.txt, and a corresponding entry in .gitattributes. There is also
|
|
|
|
# 140 in a.md, with no corresponding entry in .gitattributes.
|
|
|
|
# It also has 140 in subtree/a.md, and a corresponding entry in subtree/.gitattributes
|
|
|
|
setup_local_branch_with_nested_gitattrs() {
|
|
|
|
set -e
|
|
|
|
|
2022-01-23 23:41:30 +00:00
|
|
|
reponame="migrate-single-local-branch-nested-attrs"
|
2018-05-26 00:11:14 +00:00
|
|
|
|
|
|
|
remove_and_create_local_repo "$reponame"
|
|
|
|
|
2018-05-31 18:26:58 +00:00
|
|
|
mkdir b
|
2018-05-26 00:11:14 +00:00
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 120 > a.txt
|
|
|
|
base64 < /dev/urandom | head -c 140 > a.md
|
2018-05-31 18:26:58 +00:00
|
|
|
base64 < /dev/urandom | head -c 140 > b/a.md
|
2018-05-26 00:11:14 +00:00
|
|
|
|
2018-05-31 18:26:58 +00:00
|
|
|
git add a.txt a.md b/a.md
|
2018-05-26 00:11:14 +00:00
|
|
|
git commit -m "initial commit"
|
|
|
|
|
|
|
|
git lfs track "*.txt"
|
|
|
|
|
|
|
|
git add .gitattributes
|
|
|
|
git commit -m "add .gitattributes"
|
|
|
|
|
2018-05-31 18:26:58 +00:00
|
|
|
cd b
|
2018-05-26 00:11:14 +00:00
|
|
|
|
|
|
|
git lfs track "*.md"
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
|
2018-05-31 18:26:58 +00:00
|
|
|
git add b/.gitattributes
|
2018-05-26 00:11:14 +00:00
|
|
|
git commit -m "add nested .gitattributes"
|
|
|
|
}
|
|
|
|
|
2020-10-09 00:50:34 +00:00
|
|
|
# setup_single_local_branch_untracked creates a repository as follows:
|
|
|
|
#
|
|
|
|
# A---B
|
|
|
|
# \
|
|
|
|
# refs/heads/main
|
|
|
|
#
|
|
|
|
# - Commit 'A' has 120, in a.txt and 140 in a.md, with neither files tracked as
|
|
|
|
# pointers in Git LFS
|
|
|
|
setup_single_local_branch_untracked() {
|
|
|
|
set -e
|
|
|
|
|
2020-11-23 21:54:34 +00:00
|
|
|
local name="${1:-a.md}"
|
|
|
|
|
2022-01-23 23:41:30 +00:00
|
|
|
reponame="migrate-single-local-branch-untracked"
|
2020-10-09 00:50:34 +00:00
|
|
|
|
|
|
|
remove_and_create_local_repo "$reponame"
|
|
|
|
|
|
|
|
git commit --allow-empty -m "initial commit"
|
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 120 > a.txt
|
2020-11-23 21:54:34 +00:00
|
|
|
base64 < /dev/urandom | head -c 140 > "$name"
|
2020-10-09 00:50:34 +00:00
|
|
|
|
2020-11-23 21:54:34 +00:00
|
|
|
git add a.txt "$name"
|
|
|
|
git commit -m "add a.txt and $name"
|
2020-10-09 00:50:34 +00:00
|
|
|
}
|
|
|
|
|
2018-06-28 21:58:41 +00:00
|
|
|
# setup_single_local_branch_tracked creates a repository as follows:
|
|
|
|
#
|
|
|
|
# A---B
|
|
|
|
# \
|
2020-06-29 16:18:57 +00:00
|
|
|
# refs/heads/main
|
2018-06-28 21:58:41 +00:00
|
|
|
#
|
|
|
|
# - Commit 'A' has 120, in a.txt and 140 in a.md, with both files tracked as
|
|
|
|
# pointers in Git LFS
|
|
|
|
setup_single_local_branch_tracked() {
|
|
|
|
set -e
|
|
|
|
|
2022-01-23 23:41:30 +00:00
|
|
|
reponame="migrate-single-local-branch-tracked"
|
2018-06-28 21:58:41 +00:00
|
|
|
|
|
|
|
remove_and_create_local_repo "$reponame"
|
|
|
|
|
2021-05-01 08:17:49 +00:00
|
|
|
echo "*.txt filter=lfs diff=lfs merge=lfs -text" > .gitattributes
|
|
|
|
echo "*.md filter=lfs diff=lfs merge=lfs -text" >> .gitattributes
|
2018-06-28 21:58:41 +00:00
|
|
|
|
|
|
|
git add .gitattributes
|
|
|
|
git commit -m "initial commit"
|
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 120 > a.txt
|
|
|
|
base64 < /dev/urandom | head -c 140 > a.md
|
|
|
|
|
|
|
|
git add a.txt a.md
|
|
|
|
git commit -m "add a.{txt,md}"
|
|
|
|
}
|
|
|
|
|
2018-07-09 16:56:40 +00:00
|
|
|
# setup_single_local_branch_complex_tracked creates a repository as follows:
|
|
|
|
#
|
|
|
|
# A
|
|
|
|
# \
|
2020-06-29 16:18:57 +00:00
|
|
|
# refs/heads/main
|
2018-07-09 16:56:40 +00:00
|
|
|
#
|
|
|
|
# - Commit 'A' has 1 byte of text in a.txt and dir/b.txt. According to the
|
|
|
|
# .gitattributes files, a.txt should be tracked using Git LFS, but b.txt should
|
|
|
|
# not be.
|
|
|
|
setup_single_local_branch_complex_tracked() {
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="migrate-single-local-branch-complex-tracked"
|
|
|
|
|
|
|
|
remove_and_create_local_repo "$reponame"
|
|
|
|
|
|
|
|
mkdir -p dir
|
|
|
|
echo "*.txt filter=lfs diff=lfs merge=lfs -text" > .gitattributes
|
|
|
|
echo "*.txt !filter !diff !merge" > dir/.gitattributes
|
|
|
|
|
|
|
|
printf "a" > a.txt
|
|
|
|
printf "b" > dir/b.txt
|
|
|
|
|
|
|
|
git lfs uninstall
|
|
|
|
|
|
|
|
git add .gitattributes dir/.gitattributes a.txt dir/b.txt
|
|
|
|
git commit -m "initial commit"
|
|
|
|
|
|
|
|
git lfs install
|
|
|
|
}
|
|
|
|
|
commands/command_migrate.go: introduce '--fixup' flag on 'import'
A common invocation of the 'git lfs migrate import' command is with
'--include' and/or '--exclude' flag(s), which specify wildmatch
pattern(s) for which paths to migrate and/or not migrate.
This is useful for retroactively importing a set of files into Git LFS's
care, or fixing up a file that should have been tracked by Git LFS but
was accidentally committed as a large object instead.
In the later case, it is often the reality that a user will run 'git lfs
migrate --import' with an '--include' path that they believe will gather
the file (and the file alone). This approach is brittle because it
requires the user to infer not only the applicable pattern but the
meaning of that pattern. It also requires the user to run more than one
migration when fixing multiple types of files.
The .gitattributes file(s) contained within a repository provide an
authoritative source on what file(s) are considered by Git to be tracked
in Git LFS. We can use this information to infer the correct patterns to
``fix up'' a broken repository.
In the simplest case, if a repository's .gitattributes file contains the
following:
*.txt filter=lfs merge=lfs diff=lfs -text
But a .txt file matched by that pattern is not parse-able as an LFS
pointer, it will appear as unable to checkout.
Running 'git lfs migrate import --fixup --everything' will correctly
traverse history and find the affected .txt file, read it, create an
object file for it, and store it as an LFS pointer in history.
Thus, a user can run one command which will recognize arbitrarily
complex problems where a file should be tracked by Git LFS, but isn't.
Later, this feature could be combined with the new 'git lfs migrate
export' functionality to also clean files _out_ of Git LFS to object
files when they are not supposed to be tracked as Git LFS objects.
2018-07-06 19:20:02 +00:00
|
|
|
# setup_single_local_branch_tracked_corrupt creates a repository as follows:
|
|
|
|
#
|
|
|
|
# A
|
|
|
|
# \
|
2020-06-29 16:18:57 +00:00
|
|
|
# refs/heads/main
|
commands/command_migrate.go: introduce '--fixup' flag on 'import'
A common invocation of the 'git lfs migrate import' command is with
'--include' and/or '--exclude' flag(s), which specify wildmatch
pattern(s) for which paths to migrate and/or not migrate.
This is useful for retroactively importing a set of files into Git LFS's
care, or fixing up a file that should have been tracked by Git LFS but
was accidentally committed as a large object instead.
In the later case, it is often the reality that a user will run 'git lfs
migrate --import' with an '--include' path that they believe will gather
the file (and the file alone). This approach is brittle because it
requires the user to infer not only the applicable pattern but the
meaning of that pattern. It also requires the user to run more than one
migration when fixing multiple types of files.
The .gitattributes file(s) contained within a repository provide an
authoritative source on what file(s) are considered by Git to be tracked
in Git LFS. We can use this information to infer the correct patterns to
``fix up'' a broken repository.
In the simplest case, if a repository's .gitattributes file contains the
following:
*.txt filter=lfs merge=lfs diff=lfs -text
But a .txt file matched by that pattern is not parse-able as an LFS
pointer, it will appear as unable to checkout.
Running 'git lfs migrate import --fixup --everything' will correctly
traverse history and find the affected .txt file, read it, create an
object file for it, and store it as an LFS pointer in history.
Thus, a user can run one command which will recognize arbitrarily
complex problems where a file should be tracked by Git LFS, but isn't.
Later, this feature could be combined with the new 'git lfs migrate
export' functionality to also clean files _out_ of Git LFS to object
files when they are not supposed to be tracked as Git LFS objects.
2018-07-06 19:20:02 +00:00
|
|
|
#
|
|
|
|
# - Commit 'A' has 120 bytes of random data in a.txt, and tracks *.txt under Git
|
|
|
|
# LFS, but a.txt is not stored as an LFS object.
|
|
|
|
setup_single_local_branch_tracked_corrupt() {
|
|
|
|
set -e
|
|
|
|
|
2021-03-11 03:45:56 +00:00
|
|
|
reponame="migrate-single-local-branch-with-attrs-corrupt"
|
commands/command_migrate.go: introduce '--fixup' flag on 'import'
A common invocation of the 'git lfs migrate import' command is with
'--include' and/or '--exclude' flag(s), which specify wildmatch
pattern(s) for which paths to migrate and/or not migrate.
This is useful for retroactively importing a set of files into Git LFS's
care, or fixing up a file that should have been tracked by Git LFS but
was accidentally committed as a large object instead.
In the later case, it is often the reality that a user will run 'git lfs
migrate --import' with an '--include' path that they believe will gather
the file (and the file alone). This approach is brittle because it
requires the user to infer not only the applicable pattern but the
meaning of that pattern. It also requires the user to run more than one
migration when fixing multiple types of files.
The .gitattributes file(s) contained within a repository provide an
authoritative source on what file(s) are considered by Git to be tracked
in Git LFS. We can use this information to infer the correct patterns to
``fix up'' a broken repository.
In the simplest case, if a repository's .gitattributes file contains the
following:
*.txt filter=lfs merge=lfs diff=lfs -text
But a .txt file matched by that pattern is not parse-able as an LFS
pointer, it will appear as unable to checkout.
Running 'git lfs migrate import --fixup --everything' will correctly
traverse history and find the affected .txt file, read it, create an
object file for it, and store it as an LFS pointer in history.
Thus, a user can run one command which will recognize arbitrarily
complex problems where a file should be tracked by Git LFS, but isn't.
Later, this feature could be combined with the new 'git lfs migrate
export' functionality to also clean files _out_ of Git LFS to object
files when they are not supposed to be tracked as Git LFS objects.
2018-07-06 19:20:02 +00:00
|
|
|
|
|
|
|
remove_and_create_local_repo "$reponame"
|
|
|
|
|
2021-05-01 08:17:49 +00:00
|
|
|
echo "*.txt filter=lfs diff=lfs merge=lfs -text" > .gitattributes
|
commands/command_migrate.go: introduce '--fixup' flag on 'import'
A common invocation of the 'git lfs migrate import' command is with
'--include' and/or '--exclude' flag(s), which specify wildmatch
pattern(s) for which paths to migrate and/or not migrate.
This is useful for retroactively importing a set of files into Git LFS's
care, or fixing up a file that should have been tracked by Git LFS but
was accidentally committed as a large object instead.
In the later case, it is often the reality that a user will run 'git lfs
migrate --import' with an '--include' path that they believe will gather
the file (and the file alone). This approach is brittle because it
requires the user to infer not only the applicable pattern but the
meaning of that pattern. It also requires the user to run more than one
migration when fixing multiple types of files.
The .gitattributes file(s) contained within a repository provide an
authoritative source on what file(s) are considered by Git to be tracked
in Git LFS. We can use this information to infer the correct patterns to
``fix up'' a broken repository.
In the simplest case, if a repository's .gitattributes file contains the
following:
*.txt filter=lfs merge=lfs diff=lfs -text
But a .txt file matched by that pattern is not parse-able as an LFS
pointer, it will appear as unable to checkout.
Running 'git lfs migrate import --fixup --everything' will correctly
traverse history and find the affected .txt file, read it, create an
object file for it, and store it as an LFS pointer in history.
Thus, a user can run one command which will recognize arbitrarily
complex problems where a file should be tracked by Git LFS, but isn't.
Later, this feature could be combined with the new 'git lfs migrate
export' functionality to also clean files _out_ of Git LFS to object
files when they are not supposed to be tracked as Git LFS objects.
2018-07-06 19:20:02 +00:00
|
|
|
git lfs uninstall
|
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 120 > a.txt
|
|
|
|
|
|
|
|
git add .gitattributes a.txt
|
|
|
|
git commit -m "initial commit"
|
|
|
|
|
|
|
|
git lfs install
|
|
|
|
}
|
|
|
|
|
2017-06-21 20:49:18 +00:00
|
|
|
# setup_multiple_local_branches creates a repository as follows:
|
2017-06-09 23:52:56 +00:00
|
|
|
#
|
|
|
|
# B
|
|
|
|
# / \
|
|
|
|
# A refs/heads/my-feature
|
|
|
|
# \
|
2020-06-29 16:18:57 +00:00
|
|
|
# refs/heads/main
|
2017-06-09 23:52:56 +00:00
|
|
|
#
|
|
|
|
# - Commit 'A' has 120, 140 bytes of data in a.txt, and a.md, respectively.
|
|
|
|
#
|
2018-07-16 22:07:57 +00:00
|
|
|
# - Commit 'B' has 30 bytes of data in a.md, and includes commit 'A' as a
|
2017-06-09 23:52:56 +00:00
|
|
|
# parent.
|
|
|
|
setup_multiple_local_branches() {
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="migrate-info-multiple-local-branches"
|
|
|
|
|
|
|
|
remove_and_create_local_repo "$reponame"
|
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 120 > a.txt
|
|
|
|
base64 < /dev/urandom | head -c 140 > a.md
|
|
|
|
|
|
|
|
git add a.txt a.md
|
|
|
|
git commit -m "initial commit"
|
|
|
|
|
|
|
|
git checkout -b my-feature
|
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 30 > a.md
|
|
|
|
|
|
|
|
git add a.md
|
|
|
|
git commit -m "add an additional 30 bytes to a.md"
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git checkout main
|
2017-06-09 23:52:56 +00:00
|
|
|
}
|
|
|
|
|
2019-01-08 09:44:06 +00:00
|
|
|
# setup_multiple_local_branches_with_alternate_names performs the same task
|
|
|
|
# as setup_multiple_local_branches, but creates a file with no extension.
|
|
|
|
setup_multiple_local_branches_with_alternate_names() {
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="migrate-info-multiple-local-branches"
|
|
|
|
|
|
|
|
remove_and_create_local_repo "$reponame"
|
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 120 > no_extension
|
|
|
|
base64 < /dev/urandom | head -c 140 > a.txt
|
|
|
|
|
|
|
|
git add no_extension a.txt
|
|
|
|
git commit -m "initial commit"
|
|
|
|
|
|
|
|
git checkout -b my-feature
|
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 30 > a.txt
|
|
|
|
base64 < /dev/urandom | head -c 100 > no_extension
|
|
|
|
|
|
|
|
git add no_extension a.txt
|
|
|
|
git commit -m "add an additional 30 bytes to a.txt"
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git checkout main
|
2019-01-08 09:44:06 +00:00
|
|
|
}
|
|
|
|
|
2018-05-26 00:11:14 +00:00
|
|
|
# setup_multiple_local_branches_with_gitattrs creates a repository in the same way
|
|
|
|
# as setup_multiple_local_branches, but also adds relevant lfs filters to the
|
2020-06-29 16:18:57 +00:00
|
|
|
# .gitattributes file in the main branch
|
2018-05-26 00:11:14 +00:00
|
|
|
setup_multiple_local_branches_with_gitattrs() {
|
|
|
|
set -e
|
|
|
|
|
|
|
|
setup_multiple_local_branches
|
|
|
|
|
|
|
|
git lfs track *.txt
|
|
|
|
git lfs track *.md
|
|
|
|
|
|
|
|
git add .gitattributes
|
|
|
|
git commit -m "add .gitattributes"
|
|
|
|
}
|
|
|
|
|
2018-07-16 22:08:24 +00:00
|
|
|
# setup_multiple_local_branches_non_standard creates a repository as follows:
|
|
|
|
#
|
|
|
|
# refs/pull/1/head
|
|
|
|
# /
|
|
|
|
# |
|
|
|
|
# B
|
|
|
|
# / \
|
|
|
|
# A refs/heads/my-feature
|
|
|
|
# |\
|
2020-06-29 16:18:57 +00:00
|
|
|
# | refs/heads/main
|
2018-07-16 22:08:24 +00:00
|
|
|
# \
|
|
|
|
# refs/pull/1/base
|
|
|
|
#
|
|
|
|
# With the same contents in 'A' and 'B' as setup_multiple_local_branches.
|
|
|
|
setup_multiple_local_branches_non_standard() {
|
|
|
|
set -e
|
|
|
|
|
|
|
|
setup_multiple_local_branches
|
|
|
|
|
2018-07-17 16:34:33 +00:00
|
|
|
git update-ref refs/pull/1/head "$(git rev-parse my-feature)"
|
2020-06-29 16:18:57 +00:00
|
|
|
git update-ref refs/pull/1/base "$(git rev-parse main)"
|
2018-07-16 22:08:24 +00:00
|
|
|
}
|
|
|
|
|
2018-06-23 00:11:44 +00:00
|
|
|
# setup_multiple_local_branches_tracked creates a repo with exactly the same
|
|
|
|
# structure as in setup_multiple_local_branches, but with all files tracked by
|
|
|
|
# Git LFS
|
|
|
|
setup_multiple_local_branches_tracked() {
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="migrate-info-multiple-local-branches"
|
|
|
|
|
|
|
|
remove_and_create_local_repo "$reponame"
|
|
|
|
|
2021-05-01 08:17:49 +00:00
|
|
|
echo "*.txt filter=lfs diff=lfs merge=lfs -text" > .gitattributes
|
|
|
|
echo "*.md filter=lfs diff=lfs merge=lfs -text" >> .gitattributes
|
2018-06-23 00:11:44 +00:00
|
|
|
git add .gitattributes
|
|
|
|
git commit -m "initial commit"
|
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 120 > a.txt
|
|
|
|
base64 < /dev/urandom | head -c 140 > a.md
|
|
|
|
|
|
|
|
git add a.txt a.md
|
|
|
|
git commit -m "add a.{txt,md}"
|
|
|
|
|
|
|
|
git checkout -b my-feature
|
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 30 > a.md
|
|
|
|
|
|
|
|
git add a.md
|
|
|
|
git commit -m "add an additional 30 bytes to a.md"
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git checkout main
|
2018-06-23 00:11:44 +00:00
|
|
|
}
|
|
|
|
|
2018-03-21 00:37:02 +00:00
|
|
|
# setup_local_branch_with_space creates a repository as follows:
|
|
|
|
#
|
|
|
|
# A
|
|
|
|
# \
|
2020-06-29 16:18:57 +00:00
|
|
|
# refs/heads/main
|
2018-03-21 00:37:02 +00:00
|
|
|
#
|
|
|
|
# - Commit 'A' has 50 bytes in a file named "a file.txt".
|
|
|
|
setup_local_branch_with_space() {
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="migrate-local-branch-with-space"
|
|
|
|
filename="a file.txt"
|
|
|
|
|
|
|
|
remove_and_create_local_repo "$reponame"
|
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 50 > "$filename"
|
|
|
|
|
|
|
|
git add "$filename"
|
|
|
|
git commit -m "initial commit"
|
|
|
|
}
|
|
|
|
|
2017-06-09 23:52:56 +00:00
|
|
|
# setup_single_remote_branch creates a repository as follows:
|
|
|
|
#
|
|
|
|
# A---B
|
|
|
|
# \ \
|
2020-06-29 16:18:57 +00:00
|
|
|
# \ refs/heads/main
|
2017-06-09 23:52:56 +00:00
|
|
|
# \
|
2020-06-29 16:18:57 +00:00
|
|
|
# refs/remotes/origin/main
|
2017-06-09 23:52:56 +00:00
|
|
|
#
|
|
|
|
# - Commit 'A' has 120, 140 bytes of data in a.txt, and a.md, respectively. It
|
|
|
|
# is the latest commit pushed to the remote 'origin'.
|
|
|
|
#
|
|
|
|
# - Commit 'B' has 30, 50 bytes of data in a.txt, and a.md, respectively.
|
|
|
|
setup_single_remote_branch() {
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="migrate-info-single-remote-branch"
|
|
|
|
|
|
|
|
remove_and_create_remote_repo "$reponame"
|
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 120 > a.txt
|
|
|
|
base64 < /dev/urandom | head -c 140 > a.md
|
|
|
|
|
|
|
|
git add a.txt a.md
|
|
|
|
git commit -m "initial commit"
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git push origin main
|
2017-06-09 23:52:56 +00:00
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 30 > a.txt
|
|
|
|
base64 < /dev/urandom | head -c 50 > a.md
|
|
|
|
|
|
|
|
git add a.md a.txt
|
|
|
|
git commit -m "add an additional 30, 50 bytes to a.{txt,md}"
|
|
|
|
}
|
|
|
|
|
2018-05-26 00:11:14 +00:00
|
|
|
setup_single_remote_branch_with_gitattrs() {
|
|
|
|
set -e
|
|
|
|
|
|
|
|
setup_single_remote_branch
|
|
|
|
|
|
|
|
git lfs track *.txt
|
|
|
|
git lfs track *.md
|
|
|
|
|
|
|
|
git add .gitattributes
|
|
|
|
git commit -m "add .gitattributes"
|
|
|
|
}
|
|
|
|
|
2018-06-21 21:03:54 +00:00
|
|
|
# Creates a repo identical to setup_single_remote_branch, except with *.md and
|
2018-06-23 00:11:44 +00:00
|
|
|
# *.txt files tracked by Git LFS
|
2018-06-21 21:03:54 +00:00
|
|
|
setup_single_remote_branch_tracked() {
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="migrate-info-single-remote-branch"
|
|
|
|
|
|
|
|
remove_and_create_remote_repo "$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.md" "*.txt"
|
|
|
|
git add .gitattributes
|
|
|
|
git commit -m "initial commit"
|
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 120 > a.txt
|
|
|
|
base64 < /dev/urandom | head -c 140 > a.md
|
|
|
|
|
|
|
|
git add a.txt a.md
|
|
|
|
git commit -m "add a.{txt,md}"
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git push origin main
|
2018-06-21 21:03:54 +00:00
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 30 > a.txt
|
|
|
|
base64 < /dev/urandom | head -c 50 > a.md
|
|
|
|
|
|
|
|
git add a.md a.txt
|
|
|
|
git commit -m "add an additional 30, 50 bytes to a.{txt,md}"
|
|
|
|
}
|
|
|
|
|
2017-06-09 23:52:56 +00:00
|
|
|
# setup_multiple_remote_branches creates a repository as follows:
|
|
|
|
#
|
|
|
|
# C
|
|
|
|
# / \
|
|
|
|
# A---B refs/heads/my-feature
|
|
|
|
# \ \
|
2020-06-29 16:18:57 +00:00
|
|
|
# \ refs/heads/main
|
2017-06-09 23:52:56 +00:00
|
|
|
# \
|
2020-06-29 16:18:57 +00:00
|
|
|
# refs/remotes/origin/main
|
2017-06-09 23:52:56 +00:00
|
|
|
#
|
|
|
|
# - Commit 'A' has 10, 11 bytes of data in a.txt, and a.md, respectively. It is
|
|
|
|
# the latest commit pushed to the remote 'origin'.
|
|
|
|
#
|
|
|
|
# - Commit 'B' has 20, 21 bytes of data in a.txt, and a.md, respectively.
|
|
|
|
#
|
|
|
|
# - Commit 'C' has 30, 31 bytes of data in a.txt, and a.md, respectively. It is
|
|
|
|
# the latest commit on refs/heads/my-feature.
|
|
|
|
setup_multiple_remote_branches() {
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="migrate-info-exclude-remote-refs-given-branch"
|
|
|
|
|
|
|
|
remove_and_create_remote_repo "$reponame"
|
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 10 > a.txt
|
|
|
|
base64 < /dev/urandom | head -c 11 > a.md
|
|
|
|
git add a.txt a.md
|
|
|
|
git commit -m "add 10, 11 bytes, a.{txt,md}"
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git push origin main
|
2017-06-09 23:52:56 +00:00
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 20 > a.txt
|
|
|
|
base64 < /dev/urandom | head -c 21 > a.md
|
|
|
|
git add a.txt a.md
|
|
|
|
git commit -m "add 20, 21 bytes, a.{txt,md}"
|
2018-06-23 00:11:44 +00:00
|
|
|
|
|
|
|
git checkout -b my-feature
|
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 30 > a.txt
|
|
|
|
base64 < /dev/urandom | head -c 31 > a.md
|
|
|
|
git add a.txt a.md
|
|
|
|
git commit -m "add 30, 31 bytes, a.{txt,md}"
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git checkout main
|
2018-06-23 00:11:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Creates a repo identical to that in setup_multiple_remote_branches(), but
|
|
|
|
# with all files tracked by Git LFS
|
|
|
|
setup_multiple_remote_branches_gitattrs() {
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="migrate-info-exclude-remote-refs-given-branch"
|
|
|
|
|
|
|
|
remove_and_create_remote_repo "$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.txt" "*.md"
|
|
|
|
git add .gitattributes
|
|
|
|
git commit -m "initial commit"
|
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 10 > a.txt
|
|
|
|
base64 < /dev/urandom | head -c 11 > a.md
|
|
|
|
git add a.txt a.md
|
|
|
|
git commit -m "add 10, 11 bytes, a.{txt,md}"
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git push origin main
|
2018-06-23 00:11:44 +00:00
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 20 > a.txt
|
|
|
|
base64 < /dev/urandom | head -c 21 > a.md
|
|
|
|
git add a.txt a.md
|
|
|
|
git commit -m "add 20, 21 bytes, a.{txt,md}"
|
2017-06-09 23:52:56 +00:00
|
|
|
|
|
|
|
git checkout -b my-feature
|
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 30 > a.txt
|
|
|
|
base64 < /dev/urandom | head -c 31 > a.md
|
|
|
|
git add a.txt a.md
|
|
|
|
git commit -m "add 30, 31 bytes, a.{txt,md}"
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git checkout main
|
2017-06-09 23:52:56 +00:00
|
|
|
}
|
|
|
|
|
2017-12-11 23:23:52 +00:00
|
|
|
# setup_single_local_branch_with_tags creates a repository as follows:
|
|
|
|
#
|
|
|
|
# A---B
|
|
|
|
# |\
|
2020-06-29 16:18:57 +00:00
|
|
|
# | refs/heads/main
|
2017-12-11 23:23:52 +00:00
|
|
|
# |
|
|
|
|
# \
|
|
|
|
# refs/tags/v1.0.0
|
|
|
|
#
|
|
|
|
# - Commit 'A' has 1 byte of data in 'a.txt'
|
|
|
|
# - Commit 'B' has 2 bytes of data in 'a.txt', and is tagged at 'v1.0.0'.
|
|
|
|
setup_single_local_branch_with_tags() {
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="migrate-single-local-branch-tags"
|
|
|
|
|
|
|
|
remove_and_create_local_repo "$reponame"
|
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 1 > a.txt
|
|
|
|
|
|
|
|
git add a.txt
|
|
|
|
git commit -m "initial commit"
|
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 2 > a.txt
|
|
|
|
|
|
|
|
git add a.txt
|
|
|
|
git commit -m "secondary commit"
|
|
|
|
git tag "v1.0.0"
|
|
|
|
}
|
|
|
|
|
|
|
|
# setup_single_local_branch_with_annotated_tags creates a repository as follows:
|
|
|
|
#
|
|
|
|
# A---B
|
|
|
|
# |\
|
2020-06-29 16:18:57 +00:00
|
|
|
# | refs/heads/main
|
2017-12-11 23:23:52 +00:00
|
|
|
# |
|
|
|
|
# \
|
|
|
|
# refs/tags/v1.0.0 (annotated)
|
|
|
|
#
|
|
|
|
# - Commit 'A' has 1 byte of data in 'a.txt'
|
|
|
|
# - Commit 'B' has 2 bytes of data in 'a.txt', and is tagged (with annotation)
|
|
|
|
# at 'v1.0.0'.
|
|
|
|
setup_single_local_branch_with_annotated_tags() {
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="migrate-single-local-branch-annotated-tags"
|
|
|
|
|
|
|
|
remove_and_create_local_repo "$reponame"
|
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 1 > a.txt
|
|
|
|
|
|
|
|
git add a.txt
|
|
|
|
git commit -m "initial commit"
|
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 2 > a.txt
|
|
|
|
|
|
|
|
git add a.txt
|
|
|
|
git commit -m "secondary commit"
|
|
|
|
git tag "v1.0.0" -m "v1.0.0"
|
|
|
|
}
|
|
|
|
|
2018-06-13 19:07:19 +00:00
|
|
|
setup_multiple_remotes() {
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="migrate-multiple-remotes"
|
|
|
|
remove_and_create_remote_repo "$reponame"
|
|
|
|
|
|
|
|
forkname="$(git remote -v \
|
|
|
|
| head -n1 \
|
|
|
|
| cut -d ' ' -f 1 \
|
|
|
|
| sed -e 's/^.*\///g')-fork"
|
|
|
|
( setup_remote_repo "$forkname" )
|
|
|
|
|
|
|
|
git remote add fork "$GITSERVER/$forkname"
|
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 16 > a.txt
|
|
|
|
git add a.txt
|
|
|
|
git commit -m "initial commit"
|
2020-06-29 16:18:57 +00:00
|
|
|
git push origin main
|
2018-06-13 19:07:19 +00:00
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 16 > a.txt
|
|
|
|
git add a.txt
|
|
|
|
git commit -m "another commit"
|
2020-06-29 16:18:57 +00:00
|
|
|
git push fork main
|
2018-06-13 19:07:19 +00:00
|
|
|
}
|
|
|
|
|
2017-08-08 16:58:01 +00:00
|
|
|
# setup_single_local_branch_deep_trees creates a repository as follows:
|
|
|
|
#
|
|
|
|
# A
|
|
|
|
# \
|
2020-06-29 16:18:57 +00:00
|
|
|
# refs/heads/main
|
2017-08-08 16:58:01 +00:00
|
|
|
#
|
|
|
|
# - Commit 'A' has 120 bytes of data in 'foo/bar/baz/a.txt'.
|
|
|
|
setup_single_local_branch_deep_trees() {
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="migrate-single-local-branch-with-deep-trees"
|
|
|
|
remove_and_create_local_repo "$reponame"
|
|
|
|
|
|
|
|
mkdir -p foo/bar/baz
|
|
|
|
base64 < /dev/urandom | head -c 120 > foo/bar/baz/a.txt
|
|
|
|
|
|
|
|
git add foo/bar/baz/a.txt
|
|
|
|
git commit -m "initial commit"
|
2018-04-14 09:47:20 +00:00
|
|
|
}
|
|
|
|
|
commands,t: gitattributes migrate filepath parsing
The --include and --exclude (-I and -X) options to the
"git lfs migrate" command allow the user to specify filepath
filters which select matching files to migrate and which are
also used to populate any .gitattributes files written by the
import or export operations.
This latter functionality implies that we need to parse
any filepath patterns supplied by these options using
gitattributes(5) rules, since the patterns will be copied
directly into .gitattributes files. (See the use of the
trackedFromFilter() and trackedFromExportFilter() functions
in particular.)
However, all other Git LFS commands which parse --include
and --exclude options, such as "git lfs fetch" and
"git lfs ls-files", expect to treat any supplied patterns
according to gitignore(5) rules. (This aligns with, for
instance, how the -x option to "git ls-files" works.)
We therefore introduce a buildFilepathFilterWithPatternType()
function which the "git lfs migrate" command can use to
specify the filepathfilter.GitAttributes parsing mode for
its filter, while the other commands continue to use the
filepathfilter.GitIgnore mode.
Note that this change change will have several consequences.
On one hand, patterns such as "*.bin" will only match against
files, not directories, which will restore the behaviour of
"git lfs migrate" in this regard prior to v3.0.0 and the
changes from PR #4556.
On the other hand, patterns such as "foo" will no longer
recursively match everything inside a directory, and "foo/**"
must be used instead. This is in line with how Git's native
gitattributes(5) matching works.
We therefore adjust one existing test to use a directory
match of the form "foo/**" instead of "foo", and add one new
test which confirms that only files named "*.txt" match a
pattern of that form, instead of all files in any directory
whose name has that form, such as a file like "foo.txt/bar.md".
This new test fails without the changes to the "git lfs migrate"
command introduced in this commit.
2021-12-03 00:09:35 +00:00
|
|
|
# setup_single_local_branch_same_file_tree_ext creates a repository as follows:
|
|
|
|
#
|
|
|
|
# A
|
|
|
|
# \
|
|
|
|
# refs/heads/main
|
|
|
|
#
|
|
|
|
# - Commit 'A' has 120 bytes of data in each of 'a.txt`, `foo/a.txt',
|
|
|
|
# `bar.txt/b.md`, and `bar.txt/b.txt`.
|
|
|
|
setup_single_local_branch_same_file_tree_ext() {
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="migrate-single-local-branch-with-same-file-tree-ext"
|
|
|
|
remove_and_create_local_repo "$reponame"
|
|
|
|
|
|
|
|
mkdir -p foo bar.txt
|
|
|
|
base64 < /dev/urandom | head -c 120 > a.txt
|
|
|
|
base64 < /dev/urandom | head -c 120 > foo/a.txt
|
|
|
|
base64 < /dev/urandom | head -c 120 > bar.txt/b.md
|
|
|
|
base64 < /dev/urandom | head -c 120 > bar.txt/b.txt
|
|
|
|
|
|
|
|
git add a.txt foo bar.txt
|
|
|
|
git commit -m "initial commit"
|
|
|
|
}
|
|
|
|
|
2018-04-14 09:47:20 +00:00
|
|
|
# setup_local_branch_with_symlink creates a repository as follows:
|
|
|
|
#
|
|
|
|
# A
|
|
|
|
# \
|
2020-06-29 16:18:57 +00:00
|
|
|
# refs/heads/main
|
2018-04-14 09:47:20 +00:00
|
|
|
#
|
|
|
|
# - Commit 'A' has 120, in a.txt, and a symbolic link link.txt to a.txt.
|
|
|
|
setup_local_branch_with_symlink() {
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="migrate-single-local-branch-with-symlink"
|
|
|
|
|
|
|
|
remove_and_create_local_repo "$reponame"
|
|
|
|
|
|
|
|
base64 < /dev/urandom | head -c 120 > a.txt
|
|
|
|
|
2018-04-27 06:33:29 +00:00
|
|
|
git add a.txt
|
2018-04-14 09:47:20 +00:00
|
|
|
git commit -m "initial commit"
|
2018-04-27 06:33:29 +00:00
|
|
|
|
|
|
|
add_symlink "a.txt" "link.txt"
|
|
|
|
git commit -m "add symlink"
|
2017-08-08 16:58:01 +00:00
|
|
|
}
|
|
|
|
|
commands: warn if working copy is dirty
In 'git lfs migrate import' and 'git lfs migrate export', Git LFS makes
destructive changes to a caller's repository and therefore invokes 'git
checkout --force', which throws away local changes.
To prevent this, let's introduce a check that notifies users when they
are going to throw away local changes, and allows for the user to abort
if they do not wish to discard their local changes.
With this, a user can safely migrate over dirty repositories (i.e., in
the case that they wanted to fix a file that should have been in Git
LFS, but wasn't) without having to finagle their repository to get it
into a migrate-able state.
For users with lots of pending migrations, also teach --yes, which
allows a user to avoid the check, and instead simply prints the warning
message to STDERR.
2018-07-10 15:18:46 +00:00
|
|
|
# setup_local_branch_with_dirty_copy creates a repository as follows:
|
|
|
|
#
|
|
|
|
# A
|
|
|
|
# \
|
2020-06-29 16:18:57 +00:00
|
|
|
# refs/heads/main
|
commands: warn if working copy is dirty
In 'git lfs migrate import' and 'git lfs migrate export', Git LFS makes
destructive changes to a caller's repository and therefore invokes 'git
checkout --force', which throws away local changes.
To prevent this, let's introduce a check that notifies users when they
are going to throw away local changes, and allows for the user to abort
if they do not wish to discard their local changes.
With this, a user can safely migrate over dirty repositories (i.e., in
the case that they wanted to fix a file that should have been in Git
LFS, but wasn't) without having to finagle their repository to get it
into a migrate-able state.
For users with lots of pending migrations, also teach --yes, which
allows a user to avoid the check, and instead simply prints the warning
message to STDERR.
2018-07-10 15:18:46 +00:00
|
|
|
#
|
2018-07-16 21:52:10 +00:00
|
|
|
# - Commit 'A' has the contents "a.txt in a.txt, and marks a.txt as unclean
|
commands: warn if working copy is dirty
In 'git lfs migrate import' and 'git lfs migrate export', Git LFS makes
destructive changes to a caller's repository and therefore invokes 'git
checkout --force', which throws away local changes.
To prevent this, let's introduce a check that notifies users when they
are going to throw away local changes, and allows for the user to abort
if they do not wish to discard their local changes.
With this, a user can safely migrate over dirty repositories (i.e., in
the case that they wanted to fix a file that should have been in Git
LFS, but wasn't) without having to finagle their repository to get it
into a migrate-able state.
For users with lots of pending migrations, also teach --yes, which
allows a user to avoid the check, and instead simply prints the warning
message to STDERR.
2018-07-10 15:18:46 +00:00
|
|
|
# in the working copy.
|
|
|
|
setup_local_branch_with_dirty_copy() {
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="migrate-single-local-branch-with-dirty-copy"
|
|
|
|
remove_and_create_local_repo "$reponame"
|
|
|
|
|
2018-07-16 21:52:10 +00:00
|
|
|
printf "a.txt" > a.txt
|
commands: warn if working copy is dirty
In 'git lfs migrate import' and 'git lfs migrate export', Git LFS makes
destructive changes to a caller's repository and therefore invokes 'git
checkout --force', which throws away local changes.
To prevent this, let's introduce a check that notifies users when they
are going to throw away local changes, and allows for the user to abort
if they do not wish to discard their local changes.
With this, a user can safely migrate over dirty repositories (i.e., in
the case that they wanted to fix a file that should have been in Git
LFS, but wasn't) without having to finagle their repository to get it
into a migrate-able state.
For users with lots of pending migrations, also teach --yes, which
allows a user to avoid the check, and instead simply prints the warning
message to STDERR.
2018-07-10 15:18:46 +00:00
|
|
|
|
|
|
|
git add a.txt
|
|
|
|
git commit -m "initial commit"
|
|
|
|
|
2018-07-16 21:52:10 +00:00
|
|
|
printf "2" >> a.txt
|
commands: warn if working copy is dirty
In 'git lfs migrate import' and 'git lfs migrate export', Git LFS makes
destructive changes to a caller's repository and therefore invokes 'git
checkout --force', which throws away local changes.
To prevent this, let's introduce a check that notifies users when they
are going to throw away local changes, and allows for the user to abort
if they do not wish to discard their local changes.
With this, a user can safely migrate over dirty repositories (i.e., in
the case that they wanted to fix a file that should have been in Git
LFS, but wasn't) without having to finagle their repository to get it
into a migrate-able state.
For users with lots of pending migrations, also teach --yes, which
allows a user to avoid the check, and instead simply prints the warning
message to STDERR.
2018-07-10 15:18:46 +00:00
|
|
|
}
|
|
|
|
|
2021-09-22 16:31:20 +00:00
|
|
|
# setup_local_branch_with_copied_file creates a repository as follows:
|
|
|
|
#
|
|
|
|
# A
|
|
|
|
# \
|
|
|
|
# refs/heads/main
|
|
|
|
#
|
2022-01-05 06:49:08 +00:00
|
|
|
# - Commit 'A' has the contents "a.txt" in a.txt, and another identical file
|
2021-09-22 16:31:20 +00:00
|
|
|
# (same name and content) in another directory.
|
|
|
|
setup_local_branch_with_copied_file() {
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="migrate-single-local-branch-with-copied-file"
|
|
|
|
remove_and_create_local_repo "$reponame"
|
|
|
|
|
|
|
|
printf "a.txt" > a.txt
|
|
|
|
mkdir dir
|
|
|
|
cp a.txt dir/
|
|
|
|
|
|
|
|
git add a.txt dir/a.txt
|
|
|
|
git commit -m "initial commit"
|
2021-10-13 18:49:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# setup_local_branch_with_special_character_files creates a repository as follows:
|
|
|
|
#
|
|
|
|
# A
|
|
|
|
# \
|
|
|
|
# refs/heads/main
|
|
|
|
#
|
|
|
|
# - Commit 'A' has binary files with special characters
|
|
|
|
setup_local_branch_with_special_character_files() {
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="migrate-single-local-branch-with-special-filenames"
|
|
|
|
remove_and_create_local_repo "$reponame"
|
|
|
|
|
|
|
|
head -c 80 /dev/urandom > './test - special.bin'
|
|
|
|
head -c 100 /dev/urandom > './test (test2) special.bin'
|
|
|
|
# Windows does not allow creation of files with '*'
|
|
|
|
[ "$IS_WINDOWS" -eq '1' ] || head -c 120 /dev/urandom > './test * ** special.bin'
|
|
|
|
|
|
|
|
git add *.bin
|
|
|
|
git commit -m "initial commit"
|
2021-09-22 16:31:20 +00:00
|
|
|
}
|
|
|
|
|
2017-07-05 16:29:23 +00:00
|
|
|
# make_bare converts the existing full checkout of a repository into a bare one,
|
|
|
|
# and then `cd`'s into it.
|
|
|
|
make_bare() {
|
|
|
|
reponame=$(basename "$(pwd)")
|
|
|
|
mv .git "../$reponame.git"
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
rm -rf "$reponame"
|
|
|
|
cd "$reponame.git"
|
|
|
|
|
|
|
|
git config --bool core.bare true
|
|
|
|
}
|
|
|
|
|
2017-06-09 23:52:56 +00:00
|
|
|
# remove_and_create_local_repo removes, creates, and checks out a local
|
|
|
|
# repository given by a particular name:
|
|
|
|
#
|
|
|
|
# remove_and_create_local_repo "$reponame"
|
|
|
|
remove_and_create_local_repo() {
|
2017-10-27 15:06:12 +00:00
|
|
|
local reponame="$(base64 < /dev/urandom | head -c 8 | $SHASUM | cut -f 1 -d ' ')-$1"
|
2017-06-09 23:52:56 +00:00
|
|
|
|
|
|
|
git init "$reponame"
|
|
|
|
cd "$reponame"
|
|
|
|
}
|
|
|
|
|
|
|
|
# remove_and_create_remote_repo removes, creates, and checks out a remote
|
|
|
|
# repository both locally and on the gitserver, given by a particular name:
|
|
|
|
#
|
|
|
|
# remove_and_create_remote_repo "$reponame"
|
|
|
|
remove_and_create_remote_repo() {
|
2017-10-27 15:06:12 +00:00
|
|
|
local reponame="$(base64 < /dev/urandom | head -c 8 | $SHASUM | cut -f 1 -d ' ')-$1"
|
2017-06-09 23:52:56 +00:00
|
|
|
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" "$reponame"
|
commands: warn if working copy is dirty
In 'git lfs migrate import' and 'git lfs migrate export', Git LFS makes
destructive changes to a caller's repository and therefore invokes 'git
checkout --force', which throws away local changes.
To prevent this, let's introduce a check that notifies users when they
are going to throw away local changes, and allows for the user to abort
if they do not wish to discard their local changes.
With this, a user can safely migrate over dirty repositories (i.e., in
the case that they wanted to fix a file that should have been in Git
LFS, but wasn't) without having to finagle their repository to get it
into a migrate-able state.
For users with lots of pending migrations, also teach --yes, which
allows a user to avoid the check, and instead simply prints the warning
message to STDERR.
2018-07-10 15:18:46 +00:00
|
|
|
|
|
|
|
rm clone.log
|
2017-06-09 23:52:56 +00:00
|
|
|
}
|