]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5710-info-alternate.sh
Git 1.8.3
[thirdparty/git.git] / t / t5710-info-alternate.sh
CommitLineData
dd05ea17
MW
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
9# test that a file is not reachable in the current repository
10# but that it is after creating a info/alternate entry
11reachable_via() {
12 alternate="$1"
13 file="$2"
14 if git cat-file -e "HEAD:$file"; then return 1; fi
15 echo "$alternate" >> .git/objects/info/alternate
16 git cat-file -e "HEAD:$file"
17}
18
19test_valid_repo() {
df391b19 20 git fsck --full > fsck.log &&
3fb0459b 21 test_line_count = 0 fsck.log
dd05ea17
MW
22}
23
24base_dir=`pwd`
25
26test_expect_success 'preparing first repository' \
27'test_create_repo A && cd A &&
28echo "Hello World" > file1 &&
29git add file1 &&
30git commit -m "Initial commit" file1 &&
31git repack -a -d &&
026aa938 32git prune'
dd05ea17
MW
33
34cd "$base_dir"
35
36test_expect_success 'preparing second repository' \
37'git clone -l -s A B && cd B &&
38echo "foo bar" > file2 &&
39git add file2 &&
40git commit -m "next commit" file2 &&
41git repack -a -d -l &&
026aa938 42git prune'
dd05ea17
MW
43
44cd "$base_dir"
45
46test_expect_success 'preparing third repository' \
47'git clone -l -s B C && cd C &&
48echo "Goodbye, cruel world" > file3 &&
49git add file3 &&
50git commit -m "one more" file3 &&
51git repack -a -d -l &&
026aa938 52git prune'
dd05ea17
MW
53
54cd "$base_dir"
55
9288beda 56test_expect_success 'creating too deep nesting' \
dd05ea17
MW
57'git clone -l -s C D &&
58git clone -l -s D E &&
59git clone -l -s E F &&
60git clone -l -s F G &&
0433ad12 61test_must_fail git clone --bare -l -s G H'
dd05ea17
MW
62
63cd "$base_dir"
64
65test_expect_success 'validity of third repository' \
66'cd C &&
67test_valid_repo'
68
69cd "$base_dir"
70
71test_expect_success 'validity of fourth repository' \
72'cd D &&
73test_valid_repo'
74
75cd "$base_dir"
76
77test_expect_success 'breaking of loops' \
f69e836f 78'echo "$base_dir"/B/.git/objects >> "$base_dir"/A/.git/objects/info/alternates&&
dd05ea17 79cd C &&
f69e836f 80test_valid_repo'
dd05ea17
MW
81
82cd "$base_dir"
83
41ac414e 84test_expect_success 'that info/alternates is necessary' \
dd05ea17 85'cd C &&
41ac414e
JH
86rm -f .git/objects/info/alternates &&
87! (test_valid_repo)'
dd05ea17
MW
88
89cd "$base_dir"
90
91test_expect_success 'that relative alternate is possible for current dir' \
92'cd C &&
93echo "../../../B/.git/objects" > .git/objects/info/alternates &&
94test_valid_repo'
95
96cd "$base_dir"
97
41ac414e
JH
98test_expect_success \
99 'that relative alternate is only possible for current dir' '
100 cd D &&
101 ! (test_valid_repo)
102'
dd05ea17
MW
103
104cd "$base_dir"
105
106test_done