t7800: improve test descriptions with empty arguments
[alt-git.git] / t / t5613-info-alternate.sh
blob7708cbafa982ef3a5579f8bde075fcad40e29e40
1 #!/bin/sh
3 # Copyright (C) 2006 Martin Waitz <tali@admingilde.org>
6 test_description='test transitive info/alternate entries'
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
11 test_expect_success 'preparing first repository' '
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
22 test_expect_success 'preparing second repository' '
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
33 test_expect_success 'preparing third repository' '
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
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
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:
58 # A --> B --> C --> D --> E --> F --> G --> H
59 # 0 1 2 3 4 5 6
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.
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.
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
77 test_expect_success 'validity of seventh repository' '
78 git -C G fsck
81 test_expect_success 'invalidity of eighth repository' '
82 test_must_fail git -C H fsck
85 test_expect_success 'breaking of loops' '
86 echo "$(pwd)"/B/.git/objects >>A/.git/objects/info/alternates &&
87 git -C C fsck
90 test_expect_success 'that info/alternates is necessary' '
91 rm -f C/.git/objects/info/alternates &&
92 test_must_fail git -C C fsck
95 test_expect_success 'that relative alternate is possible for current dir' '
96 echo "../../../B/.git/objects" >C/.git/objects/info/alternates &&
97 git fsck
100 test_expect_success 'that relative alternate is recursive' '
101 git -C D fsck
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
114 cat >expect <<-EOF &&
115 alternate: $(pwd)/C/.git/objects
116 alternate: $(pwd)/B/.git/objects
117 alternate: $(pwd)/A/.git/objects
119 git -C deep/subdir/duplicate.git count-objects -v >actual &&
120 grep ^alternate: actual >actual.alternates &&
121 test_cmp expect actual.alternates
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
131 cat >expect <<-EOF &&
132 alternate: $(pwd)/C/.git/objects
133 alternate: $(pwd)/B/.git/objects
134 alternate: $(pwd)/A/.git/objects
136 git -C insensitive.git count-objects -v >actual &&
137 grep ^alternate: actual >actual.alternates &&
138 test_cmp expect actual.alternates
141 test_done