Add more checkout tests
If you have local changes that don't conflict with the branch-switching changes, these should be kept, not cause errors even without -m, and be reported afterwards in name-status format. With -m, the changes carried across should be listed as well. And, for now, include the merge-recursive output from this process. Also test the detatched head message in at least one case. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Daniel Barkalow committed
Dec 9, 2007 at 22:05 UTC
c07c7bf630efd8ddcd41490036c1eefb01a39f98
1 file changed
+43
-3
t/t7201-co.sh
+43
-3
@@ -20,6 +20,8 @@ Test switching across them.
20
21
. ./test-lib.sh
22
23
+test_tick
24
+
25
fill () {
26
for i
27
do
@@ -30,9 +32,10 @@ fill () {
32
33
test_expect_success setup '
34
35
+ fill x y z > same &&
36
fill 1 2 3 4 5 6 7 8 >one &&
37
fill a b c d e >two &&
35
- git add one two &&
38
+ git add same one two &&
39
git commit -m "Initial A one, A two" &&
40
41
git checkout -b renamer &&
@@ -74,16 +77,44 @@ test_expect_success "checkout with dirty tree without -m" '
77
78
'
79
80
+test_expect_success "checkout with unrelated dirty tree without -m" '
81
+
82
+ git checkout -f master &&
83
+ fill 0 1 2 3 4 5 6 7 8 >same &&
84
+ cp same kept
85
+ git checkout side >messages &&
86
+ git diff same kept
87
+ (cat > messages.expect <<EOF
88
+M same
89
+EOF
90
+) &&
91
+ touch messages.expect &&
92
+ git diff messages.expect messages
93
+'
94
+
95
test_expect_success "checkout -m with dirty tree" '
96
97
git checkout -f master &&
98
git clean -f &&
99
100
fill 0 1 2 3 4 5 6 7 8 >one &&
83
- git checkout -m side &&
101
+ git checkout -m side > messages &&
102
103
test "$(git symbolic-ref HEAD)" = "refs/heads/side" &&
104
105
+ (cat >expect.messages <<EOF
106
+Merging side with local
107
+Merging:
108
+ab76817 Side M one, D two, A three
109
+virtual local
110
+found 1 common ancestor(s):
111
+7329388 Initial A one, A two
112
+Auto-merged one
113
+M one
114
+EOF
115
+) &&
116
+ git diff expect.messages messages &&
117
+
118
fill "M one" "A three" "D two" >expect.master &&
119
git diff --name-status master >current.master &&
120
diff expect.master current.master &&
@@ -145,7 +176,16 @@ test_expect_success 'checkout -m with merge conflict' '
176
test_expect_success 'checkout to detach HEAD' '
177
178
git checkout -f renamer && git clean -f &&
148
- git checkout renamer^ &&
179
+ git checkout renamer^ 2>messages &&
180
+ (cat >messages.expect <<EOF
181
+Note: moving to "renamer^" which isn'"'"'t a local branch
182
+If you want to create a new branch from this checkout, you may do so
183
+(now or later) by using -b with the checkout command again. Example:
184
+ git checkout -b <new_branch_name>
185
+HEAD is now at 7329388... Initial A one, A two
186
+EOF
187
+) &&
188
+ git diff messages.expect messages &&
189
H=$(git rev-parse --verify HEAD) &&
190
M=$(git show-ref -s --verify refs/heads/master) &&
191
test "z$H" = "z$M" &&