t5613: use test_must_fail
[alt-git.git] / t / t5613-info-alternate.sh
blob65074ddc1301b1ce9cf64d77b219b195586428d2
1 #!/bin/sh
3 # Copyright (C) 2006 Martin Waitz <tali@admingilde.org>
6 test_description='test transitive info/alternate entries'
7 . ./test-lib.sh
9 base_dir=$(pwd)
11 test_expect_success 'preparing first repository' \
12 'test_create_repo A && cd A &&
13 echo "Hello World" > file1 &&
14 git add file1 &&
15 git commit -m "Initial commit" file1 &&
16 git repack -a -d &&
17 git prune'
19 cd "$base_dir"
21 test_expect_success 'preparing second repository' \
22 'git clone -l -s A B && cd B &&
23 echo "foo bar" > file2 &&
24 git add file2 &&
25 git commit -m "next commit" file2 &&
26 git repack -a -d -l &&
27 git prune'
29 cd "$base_dir"
31 test_expect_success 'preparing third repository' \
32 'git clone -l -s B C && cd C &&
33 echo "Goodbye, cruel world" > file3 &&
34 git add file3 &&
35 git commit -m "one more" file3 &&
36 git repack -a -d -l &&
37 git prune'
39 cd "$base_dir"
41 test_expect_success 'creating too deep nesting' \
42 'git clone -l -s C D &&
43 git clone -l -s D E &&
44 git clone -l -s E F &&
45 git clone -l -s F G &&
46 git clone --bare -l -s G H'
48 test_expect_success 'invalidity of deepest repository' \
49 'cd H &&
50 test_must_fail git fsck
53 cd "$base_dir"
55 test_expect_success 'validity of third repository' \
56 'cd C &&
57 git fsck'
59 cd "$base_dir"
61 test_expect_success 'validity of fourth repository' \
62 'cd D &&
63 git fsck'
65 cd "$base_dir"
67 test_expect_success 'breaking of loops' \
68 'echo "$base_dir"/B/.git/objects >> "$base_dir"/A/.git/objects/info/alternates&&
69 cd C &&
70 git fsck'
72 cd "$base_dir"
74 test_expect_success 'that info/alternates is necessary' \
75 'cd C &&
76 rm -f .git/objects/info/alternates &&
77 test_must_fail git fsck
80 cd "$base_dir"
82 test_expect_success 'that relative alternate is possible for current dir' \
83 'cd C &&
84 echo "../../../B/.git/objects" > .git/objects/info/alternates &&
85 git fsck'
87 cd "$base_dir"
89 test_expect_success \
90 'that relative alternate is only possible for current dir' '
91 cd D &&
92 test_must_fail git fsck
95 cd "$base_dir"
97 test_done