2016-02-09 12:52:38 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2018-07-10 18:48:02 +00:00
|
|
|
. "$(dirname "$0")/testlib.sh"
|
2016-02-09 12:52:38 +00:00
|
|
|
|
2016-02-12 14:49:56 +00:00
|
|
|
ensure_git_version_isnt $VERSION_LOWER "2.2.0"
|
|
|
|
|
2016-02-09 12:52:38 +00:00
|
|
|
begin_test "clone"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="$(basename "$0" ".sh")"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" repo
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
2017-03-24 16:59:03 +00:00
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
2016-02-09 12:52:38 +00:00
|
|
|
|
|
|
|
# generate some test data & commits with random LFS data
|
|
|
|
echo "[
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -10d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":100},
|
|
|
|
{\"Filename\":\"file2.dat\",\"Size\":75}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -7d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":110},
|
|
|
|
{\"Filename\":\"file3.dat\",\"Size\":66},
|
|
|
|
{\"Filename\":\"file4.dat\",\"Size\":23}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -10d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file5.dat\",\"Size\":120},
|
|
|
|
{\"Filename\":\"file6.dat\",\"Size\":30}]
|
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
|
|
|
git push origin master
|
|
|
|
|
|
|
|
# Now clone again, test specific clone dir
|
|
|
|
cd "$TRASHDIR"
|
|
|
|
|
|
|
|
newclonedir="testclone1"
|
|
|
|
git lfs clone "$GITSERVER/$reponame" "$newclonedir" 2>&1 | tee lfsclone.log
|
|
|
|
grep "Cloning into" lfsclone.log
|
2018-01-06 02:01:50 +00:00
|
|
|
grep "Downloading LFS objects:" lfsclone.log
|
2016-02-09 12:52:38 +00:00
|
|
|
# should be no filter errors
|
|
|
|
[ ! $(grep "filter" lfsclone.log) ]
|
|
|
|
[ ! $(grep "error" lfsclone.log) ]
|
|
|
|
# should be cloned into location as per arg
|
|
|
|
[ -d "$newclonedir" ]
|
|
|
|
|
|
|
|
# check a few file sizes to make sure pulled
|
|
|
|
pushd "$newclonedir"
|
2017-10-04 16:26:38 +00:00
|
|
|
[ $(wc -c < "file1.dat") -eq 110 ]
|
|
|
|
[ $(wc -c < "file2.dat") -eq 75 ]
|
|
|
|
[ $(wc -c < "file3.dat") -eq 66 ]
|
|
|
|
assert_hooks "$(dot_git_dir)"
|
|
|
|
[ ! -e "lfs" ]
|
|
|
|
assert_clean_status
|
2016-02-09 12:52:38 +00:00
|
|
|
popd
|
2017-10-04 16:26:38 +00:00
|
|
|
|
2016-02-09 12:52:38 +00:00
|
|
|
# Now check clone with implied dir
|
|
|
|
rm -rf "$reponame"
|
|
|
|
git lfs clone "$GITSERVER/$reponame" 2>&1 | tee lfsclone.log
|
|
|
|
grep "Cloning into" lfsclone.log
|
2018-01-06 02:01:50 +00:00
|
|
|
grep "Downloading LFS objects:" lfsclone.log
|
2016-02-09 12:52:38 +00:00
|
|
|
# should be no filter errors
|
|
|
|
[ ! $(grep "filter" lfsclone.log) ]
|
|
|
|
[ ! $(grep "error" lfsclone.log) ]
|
|
|
|
# clone location should be implied
|
|
|
|
[ -d "$reponame" ]
|
2017-10-04 16:26:38 +00:00
|
|
|
|
2016-02-09 12:52:38 +00:00
|
|
|
pushd "$reponame"
|
2017-10-04 16:26:38 +00:00
|
|
|
[ $(wc -c < "file1.dat") -eq 110 ]
|
|
|
|
[ $(wc -c < "file2.dat") -eq 75 ]
|
|
|
|
[ $(wc -c < "file3.dat") -eq 66 ]
|
|
|
|
assert_hooks "$(dot_git_dir)"
|
|
|
|
[ ! -e "lfs" ]
|
|
|
|
assert_clean_status
|
2016-02-09 12:52:38 +00:00
|
|
|
popd
|
|
|
|
|
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2016-03-09 17:31:04 +00:00
|
|
|
begin_test "cloneSSL"
|
|
|
|
(
|
|
|
|
set -e
|
2016-03-17 10:34:33 +00:00
|
|
|
if $TRAVIS; then
|
|
|
|
echo "Skipping SSL tests, Travis has weird behaviour in validating custom certs, test locally only"
|
|
|
|
exit 0
|
|
|
|
fi
|
2016-03-09 17:31:04 +00:00
|
|
|
|
|
|
|
reponame="test-cloneSSL"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo_ssl "$reponame" "$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
2017-03-24 16:59:03 +00:00
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
2016-03-09 17:31:04 +00:00
|
|
|
|
|
|
|
# generate some test data & commits with random LFS data
|
|
|
|
echo "[
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -5d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":100},
|
|
|
|
{\"Filename\":\"file2.dat\",\"Size\":75}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -1d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file3.dat\",\"Size\":30}]
|
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
|
|
|
git push origin master
|
|
|
|
|
|
|
|
# Now SSL clone again with 'git lfs clone', test specific clone dir
|
|
|
|
cd "$TRASHDIR"
|
|
|
|
|
2016-03-10 11:33:51 +00:00
|
|
|
newclonedir="testcloneSSL1"
|
2016-03-09 17:58:28 +00:00
|
|
|
git lfs clone "$SSLGITSERVER/$reponame" "$newclonedir" 2>&1 | tee lfsclone.log
|
2017-10-05 22:24:22 +00:00
|
|
|
assert_clean_status
|
2016-03-09 17:31:04 +00:00
|
|
|
grep "Cloning into" lfsclone.log
|
|
|
|
grep "Git LFS:" lfsclone.log
|
|
|
|
# should be no filter errors
|
|
|
|
[ ! $(grep "filter" lfsclone.log) ]
|
|
|
|
[ ! $(grep "error" lfsclone.log) ]
|
|
|
|
# should be cloned into location as per arg
|
|
|
|
[ -d "$newclonedir" ]
|
|
|
|
|
|
|
|
# check a few file sizes to make sure pulled
|
|
|
|
pushd "$newclonedir"
|
2016-12-07 00:13:38 +00:00
|
|
|
[ $(wc -c < "file1.dat") -eq 100 ]
|
|
|
|
[ $(wc -c < "file2.dat") -eq 75 ]
|
|
|
|
[ $(wc -c < "file3.dat") -eq 30 ]
|
2017-03-23 16:54:52 +00:00
|
|
|
assert_hooks "$(dot_git_dir)"
|
2016-03-09 17:31:04 +00:00
|
|
|
popd
|
|
|
|
|
|
|
|
|
|
|
|
# Now check SSL clone with standard 'git clone' and smudge download
|
|
|
|
rm -rf "$reponame"
|
2016-03-10 11:33:51 +00:00
|
|
|
git clone "$SSLGITSERVER/$reponame"
|
2016-03-09 17:31:04 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2017-01-24 14:53:43 +00:00
|
|
|
begin_test "clone ClientCert"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
reponame="test-cloneClientCert"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo_clientcert "$reponame" "$reponame"
|
2017-01-25 21:49:35 +00:00
|
|
|
if [ $(grep -c "client-cert-mac-openssl" clone_client_cert.log) -gt 0 ]; then
|
|
|
|
echo "Skipping due to SSL client cert bug in Git"
|
|
|
|
exit 0
|
|
|
|
fi
|
2017-01-24 14:53:43 +00:00
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
2017-03-24 16:59:03 +00:00
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
2017-01-24 14:53:43 +00:00
|
|
|
|
|
|
|
# generate some test data & commits with random LFS data
|
|
|
|
echo "[
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -5d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":100},
|
|
|
|
{\"Filename\":\"file2.dat\",\"Size\":75}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -1d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file3.dat\",\"Size\":30}]
|
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
|
|
|
git push origin master
|
|
|
|
|
|
|
|
# Now clone again with 'git lfs clone', test specific clone dir
|
|
|
|
cd "$TRASHDIR"
|
|
|
|
|
|
|
|
newclonedir="testcloneClietCert1"
|
|
|
|
git lfs clone "$CLIENTCERTGITSERVER/$reponame" "$newclonedir" 2>&1 | tee lfsclone.log
|
|
|
|
grep "Cloning into" lfsclone.log
|
|
|
|
grep "Git LFS:" lfsclone.log
|
|
|
|
# should be no filter errors
|
|
|
|
[ ! $(grep "filter" lfsclone.log) ]
|
|
|
|
[ ! $(grep "error" lfsclone.log) ]
|
|
|
|
# should be cloned into location as per arg
|
|
|
|
[ -d "$newclonedir" ]
|
|
|
|
|
|
|
|
# check a few file sizes to make sure pulled
|
|
|
|
pushd "$newclonedir"
|
2017-10-04 16:26:38 +00:00
|
|
|
[ $(wc -c < "file1.dat") -eq 100 ]
|
|
|
|
[ $(wc -c < "file2.dat") -eq 75 ]
|
|
|
|
[ $(wc -c < "file3.dat") -eq 30 ]
|
|
|
|
assert_hooks "$(dot_git_dir)"
|
|
|
|
assert_clean_status
|
2017-01-24 14:53:43 +00:00
|
|
|
popd
|
|
|
|
|
|
|
|
|
|
|
|
# Now check SSL clone with standard 'git clone' and smudge download
|
|
|
|
rm -rf "$reponame"
|
|
|
|
git clone "$CLIENTCERTGITSERVER/$reponame"
|
|
|
|
|
|
|
|
)
|
|
|
|
end_test
|
2016-04-19 14:15:58 +00:00
|
|
|
|
|
|
|
begin_test "clone with flags"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="$(basename "$0" ".sh")-flags"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" "$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
2017-03-24 16:59:03 +00:00
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
2016-04-19 14:15:58 +00:00
|
|
|
|
|
|
|
# generate some test data & commits with random LFS data
|
|
|
|
echo "[
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -10d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":100},
|
|
|
|
{\"Filename\":\"file2.dat\",\"Size\":75}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -7d)\",
|
2016-12-07 00:13:38 +00:00
|
|
|
\"NewBranch\":\"branch2\",
|
2016-04-19 14:15:58 +00:00
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"fileonbranch2.dat\",\"Size\":66}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -3d)\",
|
|
|
|
\"ParentBranches\":[\"master\"],
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file3.dat\",\"Size\":120},
|
|
|
|
{\"Filename\":\"file4.dat\",\"Size\":30}]
|
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
|
|
|
git push origin master branch2
|
|
|
|
|
|
|
|
# Now clone again, test specific clone dir
|
|
|
|
cd "$TRASHDIR"
|
|
|
|
mkdir "$TRASHDIR/templatedir"
|
|
|
|
|
|
|
|
newclonedir="testflagsclone1"
|
|
|
|
# many of these flags won't do anything but make sure they're not rejected
|
|
|
|
git lfs clone --template "$TRASHDIR/templatedir" --local --no-hardlinks --shared --verbose --progress --recursive "$GITSERVER/$reponame" "$newclonedir"
|
|
|
|
rm -rf "$newclonedir"
|
|
|
|
|
|
|
|
# specific test for --no-checkout
|
|
|
|
git lfs clone --quiet --no-checkout "$GITSERVER/$reponame" "$newclonedir"
|
|
|
|
if [ -e "$newclonedir/file1.dat" ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
rm -rf "$newclonedir"
|
|
|
|
|
|
|
|
# specific test for --branch and --origin
|
|
|
|
git lfs clone --branch branch2 --recurse-submodules --origin differentorigin "$GITSERVER/$reponame" "$newclonedir"
|
|
|
|
pushd "$newclonedir"
|
|
|
|
# this file is only on branch2
|
|
|
|
[ -e "fileonbranch2.dat" ]
|
|
|
|
# confirm remote is called differentorigin
|
|
|
|
git remote get-url differentorigin
|
2017-03-23 16:54:52 +00:00
|
|
|
assert_hooks "$(dot_git_dir)"
|
2016-04-19 14:15:58 +00:00
|
|
|
popd
|
|
|
|
rm -rf "$newclonedir"
|
|
|
|
|
|
|
|
# specific test for --separate-git-dir
|
|
|
|
gitdir="$TRASHDIR/separategitdir"
|
|
|
|
git lfs clone --separate-git-dir "$gitdir" "$GITSERVER/$reponame" "$newclonedir"
|
|
|
|
# .git should be a file not dir
|
|
|
|
if [ -d "$newclonedir/.git" ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
[ -e "$newclonedir/.git" ]
|
|
|
|
[ -d "$gitdir/objects" ]
|
2017-03-23 16:54:52 +00:00
|
|
|
assert_hooks "$gitdir"
|
2016-04-19 14:15:58 +00:00
|
|
|
rm -rf "$newclonedir"
|
|
|
|
rm -rf "$gitdir"
|
|
|
|
|
|
|
|
# specific test for --bare
|
|
|
|
git lfs clone --bare "$GITSERVER/$reponame" "$newclonedir"
|
2016-12-07 00:13:38 +00:00
|
|
|
[ -d "$newclonedir/objects" ]
|
2017-05-22 15:43:26 +00:00
|
|
|
rm -rf "$newclonedir"
|
2016-04-19 14:15:58 +00:00
|
|
|
|
|
|
|
# short flags
|
|
|
|
git lfs clone -l -v -n -s -b branch2 "$GITSERVER/$reponame" "$newclonedir"
|
|
|
|
rm -rf "$newclonedir"
|
|
|
|
)
|
|
|
|
end_test
|
2016-06-22 21:45:59 +00:00
|
|
|
|
|
|
|
begin_test "clone (with include/exclude args)"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="clone_include_exclude"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" "$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
2017-03-24 16:59:03 +00:00
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
2016-06-22 21:45:59 +00:00
|
|
|
|
|
|
|
contents_a="a"
|
|
|
|
contents_a_oid=$(calc_oid "$contents_a")
|
|
|
|
printf "$contents_a" > "a.dat"
|
2016-12-07 02:10:46 +00:00
|
|
|
printf "$contents_a" > "a-dupe.dat"
|
|
|
|
printf "$contents_a" > "dupe-a.dat"
|
2016-06-22 21:45:59 +00:00
|
|
|
|
|
|
|
contents_b="b"
|
|
|
|
contents_b_oid=$(calc_oid "$contents_b")
|
|
|
|
printf "$contents_b" > "b.dat"
|
|
|
|
|
2016-12-07 02:10:46 +00:00
|
|
|
git add *.dat .gitattributes
|
2016-06-22 21:45:59 +00:00
|
|
|
git commit -m "add a.dat, b.dat" 2>&1 | tee commit.log
|
|
|
|
grep "master (root-commit)" commit.log
|
2016-12-07 02:10:46 +00:00
|
|
|
grep "5 files changed" commit.log
|
2016-06-22 21:45:59 +00:00
|
|
|
grep "create mode 100644 a.dat" commit.log
|
2016-12-07 02:10:46 +00:00
|
|
|
grep "create mode 100644 a-dupe.dat" commit.log
|
|
|
|
grep "create mode 100644 dupe-a.dat" commit.log
|
2016-06-22 21:45:59 +00:00
|
|
|
grep "create mode 100644 b.dat" commit.log
|
|
|
|
grep "create mode 100644 .gitattributes" commit.log
|
|
|
|
|
|
|
|
git push origin master 2>&1 | tee push.log
|
|
|
|
grep "master -> master" push.log
|
2018-01-06 02:01:50 +00:00
|
|
|
grep "Uploading LFS objects: 100% (2/2), 2 B" push.log
|
2016-06-22 21:45:59 +00:00
|
|
|
|
|
|
|
cd "$TRASHDIR"
|
|
|
|
|
|
|
|
local_reponame="clone_with_includes"
|
2016-12-07 02:10:46 +00:00
|
|
|
git lfs clone "$GITSERVER/$reponame" "$local_reponame" -I "a*.dat"
|
2016-06-22 21:45:59 +00:00
|
|
|
pushd "$local_reponame"
|
|
|
|
assert_local_object "$contents_a_oid" 1
|
|
|
|
refute_local_object "$contents_b_oid"
|
2016-12-07 00:13:38 +00:00
|
|
|
[ "a" = "$(cat a.dat)" ]
|
2016-12-07 02:10:46 +00:00
|
|
|
[ "a" = "$(cat a-dupe.dat)" ]
|
|
|
|
[ "$(pointer $contents_a_oid 1)" = "$(cat dupe-a.dat)" ]
|
2016-12-07 00:13:38 +00:00
|
|
|
[ "$(pointer $contents_b_oid 1)" = "$(cat b.dat)" ]
|
2017-03-23 16:54:52 +00:00
|
|
|
assert_hooks "$(dot_git_dir)"
|
2016-06-22 21:45:59 +00:00
|
|
|
popd
|
|
|
|
|
|
|
|
local_reponame="clone_with_excludes"
|
|
|
|
git lfs clone "$GITSERVER/$reponame" "$local_reponame" -I "b.dat" -X "a.dat"
|
|
|
|
pushd "$local_reponame"
|
|
|
|
assert_local_object "$contents_b_oid" 1
|
|
|
|
refute_local_object "$contents_a_oid"
|
2016-12-07 00:13:38 +00:00
|
|
|
[ "$(pointer $contents_a_oid 1)" = "$(cat a.dat)" ]
|
|
|
|
[ "b" = "$(cat b.dat)" ]
|
2017-03-23 16:54:52 +00:00
|
|
|
assert_hooks "$(dot_git_dir)"
|
2016-06-22 21:45:59 +00:00
|
|
|
popd
|
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2016-06-23 17:39:36 +00:00
|
|
|
begin_test "clone (with .lfsconfig)"
|
2016-06-22 21:45:59 +00:00
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
2016-06-23 17:39:36 +00:00
|
|
|
reponame="clone_with_lfsconfig"
|
2016-06-22 21:45:59 +00:00
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" "$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
2017-03-24 16:59:03 +00:00
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
2016-06-22 21:45:59 +00:00
|
|
|
|
|
|
|
contents_a="a"
|
|
|
|
contents_a_oid=$(calc_oid "$contents_a")
|
|
|
|
printf "$contents_a" > "a.dat"
|
|
|
|
|
|
|
|
contents_b="b"
|
|
|
|
contents_b_oid=$(calc_oid "$contents_b")
|
|
|
|
printf "$contents_b" > "b.dat"
|
|
|
|
|
2016-06-23 17:39:36 +00:00
|
|
|
git add a.dat b.dat .gitattributes
|
2016-06-22 21:45:59 +00:00
|
|
|
git commit -m "add a.dat, b.dat" 2>&1 | tee commit.log
|
|
|
|
grep "master (root-commit)" commit.log
|
2016-06-23 17:39:36 +00:00
|
|
|
grep "3 files changed" commit.log
|
2016-06-22 21:45:59 +00:00
|
|
|
grep "create mode 100644 a.dat" commit.log
|
|
|
|
grep "create mode 100644 b.dat" commit.log
|
|
|
|
grep "create mode 100644 .gitattributes" commit.log
|
|
|
|
|
2016-06-23 17:39:36 +00:00
|
|
|
git config -f ".lfsconfig" "lfs.fetchinclude" "a*"
|
|
|
|
git add ".lfsconfig"
|
|
|
|
git commit -m "config lfs.fetchinclude a*" 2>&1 | tee commit.log
|
|
|
|
grep "master" commit.log
|
|
|
|
grep "1 file changed" commit.log
|
|
|
|
grep "create mode 100644 .lfsconfig" commit.log
|
|
|
|
|
2016-06-22 21:45:59 +00:00
|
|
|
git push origin master 2>&1 | tee push.log
|
|
|
|
grep "master -> master" push.log
|
2018-01-06 02:01:50 +00:00
|
|
|
grep "Uploading LFS objects: 100% (2/2), 2 B" push.log
|
2016-06-22 21:45:59 +00:00
|
|
|
|
2016-06-23 17:39:36 +00:00
|
|
|
pushd "$TRASHDIR"
|
2016-06-22 21:45:59 +00:00
|
|
|
|
2016-06-23 17:39:36 +00:00
|
|
|
echo "test: clone with lfs.fetchinclude in .lfsconfig"
|
|
|
|
local_reponame="clone_with_config_include"
|
2016-12-26 20:53:09 +00:00
|
|
|
set +x
|
2016-06-22 21:45:59 +00:00
|
|
|
git lfs clone "$GITSERVER/$reponame" "$local_reponame"
|
2016-12-26 20:53:09 +00:00
|
|
|
ok="$?"
|
|
|
|
set -x
|
|
|
|
if [ "0" -ne "$ok" ]; then
|
|
|
|
# TEMP: used to catch transient failure from above `clone` command, as in:
|
|
|
|
# https://github.com/git-lfs/git-lfs/pull/1782#issuecomment-267678319
|
|
|
|
echo >&2 "[!] \`git lfs clone $GITSERVER/$reponame $local_reponame\` failed"
|
|
|
|
git lfs logs last
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
fi
|
2016-06-22 21:45:59 +00:00
|
|
|
pushd "$local_reponame"
|
|
|
|
assert_local_object "$contents_a_oid" 1
|
|
|
|
refute_local_object "$contents_b_oid"
|
2017-03-23 16:54:52 +00:00
|
|
|
assert_hooks "$(dot_git_dir)"
|
2016-06-22 21:45:59 +00:00
|
|
|
popd
|
|
|
|
|
2016-06-23 17:39:36 +00:00
|
|
|
echo "test: clone with lfs.fetchinclude in .lfsconfig, and args"
|
|
|
|
local_reponame="clone_with_config_include_and_args"
|
|
|
|
git lfs clone "$GITSERVER/$reponame" "$local_reponame" -I "b.dat"
|
|
|
|
pushd "$local_reponame"
|
|
|
|
refute_local_object "$contents_a_oid"
|
|
|
|
assert_local_object "$contents_b_oid" 1
|
2017-03-23 16:54:52 +00:00
|
|
|
assert_hooks "$(dot_git_dir)"
|
2016-06-23 17:39:36 +00:00
|
|
|
popd
|
2016-06-22 21:45:59 +00:00
|
|
|
|
2016-06-23 17:39:36 +00:00
|
|
|
popd
|
2016-06-22 21:45:59 +00:00
|
|
|
|
|
|
|
git config -f ".lfsconfig" "lfs.fetchinclude" "b*"
|
|
|
|
git config -f ".lfsconfig" "lfs.fetchexclude" "a*"
|
2016-06-23 17:39:36 +00:00
|
|
|
git add .lfsconfig
|
|
|
|
git commit -m "config lfs.fetchinclude a*" 2>&1 | tee commit.log
|
|
|
|
grep "master" commit.log
|
|
|
|
grep "1 file changed" commit.log
|
2016-06-22 21:45:59 +00:00
|
|
|
git push origin master 2>&1 | tee push.log
|
|
|
|
grep "master -> master" push.log
|
|
|
|
|
2016-06-23 17:39:36 +00:00
|
|
|
pushd "$TRASHDIR"
|
2016-06-22 21:45:59 +00:00
|
|
|
|
2016-06-23 17:39:36 +00:00
|
|
|
echo "test: clone with lfs.fetchexclude in .lfsconfig"
|
|
|
|
local_reponame="clone_with_config_exclude"
|
2016-06-22 21:45:59 +00:00
|
|
|
git lfs clone "$GITSERVER/$reponame" "$local_reponame"
|
|
|
|
pushd "$local_reponame"
|
2016-06-23 17:39:36 +00:00
|
|
|
cat ".lfsconfig"
|
2016-06-22 21:45:59 +00:00
|
|
|
assert_local_object "$contents_b_oid" 1
|
|
|
|
refute_local_object "$contents_a_oid"
|
2017-03-23 16:54:52 +00:00
|
|
|
assert_hooks "$(dot_git_dir)"
|
2016-06-22 21:45:59 +00:00
|
|
|
popd
|
2016-06-23 17:39:36 +00:00
|
|
|
|
|
|
|
echo "test: clone with lfs.fetchexclude in .lfsconfig, and args"
|
|
|
|
local_reponame="clone_with_config_exclude_and_args"
|
|
|
|
git lfs clone "$GITSERVER/$reponame" "$local_reponame" -I "a.dat" -X "b.dat"
|
|
|
|
pushd "$local_reponame"
|
|
|
|
assert_local_object "$contents_a_oid" 1
|
|
|
|
refute_local_object "$contents_b_oid"
|
2017-03-23 16:54:52 +00:00
|
|
|
assert_hooks "$(dot_git_dir)"
|
2016-06-23 17:39:36 +00:00
|
|
|
popd
|
|
|
|
|
|
|
|
popd
|
2016-06-22 21:45:59 +00:00
|
|
|
)
|
|
|
|
end_test
|
2016-07-14 16:12:57 +00:00
|
|
|
|
2017-09-27 23:11:42 +00:00
|
|
|
begin_test "clone (without clean filter)"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="clone_with_clean"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" "$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
|
|
|
|
|
|
|
contents_a="a"
|
|
|
|
contents_a_oid=$(calc_oid "$contents_a")
|
|
|
|
printf "$contents_a" > "a.dat"
|
|
|
|
|
|
|
|
git add *.dat .gitattributes
|
|
|
|
git commit -m "add a.dat, b.dat" 2>&1 | tee commit.log
|
|
|
|
grep "master (root-commit)" commit.log
|
|
|
|
|
|
|
|
git push origin master 2>&1 | tee push.log
|
|
|
|
grep "master -> master" push.log
|
2018-01-06 02:01:50 +00:00
|
|
|
grep "Uploading LFS objects: 100% (1/1), 1 B" push.log
|
2017-09-27 23:11:42 +00:00
|
|
|
|
|
|
|
cd "$TRASHDIR"
|
|
|
|
|
|
|
|
git lfs uninstall
|
|
|
|
git config --list > config.txt
|
|
|
|
grep "filter.lfs.clean" config.txt && {
|
|
|
|
echo "clean filter still configured:"
|
|
|
|
cat config.txt
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
local_reponame="clone_without_clean"
|
|
|
|
git lfs clone "$GITSERVER/$reponame" "$local_reponame" -I "a*.dat" | tee clone.txt
|
|
|
|
if [ "0" -ne "${PIPESTATUS[0]}" ]; then
|
|
|
|
echo >&2 "fatal: expected clone to succeed ..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
grep "Git LFS is not installed" clone.txt
|
|
|
|
|
|
|
|
cd "$local_reponame"
|
|
|
|
assert_local_object "$contents_a_oid" 1
|
|
|
|
[ "$(pointer $contents_a_oid 1)" = "$(cat a.dat)" ]
|
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2016-07-14 16:12:57 +00:00
|
|
|
begin_test "clone with submodules"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# set up a doubly nested submodule, each with LFS content
|
|
|
|
reponame="submod-root"
|
|
|
|
submodname1="submod-level1"
|
|
|
|
submodname2="submod-level2"
|
|
|
|
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
setup_remote_repo "$submodname1"
|
|
|
|
setup_remote_repo "$submodname2"
|
|
|
|
|
|
|
|
clone_repo "$submodname2" submod2
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
2017-03-24 16:59:03 +00:00
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
2016-07-14 16:12:57 +00:00
|
|
|
|
|
|
|
contents_sub2="Inception. Now, before you bother telling me it's impossible..."
|
|
|
|
contents_sub2_oid=$(calc_oid "$contents_sub2")
|
|
|
|
printf "$contents_sub2" > "sub2.dat"
|
2016-12-07 00:13:38 +00:00
|
|
|
git add sub2.dat .gitattributes
|
2016-07-14 16:12:57 +00:00
|
|
|
git commit -m "Nested submodule level 2"
|
|
|
|
git push origin master
|
|
|
|
|
|
|
|
clone_repo "$submodname1" submod1
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
2017-03-24 16:59:03 +00:00
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
2016-07-14 16:12:57 +00:00
|
|
|
|
|
|
|
contents_sub1="We're dreaming?"
|
|
|
|
contents_sub1_oid=$(calc_oid "$contents_sub1")
|
|
|
|
printf "$contents_sub1" > "sub1.dat"
|
|
|
|
# add submodule2 as submodule of submodule1
|
|
|
|
git submodule add "$GITSERVER/$submodname2" sub2
|
|
|
|
git submodule update
|
2016-12-07 00:13:38 +00:00
|
|
|
git add sub2 sub1.dat .gitattributes
|
2016-07-14 16:12:57 +00:00
|
|
|
git commit -m "Nested submodule level 1"
|
|
|
|
git push origin master
|
|
|
|
|
|
|
|
clone_repo "$reponame" rootrepo
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
2017-03-24 16:59:03 +00:00
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
2016-07-14 16:12:57 +00:00
|
|
|
|
|
|
|
contents_root="Downwards is the only way forwards."
|
|
|
|
contents_root_oid=$(calc_oid "$contents_root")
|
|
|
|
printf "$contents_root" > "root.dat"
|
|
|
|
# add submodule1 as submodule of root
|
|
|
|
git submodule add "$GITSERVER/$submodname1" sub1
|
|
|
|
git submodule update
|
2016-12-07 00:13:38 +00:00
|
|
|
git add sub1 root.dat .gitattributes
|
2016-07-14 16:12:57 +00:00
|
|
|
git commit -m "Root repo"
|
|
|
|
git push origin master
|
|
|
|
|
|
|
|
pushd "$TRASHDIR"
|
|
|
|
|
|
|
|
local_reponame="submod-clone"
|
|
|
|
git lfs clone --recursive "$GITSERVER/$reponame" "$local_reponame"
|
|
|
|
|
|
|
|
# check everything is where it should be
|
|
|
|
cd $local_reponame
|
2017-03-23 16:54:52 +00:00
|
|
|
assert_hooks "$(dot_git_dir)"
|
2016-07-14 16:12:57 +00:00
|
|
|
# check LFS store and working copy
|
|
|
|
assert_local_object "$contents_root_oid" "${#contents_root}"
|
2016-12-07 00:13:38 +00:00
|
|
|
[ $(wc -c < "root.dat") -eq ${#contents_root} ]
|
2016-07-14 16:12:57 +00:00
|
|
|
# and so on for nested subs
|
|
|
|
cd sub1
|
|
|
|
assert_local_object "$contents_sub1_oid" "${#contents_sub1}"
|
2016-12-07 00:13:38 +00:00
|
|
|
[ $(wc -c < "sub1.dat") -eq ${#contents_sub1} ]
|
2016-07-14 16:12:57 +00:00
|
|
|
cd sub2
|
|
|
|
assert_local_object "$contents_sub2_oid" "${#contents_sub2}"
|
2016-12-07 00:13:38 +00:00
|
|
|
[ $(wc -c < "sub2.dat") -eq ${#contents_sub2} ]
|
2016-07-14 16:12:57 +00:00
|
|
|
|
|
|
|
popd
|
|
|
|
)
|
|
|
|
end_test
|
2016-08-22 21:41:43 +00:00
|
|
|
|
|
|
|
begin_test "clone in current directory"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="clone_in_current_dir"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" $reponame
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
2017-03-24 16:59:03 +00:00
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
2016-08-22 21:41:43 +00:00
|
|
|
|
|
|
|
contents="contents"
|
|
|
|
contents_oid="$(calc_oid "$contents")"
|
|
|
|
|
|
|
|
printf "$contents" > a.dat
|
|
|
|
|
|
|
|
git add .gitattributes a.dat
|
|
|
|
|
|
|
|
git commit -m "initial commit" 2>&1 | tee commit.log
|
|
|
|
grep "master (root-commit)" commit.log
|
|
|
|
grep "2 files changed" commit.log
|
|
|
|
grep "create mode 100644 a.dat" commit.log
|
|
|
|
grep "create mode 100644 .gitattributes" commit.log
|
|
|
|
|
|
|
|
git push origin master 2>&1 | tee push.log
|
|
|
|
|
|
|
|
pushd $TRASHDIR
|
|
|
|
mkdir "$reponame-clone"
|
|
|
|
cd "$reponame-clone"
|
|
|
|
|
2018-01-06 02:01:50 +00:00
|
|
|
git lfs clone $GITSERVER/$reponame "." 2>&1 | grep "Downloading LFS objects: 100% (1/1), 8 B"
|
2016-08-22 21:41:43 +00:00
|
|
|
|
|
|
|
assert_local_object "$contents_oid" 8
|
2017-03-23 16:54:52 +00:00
|
|
|
assert_hooks "$(dot_git_dir)"
|
2016-08-22 21:46:24 +00:00
|
|
|
[ ! -f ./lfs ]
|
2016-08-22 21:41:43 +00:00
|
|
|
popd
|
|
|
|
)
|
|
|
|
end_test
|
2017-09-19 22:31:49 +00:00
|
|
|
|
|
|
|
begin_test "clone empty repository"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="clone_empty"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
|
|
|
|
cd "$TRASHDIR"
|
|
|
|
git lfs clone "$GITSERVER/$reponame" "$reponame" 2>&1 | tee clone.log
|
|
|
|
if [ "0" -ne "${PIPESTATUS[0]}" ]; then
|
|
|
|
echo >&2 "fatal: expected clone to succeed ..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "clone bare empty repository"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="clone_bare_empty"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
|
|
|
|
cd "$TRASHDIR"
|
|
|
|
git lfs clone "$GITSERVER/$reponame" "$reponame" --bare 2>&1 | tee clone.log
|
|
|
|
if [ "0" -ne "${PIPESTATUS[0]}" ]; then
|
|
|
|
echo >&2 "fatal: expected clone to succeed ..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
)
|
2017-09-27 23:11:42 +00:00
|
|
|
end_test
|