Raw
1 #!/bin/sh
2
3 test_description='--reverse combines with --parents'
4
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
8 . ./test-lib.sh
9
10
11 commit () {
12 test_tick &&
13 echo $1 > foo &&
14 git add foo &&
15 git commit -m "$1"
16 }
17
18 test_expect_success 'set up --reverse example' '
19 commit one &&
20 git tag root &&
21 commit two &&
22 git checkout -b side HEAD^ &&
23 commit three &&
24 git checkout main &&
25 git merge -s ours side &&
26 commit five
27 '
28
29 reverse () {
30 awk '{a[i++]=$0} END {for (j=i-1; j>=0;) print a[j--] }'
31 }
32
33 test_expect_success '--reverse --parents --full-history combines correctly' '
34 git rev-list --parents --full-history main -- foo | reverse >expected &&
35 git rev-list --reverse --parents --full-history main -- foo \
36 > actual &&
37 test_cmp expected actual
38 '
39
40 test_expect_success '--boundary does too' '
41 git rev-list --boundary --parents --full-history main ^root -- foo | reverse >expected &&
42 git rev-list --boundary --reverse --parents --full-history \
43 main ^root -- foo > actual &&
44 test_cmp expected actual
45 '
46
47 test_done