]>
Commit | Line | Data |
---|---|---|
dd05ea17 MW |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (C) 2006 Martin Waitz <tali@admingilde.org> | |
4 | # | |
5 | ||
6 | test_description='test transitive info/alternate entries' | |
b2e5d75d ÆAB |
7 | |
8 | TEST_PASSES_SANITIZE_LEAK=true | |
dd05ea17 MW |
9 | . ./test-lib.sh |
10 | ||
128a348d | 11 | test_expect_success 'preparing first repository' ' |
8f2ed267 JK |
12 | test_create_repo A && ( |
13 | cd A && | |
14 | echo "Hello World" > file1 && | |
15 | git add file1 && | |
16 | git commit -m "Initial commit" file1 && | |
17 | git repack -a -d && | |
18 | git prune | |
19 | ) | |
128a348d | 20 | ' |
dd05ea17 | 21 | |
128a348d | 22 | test_expect_success 'preparing second repository' ' |
8f2ed267 JK |
23 | git clone -l -s A B && ( |
24 | cd B && | |
25 | echo "foo bar" > file2 && | |
26 | git add file2 && | |
27 | git commit -m "next commit" file2 && | |
28 | git repack -a -d -l && | |
29 | git prune | |
30 | ) | |
128a348d | 31 | ' |
dd05ea17 | 32 | |
128a348d | 33 | test_expect_success 'preparing third repository' ' |
8f2ed267 JK |
34 | git clone -l -s B C && ( |
35 | cd C && | |
36 | echo "Goodbye, cruel world" > file3 && | |
37 | git add file3 && | |
38 | git commit -m "one more" file3 && | |
39 | git repack -a -d -l && | |
40 | git prune | |
41 | ) | |
128a348d | 42 | ' |
dd05ea17 | 43 | |
5fe849d6 JK |
44 | test_expect_success 'count-objects shows the alternates' ' |
45 | cat >expect <<-EOF && | |
46 | alternate: $(pwd)/B/.git/objects | |
47 | alternate: $(pwd)/A/.git/objects | |
48 | EOF | |
49 | git -C C count-objects -v >actual && | |
50 | grep ^alternate: actual >actual.alternates && | |
51 | test_cmp expect actual.alternates | |
52 | ' | |
53 | ||
f0f86fa9 JK |
54 | # Note: These tests depend on the hard-coded value of 5 as the maximum depth |
55 | # we will follow recursion. We start the depth at 0 and count links, not | |
56 | # repositories. This means that in a chain like: | |
57 | # | |
58 | # A --> B --> C --> D --> E --> F --> G --> H | |
59 | # 0 1 2 3 4 5 6 | |
60 | # | |
61 | # we are OK at "G", but break at "H", even though "H" is actually the 8th | |
62 | # repository, not the 6th, which you might expect. Counting the links allows | |
63 | # N+1 repositories, and counting from 0 to 5 inclusive allows 6 links. | |
64 | # | |
65 | # Note also that we must use "--bare -l" to make the link to H. The "-l" | |
66 | # ensures we do not do a connectivity check, and the "--bare" makes sure | |
67 | # we do not try to checkout the result (which needs objects), either of | |
68 | # which would cause the clone to fail. | |
128a348d JK |
69 | test_expect_success 'creating too deep nesting' ' |
70 | git clone -l -s C D && | |
71 | git clone -l -s D E && | |
72 | git clone -l -s E F && | |
73 | git clone -l -s F G && | |
74 | git clone --bare -l -s G H | |
75 | ' | |
125a05fd | 76 | |
f0f86fa9 JK |
77 | test_expect_success 'validity of seventh repository' ' |
78 | git -C G fsck | |
128a348d | 79 | ' |
dd05ea17 | 80 | |
f0f86fa9 JK |
81 | test_expect_success 'invalidity of eighth repository' ' |
82 | test_must_fail git -C H fsck | |
128a348d | 83 | ' |
dd05ea17 | 84 | |
128a348d | 85 | test_expect_success 'breaking of loops' ' |
8f2ed267 JK |
86 | echo "$(pwd)"/B/.git/objects >>A/.git/objects/info/alternates && |
87 | git -C C fsck | |
128a348d | 88 | ' |
dd05ea17 | 89 | |
128a348d | 90 | test_expect_success 'that info/alternates is necessary' ' |
8f2ed267 JK |
91 | rm -f C/.git/objects/info/alternates && |
92 | test_must_fail git -C C fsck | |
195eb465 | 93 | ' |
dd05ea17 | 94 | |
128a348d | 95 | test_expect_success 'that relative alternate is possible for current dir' ' |
8f2ed267 | 96 | echo "../../../B/.git/objects" >C/.git/objects/info/alternates && |
128a348d JK |
97 | git fsck |
98 | ' | |
dd05ea17 | 99 | |
087b6d58 JK |
100 | test_expect_success 'that relative alternate is recursive' ' |
101 | git -C D fsck | |
102 | ' | |
103 | ||
104 | # we can reach "A" from our new repo both directly, and via "C". | |
105 | # The deep/subdir is there to make sure we are not doing a stupid | |
106 | # pure-text comparison of the alternate names. | |
107 | test_expect_success 'relative duplicates are eliminated' ' | |
108 | mkdir -p deep/subdir && | |
109 | git init --bare deep/subdir/duplicate.git && | |
110 | cat >deep/subdir/duplicate.git/objects/info/alternates <<-\EOF && | |
111 | ../../../../C/.git/objects | |
112 | ../../../../A/.git/objects | |
113 | EOF | |
114 | cat >expect <<-EOF && | |
115 | alternate: $(pwd)/C/.git/objects | |
116 | alternate: $(pwd)/B/.git/objects | |
117 | alternate: $(pwd)/A/.git/objects | |
118 | EOF | |
119 | git -C deep/subdir/duplicate.git count-objects -v >actual && | |
120 | grep ^alternate: actual >actual.alternates && | |
121 | test_cmp expect actual.alternates | |
41ac414e | 122 | ' |
dd05ea17 | 123 | |
ea0fc3b4 JK |
124 | test_expect_success CASE_INSENSITIVE_FS 'dup finding can be case-insensitive' ' |
125 | git init --bare insensitive.git && | |
126 | # the previous entry for "A" will have used uppercase | |
127 | cat >insensitive.git/objects/info/alternates <<-\EOF && | |
128 | ../../C/.git/objects | |
129 | ../../a/.git/objects | |
130 | EOF | |
131 | cat >expect <<-EOF && | |
132 | alternate: $(pwd)/C/.git/objects | |
133 | alternate: $(pwd)/B/.git/objects | |
134 | alternate: $(pwd)/A/.git/objects | |
135 | EOF | |
136 | git -C insensitive.git count-objects -v >actual && | |
137 | grep ^alternate: actual >actual.alternates && | |
138 | test_cmp expect actual.alternates | |
139 | ' | |
140 | ||
dd05ea17 | 141 | test_done |