e13f57d2625e8419a5d67e4c03288eb39e20b045
1#!/bin/sh
2#
3# Copyright (C) 2006 Martin Waitz <tali@admingilde.org>
4#
5
6test_description='test transitive info/alternate entries'
7. ./test-lib.sh
8
9test_valid_repo() {
10 git fsck --full > fsck.log &&
11 test_line_count = 0 fsck.log
12}
13
14base_dir=$(pwd)
15
16test_expect_success 'preparing first repository' \
17'test_create_repo A && cd A &&
18echo "Hello World" > file1 &&
19git add file1 &&
20git commit -m "Initial commit" file1 &&
21git repack -a -d &&
22git prune'
23
24cd "$base_dir"
25
26test_expect_success 'preparing second repository' \
27'git clone -l -s A B && cd B &&
28echo "foo bar" > file2 &&
29git add file2 &&
30git commit -m "next commit" file2 &&
31git repack -a -d -l &&
32git prune'
33
34cd "$base_dir"
35
36test_expect_success 'preparing third repository' \
37'git clone -l -s B C && cd C &&
38echo "Goodbye, cruel world" > file3 &&
39git add file3 &&
40git commit -m "one more" file3 &&
41git repack -a -d -l &&
42git prune'
43
44cd "$base_dir"
45
46test_expect_success 'creating too deep nesting' \
47'git clone -l -s C D &&
48git clone -l -s D E &&
49git clone -l -s E F &&
50git clone -l -s F G &&
51git clone --bare -l -s G H'
52
53test_expect_success 'invalidity of deepest repository' \
54'cd H && {
55 test_valid_repo
56 test $? -ne 0
57}'
58
59cd "$base_dir"
60
61test_expect_success 'validity of third repository' \
62'cd C &&
63test_valid_repo'
64
65cd "$base_dir"
66
67test_expect_success 'validity of fourth repository' \
68'cd D &&
69test_valid_repo'
70
71cd "$base_dir"
72
73test_expect_success 'breaking of loops' \
74'echo "$base_dir"/B/.git/objects >> "$base_dir"/A/.git/objects/info/alternates&&
75cd C &&
76test_valid_repo'
77
78cd "$base_dir"
79
80test_expect_success 'that info/alternates is necessary' \
81'cd C &&
82rm -f .git/objects/info/alternates &&
83! (test_valid_repo)'
84
85cd "$base_dir"
86
87test_expect_success 'that relative alternate is possible for current dir' \
88'cd C &&
89echo "../../../B/.git/objects" > .git/objects/info/alternates &&
90test_valid_repo'
91
92cd "$base_dir"
93
94test_expect_success \
95 'that relative alternate is only possible for current dir' '
96 cd D &&
97 ! (test_valid_repo)
98'
99
100cd "$base_dir"
101
102test_done