strbuf: simplify comment-handling in add_lines() helper
[git.git] / t / t6019-rev-list-ancestry-path.sh
blob738da23628b12b4660105195e2bbcedf68416f33
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-lib.sh
34 test_merge () {
35 test_tick &&
36 git merge -s ours -m "$2" "$1" &&
37 git tag "$2"
40 test_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
58 test_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 &&
65 if test -n \"$expected\"
66 then
67 sort raw >actual &&
68 test_cmp expect actual
69 else
70 test_must_be_empty raw
75 test_ancestry "D..M" "E F G H I J K L M"
77 test_ancestry "--ancestry-path D..M" "E F H I J L M"
78 test_ancestry "--ancestry-path=F D..M" "E F J L M"
79 test_ancestry "--ancestry-path=G D..M" "G H I J L M"
80 test_ancestry "--ancestry-path=H D..M" "E G H I J L M"
81 test_ancestry "--ancestry-path=K D..M" "K L M"
82 test_ancestry "--ancestry-path=F --ancestry-path=K D..M" "E F J K L M"
84 test_ancestry "D..M -- M.t" "M"
85 test_ancestry "--ancestry-path D..M -- M.t" "M"
87 test_ancestry "F...I" "F G H I"
88 test_ancestry "--ancestry-path F...I" "F H I"
90 test_ancestry "G..M -- G.t" ""
91 test_ancestry "--ancestry-path G..M -- G.t" "L"
92 test_ancestry "--ancestry-path --simplify-merges G^..M -- G.t" "G L"
94 # b---bc
95 # / \ /
96 # a X
97 # \ / \
98 # c---cb
100 # All refnames prefixed with 'x' to avoid confusion with the tags
101 # generated by test_commit on case-insensitive systems.
102 test_expect_success 'setup criss-cross' '
103 mkdir criss-cross &&
104 (cd criss-cross &&
105 git init &&
106 test_commit A &&
107 git checkout -b xb main &&
108 test_commit B &&
109 git checkout -b xc main &&
110 test_commit C &&
111 git checkout -b xbc xb -- &&
112 git merge xc &&
113 git checkout -b xcb xc -- &&
114 git merge xb &&
115 git checkout main)
118 # no commits in bc descend from cb
119 test_expect_success 'criss-cross: rev-list --ancestry-path cb..bc' '
120 (cd criss-cross &&
121 git rev-list --ancestry-path xcb..xbc > actual &&
122 test_must_be_empty actual)
125 # no commits in repository descend from cb
126 test_expect_success 'criss-cross: rev-list --ancestry-path --all ^cb' '
127 (cd criss-cross &&
128 git rev-list --ancestry-path --all ^xcb > actual &&
129 test_must_be_empty actual)
132 test_done