Merge branch '2.29-r2' of github.com:bitigchi/git-po
[alt-git.git] / t / t4068-diff-symmetric.sh
blob31d17a5af02fc0a1671a80bbf2d15b7cd955621f
1 #!/bin/sh
3 test_description='behavior of diff with symmetric-diff setups'
5 . ./test-lib.sh
7 # build these situations:
8 # - normal merge with one merge base (br1...b2r);
9 # - criss-cross merge ie 2 merge bases (br1...master);
10 # - disjoint subgraph (orphan branch, br3...master).
12 # B---E <-- master
13 # / \ /
14 # A X
15 # \ / \
16 # C---D--G <-- br1
17 # \ /
18 # ---F <-- br2
20 # H <-- br3
22 # We put files into a few commits so that we can verify the
23 # output as well.
25 test_expect_success setup '
26 git commit --allow-empty -m A &&
27 echo b >b &&
28 git add b &&
29 git commit -m B &&
30 git checkout -b br1 HEAD^ &&
31 echo c >c &&
32 git add c &&
33 git commit -m C &&
34 git tag commit-C &&
35 git merge -m D master &&
36 git tag commit-D &&
37 git checkout master &&
38 git merge -m E commit-C &&
39 git checkout -b br2 commit-C &&
40 echo f >f &&
41 git add f &&
42 git commit -m F &&
43 git checkout br1 &&
44 git merge -m G br2 &&
45 git checkout --orphan br3 &&
46 git commit -m H
49 test_expect_success 'diff with one merge base' '
50 git diff commit-D...br1 >tmp &&
51 tail -n 1 tmp >actual &&
52 echo +f >expect &&
53 test_cmp expect actual
56 # The output (in tmp) can have +b or +c depending
57 # on which merge base (commit B or C) is picked.
58 # It should have one of those two, which comes out
59 # to seven lines.
60 test_expect_success 'diff with two merge bases' '
61 git diff br1...master >tmp 2>err &&
62 test_line_count = 7 tmp &&
63 test_line_count = 1 err
66 test_expect_success 'diff with no merge bases' '
67 test_must_fail git diff br2...br3 >tmp 2>err &&
68 test_i18ngrep "fatal: br2...br3: no merge base" err
71 test_expect_success 'diff with too many symmetric differences' '
72 test_must_fail git diff br1...master br2...br3 >tmp 2>err &&
73 test_i18ngrep "usage" err
76 test_expect_success 'diff with symmetric difference and extraneous arg' '
77 test_must_fail git diff master br1...master >tmp 2>err &&
78 test_i18ngrep "usage" err
81 test_expect_success 'diff with two ranges' '
82 test_must_fail git diff master br1..master br2..br3 >tmp 2>err &&
83 test_i18ngrep "usage" err
86 test_expect_success 'diff with ranges and extra arg' '
87 test_must_fail git diff master br1..master commit-D >tmp 2>err &&
88 test_i18ngrep "usage" err
91 test_done