t1200: Make documentation and test agree
There were some differences between t1200 and the gitcore-tutorial. Add missing tests for manually merging two branches, and use the same commands in both files. Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stephen Boyd committed
Nov 4, 2009 at 22:33 UTC
7c5858a643724a9a4a67f1290c03d57f483ed261
2 files changed
+98
-18
Documentation/gitcore-tutorial.txt
+10
-10
@@ -185,7 +185,7 @@ object is. git will tell you that you have a "blob" object (i.e., just a
185
regular file), and you can see the contents with
186
187
----------------
188
-$ git cat-file "blob" 557db03
188
+$ git cat-file blob 557db03
189
----------------
190
191
which will print out "Hello World". The object `557db03` is nothing
@@ -1188,7 +1188,7 @@ $ git show-branch
1188
--
1189
+ [mybranch] Some work.
1190
* [master] Some fun.
1191
-*+ [mybranch^] New day.
1191
+*+ [mybranch^] Initial commit
1192
------------
1193
1194
Now we are ready to experiment with the merge by hand.
@@ -1204,11 +1204,11 @@ $ mb=$(git merge-base HEAD mybranch)
1204
The command writes the commit object name of the common ancestor
1205
to the standard output, so we captured its output to a variable,
1206
because we will be using it in the next step. By the way, the common
1207
-ancestor commit is the "New day." commit in this case. You can
1207
+ancestor commit is the "Initial commit" commit in this case. You can
1208
tell it by:
1209
1210
------------
1211
-$ git name-rev $mb
1211
+$ git name-rev --name-only --tags $mb
1212
my-first-tag
1213
------------
1214
@@ -1237,8 +1237,8 @@ inspect the index file with this command:
1237
------------
1238
$ git ls-files --stage
1239
100644 7f8b141b65fdcee47321e399a2598a235a032422 0 example
1240
-100644 263414f423d0e4d70dae8fe53fa34614ff3e2860 1 hello
1241
-100644 06fa6a24256dc7e560efa5687fa84b51f0263c3a 2 hello
1240
+100644 557db03de997c86a4a028e1ebd3a1ceb225be238 1 hello
1241
+100644 ba42a2a96e3027f3333e13ede4ccf4498c3ae942 2 hello
1242
100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello
1243
------------
1244
@@ -1253,8 +1253,8 @@ To look at only non-zero stages, use `\--unmerged` flag:
1253
1254
------------
1255
$ git ls-files --unmerged
1256
-100644 263414f423d0e4d70dae8fe53fa34614ff3e2860 1 hello
1257
-100644 06fa6a24256dc7e560efa5687fa84b51f0263c3a 2 hello
1256
+100644 557db03de997c86a4a028e1ebd3a1ceb225be238 1 hello
1257
+100644 ba42a2a96e3027f3333e13ede4ccf4498c3ae942 2 hello
1258
100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello
1259
------------
1260
@@ -1283,8 +1283,8 @@ the working tree.. This can be seen if you run `ls-files
1283
------------
1284
$ git ls-files --stage
1285
100644 7f8b141b65fdcee47321e399a2598a235a032422 0 example
1286
-100644 263414f423d0e4d70dae8fe53fa34614ff3e2860 1 hello
1287
-100644 06fa6a24256dc7e560efa5687fa84b51f0263c3a 2 hello
1286
+100644 557db03de997c86a4a028e1ebd3a1ceb225be238 1 hello
1287
+100644 ba42a2a96e3027f3333e13ede4ccf4498c3ae942 2 hello
1288
100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello
1289
------------
1290
t/t1200-tutorial.sh
renamed
+88
-8
@@ -47,8 +47,9 @@ test_expect_success 'tree' '
47
'
48
49
test_expect_success 'git diff-index -p HEAD' '
50
- echo "Initial commit" | \
51
- git commit-tree $(git write-tree) 2>&1 > .git/refs/heads/master &&
50
+ tree=$(git write-tree)
51
+ commit=$(echo "Initial commit" | git commit-tree $tree) &&
52
+ git update-ref HEAD $commit &&
53
git diff-index -p HEAD > diff.output &&
54
cmp diff.expect diff.output
55
'
@@ -131,16 +132,18 @@ Work, work, work
132
EOF
133
134
cat > show-branch.expect << EOF
134
-* [master] Merged "mybranch" changes.
135
+* [master] Merge work in mybranch
136
! [mybranch] Some work.
137
--
137
-- [master] Merged "mybranch" changes.
138
+- [master] Merge work in mybranch
139
*+ [mybranch] Some work.
140
+* [master^] Some fun.
141
EOF
142
143
test_expect_success 'git show-branch' '
142
- git commit -m "Merged \"mybranch\" changes." -i hello &&
143
- git show-branch --topo-order master mybranch > show-branch.output &&
144
+ git commit -m "Merge work in mybranch" -i hello &&
145
+ git show-branch --topo-order --more=1 master mybranch \
146
+ > show-branch.output &&
147
cmp show-branch.expect show-branch.output
148
'
149
@@ -160,10 +163,10 @@ test_expect_success 'git resolve' '
163
'
164
165
cat > show-branch2.expect << EOF
163
-! [master] Merged "mybranch" changes.
164
- * [mybranch] Merged "mybranch" changes.
166
+! [master] Merge work in mybranch
167
+ * [mybranch] Merge work in mybranch
168
--
169
+-- [master] Merge work in mybranch
170
EOF
171
172
test_expect_success 'git show-branch (part 2)' '
@@ -171,6 +174,82 @@ test_expect_success 'git show-branch (part 2)' '
174
cmp show-branch2.expect show-branch2.output
175
'
176
177
+cat > show-branch3.expect << EOF
178
+! [master] Merge work in mybranch
179
+ * [mybranch] Merge work in mybranch
180
+--
181
+-- [master] Merge work in mybranch
182
++* [master^2] Some work.
183
++* [master^] Some fun.
184
+EOF
185
+
186
+test_expect_success 'git show-branch (part 3)' '
187
+ git show-branch --topo-order --more=2 master mybranch \
188
+ > show-branch3.output &&
189
+ cmp show-branch3.expect show-branch3.output
190
+'
191
+
192
+test_expect_success 'rewind to "Some fun." and "Some work."' '
193
+ git checkout mybranch &&
194
+ git reset --hard master^2 &&
195
+ git checkout master &&
196
+ git reset --hard master^
197
+'
198
+
199
+cat > show-branch4.expect << EOF
200
+* [master] Some fun.
201
+ ! [mybranch] Some work.
202
+--
203
+ + [mybranch] Some work.
204
+* [master] Some fun.
205
+*+ [mybranch^] Initial commit
206
+EOF
207
+
208
+test_expect_success 'git show-branch (part 4)' '
209
+ git show-branch --topo-order > show-branch4.output &&
210
+ cmp show-branch4.expect show-branch4.output
211
+'
212
+
213
+test_expect_success 'manual merge' '
214
+ mb=$(git merge-base HEAD mybranch) &&
215
+ git name-rev --name-only --tags $mb > name-rev.output &&
216
+ test "my-first-tag" = $(cat name-rev.output) &&
217
+
218
+ git read-tree -m -u $mb HEAD mybranch
219
+'
220
+
221
+cat > ls-files.expect << EOF
222
+100644 7f8b141b65fdcee47321e399a2598a235a032422 0 example
223
+100644 557db03de997c86a4a028e1ebd3a1ceb225be238 1 hello
224
+100644 ba42a2a96e3027f3333e13ede4ccf4498c3ae942 2 hello
225
+100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello
226
+EOF
227
+
228
+test_expect_success 'git ls-files --stage' '
229
+ git ls-files --stage > ls-files.output &&
230
+ cmp ls-files.expect ls-files.output
231
+'
232
+
233
+cat > ls-files-unmerged.expect << EOF
234
+100644 557db03de997c86a4a028e1ebd3a1ceb225be238 1 hello
235
+100644 ba42a2a96e3027f3333e13ede4ccf4498c3ae942 2 hello
236
+100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello
237
+EOF
238
+
239
+test_expect_success 'git ls-files --unmerged' '
240
+ git ls-files --unmerged > ls-files-unmerged.output &&
241
+ cmp ls-files-unmerged.expect ls-files-unmerged.output
242
+'
243
+
244
+test_expect_success 'git-merge-index' '
245
+ test_must_fail git merge-index git-merge-one-file hello
246
+'
247
+
248
+test_expect_success 'git ls-files --stage (part 2)' '
249
+ git ls-files --stage > ls-files.output2 &&
250
+ cmp ls-files.expect ls-files.output2
251
+'
252
+
253
test_expect_success 'git repack' 'git repack'
254
test_expect_success 'git prune-packed' 'git prune-packed'
255
test_expect_success '-> only packed objects' '