create_directories(): remove some memcpy() and strchr() calls
[git/jnareb-git.git] / t / t7607-merge-overwrite.sh
blob49f4e1599acd829fdd930c1f9b5bc30ac719053d
1 #!/bin/sh
3 test_description='git-merge
5 Do not overwrite changes.'
7 . ./test-lib.sh
9 test_expect_success 'setup' '
10 echo c0 > c0.c &&
11 git add c0.c &&
12 git commit -m c0 &&
13 git tag c0 &&
14 echo c1 > c1.c &&
15 git add c1.c &&
16 git commit -m c1 &&
17 git tag c1 &&
18 git reset --hard c0 &&
19 echo c2 > c2.c &&
20 git add c2.c &&
21 git commit -m c2 &&
22 git tag c2 &&
23 git reset --hard c1 &&
24 echo "c1 a" > c1.c &&
25 git add c1.c &&
26 git commit -m "c1 a" &&
27 git tag c1a &&
28 echo "VERY IMPORTANT CHANGES" > important
31 test_expect_success 'will not overwrite untracked file' '
32 git reset --hard c1 &&
33 cat important > c2.c &&
34 ! git merge c2 &&
35 test_cmp important c2.c
38 test_expect_success 'will not overwrite new file' '
39 git reset --hard c1 &&
40 cat important > c2.c &&
41 git add c2.c &&
42 ! git merge c2 &&
43 test_cmp important c2.c
46 test_expect_success 'will not overwrite staged changes' '
47 git reset --hard c1 &&
48 cat important > c2.c &&
49 git add c2.c &&
50 rm c2.c &&
51 ! git merge c2 &&
52 git checkout c2.c &&
53 test_cmp important c2.c
56 test_expect_success 'will not overwrite removed file' '
57 git reset --hard c1 &&
58 git rm c1.c &&
59 git commit -m "rm c1.c" &&
60 cat important > c1.c &&
61 ! git merge c1a &&
62 test_cmp important c1.c
65 test_expect_success 'will not overwrite re-added file' '
66 git reset --hard c1 &&
67 git rm c1.c &&
68 git commit -m "rm c1.c" &&
69 cat important > c1.c &&
70 git add c1.c &&
71 ! git merge c1a &&
72 test_cmp important c1.c
75 test_expect_success 'will not overwrite removed file with staged changes' '
76 git reset --hard c1 &&
77 git rm c1.c &&
78 git commit -m "rm c1.c" &&
79 cat important > c1.c &&
80 git add c1.c &&
81 rm c1.c &&
82 ! git merge c1a &&
83 git checkout c1.c &&
84 test_cmp important c1.c
87 test_done