]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6019-rev-list-ancestry-path.sh
The third batch
[thirdparty/git.git] / t / t6019-rev-list-ancestry-path.sh
CommitLineData
ebdc94f3
JH
1#!/bin/sh
2
3test_description='--ancestry-path'
4
5# D---E-------F
6# / \ \
7# B---C---G---H---I---J
8# / \
9# A-------K---------------L--M
10#
257418c5
EN
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
cb7529e1
JH
18#
19# D..M -- M.t == M
20# --ancestry-path D..M -- M.t == M
f659031c
KB
21#
22# F...I == F G H I
23# --ancestry-path F...I == F H I
c72424b1
KB
24#
25# G..M -- G.t == [nothing - was dropped in "-s ours" merge L]
4d826608
KB
26# --ancestry-path G..M -- G.t == L
27# --ancestry-path --simplify-merges G^..M -- G.t == G L
ebdc94f3 28
1550bb6e 29GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
30export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
31
ebdc94f3
JH
32. ./test-lib.sh
33
34test_merge () {
35 test_tick &&
36 git merge -s ours -m "$2" "$1" &&
37 git tag "$2"
38}
39
40test_expect_success setup '
41 test_commit A &&
42 test_commit B &&
43 test_commit C &&
44 test_commit D &&
45 test_commit E &&
46 test_commit F &&
47 git reset --hard C &&
48 test_commit G &&
49 test_merge E H &&
50 test_commit I &&
51 test_merge F J &&
52 git reset --hard A &&
53 test_commit K &&
54 test_merge J L &&
55 test_commit M
56'
57
1838e21c
DS
58test_ancestry () {
59 args=$1
60 expected=$2
61 test_expect_success "log $args" "
62 test_write_lines $expected >expect &&
63 git log --format=%s $args >raw &&
64
65 if test -n \"$expected\"
66 then
67 sort raw >actual &&
68 test_cmp expect actual
69 else
70 test_must_be_empty raw
71 fi
72 "
73}
cb7529e1 74
1838e21c 75test_ancestry "D..M" "E F G H I J K L M"
f659031c 76
1838e21c 77test_ancestry "--ancestry-path D..M" "E F H I J L M"
257418c5
EN
78test_ancestry "--ancestry-path=F D..M" "E F J L M"
79test_ancestry "--ancestry-path=G D..M" "G H I J L M"
80test_ancestry "--ancestry-path=H D..M" "E G H I J L M"
81test_ancestry "--ancestry-path=K D..M" "K L M"
82test_ancestry "--ancestry-path=F --ancestry-path=K D..M" "E F J K L M"
f659031c 83
1838e21c
DS
84test_ancestry "D..M -- M.t" "M"
85test_ancestry "--ancestry-path D..M -- M.t" "M"
c72424b1 86
1838e21c
DS
87test_ancestry "F...I" "F G H I"
88test_ancestry "--ancestry-path F...I" "F H I"
4d826608 89
1838e21c
DS
90test_ancestry "G..M -- G.t" ""
91test_ancestry "--ancestry-path G..M -- G.t" "L"
92test_ancestry "--ancestry-path --simplify-merges G^..M -- G.t" "G L"
c72424b1 93
81f49531
BK
94# b---bc
95# / \ /
96# a X
97# \ / \
98# c---cb
c05b988a
TR
99#
100# All refnames prefixed with 'x' to avoid confusion with the tags
101# generated by test_commit on case-insensitive systems.
81f49531
BK
102test_expect_success 'setup criss-cross' '
103 mkdir criss-cross &&
104 (cd criss-cross &&
105 git init &&
106 test_commit A &&
1550bb6e 107 git checkout -b xb main &&
81f49531 108 test_commit B &&
1550bb6e 109 git checkout -b xc main &&
81f49531 110 test_commit C &&
c05b988a
TR
111 git checkout -b xbc xb -- &&
112 git merge xc &&
113 git checkout -b xcb xc -- &&
114 git merge xb &&
1550bb6e 115 git checkout main)
81f49531
BK
116'
117
118# no commits in bc descend from cb
119test_expect_success 'criss-cross: rev-list --ancestry-path cb..bc' '
120 (cd criss-cross &&
c05b988a 121 git rev-list --ancestry-path xcb..xbc > actual &&
213dabf4 122 test_must_be_empty actual)
81f49531
BK
123'
124
125# no commits in repository descend from cb
c3502fa8 126test_expect_success 'criss-cross: rev-list --ancestry-path --all ^cb' '
81f49531 127 (cd criss-cross &&
c05b988a 128 git rev-list --ancestry-path --all ^xcb > actual &&
213dabf4 129 test_must_be_empty actual)
81f49531
BK
130'
131
ebdc94f3 132test_done