The eleventh batch
[alt-git.git] / t / t6019-rev-list-ancestry-path.sh
blob1aabab69568a18d103db308f53a8b2e05cfe643d
1 #!/bin/sh
3 test_description='--ancestry-path'
5 # D---E-------F
6 # / \ \
7 # B---C---G---H---I---J
8 # / \
9 # A-------K---------------L--M
11 # D..M == E F G H I J K L M
12 # --ancestry-path D..M == E F H I J L M
13 # --ancestry-path=F D..M == E F J L M
14 # --ancestry-path=G D..M == G H I J L M
15 # --ancestry-path=H D..M == E G H I J L M
16 # --ancestry-path=K D..M == K L M
17 # --ancestry-path=K --ancestry-path=F D..M == E F J K L M
19 # D..M -- M.t == M
20 # --ancestry-path D..M -- M.t == M
22 # F...I == F G H I
23 # --ancestry-path F...I == F H I
25 # G..M -- G.t == [nothing - was dropped in "-s ours" merge L]
26 # --ancestry-path G..M -- G.t == L
27 # --ancestry-path --simplify-merges G^..M -- G.t == G L
29 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
30 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
32 TEST_PASSES_SANITIZE_LEAK=true
33 . ./test-lib.sh
35 test_merge () {
36 test_tick &&
37 git merge -s ours -m "$2" "$1" &&
38 git tag "$2"
41 test_expect_success setup '
42 test_commit A &&
43 test_commit B &&
44 test_commit C &&
45 test_commit D &&
46 test_commit E &&
47 test_commit F &&
48 git reset --hard C &&
49 test_commit G &&
50 test_merge E H &&
51 test_commit I &&
52 test_merge F J &&
53 git reset --hard A &&
54 test_commit K &&
55 test_merge J L &&
56 test_commit M
59 test_ancestry () {
60 args=$1
61 expected=$2
62 test_expect_success "log $args" "
63 test_write_lines $expected >expect &&
64 git log --format=%s $args >raw &&
66 if test -n \"$expected\"
67 then
68 sort raw >actual &&
69 test_cmp expect actual
70 else
71 test_must_be_empty raw
76 test_ancestry "D..M" "E F G H I J K L M"
78 test_ancestry "--ancestry-path D..M" "E F H I J L M"
79 test_ancestry "--ancestry-path=F D..M" "E F J L M"
80 test_ancestry "--ancestry-path=G D..M" "G H I J L M"
81 test_ancestry "--ancestry-path=H D..M" "E G H I J L M"
82 test_ancestry "--ancestry-path=K D..M" "K L M"
83 test_ancestry "--ancestry-path=F --ancestry-path=K D..M" "E F J K L M"
85 test_ancestry "D..M -- M.t" "M"
86 test_ancestry "--ancestry-path D..M -- M.t" "M"
88 test_ancestry "F...I" "F G H I"
89 test_ancestry "--ancestry-path F...I" "F H I"
91 test_ancestry "G..M -- G.t" ""
92 test_ancestry "--ancestry-path G..M -- G.t" "L"
93 test_ancestry "--ancestry-path --simplify-merges G^..M -- G.t" "G L"
95 # b---bc
96 # / \ /
97 # a X
98 # \ / \
99 # c---cb
101 # All refnames prefixed with 'x' to avoid confusion with the tags
102 # generated by test_commit on case-insensitive systems.
103 test_expect_success 'setup criss-cross' '
104 mkdir criss-cross &&
105 (cd criss-cross &&
106 git init &&
107 test_commit A &&
108 git checkout -b xb main &&
109 test_commit B &&
110 git checkout -b xc main &&
111 test_commit C &&
112 git checkout -b xbc xb -- &&
113 git merge xc &&
114 git checkout -b xcb xc -- &&
115 git merge xb &&
116 git checkout main)
119 # no commits in bc descend from cb
120 test_expect_success 'criss-cross: rev-list --ancestry-path cb..bc' '
121 (cd criss-cross &&
122 git rev-list --ancestry-path xcb..xbc > actual &&
123 test_must_be_empty actual)
126 # no commits in repository descend from cb
127 test_expect_success 'criss-cross: rev-list --ancestry-path --all ^cb' '
128 (cd criss-cross &&
129 git rev-list --ancestry-path --all ^xcb > actual &&
130 test_must_be_empty actual)
133 test_done