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