interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t5618-alternate-refs.sh

86 lines · 2744 bytes Raw Blame History
1#!/bin/sh
2
3test_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.
15test_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).
29test_expect_success 'set up shared clone' '
30 git clone -s . child &&
31 cd child &&
32 git merge origin/one
33'
34
35test_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
41test_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
47test_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
54test_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
61test_expect_success 'connectivity check of a fetch excludes alternate refs' '
62 GIT_TRACE2_EVENT="$(pwd)/fetch.trace" git fetch origin &&
63 test_subcommand_flex git rev-list --objects --stdin --not --all \
64 --alternate-refs --quiet <fetch.trace
65'
66
67test_expect_success 'connectivity check of a deepening fetch excludes alternate refs' '
68 GIT_TRACE2_EVENT="$(pwd)/deepen.trace" git fetch --depth=1 origin one &&
69 test_subcommand_flex git rev-list --objects --stdin --not \
70 --alternate-refs --quiet <deepen.trace
71'
72
73test_expect_success 'refs of a shallow alternate are ignored' '
74 git clone --depth=1 --no-local . shallow &&
75 test_commit -C shallow shallow-only &&
76 shallow_tip=$(git -C shallow rev-parse HEAD) &&
77 cp .git/objects/info/alternates alternates.bak &&
78 test_when_finished "mv alternates.bak .git/objects/info/alternates" &&
79 echo "$(pwd)/shallow/.git/objects" >>.git/objects/info/alternates &&
80 git cat-file -e $shallow_tip &&
81 git rev-list --remotes=origin >expect &&
82 git rev-list --alternate-refs >actual &&
83 test_cmp expect actual
84'
85
86test_done