Raw
1 #!/bin/sh
2
3 test_description='test handling of --alternate-refs traversal'
4
5 . ./test-lib.sh
6
7 # Avoid test_commit because we want a specific and known set of refs:
8 #
9 # base -- one
10 # \ \
11 # two -- merged
12 #
13 # where "one" and "two" are on separate refs, and "merged" is available only in
14 # the dependent child repository.
15 test_expect_success 'set up local refs' '
16 git checkout -b one &&
17 test_tick &&
18 git commit --allow-empty -m base &&
19 test_tick &&
20 git commit --allow-empty -m one &&
21 git checkout -b two HEAD^ &&
22 test_tick &&
23 git commit --allow-empty -m two
24 '
25
26 # We'll enter the child repository after it's set up since that's where
27 # all of the subsequent tests will want to run (and it's easy to forget a
28 # "-C child" and get nonsense results).
29 test_expect_success 'set up shared clone' '
30 git clone -s . child &&
31 cd child &&
32 git merge origin/one
33 '
34
35 test_expect_success 'rev-list --alternate-refs' '
36 git rev-list --remotes=origin >expect &&
37 git rev-list --alternate-refs >actual &&
38 test_cmp expect actual
39 '
40
41 test_expect_success 'rev-list --not --alternate-refs' '
42 git rev-parse HEAD >expect &&
43 git rev-list HEAD --not --alternate-refs >actual &&
44 test_cmp expect actual
45 '
46
47 test_expect_success 'limiting with alternateRefsPrefixes' '
48 test_config core.alternateRefsPrefixes refs/heads/one &&
49 git rev-list origin/one >expect &&
50 git rev-list --alternate-refs >actual &&
51 test_cmp expect actual
52 '
53
54 test_expect_success 'log --source shows .alternate marker' '
55 git log --oneline --source --remotes=origin >expect.orig &&
56 sed "s/origin.* /.alternate /" <expect.orig >expect &&
57 git log --oneline --source --alternate-refs >actual &&
58 test_cmp expect actual
59 '
60
61 test_done