2015-06-08 20:11:11 +03:00
#!/bin/bash
#
# Copyright (C) 2015 Dan Nicholson <nicholson@endlessm.com>
#
2018-01-30 22:26:26 +03:00
# SPDX-License-Identifier: LGPL-2.0+
#
2015-06-08 20:11:11 +03:00
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
2021-12-07 04:20:55 +03:00
# License along with this library. If not, see <https://www.gnu.org/licenses/>.
2015-06-08 20:11:11 +03:00
2016-01-27 19:44:10 +03:00
set -euo pipefail
2015-06-08 20:11:11 +03:00
. $( dirname $0 ) /libtest.sh
2017-09-01 23:15:33 +03:00
setup_test_repository "archive"
2015-06-08 20:11:11 +03:00
2021-01-12 02:52:34 +03:00
echo "1..3"
2015-06-08 20:11:11 +03:00
cd ${ test_tmpdir }
mkdir repo2
2017-09-01 23:15:33 +03:00
ostree_repo_init repo2 --mode= "archive"
2015-06-08 20:11:11 +03:00
${ CMD_PREFIX } ostree --repo= repo2 pull-local repo
find repo2/objects -name '*.commit' | wc -l > commitcount
assert_file_has_content commitcount " ^1 $"
2020-03-19 17:05:57 +03:00
find repo2/state -name '*.commitpartial' | wc -l > commitpartialcount
assert_file_has_content commitpartialcount " ^0 $"
2015-06-08 20:11:11 +03:00
${ CMD_PREFIX } ostree --repo= repo2 pull-local --depth= 0 repo
find repo2/objects -name '*.commit' | wc -l > commitcount
assert_file_has_content commitcount " ^1 $"
2020-03-19 17:05:57 +03:00
find repo2/state -name '*.commitpartial' | wc -l > commitpartialcount
assert_file_has_content commitpartialcount " ^0 $"
2015-06-08 20:11:11 +03:00
2020-03-19 17:05:57 +03:00
${ CMD_PREFIX } ostree --repo= repo2 pull-local --depth= 1 --commit-metadata-only repo
2015-06-08 20:11:11 +03:00
find repo2/objects -name '*.commit' | wc -l > commitcount
assert_file_has_content commitcount " ^2 $"
2020-03-19 17:05:57 +03:00
find repo2/state -name '*.commitpartial' | wc -l > commitpartialcount
assert_file_has_content commitpartialcount " ^1 $"
2015-06-08 20:11:11 +03:00
${ CMD_PREFIX } ostree --repo= repo2 pull-local --depth= 1 repo
find repo2/objects -name '*.commit' | wc -l > commitcount
assert_file_has_content commitcount " ^2 $"
2020-03-19 17:05:57 +03:00
find repo2/state -name '*.commitpartial' | wc -l > commitpartialcount
assert_file_has_content commitpartialcount " ^0 $"
2015-06-08 20:11:11 +03:00
${ CMD_PREFIX } ostree --repo= repo2 pull-local --depth= -1 repo
find repo2/objects -name '*.commit' | wc -l > commitcount
assert_file_has_content commitcount " ^2 $"
2020-03-19 17:05:57 +03:00
find repo2/state -name '*.commitpartial' | wc -l > commitpartialcount
assert_file_has_content commitpartialcount " ^0 $"
2015-06-08 20:11:11 +03:00
echo "ok local pull depth"
2021-01-12 02:52:34 +03:00
# Check that pulling with depth != 0 succeeds with a missing parent
# commit. Prune the remote to truncate the history.
cd ${ test_tmpdir }
${ CMD_PREFIX } ostree --repo= repo prune --refs-only --depth= 0
rm -rf repo2/refs/heads/* repo2/refs/remotes/* repo2/objects/*/*.commit
${ CMD_PREFIX } ostree --repo= repo2 pull-local --depth= 1 repo
find repo/objects -name '*.commit' | wc -l > commitcount
assert_file_has_content commitcount " ^1 $"
find repo/state -name '*.commitpartial' | wc -l > commitpartialcount
assert_file_has_content commitpartialcount " ^0 $"
rm -rf repo2/refs/heads/* repo2/refs/remotes/* repo2/objects/*/*.commit
${ CMD_PREFIX } ostree --repo= repo2 pull-local --depth= -1 repo
find repo/objects -name '*.commit' | wc -l > commitcount
assert_file_has_content commitcount " ^1 $"
find repo/state -name '*.commitpartial' | wc -l > commitpartialcount
assert_file_has_content commitpartialcount " ^0 $"
echo "ok local pull depth missing parent"
# Check that it errors if the ref head commit is missing.
cd ${ test_tmpdir }
rm -f repo/objects/*/*.commit
rm -rf repo2/refs/heads/* repo2/refs/remotes/* repo2/objects/*/*.commit
if ${ CMD_PREFIX } ostree --repo= repo2 pull-local --depth= -1 repo; then
fatal "Local pull with depth -1 succeeded with missing HEAD commit"
fi
echo "ok local pull depth missing HEAD commit"