2015-07-30 02:37:31 +00:00
|
|
|
#!/usr/bin/env bash
|
2015-05-26 21:09:24 +00:00
|
|
|
|
2018-07-10 18:48:02 +00:00
|
|
|
. "$(dirname "$0")/testlib.sh"
|
2015-05-26 21:09:24 +00:00
|
|
|
|
2018-07-20 23:46:33 +00:00
|
|
|
# sets up the repos for the first few push tests. The passed argument is the
|
|
|
|
# name of the repo to setup. The resuling repo will have a local file tracked
|
|
|
|
# with LFS and committed, but not yet pushed to the remote
|
|
|
|
push_repo_setup() {
|
|
|
|
reponame="$1"
|
2018-01-05 18:12:57 +00:00
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" "$reponame"
|
|
|
|
|
|
|
|
git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame").locksverify" false
|
|
|
|
git lfs track "*.dat"
|
|
|
|
echo "push a" > a.dat
|
|
|
|
git add .gitattributes a.dat
|
|
|
|
git commit -m "add a.dat"
|
2018-07-20 23:46:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
begin_test "push with good ref"
|
|
|
|
(
|
|
|
|
set -e
|
2020-06-29 16:18:57 +00:00
|
|
|
push_repo_setup "push-main-branch-required"
|
2018-01-05 18:12:57 +00:00
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git lfs push origin main
|
2018-01-05 18:12:57 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "push with tracked ref"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
2018-07-20 23:46:33 +00:00
|
|
|
push_repo_setup "push-tracked-branch-required"
|
2018-01-05 18:12:57 +00:00
|
|
|
|
|
|
|
git config push.default upstream
|
2020-06-29 16:18:57 +00:00
|
|
|
git config branch.main.merge refs/heads/tracked
|
|
|
|
git lfs push origin main
|
2018-01-05 18:12:57 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "push with bad ref"
|
|
|
|
(
|
|
|
|
set -e
|
2018-07-20 23:46:33 +00:00
|
|
|
push_repo_setup "push-other-branch-required"
|
2018-01-05 18:12:57 +00:00
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git lfs push origin main 2>&1 | tee push.log
|
2018-01-05 18:12:57 +00:00
|
|
|
if [ "0" -eq "${PIPESTATUS[0]}" ]; then
|
|
|
|
echo "expected command to fail"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
grep 'batch response: Expected ref "refs/heads/other", got "refs/heads/main"' push.log
|
2018-01-05 18:12:57 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2018-07-20 23:38:39 +00:00
|
|
|
begin_test "push with given remote, configured pushRemote"
|
|
|
|
(
|
|
|
|
set -e
|
2018-07-20 23:46:33 +00:00
|
|
|
push_repo_setup "push-given-and-config"
|
2018-07-20 23:38:39 +00:00
|
|
|
|
|
|
|
git remote add bad-remote "invalid-url"
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git config branch.main.pushRemote bad-remote
|
2018-07-20 23:38:39 +00:00
|
|
|
|
|
|
|
git lfs push --all origin
|
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2015-05-26 21:09:24 +00:00
|
|
|
begin_test "push"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="$(basename "$0" ".sh")"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" repo
|
|
|
|
|
2017-02-16 20:10:05 +00:00
|
|
|
git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame").locksverify" true
|
|
|
|
|
2015-05-26 21:09:24 +00:00
|
|
|
git lfs track "*.dat"
|
|
|
|
echo "push a" > a.dat
|
|
|
|
git add .gitattributes a.dat
|
|
|
|
git commit -m "add a.dat"
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git lfs push --dry-run origin main 2>&1 | tee push.log
|
2015-09-09 20:18:51 +00:00
|
|
|
grep "push 4c48d2a6991c9895bcddcf027e1e4907280bcf21975492b1afbade396d6a3340 => a.dat" push.log
|
2018-09-18 20:38:19 +00:00
|
|
|
[ $(grep -c "^push " push.log) -eq 1 ]
|
2015-09-09 20:18:51 +00:00
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git lfs push origin main 2>&1 | tee push.log
|
2018-01-06 02:01:50 +00:00
|
|
|
grep "Uploading LFS objects: 100% (1/1), 7 B" push.log
|
2015-05-26 21:09:24 +00:00
|
|
|
|
|
|
|
git checkout -b push-b
|
|
|
|
echo "push b" > b.dat
|
|
|
|
git add b.dat
|
|
|
|
git commit -m "add b.dat"
|
|
|
|
|
2015-09-09 20:18:51 +00:00
|
|
|
git lfs push --dry-run origin push-b 2>&1 | tee push.log
|
|
|
|
grep "push 4c48d2a6991c9895bcddcf027e1e4907280bcf21975492b1afbade396d6a3340 => a.dat" push.log
|
|
|
|
grep "push 82be50ad35070a4ef3467a0a650c52d5b637035e7ad02c36652e59d01ba282b7 => b.dat" push.log
|
2018-09-18 20:38:19 +00:00
|
|
|
[ $(grep -c "^push " < push.log) -eq 2 ]
|
2015-09-09 20:18:51 +00:00
|
|
|
|
2015-09-09 20:58:58 +00:00
|
|
|
# simulate remote ref
|
|
|
|
mkdir -p .git/refs/remotes/origin
|
|
|
|
git rev-parse HEAD > .git/refs/remotes/origin/HEAD
|
|
|
|
|
|
|
|
git lfs push --dry-run origin push-b 2>&1 | tee push.log
|
2018-09-18 20:38:19 +00:00
|
|
|
[ $(grep -c "^push " push.log) -eq 0 ]
|
2015-09-09 20:58:58 +00:00
|
|
|
|
|
|
|
rm -rf .git/refs/remotes
|
|
|
|
|
2015-05-27 20:18:02 +00:00
|
|
|
git lfs push origin push-b 2>&1 | tee push.log
|
2018-01-06 02:01:50 +00:00
|
|
|
grep "Uploading LFS objects: 100% (2/2), 14 B" push.log
|
2015-05-26 21:09:24 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2020-11-17 06:31:44 +00:00
|
|
|
# helper used by the next few push --all tests to set up their repos
|
2015-09-09 20:18:51 +00:00
|
|
|
push_all_setup() {
|
2015-09-09 20:58:58 +00:00
|
|
|
suffix="$1"
|
2020-11-17 06:31:44 +00:00
|
|
|
reponame="$(basename "$0" ".sh")-all-$suffix"
|
2015-09-09 20:18:51 +00:00
|
|
|
content1="initial"
|
|
|
|
content2="update"
|
|
|
|
content3="branch"
|
|
|
|
content4="tagged"
|
2020-06-29 16:18:57 +00:00
|
|
|
content5="main"
|
2015-09-09 20:18:51 +00:00
|
|
|
extracontent="extra"
|
2015-09-21 17:50:22 +00:00
|
|
|
oid1=$(calc_oid "$content1")
|
|
|
|
oid2=$(calc_oid "$content2")
|
|
|
|
oid3=$(calc_oid "$content3")
|
|
|
|
oid4=$(calc_oid "$content4")
|
|
|
|
oid5=$(calc_oid "$content5")
|
|
|
|
extraoid=$(calc_oid "$extracontent")
|
2015-09-09 20:18:51 +00:00
|
|
|
|
2020-11-17 06:31:44 +00:00
|
|
|
clone_repo "$reponame" "push-all-$suffix"
|
2017-02-16 20:10:05 +00:00
|
|
|
git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame").locksverify" true
|
2015-09-09 20:58:58 +00:00
|
|
|
git lfs track "*.dat"
|
|
|
|
|
2015-09-09 20:18:51 +00:00
|
|
|
echo "[
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -6m)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":${#content1},\"Data\":\"$content1\"}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -5m)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":${#content2},\"Data\":\"$content2\"}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -4m)\",
|
|
|
|
\"NewBranch\":\"branch\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":${#content3},\"Data\":\"$content3\"}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -4m)\",
|
2020-06-29 16:18:57 +00:00
|
|
|
\"ParentBranches\":[\"main\"],
|
2015-09-09 20:18:51 +00:00
|
|
|
\"Tags\":[\"tag\"],
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":${#content4},\"Data\":\"$content4\"}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -2m)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":${#content5},\"Data\":\"$content5\"},
|
|
|
|
{\"Filename\":\"file2.dat\",\"Size\":${#extracontent},\"Data\":\"$extracontent\"}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
|
|
|
git rm file2.dat
|
|
|
|
git commit -m "remove file2.dat"
|
|
|
|
|
2015-09-09 20:58:58 +00:00
|
|
|
# simulate remote ref
|
|
|
|
mkdir -p .git/refs/remotes/origin
|
|
|
|
git rev-parse HEAD > .git/refs/remotes/origin/HEAD
|
|
|
|
|
2015-09-09 20:18:51 +00:00
|
|
|
setup_alternate_remote "$reponame-$suffix"
|
2017-02-16 20:10:05 +00:00
|
|
|
git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame-$suffix").locksverify" true
|
2015-09-09 20:18:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
begin_test "push --all (no ref args)"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
push_all_setup "everything"
|
|
|
|
|
|
|
|
git lfs push --dry-run --all origin 2>&1 | tee push.log
|
|
|
|
grep "push $oid1 => file1.dat" push.log
|
|
|
|
grep "push $oid2 => file1.dat" push.log
|
|
|
|
grep "push $oid3 => file1.dat" push.log
|
|
|
|
grep "push $oid4 => file1.dat" push.log
|
|
|
|
grep "push $oid5 => file1.dat" push.log
|
|
|
|
grep "push $extraoid => file2.dat" push.log
|
2018-09-18 20:38:19 +00:00
|
|
|
[ $(grep -c "^push " < push.log) -eq 6 ]
|
2015-09-09 20:18:51 +00:00
|
|
|
|
|
|
|
git push --all origin 2>&1 | tee push.log
|
2020-06-16 19:20:54 +00:00
|
|
|
[ $(grep -c "Uploading LFS objects: 100% (6/6)" push.log) -eq 1 ]
|
2015-09-09 20:58:58 +00:00
|
|
|
assert_server_object "$reponame-$suffix" "$oid1"
|
|
|
|
assert_server_object "$reponame-$suffix" "$oid2"
|
|
|
|
assert_server_object "$reponame-$suffix" "$oid3"
|
|
|
|
assert_server_object "$reponame-$suffix" "$oid4"
|
|
|
|
assert_server_object "$reponame-$suffix" "$oid5"
|
|
|
|
assert_server_object "$reponame-$suffix" "$extraoid"
|
|
|
|
|
|
|
|
echo "push while missing old objects locally"
|
|
|
|
setup_alternate_remote "$reponame-$suffix-2"
|
2017-02-16 20:10:05 +00:00
|
|
|
git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame-$suffix-2").locksverify" true
|
|
|
|
|
2015-09-09 20:58:58 +00:00
|
|
|
git lfs push --object-id origin $oid1
|
|
|
|
assert_server_object "$reponame-$suffix-2" "$oid1"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$oid2"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$oid3"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$oid4"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$oid5"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$extraoid"
|
|
|
|
rm ".git/lfs/objects/${oid1:0:2}/${oid1:2:2}/$oid1"
|
|
|
|
|
2016-04-06 19:06:34 +00:00
|
|
|
echo "dry run missing local object that exists on server"
|
2015-09-09 20:58:58 +00:00
|
|
|
git lfs push --dry-run --all origin 2>&1 | tee push.log
|
|
|
|
grep "push $oid1 => file1.dat" push.log
|
|
|
|
grep "push $oid2 => file1.dat" push.log
|
|
|
|
grep "push $oid3 => file1.dat" push.log
|
|
|
|
grep "push $oid4 => file1.dat" push.log
|
|
|
|
grep "push $oid5 => file1.dat" push.log
|
|
|
|
grep "push $extraoid => file2.dat" push.log
|
2018-09-18 20:38:19 +00:00
|
|
|
[ $(grep -c "^push " push.log) -eq 6 ]
|
2015-09-09 20:58:58 +00:00
|
|
|
|
|
|
|
git push --all origin 2>&1 | tee push.log
|
2020-06-16 19:20:54 +00:00
|
|
|
grep "Uploading LFS objects: 100% (6/6)" push.log
|
2015-09-09 20:58:58 +00:00
|
|
|
assert_server_object "$reponame-$suffix-2" "$oid2"
|
|
|
|
assert_server_object "$reponame-$suffix-2" "$oid3"
|
|
|
|
assert_server_object "$reponame-$suffix-2" "$oid4"
|
|
|
|
assert_server_object "$reponame-$suffix-2" "$oid5"
|
|
|
|
assert_server_object "$reponame-$suffix-2" "$extraoid"
|
2015-09-09 20:18:51 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "push --all (1 ref arg)"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
push_all_setup "ref"
|
|
|
|
|
|
|
|
git lfs push --dry-run --all origin branch 2>&1 | tee push.log
|
|
|
|
grep "push $oid1 => file1.dat" push.log
|
|
|
|
grep "push $oid2 => file1.dat" push.log
|
|
|
|
grep "push $oid3 => file1.dat" push.log
|
2018-09-18 20:38:19 +00:00
|
|
|
[ $(grep -c "^push " < push.log) -eq 3 ]
|
2015-09-09 20:18:51 +00:00
|
|
|
|
|
|
|
git lfs push --all origin branch 2>&1 | tee push.log
|
2020-11-17 06:31:44 +00:00
|
|
|
[ $(grep -c "Uploading LFS objects: 100% (3/3)" push.log) -eq 1 ]
|
2015-09-09 20:58:58 +00:00
|
|
|
assert_server_object "$reponame-$suffix" "$oid1"
|
|
|
|
assert_server_object "$reponame-$suffix" "$oid2"
|
|
|
|
assert_server_object "$reponame-$suffix" "$oid3"
|
2020-06-29 16:18:57 +00:00
|
|
|
refute_server_object "$reponame-$suffix" "$oid4" # in main and the tag
|
2015-09-09 20:58:58 +00:00
|
|
|
refute_server_object "$reponame-$suffix" "$oid5"
|
|
|
|
refute_server_object "$reponame-$suffix" "$extraoid"
|
|
|
|
|
|
|
|
echo "push while missing old objects locally"
|
|
|
|
setup_alternate_remote "$reponame-$suffix-2"
|
2017-02-16 20:10:05 +00:00
|
|
|
git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame-$suffix-2").locksverify" true
|
2015-09-09 20:58:58 +00:00
|
|
|
git lfs push --object-id origin $oid1
|
|
|
|
assert_server_object "$reponame-$suffix-2" "$oid1"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$oid2"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$oid3"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$oid4"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$oid5"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$extraoid"
|
|
|
|
rm ".git/lfs/objects/${oid1:0:2}/${oid1:2:2}/$oid1"
|
|
|
|
|
|
|
|
# dry run doesn't change
|
|
|
|
git lfs push --dry-run --all origin branch 2>&1 | tee push.log
|
|
|
|
grep "push $oid1 => file1.dat" push.log
|
|
|
|
grep "push $oid2 => file1.dat" push.log
|
|
|
|
grep "push $oid3 => file1.dat" push.log
|
2018-09-18 20:38:19 +00:00
|
|
|
[ $(grep -c "^push " push.log) -eq 3 ]
|
2015-09-09 20:58:58 +00:00
|
|
|
|
2020-11-17 06:31:44 +00:00
|
|
|
git push origin branch 2>&1 | tee push.log
|
|
|
|
[ $(grep -c "Uploading LFS objects: 100% (3/3)" push.log) -eq 1 ]
|
2015-09-09 20:58:58 +00:00
|
|
|
assert_server_object "$reponame-$suffix-2" "$oid2"
|
|
|
|
assert_server_object "$reponame-$suffix-2" "$oid3"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$oid4"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$oid5"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$extraoid"
|
2015-09-09 20:18:51 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "push --all (multiple ref args)"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
push_all_setup "multiple-refs"
|
|
|
|
|
|
|
|
git lfs push --dry-run --all origin branch tag 2>&1 | tee push.log
|
|
|
|
grep "push $oid1 => file1.dat" push.log
|
|
|
|
grep "push $oid2 => file1.dat" push.log
|
|
|
|
grep "push $oid3 => file1.dat" push.log
|
|
|
|
grep "push $oid4 => file1.dat" push.log
|
2018-09-18 20:38:19 +00:00
|
|
|
[ $(grep -c "^push " push.log) -eq 4 ]
|
2015-09-09 20:18:51 +00:00
|
|
|
|
|
|
|
git lfs push --all origin branch tag 2>&1 | tee push.log
|
2020-11-17 06:31:44 +00:00
|
|
|
[ $(grep -c "Uploading LFS objects: 100% (4/4)" push.log) -eq 1 ]
|
2015-09-09 20:58:58 +00:00
|
|
|
assert_server_object "$reponame-$suffix" "$oid1"
|
|
|
|
assert_server_object "$reponame-$suffix" "$oid2"
|
|
|
|
assert_server_object "$reponame-$suffix" "$oid3"
|
|
|
|
assert_server_object "$reponame-$suffix" "$oid4"
|
2020-06-29 16:18:57 +00:00
|
|
|
refute_server_object "$reponame-$suffix" "$oid5" # only in main
|
2015-09-09 20:58:58 +00:00
|
|
|
refute_server_object "$reponame-$suffix" "$extraoid"
|
|
|
|
|
|
|
|
echo "push while missing old objects locally"
|
|
|
|
setup_alternate_remote "$reponame-$suffix-2"
|
2017-02-16 20:10:05 +00:00
|
|
|
git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame-$suffix-2").locksverify" true
|
2015-09-09 20:58:58 +00:00
|
|
|
git lfs push --object-id origin $oid1
|
|
|
|
assert_server_object "$reponame-$suffix-2" "$oid1"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$oid2"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$oid3"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$oid4"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$oid5"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$extraoid"
|
|
|
|
rm ".git/lfs/objects/${oid1:0:2}/${oid1:2:2}/$oid1"
|
|
|
|
|
|
|
|
# dry run doesn't change
|
|
|
|
git lfs push --dry-run --all origin branch tag 2>&1 | tee push.log
|
|
|
|
grep "push $oid1 => file1.dat" push.log
|
|
|
|
grep "push $oid2 => file1.dat" push.log
|
|
|
|
grep "push $oid3 => file1.dat" push.log
|
|
|
|
grep "push $oid4 => file1.dat" push.log
|
2020-11-17 06:31:44 +00:00
|
|
|
[ $(grep -c "^push " push.log) -eq 4 ]
|
2015-09-09 20:58:58 +00:00
|
|
|
|
2020-11-17 06:31:44 +00:00
|
|
|
git push origin branch refs/tags/tag 2>&1 | tee push.log
|
|
|
|
[ $(grep -c "Uploading LFS objects: 100% (4/4)" push.log) -eq 1 ]
|
2015-09-09 20:58:58 +00:00
|
|
|
assert_server_object "$reponame-$suffix-2" "$oid2"
|
|
|
|
assert_server_object "$reponame-$suffix-2" "$oid3"
|
|
|
|
assert_server_object "$reponame-$suffix-2" "$oid4"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$oid5"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$extraoid"
|
2015-09-09 20:18:51 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "push --all (ref with deleted files)"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
push_all_setup "ref-with-deleted"
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git lfs push --dry-run --all origin main 2>&1 | tee push.log
|
2015-09-09 20:18:51 +00:00
|
|
|
grep "push $oid1 => file1.dat" push.log
|
|
|
|
grep "push $oid2 => file1.dat" push.log
|
|
|
|
grep "push $oid4 => file1.dat" push.log
|
|
|
|
grep "push $oid5 => file1.dat" push.log
|
|
|
|
grep "push $extraoid => file2.dat" push.log
|
2018-09-18 20:38:19 +00:00
|
|
|
[ $(grep -c "^push " push.log) -eq 5 ]
|
2015-09-09 20:18:51 +00:00
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git lfs push --all origin main 2>&1 | tee push.log
|
2020-11-17 06:31:44 +00:00
|
|
|
[ $(grep -c "Uploading LFS objects: 100% (5/5)" push.log) -eq 1 ]
|
2015-09-09 20:58:58 +00:00
|
|
|
assert_server_object "$reponame-$suffix" "$oid1"
|
|
|
|
assert_server_object "$reponame-$suffix" "$oid2"
|
|
|
|
refute_server_object "$reponame-$suffix" "$oid3" # only in the branch
|
|
|
|
assert_server_object "$reponame-$suffix" "$oid4"
|
|
|
|
assert_server_object "$reponame-$suffix" "$oid5"
|
|
|
|
assert_server_object "$reponame-$suffix" "$extraoid"
|
|
|
|
|
|
|
|
echo "push while missing old objects locally"
|
|
|
|
setup_alternate_remote "$reponame-$suffix-2"
|
2017-02-16 20:10:05 +00:00
|
|
|
git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame-$suffix-2").locksverify" true
|
2015-09-09 20:58:58 +00:00
|
|
|
git lfs push --object-id origin $oid1
|
|
|
|
assert_server_object "$reponame-$suffix-2" "$oid1"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$oid2"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$oid3"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$oid4"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$oid5"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$extraoid"
|
|
|
|
rm ".git/lfs/objects/${oid1:0:2}/${oid1:2:2}/$oid1"
|
|
|
|
|
|
|
|
# dry run doesn't change
|
2020-06-29 16:18:57 +00:00
|
|
|
git lfs push --dry-run --all origin main 2>&1 | tee push.log
|
2015-09-09 20:58:58 +00:00
|
|
|
grep "push $oid1 => file1.dat" push.log
|
|
|
|
grep "push $oid2 => file1.dat" push.log
|
|
|
|
grep "push $oid4 => file1.dat" push.log
|
|
|
|
grep "push $oid5 => file1.dat" push.log
|
|
|
|
grep "push $extraoid => file2.dat" push.log
|
2018-09-18 20:38:19 +00:00
|
|
|
[ $(grep -c "^push " push.log) -eq 5 ]
|
2015-09-09 20:58:58 +00:00
|
|
|
|
2020-11-17 06:31:44 +00:00
|
|
|
git push origin main 2>&1 | tee push.log
|
|
|
|
[ $(grep -c "Uploading LFS objects: 100% (5/5)" push.log) -eq 1 ]
|
2015-09-09 20:58:58 +00:00
|
|
|
assert_server_object "$reponame-$suffix-2" "$oid2"
|
|
|
|
refute_server_object "$reponame-$suffix-2" "$oid3"
|
|
|
|
assert_server_object "$reponame-$suffix-2" "$oid4"
|
|
|
|
assert_server_object "$reponame-$suffix-2" "$oid5"
|
|
|
|
assert_server_object "$reponame-$suffix-2" "$extraoid"
|
2015-05-26 21:09:24 +00:00
|
|
|
)
|
|
|
|
end_test
|
2015-06-28 15:13:44 +00:00
|
|
|
|
|
|
|
begin_test "push object id(s)"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="$(basename "$0" ".sh")"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" repo2
|
|
|
|
|
2017-02-16 20:10:05 +00:00
|
|
|
git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame").locksverify" true
|
|
|
|
|
2015-06-28 15:13:44 +00:00
|
|
|
git lfs track "*.dat"
|
|
|
|
echo "push a" > a.dat
|
|
|
|
git add .gitattributes a.dat
|
|
|
|
git commit -m "add a.dat"
|
|
|
|
|
2015-07-06 09:34:49 +00:00
|
|
|
git lfs push --object-id origin \
|
2015-06-28 15:13:44 +00:00
|
|
|
4c48d2a6991c9895bcddcf027e1e4907280bcf21975492b1afbade396d6a3340 \
|
|
|
|
2>&1 | tee push.log
|
2018-01-06 02:01:50 +00:00
|
|
|
grep "Uploading LFS objects: 100% (1/1), 7 B" push.log
|
2015-06-28 15:13:44 +00:00
|
|
|
|
|
|
|
echo "push b" > b.dat
|
|
|
|
git add b.dat
|
|
|
|
git commit -m "add b.dat"
|
|
|
|
|
2015-07-06 09:34:49 +00:00
|
|
|
git lfs push --object-id origin \
|
2015-06-28 15:13:44 +00:00
|
|
|
4c48d2a6991c9895bcddcf027e1e4907280bcf21975492b1afbade396d6a3340 \
|
|
|
|
82be50ad35070a4ef3467a0a650c52d5b637035e7ad02c36652e59d01ba282b7 \
|
|
|
|
2>&1 | tee push.log
|
2018-01-06 02:01:50 +00:00
|
|
|
grep "Uploading LFS objects: 100% (2/2), 14 B" push.log
|
2015-06-28 15:13:44 +00:00
|
|
|
)
|
|
|
|
end_test
|
2015-08-25 16:39:33 +00:00
|
|
|
|
|
|
|
begin_test "push modified files"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="$(basename "$0" ".sh")-modified"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" "$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat"
|
|
|
|
# generate content we'll use
|
|
|
|
content1="filecontent1"
|
|
|
|
content2="filecontent2"
|
|
|
|
content3="filecontent3"
|
2015-08-26 10:29:57 +00:00
|
|
|
content4="filecontent4"
|
|
|
|
content5="filecontent5"
|
2015-09-21 17:50:22 +00:00
|
|
|
oid1=$(calc_oid "$content1")
|
|
|
|
oid2=$(calc_oid "$content2")
|
|
|
|
oid3=$(calc_oid "$content3")
|
|
|
|
oid4=$(calc_oid "$content4")
|
|
|
|
oid5=$(calc_oid "$content5")
|
2015-09-01 20:31:51 +00:00
|
|
|
|
2015-08-25 16:39:33 +00:00
|
|
|
echo "[
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -6m)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":${#content1}, \"Data\":\"$content1\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -3m)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":${#content2}, \"Data\":\"$content2\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -1m)\",
|
2015-08-26 10:29:57 +00:00
|
|
|
\"NewBranch\":\"other_branch\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":${#content5}, \"Data\":\"$content5\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -1m)\",
|
2020-06-29 16:18:57 +00:00
|
|
|
\"ParentBranches\":[\"main\"],
|
2015-08-25 16:39:33 +00:00
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":${#content3}, \"Data\":\"$content3\"},
|
|
|
|
{\"Filename\":\"file2.dat\",\"Size\":${#content4}, \"Data\":\"$content4\"}]
|
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git lfs push origin main
|
2015-08-26 10:29:57 +00:00
|
|
|
git lfs push origin other_branch
|
2015-08-25 16:39:33 +00:00
|
|
|
assert_server_object "$reponame" "$oid1"
|
|
|
|
assert_server_object "$reponame" "$oid2"
|
|
|
|
assert_server_object "$reponame" "$oid3"
|
|
|
|
assert_server_object "$reponame" "$oid4"
|
2015-08-26 10:29:57 +00:00
|
|
|
assert_server_object "$reponame" "$oid5"
|
2015-08-25 16:39:33 +00:00
|
|
|
)
|
|
|
|
end_test
|
2016-02-03 20:06:05 +00:00
|
|
|
|
|
|
|
begin_test "push with invalid remote"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
cd repo
|
|
|
|
git lfs push not-a-remote 2>&1 | tee push.log
|
|
|
|
grep "Invalid remote name" push.log
|
|
|
|
)
|
|
|
|
end_test
|
2016-03-31 15:38:55 +00:00
|
|
|
|
|
|
|
begin_test "push ambiguous branch name"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="$(basename "$0" ".sh")-ambiguous-branch"
|
|
|
|
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-03-31 15:38:55 +00:00
|
|
|
|
|
|
|
NUMFILES=5
|
|
|
|
# generate content we'll use
|
|
|
|
for ((a=0; a < NUMFILES ; a++))
|
|
|
|
do
|
|
|
|
content[$a]="filecontent$a"
|
|
|
|
oid[$a]=$(calc_oid "${content[$a]}")
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "[
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -10d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":${#content[0]}, \"Data\":\"${content[0]}\"},
|
|
|
|
{\"Filename\":\"file2.dat\",\"Size\":${#content[1]}, \"Data\":\"${content[1]}\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"NewBranch\":\"ambiguous\",
|
|
|
|
\"CommitDate\":\"$(get_date -5d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file3.dat\",\"Size\":${#content[2]}, \"Data\":\"${content[2]}\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -2d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file4.dat\",\"Size\":${#content[3]}, \"Data\":\"${content[3]}\"}]
|
|
|
|
},
|
|
|
|
{
|
2020-06-29 16:18:57 +00:00
|
|
|
\"ParentBranches\":[\"main\"],
|
2016-03-31 15:38:55 +00:00
|
|
|
\"CommitDate\":\"$(get_date -1d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":${#content[4]}, \"Data\":\"${content[4]}\"}]
|
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
|
|
|
# create tag with same name as branch
|
|
|
|
git tag ambiguous
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
# lfs push main, should work
|
|
|
|
git lfs push origin main
|
2016-03-31 15:38:55 +00:00
|
|
|
|
2017-11-01 23:35:43 +00:00
|
|
|
# push ambiguous, does not fail since lfs scans git with sha, not ref name
|
2016-03-31 15:38:55 +00:00
|
|
|
git lfs push origin ambiguous
|
|
|
|
)
|
|
|
|
end_test
|
2016-07-05 17:24:46 +00:00
|
|
|
|
|
|
|
begin_test "push (retry with expired actions)"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="push_retry_expired_action"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" "$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat"
|
2017-04-26 17:23:29 +00:00
|
|
|
contents="return-expired-action"
|
|
|
|
contents_oid="$(calc_oid "$contents")"
|
2018-09-10 14:57:10 +00:00
|
|
|
contents_size="$(printf "%s" "$contents" | wc -c | awk '{ print $1 }')"
|
|
|
|
printf "%s" "$contents" > a.dat
|
2016-07-05 17:24:46 +00:00
|
|
|
git add .gitattributes a.dat
|
|
|
|
|
|
|
|
git commit -m "add a.dat, .gitattributes" 2>&1 | tee commit.log
|
2020-06-29 16:18:57 +00:00
|
|
|
grep "main (root-commit)" commit.log
|
2016-07-05 17:24:46 +00:00
|
|
|
grep "2 files changed" commit.log
|
|
|
|
grep "create mode 100644 a.dat" commit.log
|
|
|
|
grep "create mode 100644 .gitattributes" commit.log
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
GIT_TRACE=1 git push origin main 2>&1 | tee push.log
|
2016-07-05 17:24:46 +00:00
|
|
|
|
2020-04-15 03:13:27 +00:00
|
|
|
expected="enqueue retry #1 after 0.25s for \"$contents_oid\" (size: $contents_size): LFS: tq: action \"upload\" expires at"
|
2017-04-26 17:23:29 +00:00
|
|
|
|
|
|
|
grep "$expected" push.log
|
2018-01-06 02:01:50 +00:00
|
|
|
grep "Uploading LFS objects: 100% (1/1), 21 B" push.log
|
2016-07-05 17:24:46 +00:00
|
|
|
)
|
|
|
|
end_test
|
2016-07-13 18:58:55 +00:00
|
|
|
|
2016-08-15 21:11:05 +00:00
|
|
|
begin_test "push to raw remote url"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
setup_remote_repo "push-raw"
|
|
|
|
mkdir push-raw
|
|
|
|
cd push-raw
|
|
|
|
git init
|
|
|
|
|
|
|
|
git lfs track "*.dat"
|
|
|
|
|
|
|
|
contents="raw"
|
|
|
|
contents_oid=$(calc_oid "$contents")
|
|
|
|
|
2018-09-10 14:57:10 +00:00
|
|
|
printf "%s" "$contents" > raw.dat
|
2016-08-15 21:11:05 +00:00
|
|
|
git add raw.dat .gitattributes
|
|
|
|
git commit -m "add" 2>&1 | tee commit.log
|
2020-06-29 16:18:57 +00:00
|
|
|
grep "main (root-commit)" commit.log
|
2016-08-15 21:11:05 +00:00
|
|
|
grep "2 files changed" commit.log
|
|
|
|
grep "create mode 100644 raw.dat" commit.log
|
|
|
|
grep "create mode 100644 .gitattributes" commit.log
|
|
|
|
|
|
|
|
refute_server_object push-raw "$contents_oid"
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git lfs push $GITSERVER/push-raw main
|
2016-08-15 21:11:05 +00:00
|
|
|
|
|
|
|
assert_server_object push-raw "$contents_oid"
|
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2016-07-13 18:58:55 +00:00
|
|
|
begin_test "push (with invalid object size)"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="push-invalid-object-size"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" "$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat"
|
|
|
|
contents="return-invalid-size"
|
2018-09-10 14:57:10 +00:00
|
|
|
printf "%s" "$contents" > a.dat
|
2016-07-13 18:58:55 +00:00
|
|
|
|
|
|
|
git add a.dat .gitattributes
|
|
|
|
git commit -m "add a.dat, .gitattributes" 2>&1 | tee commit.log
|
2020-06-29 16:18:57 +00:00
|
|
|
grep "main (root-commit)" commit.log
|
2016-07-13 18:58:55 +00:00
|
|
|
grep "2 files changed" commit.log
|
|
|
|
grep "create mode 100644 a.dat" commit.log
|
|
|
|
grep "create mode 100644 .gitattributes" commit.log
|
|
|
|
|
|
|
|
set +e
|
2020-06-29 16:18:57 +00:00
|
|
|
git push origin main 2>&1 2> push.log
|
2016-07-13 18:58:55 +00:00
|
|
|
res="$?"
|
|
|
|
set -e
|
|
|
|
|
|
|
|
grep "invalid size (got: -1)" push.log
|
2018-03-07 00:35:50 +00:00
|
|
|
[ "0" -eq "$(grep -c "panic" push.log)" ]
|
2016-07-13 18:58:55 +00:00
|
|
|
[ "0" -ne "$res" ]
|
|
|
|
|
|
|
|
refute_server_object "$reponame" "$(calc_oid "$contents")"
|
|
|
|
)
|
|
|
|
end_test
|
2017-03-06 20:12:09 +00:00
|
|
|
|
|
|
|
begin_test "push with deprecated _links"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="$(basename "$0" ".sh")-deprecated"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" "$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat"
|
|
|
|
git add .gitattributes
|
|
|
|
git commit -m "initial commit"
|
|
|
|
|
|
|
|
contents="send-deprecated-links"
|
|
|
|
contents_oid="$(calc_oid "$contents")"
|
2018-09-10 14:57:10 +00:00
|
|
|
printf "%s" "$contents" > a.dat
|
2017-03-06 20:12:09 +00:00
|
|
|
git add a.dat
|
|
|
|
git commit -m "add a.dat"
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git push origin main
|
2017-03-06 20:12:09 +00:00
|
|
|
|
|
|
|
assert_server_object "$reponame" "$contents_oid"
|
|
|
|
)
|
2017-09-12 14:33:52 +00:00
|
|
|
end_test
|
2019-04-02 08:48:21 +00:00
|
|
|
|
|
|
|
begin_test "push with invalid pushInsteadof"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
push_repo_setup "push-invalid-pushinsteadof"
|
|
|
|
|
|
|
|
# set pushInsteadOf to rewrite the href of uploading LFS object.
|
|
|
|
git config url."$GITSERVER/storage/invalid".pushInsteadOf "$GITSERVER/storage/"
|
2019-04-03 04:01:37 +00:00
|
|
|
# Enable href rewriting explicitly.
|
|
|
|
git config lfs.transfer.enablehrefrewrite true
|
2019-04-02 08:48:21 +00:00
|
|
|
|
|
|
|
set +e
|
2020-06-29 16:18:57 +00:00
|
|
|
git lfs push origin main > push.log 2>&1
|
2019-04-02 08:48:21 +00:00
|
|
|
res=$?
|
|
|
|
|
|
|
|
set -e
|
|
|
|
[ "$res" = "2" ]
|
|
|
|
|
|
|
|
# check rewritten href is used to upload LFS object.
|
|
|
|
grep "LFS: Authorization error: $GITSERVER/storage/invalid" push.log
|
2019-04-03 04:01:37 +00:00
|
|
|
|
2019-04-04 02:04:00 +00:00
|
|
|
# lfs-push succeed after unsetting enableHrefRewrite config
|
2019-04-03 04:01:37 +00:00
|
|
|
git config --unset lfs.transfer.enablehrefrewrite
|
2020-06-29 16:18:57 +00:00
|
|
|
git lfs push origin main
|
2019-04-02 08:48:21 +00:00
|
|
|
)
|
|
|
|
end_test
|
Don't fail if we lack objects the server has
A Git LFS client may not have the entire history of the objects for the
repository. However, in some situations, we traverse the entire history
of a branch when pushing it, meaning that we need to process every
LFS object in the history of that branch. If the objects for the entire
history are not present, we currently fail to push.
Instead, let's mark objects we don't have on disk as missing and only
fail when we would need to upload those objects. We'll know the server
has the objects if the batch response provides no actions to take for
them when we request an upload. Pass the missing flag down through the
code, and always set it to false for non-uploads.
If for some reason we fail to properly flag a missing object, we will
still fail later on when we cannot open the file, just in a messier and
more poorly controlled way. The technique used here will attempt to
abort the batch as soon as we notice a problem, which means that in the
common case (less than 100 objects) we won't have transferred any
objects, so the user can notice the failure as soon as possible.
Update the tests to look for a string which will occur in the error
message, since we no longer produce the system error message for ENOENT.
2019-04-30 19:18:18 +00:00
|
|
|
|
|
|
|
begin_test 'push with data the server already has'
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="push-server-data"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" "$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat"
|
|
|
|
git add .gitattributes
|
|
|
|
git commit -m "initial commit"
|
|
|
|
|
|
|
|
contents="abc123"
|
|
|
|
contents_oid="$(calc_oid "$contents")"
|
|
|
|
printf "%s" "$contents" > a.dat
|
|
|
|
git add a.dat
|
|
|
|
git commit -m "add a.dat"
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git push origin main
|
Don't fail if we lack objects the server has
A Git LFS client may not have the entire history of the objects for the
repository. However, in some situations, we traverse the entire history
of a branch when pushing it, meaning that we need to process every
LFS object in the history of that branch. If the objects for the entire
history are not present, we currently fail to push.
Instead, let's mark objects we don't have on disk as missing and only
fail when we would need to upload those objects. We'll know the server
has the objects if the batch response provides no actions to take for
them when we request an upload. Pass the missing flag down through the
code, and always set it to false for non-uploads.
If for some reason we fail to properly flag a missing object, we will
still fail later on when we cannot open the file, just in a messier and
more poorly controlled way. The technique used here will attempt to
abort the batch as soon as we notice a problem, which means that in the
common case (less than 100 objects) we won't have transferred any
objects, so the user can notice the failure as soon as possible.
Update the tests to look for a string which will occur in the error
message, since we no longer produce the system error message for ENOENT.
2019-04-30 19:18:18 +00:00
|
|
|
|
|
|
|
assert_server_object "$reponame" "$contents_oid"
|
|
|
|
|
|
|
|
git checkout -b side
|
|
|
|
|
|
|
|
# Use a different file name for the second file; otherwise, this test
|
|
|
|
# unexpectedly passes with the old code, since we fail to notice that the
|
|
|
|
# object we run through the clean filter is not the object we wanted.
|
|
|
|
contents2="def456"
|
|
|
|
contents2_oid="$(calc_oid "$contents2")"
|
|
|
|
printf "%s" "$contents2" > b.dat
|
|
|
|
git add b.dat
|
|
|
|
git commit -m "add b.dat"
|
|
|
|
|
|
|
|
# We remove the original object. The server already has this.
|
|
|
|
delete_local_object "$contents_oid"
|
|
|
|
|
|
|
|
# We use the URL so that we cannot take advantage of the existing "origin/*"
|
|
|
|
# refs that we know the server must have. We will traverse the entire history
|
|
|
|
# for this push, and we should not fail because the server already has the
|
|
|
|
# object we deleted above.
|
|
|
|
git push "$(git config remote.origin.url)" side
|
|
|
|
|
|
|
|
assert_server_object "$reponame" "$contents2_oid"
|
|
|
|
)
|
|
|
|
end_test
|
2019-10-30 00:59:27 +00:00
|
|
|
|
Optimize pushes of multiple refs
When pushing multiple refs, we know any Git objects on the remote side
can be excluded from the objects that refer to LFS objects we need to
push, since if the remote side already has the Git objects, it should
have the corresponding LFS objects as well.
However, when traversing Git objects, we traverse them on a per-ref
basis, which is required since any LFS objects which spawn a batch
request will need the ref to be placed in the batch request as part of
the protocol.
Let's find a list of all the remote sides that exist before traversing
any Git objects, and exclude traversing any of those objects in any
traversal. As a result, we can traverse far, far fewer objects,
especially when pushing new refs in a large repository.
Note that we exclude the case when the left and right sides are the same
because our code sets them to the same thing in some cases even though
Git does not, so we cannot reason about the values in that case.
2020-01-14 19:43:35 +00:00
|
|
|
begin_test 'push with multiple refs and data the server already has'
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="push-multi-ref-server-data"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" "$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat"
|
|
|
|
git add .gitattributes
|
|
|
|
git commit -m "initial commit"
|
|
|
|
|
|
|
|
contents="abc123"
|
|
|
|
contents_oid="$(calc_oid "$contents")"
|
|
|
|
printf "%s" "$contents" > a.dat
|
|
|
|
git add a.dat
|
|
|
|
git commit -m "add a.dat"
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git push origin main
|
Optimize pushes of multiple refs
When pushing multiple refs, we know any Git objects on the remote side
can be excluded from the objects that refer to LFS objects we need to
push, since if the remote side already has the Git objects, it should
have the corresponding LFS objects as well.
However, when traversing Git objects, we traverse them on a per-ref
basis, which is required since any LFS objects which spawn a batch
request will need the ref to be placed in the batch request as part of
the protocol.
Let's find a list of all the remote sides that exist before traversing
any Git objects, and exclude traversing any of those objects in any
traversal. As a result, we can traverse far, far fewer objects,
especially when pushing new refs in a large repository.
Note that we exclude the case when the left and right sides are the same
because our code sets them to the same thing in some cases even though
Git does not, so we cannot reason about the values in that case.
2020-01-14 19:43:35 +00:00
|
|
|
|
|
|
|
assert_server_object "$reponame" "$contents_oid"
|
|
|
|
|
|
|
|
contents2="def456"
|
|
|
|
contents2_oid="$(calc_oid "$contents2")"
|
|
|
|
printf "%s" "$contents2" > b.dat
|
|
|
|
git add b.dat
|
|
|
|
git commit -m "add b.dat"
|
|
|
|
|
|
|
|
# Create a tag. Normally this would cause the entire history to be traversed
|
|
|
|
# since it's a new ref, but we no longer do that since we're pushing multiple
|
|
|
|
# refs.
|
|
|
|
git tag -m v1.0.0 -a v1.0.0
|
|
|
|
|
|
|
|
# We remove the original object. The server already has this.
|
|
|
|
delete_local_object "$contents_oid"
|
|
|
|
|
|
|
|
# We use the URL so that we cannot take advantage of the existing "origin/*"
|
|
|
|
# refs that we know the server must have.
|
|
|
|
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 GIT_CURL_VERBOSE=1 \
|
2020-06-29 16:18:57 +00:00
|
|
|
git push "$(git config remote.origin.url)" main v1.0.0 2>&1 | tee push.log
|
Optimize pushes of multiple refs
When pushing multiple refs, we know any Git objects on the remote side
can be excluded from the objects that refer to LFS objects we need to
push, since if the remote side already has the Git objects, it should
have the corresponding LFS objects as well.
However, when traversing Git objects, we traverse them on a per-ref
basis, which is required since any LFS objects which spawn a batch
request will need the ref to be placed in the batch request as part of
the protocol.
Let's find a list of all the remote sides that exist before traversing
any Git objects, and exclude traversing any of those objects in any
traversal. As a result, we can traverse far, far fewer objects,
especially when pushing new refs in a large repository.
Note that we exclude the case when the left and right sides are the same
because our code sets them to the same thing in some cases even though
Git does not, so we cannot reason about the values in that case.
2020-01-14 19:43:35 +00:00
|
|
|
|
|
|
|
# We should not find a batch request for the object which is in the earlier
|
2020-06-29 16:18:57 +00:00
|
|
|
# version of main, since we know the remote side has it.
|
Optimize pushes of multiple refs
When pushing multiple refs, we know any Git objects on the remote side
can be excluded from the objects that refer to LFS objects we need to
push, since if the remote side already has the Git objects, it should
have the corresponding LFS objects as well.
However, when traversing Git objects, we traverse them on a per-ref
basis, which is required since any LFS objects which spawn a batch
request will need the ref to be placed in the batch request as part of
the protocol.
Let's find a list of all the remote sides that exist before traversing
any Git objects, and exclude traversing any of those objects in any
traversal. As a result, we can traverse far, far fewer objects,
especially when pushing new refs in a large repository.
Note that we exclude the case when the left and right sides are the same
because our code sets them to the same thing in some cases even though
Git does not, so we cannot reason about the values in that case.
2020-01-14 19:43:35 +00:00
|
|
|
[ "$(grep -c "$contents_oid" push.log)" = 0 ]
|
|
|
|
|
|
|
|
# Yet we should have pushed the new object successfully.
|
|
|
|
assert_server_object "$reponame" "$contents2_oid"
|
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2019-10-30 00:59:27 +00:00
|
|
|
begin_test "push custom reference"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="push-custom-reference"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" "$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat"
|
|
|
|
# generate content we'll use
|
|
|
|
content="filecontent"
|
|
|
|
oid=$(calc_oid "$content")
|
|
|
|
|
|
|
|
echo "[
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -6m)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content}, \"Data\":\"$content\"}]
|
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
|
|
|
# Create and try pushing a reference in a nonstandard namespace, that is,
|
|
|
|
# outside of refs/heads, refs/tags, and refs/remotes.
|
2020-06-29 16:18:57 +00:00
|
|
|
git update-ref refs/custom/remote/heads/main refs/heads/main
|
2019-10-30 00:59:27 +00:00
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git lfs push origin refs/custom/remote/heads/main
|
2019-10-30 00:59:27 +00:00
|
|
|
assert_server_object "$reponame" "$oid"
|
|
|
|
)
|
|
|
|
end_test
|
2020-11-16 15:30:18 +00:00
|
|
|
|
|
|
|
begin_test "push --object-id (invalid value)"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
2020-11-17 06:31:08 +00:00
|
|
|
push_all_setup "push-invalid-oid"
|
2020-11-16 15:30:18 +00:00
|
|
|
|
|
|
|
git lfs push --object-id origin '' 2>&1 | tee push.log
|
2020-11-17 06:31:08 +00:00
|
|
|
git lfs push --object-id origin "${oid1:0:3}" 2>&1 | tee -a push.log
|
2020-11-16 15:30:18 +00:00
|
|
|
|
|
|
|
[ "$(grep -c 'too short object ID' push.log)" -eq 2 ]
|
|
|
|
)
|
|
|
|
end_test
|
2020-12-10 20:42:36 +00:00
|
|
|
|
|
|
|
begin_test "storage upload with compression"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="storage-compress"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
clone_repo "$reponame" storage-compress
|
|
|
|
|
|
|
|
contents="storage-compress"
|
|
|
|
oid="$(calc_oid "$contents")"
|
|
|
|
printf "%s" "$contents" > a.dat
|
|
|
|
|
|
|
|
git lfs track "*.dat"
|
|
|
|
git add .gitattributes a.dat
|
|
|
|
git commit -m "initial commit"
|
|
|
|
|
|
|
|
GIT_CURL_VERBOSE=1 git push origin main | tee push.log
|
|
|
|
assert_server_object "$reponame" "$oid"
|
|
|
|
|
|
|
|
pushd ..
|
|
|
|
git \
|
|
|
|
-c "filter.lfs.process=" \
|
|
|
|
-c "filter.lfs.smudge=cat" \
|
|
|
|
-c "filter.lfs.required=false" \
|
|
|
|
clone "$GITSERVER/$reponame" "$reponame-assert"
|
|
|
|
|
|
|
|
cd "$reponame-assert"
|
|
|
|
|
|
|
|
git config credential.helper lfstest
|
|
|
|
|
|
|
|
GIT_TRACE=1 git lfs pull origin main 2>&1 | tee pull.log
|
|
|
|
if [ "0" -ne "${PIPESTATUS[0]}" ]; then
|
|
|
|
echo >&2 "fatal: expected \`git lfs pull origin main\` to succeed ..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
grep "decompressed gzipped response" pull.log
|
|
|
|
assert_local_object "$oid" "${#contents}"
|
|
|
|
popd
|
|
|
|
)
|
|
|
|
end_test
|