Demonstrate bugs when a directory is replaced with a symlink
This test creates two directories, a/b and a/b-2, then replaces a/b with a symlink to a/b-2, then merges that change into the 'baseline' commit, which contains an unrelated change. There are two bugs: 1. 'git checkout' incorrectly deletes work tree file a/b-2/d. 2. 'git merge' incorrectly deletes work tree file a/b-2/d. The test goes on to create another branch in which a/b-2 is replaced with a symlink to a/b (i.e., the reverse of what was done the first time), and merge it into the 'baseline' commit. There is a different bug: 3. The merge should be clean, but git reports a conflict. Signed-off-by: James Pickens <james.e.pickens@intel.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Pickens, James E committed
Jul 29, 2009 at 14:02 UTC
4f6339b0c353b5c03b566b605e50a743d97fc08e
1 file changed
+87
t/t6035-merge-dir-to-symlink.sh
new
+87
@@ -0,0 +1,87 @@
1
+#!/bin/sh
2
+
3
+test_description='merging when a directory was replaced with a symlink'
4
+. ./test-lib.sh
5
+
6
+test_expect_success 'create a commit where dir a/b changed to symlink' '
7
+ mkdir -p a/b/c a/b-2/c &&
8
+ > a/b/c/d &&
9
+ > a/b-2/c/d &&
10
+ > a/x &&
11
+ git add -A &&
12
+ git commit -m base &&
13
+ git tag start &&
14
+ rm -rf a/b &&
15
+ ln -s b-2 a/b &&
16
+ git add -A &&
17
+ git commit -m "dir to symlink"
18
+'
19
+
20
+test_expect_failure 'keep a/b-2/c/d across checkout' '
21
+ git checkout HEAD^0 &&
22
+ git reset --hard master &&
23
+ git rm --cached a/b &&
24
+ git commit -m "untracked symlink remains" &&
25
+ git checkout start^0 &&
26
+ test -f a/b-2/c/d
27
+'
28
+
29
+test_expect_failure 'checkout should not have deleted a/b-2/c/d' '
30
+ git checkout HEAD^0 &&
31
+ git reset --hard master &&
32
+ git checkout start^0 &&
33
+ test -f a/b-2/c/d
34
+'
35
+
36
+test_expect_success 'setup for merge test' '
37
+ git reset --hard &&
38
+ test -f a/b-2/c/d &&
39
+ echo x > a/x &&
40
+ git add a/x &&
41
+ git commit -m x &&
42
+ git tag baseline
43
+'
44
+
45
+test_expect_success 'do not lose a/b-2/c/d in merge (resolve)' '
46
+ git reset --hard &&
47
+ git checkout baseline^0 &&
48
+ git merge -s resolve master &&
49
+ test -h a/b &&
50
+ test -f a/b-2/c/d
51
+'
52
+
53
+test_expect_failure 'do not lose a/b-2/c/d in merge (recursive)' '
54
+ git reset --hard &&
55
+ git checkout baseline^0 &&
56
+ git merge -s recursive master &&
57
+ test -h a/b &&
58
+ test -f a/b-2/c/d
59
+'
60
+
61
+test_expect_success 'setup a merge where dir a/b-2 changed to symlink' '
62
+ git reset --hard &&
63
+ git checkout start^0 &&
64
+ rm -rf a/b-2 &&
65
+ ln -s b a/b-2 &&
66
+ git add -A &&
67
+ git commit -m "dir a/b-2 to symlink" &&
68
+ git tag test2
69
+'
70
+
71
+test_expect_failure 'merge should not have conflicts (resolve)' '
72
+ git reset --hard &&
73
+ git checkout baseline^0 &&
74
+ git merge -s resolve test2 &&
75
+ test -h a/b-2 &&
76
+ test -f a/b/c/d
77
+'
78
+
79
+test_expect_failure 'merge should not have conflicts (recursive)' '
80
+ git reset --hard &&
81
+ git checkout baseline^0 &&
82
+ git merge -s recursive test2 &&
83
+ test -h a/b-2 &&
84
+ test -f a/b/c/d
85
+'
86
+
87
+test_done