3 test_description
='behavior of diff with symmetric-diff setups'
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).
22 # We put files into a few commits so that we can verify the
25 test_expect_success setup
'
26 git commit --allow-empty -m A &&
30 git checkout -b br1 HEAD^ &&
35 git merge -m D master &&
37 git checkout master &&
38 git merge -m E commit-C &&
39 git checkout -b br2 commit-C &&
45 git checkout --orphan br3 &&
49 test_expect_success
'diff with one merge base' '
50 git diff commit-D...br1 >tmp &&
51 tail -n 1 tmp >actual &&
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
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