2011-10-15 21:07:26 +04:00
#!/bin/bash
#
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
#
2011-11-10 22:17:04 +04: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.
2011-10-15 21:07:26 +04:00
#
2011-11-10 22:17:04 +04:00
# This library is distributed in the hope that it will be useful,
2011-10-15 21:07:26 +04:00
# but WITHOUT ANY WARRANTY; without even the implied warranty of
2011-11-10 22:17:04 +04:00
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
2011-10-15 21:07:26 +04:00
#
2011-11-10 22:17:04 +04:00
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
2011-10-15 21:07:26 +04:00
set -e
2013-07-28 04:12:07 +04:00
echo "1..35"
2011-11-01 06:42:14 +04:00
2013-05-01 23:26:21 +04:00
. $( dirname $0 ) /libtest.sh
2011-10-15 21:07:26 +04:00
2012-09-15 20:44:57 +04:00
setup_test_repository "bare"
2011-11-01 06:42:14 +04:00
echo "ok setup"
2011-11-04 07:08:28 +04:00
$OSTREE checkout test2 checkout-test2
2011-11-01 06:42:14 +04:00
echo "ok checkout"
2011-11-04 07:08:28 +04:00
$OSTREE rev-parse test2
$OSTREE rev-parse 'test2^'
$OSTREE rev-parse 'test2^^' 2>/dev/null && ( echo 1>& 2 "rev-parse test2^^ unexpectedly succeeded!" ; exit 1)
2011-11-02 21:22:13 +04:00
echo "ok rev-parse"
2013-07-24 22:05:12 +04:00
( cd repo && ostree rev-parse test2)
echo "ok repo-in-cwd"
2013-06-29 22:51:08 +04:00
$OSTREE refs > reflist
assert_file_has_content reflist '^test2$'
rm reflist
echo "ok refs"
2011-11-01 06:42:14 +04:00
cd checkout-test2
assert_has_file firstfile
assert_has_file baz/cow
assert_file_has_content baz/cow moo
assert_has_file baz/deeper/ohyeah
echo "ok content"
2011-11-09 03:11:42 +04:00
rm firstfile
$OSTREE commit -b test2 -s delete
2011-11-01 06:42:14 +04:00
cd $test_tmpdir
2011-11-04 07:08:28 +04:00
$OSTREE checkout test2 $test_tmpdir /checkout-test2-2
2011-11-01 06:42:14 +04:00
cd $test_tmpdir /checkout-test2-2
assert_not_has_file firstfile
assert_has_file baz/saucer
echo "ok removal"
2011-10-15 21:07:26 +04:00
mkdir -p a/nested/tree
echo one > a/nested/tree/1
echo two2 > a/nested/2
echo 3 > a/nested/3
touch a/4
echo fivebaby > a/5
touch a/6
echo whee > 7
mkdir -p another/nested/tree
echo anotherone > another/nested/tree/1
echo whee2 > another/whee
# FIXME - remove grep for .
2011-11-28 03:03:05 +04:00
$OSTREE commit -b test2 -s "Another commit"
echo "ok commit"
2011-11-01 06:42:14 +04:00
cd ${ test_tmpdir }
2011-11-04 07:08:28 +04:00
$OSTREE checkout test2 $test_tmpdir /checkout-test2-3
2011-11-01 06:42:14 +04:00
cd checkout-test2-3
2011-10-15 21:07:26 +04:00
assert_has_file a/nested/2
assert_file_has_content a/nested/2 'two2'
echo "ok stdin contents"
2011-11-04 18:53:47 +04:00
cd ${ test_tmpdir } /checkout-test2-3
echo 4 > four
mkdir -p yet/another/tree
echo leaf > yet/another/tree/green
echo helloworld > yet/message
2011-11-17 02:48:29 +04:00
rm a/5
2011-11-04 18:53:47 +04:00
$OSTREE commit -b test2 -s "Current directory"
echo "ok cwd commit"
cd ${ test_tmpdir }
$OSTREE checkout test2 $test_tmpdir /checkout-test2-4
cd checkout-test2-4
assert_file_has_content yet/another/tree/green 'leaf'
assert_file_has_content four '4'
echo "ok cwd contents"
2011-11-17 02:48:29 +04:00
cd ${ test_tmpdir }
$OSTREE diff test2^ test2 > diff-test2
assert_file_has_content diff-test2 'D */a/5'
assert_file_has_content diff-test2 'A */yet$'
assert_file_has_content diff-test2 'A */yet/message$'
assert_file_has_content diff-test2 'A */yet/another/tree/green$'
echo "ok diff revisions"
cd ${ test_tmpdir } /checkout-test2-4
echo afile > oh-look-a-file
$OSTREE diff test2 ./ > ${ test_tmpdir } /diff-test2-2
rm oh-look-a-file
cd ${ test_tmpdir }
2013-03-26 16:29:30 +04:00
assert_file_has_content diff-test2-2 'A *oh-look-a-file$'
2011-11-17 02:48:29 +04:00
echo "ok diff cwd"
2011-11-17 08:09:32 +04:00
cd ${ test_tmpdir } /checkout-test2-4
rm four
mkdir four
touch four/other
$OSTREE diff test2 ./ > ${ test_tmpdir } /diff-test2-2
cd ${ test_tmpdir }
assert_file_has_content diff-test2-2 'M */four$'
echo "ok diff file changing type"
2011-11-19 03:50:53 +04:00
cd ${ test_tmpdir }
mkdir repo2
2012-05-04 18:04:32 +04:00
${ CMD_PREFIX } ostree --repo= repo2 init
${ CMD_PREFIX } ostree --repo= repo2 pull-local repo
2012-05-02 01:43:26 +04:00
echo "ok pull-local"
2011-11-19 03:50:53 +04:00
cd ${ test_tmpdir }
2012-05-04 18:04:32 +04:00
${ CMD_PREFIX } ostree --repo= repo2 checkout test2 test2-checkout-from-local-clone
2011-11-19 03:50:53 +04:00
cd test2-checkout-from-local-clone
assert_file_has_content yet/another/tree/green 'leaf'
echo "ok local clone checkout"
2011-12-16 01:12:31 +04:00
$OSTREE checkout -U test2 checkout-user-test2
echo "ok user checkout"
2011-12-22 05:10:10 +04:00
$OSTREE commit -b test2 -s "Another commit" --tree= ref = test2
echo "ok commit from ref"
2011-12-23 00:59:47 +04:00
$OSTREE commit -b trees/test2 -s 'ref with / in it' --tree= ref = test2
echo "ok commit ref with /"
2011-12-23 03:47:30 +04:00
old_rev = $( $OSTREE rev-parse test2)
$OSTREE commit --skip-if-unchanged -b test2 -s 'should not be committed' --tree= ref = test2
new_rev = $( $OSTREE rev-parse test2)
assert_streq " ${ old_rev } " " ${ new_rev } "
echo "ok commit --skip-if-unchanged"
2012-01-06 03:56:21 +04:00
cd ${ test_tmpdir } /checkout-test2-4
$OSTREE commit -b test2 -s "no xattrs" --no-xattrs
echo "ok commit with no xattrs"
2012-01-22 22:27:38 +04:00
cd ${ test_tmpdir }
cat > test-statoverride.txt <<EOF
+2048 /a/nested/3
EOF
cd ${ test_tmpdir } /checkout-test2-4
$OSTREE commit -b test2 -s "with statoverride" --statoverride= ../test-statoverride.txt
echo "ok commit statoverridde"
2012-02-27 14:58:42 +04:00
cd ${ test_tmpdir }
$OSTREE prune
echo "ok prune didn't fail"
2012-03-05 20:32:48 +04:00
cd ${ test_tmpdir }
$OSTREE cat test2 /yet/another/tree/green > greenfile-contents
assert_file_has_content greenfile-contents "leaf"
echo "ok cat-file"
2012-03-06 17:57:31 +04:00
cd ${ test_tmpdir }
$OSTREE checkout --subpath /yet/another test2 checkout-test2-subpath
cd checkout-test2-subpath
assert_file_has_content tree/green "leaf"
echo "ok checkout subpath"
2012-03-06 20:37:50 +04:00
cd ${ test_tmpdir }
$OSTREE checkout --union test2 checkout-test2-union
find checkout-test2-union | wc -l > union-files-count
$OSTREE checkout --union test2 checkout-test2-union
find checkout-test2-union | wc -l > union-files-count.new
cmp union-files-count{ ,.new}
cd checkout-test2-union
assert_file_has_content ./yet/another/tree/green "leaf"
echo "ok checkout union 1"
2012-04-04 07:45:48 +04:00
2012-04-17 05:21:50 +04:00
cd ${ test_tmpdir }
rm -rf shadow-repo
mkdir shadow-repo
2012-05-04 18:04:32 +04:00
${ CMD_PREFIX } ostree --repo= shadow-repo init
${ CMD_PREFIX } ostree --repo= shadow-repo config set core.parent $( pwd ) /repo
2012-04-17 05:21:50 +04:00
rm -rf test2-checkout
parent_rev_test2 = $( ostree --repo= repo rev-parse test2)
2012-05-04 18:04:32 +04:00
${ CMD_PREFIX } ostree --repo= shadow-repo checkout " ${ parent_rev_test2 } " test2-checkout
2012-04-17 05:21:50 +04:00
echo "ok checkout from shadow repo"
2013-05-01 20:15:02 +04:00
cd ${ test_tmpdir }
rm -f expected-fail
$OSTREE checkout test2 --subpath /enoent 2>/dev/null || touch expected-fail
assert_has_file expected-fail
echo "ok subdir enoent"
cd ${ test_tmpdir }
$OSTREE checkout test2 --allow-noent --subpath /enoent 2>/dev/null
echo "ok subdir noent"
2013-06-29 19:44:26 +04:00
cd ${ test_tmpdir }
mkdir repo3
${ CMD_PREFIX } ostree --repo= repo3 init
${ CMD_PREFIX } ostree --repo= repo3 pull-local --remote= aremote repo test2
ostree --repo= repo3 rev-parse aremote/test2
echo "ok pull-local with --remote arg"
2013-06-29 22:02:17 +04:00
cd ${ test_tmpdir }
ostree --repo= repo3 prune
find repo3/objects -name '*.commit' > objlist-before-prune
rm repo3/refs/heads/* repo3/refs/remotes/* -rf
ostree --repo= repo3 prune --refs-only
find repo3/objects -name '*.commit' > objlist-after-prune
if cmp -s objlist-before-prune objlist-after-prune; then
echo "Prune didn't delete anything!" ; exit 1
fi
rm repo3 objlist-before-prune objlist-after-prune -rf
echo "ok prune"
2013-07-01 18:18:26 +04:00
cd ${ test_tmpdir }
$OSTREE commit -b test3 -s "Another commit" --tree= ref = test2
ostree --repo= repo refs > reflist
assert_file_has_content reflist '^test3$'
ostree --repo= repo refs --delete test3
ostree --repo= repo refs > reflist
assert_not_file_has_content reflist '^test3$'
echo "ok reflist --delete"
2013-07-18 03:47:40 +04:00
cd ${ test_tmpdir }
rm -rf test2-checkout
$OSTREE checkout test2 test2-checkout
( cd test2-checkout && $OSTREE commit --link-checkout-speedup -b test2 -s "tmp" )
echo "ok commit with link speedup"
2013-07-01 18:18:26 +04:00
2013-07-28 04:12:07 +04:00
cd ${ test_tmpdir }
$OSTREE ls test2
echo "ok ls with no argument"