3 test_description='read-tree -m -u checks working tree files'
9 test_expect_success 'two-way setup' '
12 echo >file1 file one &&
13 echo >file2 file two &&
14 echo >subdir/file1 file one in subdirectory &&
15 echo >subdir/file2 file two in subdirectory &&
16 git update-index --add file1 file2 subdir/file1 subdir/file2 &&
17 git commit -m initial &&
20 git tag -f branch-point &&
22 echo file2 is not tracked on the master anymore &&
23 rm -f file2 subdir/file2 &&
24 git update-index --remove file2 subdir/file2 &&
25 git commit -a -m "master removes file2 and subdir/file2"
28 test_expect_success 'two-way not clobbering' '
30 echo >file2 master creates untracked file2 &&
31 echo >subdir/file2 master creates untracked subdir/file2 &&
32 if err=`git read-tree -m -u master side 2>&1`
34 echo should have complained
37 echo "happy to see $err"
41 echo file2 >.gitignore
43 test_expect_success 'two-way with incorrect --exclude-per-directory (1)' '
45 if err=`git read-tree -m --exclude-per-directory=.gitignore master side 2>&1`
47 echo should have complained
50 echo "happy to see $err"
54 test_expect_success 'two-way with incorrect --exclude-per-directory (2)' '
56 if err=`git read-tree -m -u --exclude-per-directory=foo --exclude-per-directory=.gitignore master side 2>&1`
58 echo should have complained
61 echo "happy to see $err"
65 test_expect_success 'two-way clobbering a ignored file' '
67 git read-tree -m -u --exclude-per-directory=.gitignore master side
74 test_expect_success 'three-way not complaining on an untracked path in both' '
76 rm -f file2 subdir/file2 &&
78 echo >file3 file three &&
79 echo >subdir/file3 file three &&
80 git update-index --add file3 subdir/file3 &&
81 git commit -a -m "side adds file3 and removes file2" &&
83 git checkout master &&
84 echo >file2 file two is untracked on the master side &&
85 echo >subdir/file2 file two is untracked on the master side &&
87 git read-tree -m -u branch-point master side
90 test_expect_success 'three-way not clobbering a working tree file' '
93 rm -f file2 subdir/file2 file3 subdir/file3 &&
94 git checkout master &&
95 echo >file3 file three created in master, untracked &&
96 echo >subdir/file3 file three created in master, untracked &&
97 if err=`git read-tree -m -u branch-point master side 2>&1`
99 echo should have complained
102 echo "happy to see $err"
106 echo >.gitignore file3
108 test_expect_success 'three-way not complaining on an untracked file' '
111 rm -f file2 subdir/file2 file3 subdir/file3 &&
112 git checkout master &&
113 echo >file3 file three created in master, untracked &&
114 echo >subdir/file3 file three created in master, untracked &&
116 git read-tree -m -u --exclude-per-directory=.gitignore branch-point master side
119 test_expect_success '3-way not overwriting local changes (setup)' '
122 git checkout -b side-a branch-point &&
123 echo >>file1 "new line to be kept in the merge result" &&
124 git commit -a -m "side-a changes file1" &&
125 git checkout -b side-b branch-point &&
126 echo >>file2 "new line to be kept in the merge result" &&
127 git commit -a -m "side-b changes file2" &&
132 test_expect_success '3-way not overwriting local changes (our side)' '
134 # At this point, file1 from side-a should be kept as side-b
139 echo >>file1 "local changes" &&
140 git read-tree -m -u branch-point side-a side-b &&
141 grep "new line to be kept" file1 &&
142 grep "local changes" file1
146 test_expect_success '3-way not overwriting local changes (their side)' '
148 # At this point, file2 from side-b should be taken as side-a
153 echo >>file2 "local changes" &&
154 test_must_fail git read-tree -m -u branch-point side-a side-b &&
155 ! grep "new line to be kept" file2 &&
156 grep "local changes" file2