Code

t6042: Add failing testcase for rename/modify/add-source conflict
[git.git] / t / t6042-merge-rename-corner-cases.sh
1 #!/bin/sh
3 test_description="recursive merge corner cases w/ renames but not criss-crosses"
4 # t6036 has corner cases that involve both criss-cross merges and renames
6 . ./test-lib.sh
8 test_expect_success 'setup rename/delete + untracked file' '
9         echo "A pretty inscription" >ring &&
10         git add ring &&
11         test_tick &&
12         git commit -m beginning &&
14         git branch people &&
15         git checkout -b rename-the-ring &&
16         git mv ring one-ring-to-rule-them-all &&
17         test_tick &&
18         git commit -m fullname &&
20         git checkout people &&
21         git rm ring &&
22         echo gollum >owner &&
23         git add owner &&
24         test_tick &&
25         git commit -m track-people-instead-of-objects &&
26         echo "Myyy PRECIOUSSS" >ring
27 '
29 test_expect_failure "Does git preserve Gollum's precious artifact?" '
30         test_must_fail git merge -s recursive rename-the-ring &&
32         # Make sure git did not delete an untracked file
33         test -f ring
34 '
36 # Testcase setup for rename/modify/add-source:
37 #   Commit A: new file: a
38 #   Commit B: modify a slightly
39 #   Commit C: rename a->b, add completely different a
40 #
41 # We should be able to merge B & C cleanly
43 test_expect_success 'setup rename/modify/add-source conflict' '
44         git rm -rf . &&
45         git clean -fdqx &&
46         rm -rf .git &&
47         git init &&
49         printf "1\n2\n3\n4\n5\n6\n7\n" >a &&
50         git add a &&
51         git commit -m A &&
52         git tag A &&
54         git checkout -b B A &&
55         echo 8 >>a &&
56         git add a &&
57         git commit -m B &&
59         git checkout -b C A &&
60         git mv a b &&
61         echo something completely different >a &&
62         git add a &&
63         git commit -m C
64 '
66 test_expect_failure 'rename/modify/add-source conflict resolvable' '
67         git checkout B^0 &&
69         git merge -s recursive C^0 &&
71         test $(git rev-parse B:a) = $(git rev-parse b) &&
72         test $(git rev-parse C:a) = $(git rev-parse a)
73 '
75 test_done