]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5618-alternate-refs.sh
Merge branch 'jk/fsck-indices-in-worktrees'
[thirdparty/git.git] / t / t5618-alternate-refs.sh
CommitLineData
39b44ba7
JK
1#!/bin/sh
2
3test_description='test handling of --alternate-refs traversal'
03267e86
ÆAB
4
5TEST_PASSES_SANITIZE_LEAK=true
39b44ba7
JK
6. ./test-lib.sh
7
8# Avoid test_commit because we want a specific and known set of refs:
9#
10# base -- one
11# \ \
12# two -- merged
13#
14# where "one" and "two" are on separate refs, and "merged" is available only in
15# the dependent child repository.
16test_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
25'
26
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).
30test_expect_success 'set up shared clone' '
31 git clone -s . child &&
32 cd child &&
33 git merge origin/one
34'
35
36test_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
40'
41
42test_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
46'
47
48test_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
53'
54
55test_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
60'
61
62test_done