]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5613-info-alternate.sh
fill_sha1_file: write into a strbuf
[thirdparty/git.git] / t / t5613-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
128a348d 9test_expect_success 'preparing first repository' '
8f2ed267
JK
10 test_create_repo A && (
11 cd A &&
12 echo "Hello World" > file1 &&
13 git add file1 &&
14 git commit -m "Initial commit" file1 &&
15 git repack -a -d &&
16 git prune
17 )
128a348d 18'
dd05ea17 19
128a348d 20test_expect_success 'preparing second repository' '
8f2ed267
JK
21 git clone -l -s A B && (
22 cd B &&
23 echo "foo bar" > file2 &&
24 git add file2 &&
25 git commit -m "next commit" file2 &&
26 git repack -a -d -l &&
27 git prune
28 )
128a348d 29'
dd05ea17 30
128a348d 31test_expect_success 'preparing third repository' '
8f2ed267
JK
32 git clone -l -s B C && (
33 cd C &&
34 echo "Goodbye, cruel world" > file3 &&
35 git add file3 &&
36 git commit -m "one more" file3 &&
37 git repack -a -d -l &&
38 git prune
39 )
128a348d 40'
dd05ea17 41
f0f86fa9
JK
42# Note: These tests depend on the hard-coded value of 5 as the maximum depth
43# we will follow recursion. We start the depth at 0 and count links, not
44# repositories. This means that in a chain like:
45#
46# A --> B --> C --> D --> E --> F --> G --> H
47# 0 1 2 3 4 5 6
48#
49# we are OK at "G", but break at "H", even though "H" is actually the 8th
50# repository, not the 6th, which you might expect. Counting the links allows
51# N+1 repositories, and counting from 0 to 5 inclusive allows 6 links.
52#
53# Note also that we must use "--bare -l" to make the link to H. The "-l"
54# ensures we do not do a connectivity check, and the "--bare" makes sure
55# we do not try to checkout the result (which needs objects), either of
56# which would cause the clone to fail.
128a348d
JK
57test_expect_success 'creating too deep nesting' '
58 git clone -l -s C D &&
59 git clone -l -s D E &&
60 git clone -l -s E F &&
61 git clone -l -s F G &&
62 git clone --bare -l -s G H
63'
125a05fd 64
f0f86fa9
JK
65test_expect_success 'validity of seventh repository' '
66 git -C G fsck
128a348d 67'
dd05ea17 68
f0f86fa9
JK
69test_expect_success 'invalidity of eighth repository' '
70 test_must_fail git -C H fsck
128a348d 71'
dd05ea17 72
128a348d 73test_expect_success 'breaking of loops' '
8f2ed267
JK
74 echo "$(pwd)"/B/.git/objects >>A/.git/objects/info/alternates &&
75 git -C C fsck
128a348d 76'
dd05ea17 77
128a348d 78test_expect_success 'that info/alternates is necessary' '
8f2ed267
JK
79 rm -f C/.git/objects/info/alternates &&
80 test_must_fail git -C C fsck
195eb465 81'
dd05ea17 82
128a348d 83test_expect_success 'that relative alternate is possible for current dir' '
8f2ed267 84 echo "../../../B/.git/objects" >C/.git/objects/info/alternates &&
128a348d
JK
85 git fsck
86'
dd05ea17 87
128a348d 88test_expect_success 'that relative alternate is only possible for current dir' '
8f2ed267 89 test_must_fail git -C D fsck
41ac414e 90'
dd05ea17 91
dd05ea17 92test_done