pack-objects: further work on internal rev-list logic.
[git/git-svn.git] / t / t5710-info-alternate.sh
blobb9f6d9636313c29cb9d9553ca908e623fdefd179
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 # test that a file is not reachable in the current repository
10 # but that it is after creating a info/alternate entry
11 reachable_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"
19 test_valid_repo() {
20 git fsck-objects --full > fsck.log &&
21 test `wc -l < fsck.log` = 0
24 base_dir=`pwd`
26 test_expect_success 'preparing first repository' \
27 'test_create_repo A && cd A &&
28 echo "Hello World" > file1 &&
29 git add file1 &&
30 git commit -m "Initial commit" file1 &&
31 git repack -a -d &&
32 git prune'
34 cd "$base_dir"
36 test_expect_success 'preparing second repository' \
37 'git clone -l -s A B && cd B &&
38 echo "foo bar" > file2 &&
39 git add file2 &&
40 git commit -m "next commit" file2 &&
41 git repack -a -d -l &&
42 git prune'
44 cd "$base_dir"
46 test_expect_success 'preparing third repository' \
47 'git clone -l -s B C && cd C &&
48 echo "Goodbye, cruel world" > file3 &&
49 git add file3 &&
50 git commit -m "one more" file3 &&
51 git repack -a -d -l &&
52 git prune'
54 cd "$base_dir"
56 test_expect_failure 'creating too deep nesting' \
57 'git clone -l -s C D &&
58 git clone -l -s D E &&
59 git clone -l -s E F &&
60 git clone -l -s F G &&
61 git clone -l -s G H &&
62 cd H &&
63 test_valid_repo'
65 cd "$base_dir"
67 test_expect_success 'validity of third repository' \
68 'cd C &&
69 test_valid_repo'
71 cd "$base_dir"
73 test_expect_success 'validity of fourth repository' \
74 'cd D &&
75 test_valid_repo'
77 cd "$base_dir"
79 test_expect_success 'breaking of loops' \
80 "echo '$base_dir/B/.git/objects' >> '$base_dir'/A/.git/objects/info/alternates&&
81 cd C &&
82 test_valid_repo"
84 cd "$base_dir"
86 test_expect_failure 'that info/alternates is necessary' \
87 'cd C &&
88 rm .git/objects/info/alternates &&
89 test_valid_repo'
91 cd "$base_dir"
93 test_expect_success 'that relative alternate is possible for current dir' \
94 'cd C &&
95 echo "../../../B/.git/objects" > .git/objects/info/alternates &&
96 test_valid_repo'
98 cd "$base_dir"
100 test_expect_failure 'that relative alternate is only possible for current dir' \
101 'cd D &&
102 test_valid_repo'
104 cd "$base_dir"
106 test_done