t0000: do not use export X=Y
[git] / t / t0000-basic.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2005 Junio C Hamano
4 #
5
6 test_description='Test the very basics part #1.
7
8 The rest of the test suite does not check the basic operation of git
9 plumbing commands to work very carefully.  Their job is to concentrate
10 on tricky features that caused bugs in the past to detect regression.
11
12 This test runs very basic features, like registering things in cache,
13 writing tree, etc.
14
15 Note that this test *deliberately* hard-codes many expected object
16 IDs.  When object ID computation changes, like in the previous case of
17 swapping compression and hashing order, the person who is making the
18 modification *should* take notice and update the test vectors here.
19 '
20
21 . ./test-lib.sh
22
23 ################################################################
24 # git init has been done in an empty repository.
25 # make sure it is empty.
26
27 test_expect_success '.git/objects should be empty after git init in an empty repo' '
28         find .git/objects -type f -print >should-be-empty &&
29         test_line_count = 0 should-be-empty
30 '
31
32 # also it should have 2 subdirectories; no fan-out anymore, pack, and info.
33 # 3 is counting "objects" itself
34 test_expect_success '.git/objects should have 3 subdirectories' '
35         find .git/objects -type d -print >full-of-directories &&
36         test_line_count = 3 full-of-directories
37 '
38
39 ################################################################
40 # Test harness
41 test_expect_success 'success is reported like this' '
42         :
43 '
44 test_expect_failure 'pretend we have a known breakage' '
45         false
46 '
47
48 run_sub_test_lib_test () {
49         name="$1" descr="$2" # stdin is the body of the test code
50         shift 2
51         mkdir "$name" &&
52         (
53                 # Pretend we're a test harness.  This prevents
54                 # test-lib from writing the counts to a file that will
55                 # later be summarized, showing spurious "failed" tests
56                 HARNESS_ACTIVE=t &&
57                 export HARNESS_ACTIVE &&
58                 cd "$name" &&
59                 cat >"$name.sh" <<-EOF &&
60                 #!$SHELL_PATH
61
62                 test_description='$descr (run in sub test-lib)
63
64                 This is run in a sub test-lib so that we do not get incorrect
65                 passing metrics
66                 '
67
68                 # Point to the t/test-lib.sh, which isn't in ../ as usual
69                 . "\$TEST_DIRECTORY"/test-lib.sh
70                 EOF
71                 cat >>"$name.sh" &&
72                 chmod +x "$name.sh" &&
73                 export TEST_DIRECTORY &&
74                 ./"$name.sh" "$@" >out 2>err
75         )
76 }
77
78 check_sub_test_lib_test () {
79         name="$1" # stdin is the expected output from the test
80         (
81                 cd "$name" &&
82                 ! test -s err &&
83                 sed -e 's/^> //' -e 's/Z$//' >expect &&
84                 test_cmp expect out
85         )
86 }
87
88 test_expect_success 'pretend we have a fully passing test suite' "
89         run_sub_test_lib_test full-pass '3 passing tests' <<-\\EOF &&
90         for i in 1 2 3
91         do
92                 test_expect_success \"passing test #\$i\" 'true'
93         done
94         test_done
95         EOF
96         check_sub_test_lib_test full-pass <<-\\EOF
97         > ok 1 - passing test #1
98         > ok 2 - passing test #2
99         > ok 3 - passing test #3
100         > # passed all 3 test(s)
101         > 1..3
102         EOF
103 "
104
105 test_expect_success 'pretend we have a partially passing test suite' "
106         test_must_fail run_sub_test_lib_test \
107                 partial-pass '2/3 tests passing' <<-\\EOF &&
108         test_expect_success 'passing test #1' 'true'
109         test_expect_success 'failing test #2' 'false'
110         test_expect_success 'passing test #3' 'true'
111         test_done
112         EOF
113         check_sub_test_lib_test partial-pass <<-\\EOF
114         > ok 1 - passing test #1
115         > not ok 2 - failing test #2
116         #       false
117         > ok 3 - passing test #3
118         > # failed 1 among 3 test(s)
119         > 1..3
120         EOF
121 "
122
123 test_expect_success 'pretend we have a known breakage' "
124         run_sub_test_lib_test failing-todo 'A failing TODO test' <<-\\EOF &&
125         test_expect_success 'passing test' 'true'
126         test_expect_failure 'pretend we have a known breakage' 'false'
127         test_done
128         EOF
129         check_sub_test_lib_test failing-todo <<-\\EOF
130         > ok 1 - passing test
131         > not ok 2 - pretend we have a known breakage # TODO known breakage
132         > # still have 1 known breakage(s)
133         > # passed all remaining 1 test(s)
134         > 1..2
135         EOF
136 "
137
138 test_expect_success 'pretend we have fixed a known breakage' "
139         run_sub_test_lib_test passing-todo 'A passing TODO test' <<-\\EOF &&
140         test_expect_failure 'pretend we have fixed a known breakage' 'true'
141         test_done
142         EOF
143         check_sub_test_lib_test passing-todo <<-\\EOF
144         > ok 1 - pretend we have fixed a known breakage # TODO known breakage vanished
145         > # 1 known breakage(s) vanished; please update test(s)
146         > 1..1
147         EOF
148 "
149
150 test_expect_success 'pretend we have fixed one of two known breakages (run in sub test-lib)' "
151         run_sub_test_lib_test partially-passing-todos \
152                 '2 TODO tests, one passing' <<-\\EOF &&
153         test_expect_failure 'pretend we have a known breakage' 'false'
154         test_expect_success 'pretend we have a passing test' 'true'
155         test_expect_failure 'pretend we have fixed another known breakage' 'true'
156         test_done
157         EOF
158         check_sub_test_lib_test partially-passing-todos <<-\\EOF
159         > not ok 1 - pretend we have a known breakage # TODO known breakage
160         > ok 2 - pretend we have a passing test
161         > ok 3 - pretend we have fixed another known breakage # TODO known breakage vanished
162         > # 1 known breakage(s) vanished; please update test(s)
163         > # still have 1 known breakage(s)
164         > # passed all remaining 1 test(s)
165         > 1..3
166         EOF
167 "
168
169 test_expect_success 'pretend we have a pass, fail, and known breakage' "
170         test_must_fail run_sub_test_lib_test \
171                 mixed-results1 'mixed results #1' <<-\\EOF &&
172         test_expect_success 'passing test' 'true'
173         test_expect_success 'failing test' 'false'
174         test_expect_failure 'pretend we have a known breakage' 'false'
175         test_done
176         EOF
177         check_sub_test_lib_test mixed-results1 <<-\\EOF
178         > ok 1 - passing test
179         > not ok 2 - failing test
180         > #     false
181         > not ok 3 - pretend we have a known breakage # TODO known breakage
182         > # still have 1 known breakage(s)
183         > # failed 1 among remaining 2 test(s)
184         > 1..3
185         EOF
186 "
187
188 test_expect_success 'pretend we have a mix of all possible results' "
189         test_must_fail run_sub_test_lib_test \
190                 mixed-results2 'mixed results #2' <<-\\EOF &&
191         test_expect_success 'passing test' 'true'
192         test_expect_success 'passing test' 'true'
193         test_expect_success 'passing test' 'true'
194         test_expect_success 'passing test' 'true'
195         test_expect_success 'failing test' 'false'
196         test_expect_success 'failing test' 'false'
197         test_expect_success 'failing test' 'false'
198         test_expect_failure 'pretend we have a known breakage' 'false'
199         test_expect_failure 'pretend we have a known breakage' 'false'
200         test_expect_failure 'pretend we have fixed a known breakage' 'true'
201         test_done
202         EOF
203         check_sub_test_lib_test mixed-results2 <<-\\EOF
204         > ok 1 - passing test
205         > ok 2 - passing test
206         > ok 3 - passing test
207         > ok 4 - passing test
208         > not ok 5 - failing test
209         > #     false
210         > not ok 6 - failing test
211         > #     false
212         > not ok 7 - failing test
213         > #     false
214         > not ok 8 - pretend we have a known breakage # TODO known breakage
215         > not ok 9 - pretend we have a known breakage # TODO known breakage
216         > ok 10 - pretend we have fixed a known breakage # TODO known breakage vanished
217         > # 1 known breakage(s) vanished; please update test(s)
218         > # still have 2 known breakage(s)
219         > # failed 3 among remaining 7 test(s)
220         > 1..10
221         EOF
222 "
223
224 test_expect_success 'test --verbose' '
225         test_must_fail run_sub_test_lib_test \
226                 test-verbose "test verbose" --verbose <<-\EOF &&
227         test_expect_success "passing test" true
228         test_expect_success "test with output" "echo foo"
229         test_expect_success "failing test" false
230         test_done
231         EOF
232         mv test-verbose/out test-verbose/out+
233         grep -v "^Initialized empty" test-verbose/out+ >test-verbose/out &&
234         check_sub_test_lib_test test-verbose <<-\EOF
235         > expecting success: true
236         > Z
237         > ok 1 - passing test
238         > Z
239         > expecting success: echo foo
240         > foo
241         > Z
242         > ok 2 - test with output
243         > Z
244         > expecting success: false
245         > Z
246         > not ok 3 - failing test
247         > #     false
248         > Z
249         > # failed 1 among 3 test(s)
250         > 1..3
251         EOF
252 '
253
254 test_expect_success 'test --verbose-only' '
255         test_must_fail run_sub_test_lib_test \
256                 test-verbose-only-2 "test verbose-only=2" \
257                 --verbose-only=2 <<-\EOF &&
258         test_expect_success "passing test" true
259         test_expect_success "test with output" "echo foo"
260         test_expect_success "failing test" false
261         test_done
262         EOF
263         check_sub_test_lib_test test-verbose-only-2 <<-\EOF
264         > ok 1 - passing test
265         > Z
266         > expecting success: echo foo
267         > foo
268         > Z
269         > ok 2 - test with output
270         > Z
271         > not ok 3 - failing test
272         > #     false
273         > # failed 1 among 3 test(s)
274         > 1..3
275         EOF
276 '
277
278 test_set_prereq HAVEIT
279 haveit=no
280 test_expect_success HAVEIT 'test runs if prerequisite is satisfied' '
281         test_have_prereq HAVEIT &&
282         haveit=yes
283 '
284 donthaveit=yes
285 test_expect_success DONTHAVEIT 'unmet prerequisite causes test to be skipped' '
286         donthaveit=no
287 '
288 if test $haveit$donthaveit != yesyes
289 then
290         say "bug in test framework: prerequisite tags do not work reliably"
291         exit 1
292 fi
293
294 test_set_prereq HAVETHIS
295 haveit=no
296 test_expect_success HAVETHIS,HAVEIT 'test runs if prerequisites are satisfied' '
297         test_have_prereq HAVEIT &&
298         test_have_prereq HAVETHIS &&
299         haveit=yes
300 '
301 donthaveit=yes
302 test_expect_success HAVEIT,DONTHAVEIT 'unmet prerequisites causes test to be skipped' '
303         donthaveit=no
304 '
305 donthaveiteither=yes
306 test_expect_success DONTHAVEIT,HAVEIT 'unmet prerequisites causes test to be skipped' '
307         donthaveiteither=no
308 '
309 if test $haveit$donthaveit$donthaveiteither != yesyesyes
310 then
311         say "bug in test framework: multiple prerequisite tags do not work reliably"
312         exit 1
313 fi
314
315 test_lazy_prereq LAZY_TRUE true
316 havetrue=no
317 test_expect_success LAZY_TRUE 'test runs if lazy prereq is satisfied' '
318         havetrue=yes
319 '
320 donthavetrue=yes
321 test_expect_success !LAZY_TRUE 'missing lazy prereqs skip tests' '
322         donthavetrue=no
323 '
324
325 if test "$havetrue$donthavetrue" != yesyes
326 then
327         say 'bug in test framework: lazy prerequisites do not work'
328         exit 1
329 fi
330
331 test_lazy_prereq LAZY_FALSE false
332 nothavefalse=no
333 test_expect_success !LAZY_FALSE 'negative lazy prereqs checked' '
334         nothavefalse=yes
335 '
336 havefalse=yes
337 test_expect_success LAZY_FALSE 'missing negative lazy prereqs will skip' '
338         havefalse=no
339 '
340
341 if test "$nothavefalse$havefalse" != yesyes
342 then
343         say 'bug in test framework: negative lazy prerequisites do not work'
344         exit 1
345 fi
346
347 clean=no
348 test_expect_success 'tests clean up after themselves' '
349         test_when_finished clean=yes
350 '
351
352 if test $clean != yes
353 then
354         say "bug in test framework: basic cleanup command does not work reliably"
355         exit 1
356 fi
357
358 test_expect_success 'tests clean up even on failures' "
359         test_must_fail run_sub_test_lib_test \
360                 failing-cleanup 'Failing tests with cleanup commands' <<-\\EOF &&
361         test_expect_success 'tests clean up even after a failure' '
362                 touch clean-after-failure &&
363                 test_when_finished rm clean-after-failure &&
364                 (exit 1)
365         '
366         test_expect_success 'failure to clean up causes the test to fail' '
367                 test_when_finished \"(exit 2)\"
368         '
369         test_done
370         EOF
371         check_sub_test_lib_test failing-cleanup <<-\\EOF
372         > not ok 1 - tests clean up even after a failure
373         > #     Z
374         > #     touch clean-after-failure &&
375         > #     test_when_finished rm clean-after-failure &&
376         > #     (exit 1)
377         > #     Z
378         > not ok 2 - failure to clean up causes the test to fail
379         > #     Z
380         > #     test_when_finished \"(exit 2)\"
381         > #     Z
382         > # failed 2 among 2 test(s)
383         > 1..2
384         EOF
385 "
386
387 ################################################################
388 # Basics of the basics
389
390 # updating a new file without --add should fail.
391 test_expect_success 'git update-index without --add should fail adding' '
392         test_must_fail git update-index should-be-empty
393 '
394
395 # and with --add it should succeed, even if it is empty (it used to fail).
396 test_expect_success 'git update-index with --add should succeed' '
397         git update-index --add should-be-empty
398 '
399
400 test_expect_success 'writing tree out with git write-tree' '
401         tree=$(git write-tree)
402 '
403
404 # we know the shape and contents of the tree and know the object ID for it.
405 test_expect_success 'validate object ID of a known tree' '
406         test "$tree" = 7bb943559a305bdd6bdee2cef6e5df2413c3d30a
407     '
408
409 # Removing paths.
410 test_expect_success 'git update-index without --remove should fail removing' '
411         rm -f should-be-empty full-of-directories &&
412         test_must_fail git update-index should-be-empty
413 '
414
415 test_expect_success 'git update-index with --remove should be able to remove' '
416         git update-index --remove should-be-empty
417 '
418
419 # Empty tree can be written with recent write-tree.
420 test_expect_success 'git write-tree should be able to write an empty tree' '
421         tree=$(git write-tree)
422 '
423
424 test_expect_success 'validate object ID of a known tree' '
425         test "$tree" = 4b825dc642cb6eb9a060e54bf8d69288fbee4904
426 '
427
428 # Various types of objects
429
430 # Some filesystems do not support symblic links; on such systems
431 # some expected values are different
432 if test_have_prereq SYMLINKS
433 then
434         expectfilter=cat
435         expectedtree=087704a96baf1c2d1c869a8b084481e121c88b5b
436         expectedptree1=21ae8269cacbe57ae09138dcc3a2887f904d02b3
437         expectedptree2=3c5e5399f3a333eddecce7a9b9465b63f65f51e2
438 else
439         expectfilter='grep -v sym'
440         expectedtree=8e18edf7d7edcf4371a3ac6ae5f07c2641db7c46
441         expectedptree1=cfb8591b2f65de8b8cc1020cd7d9e67e7793b325
442         expectedptree2=ce580448f0148b985a513b693fdf7d802cacb44f
443 fi
444
445
446 test_expect_success 'adding various types of objects with git update-index --add' '
447         mkdir path2 path3 path3/subp3 &&
448         paths="path0 path2/file2 path3/file3 path3/subp3/file3" &&
449         (
450                 for p in $paths
451                 do
452                         echo "hello $p" >$p || exit 1
453                         if test_have_prereq SYMLINKS
454                         then
455                                 ln -s "hello $p" ${p}sym || exit 1
456                         fi
457                 done
458         ) &&
459         find path* ! -type d -print | xargs git update-index --add
460 '
461
462 # Show them and see that matches what we expect.
463 test_expect_success 'showing stage with git ls-files --stage' '
464         git ls-files --stage >current
465 '
466
467 test_expect_success 'validate git ls-files output for a known tree' '
468         $expectfilter >expected <<-\EOF &&
469         100644 f87290f8eb2cbbea7857214459a0739927eab154 0       path0
470         120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0       path0sym
471         100644 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 0       path2/file2
472         120000 d8ce161addc5173867a3c3c730924388daedbc38 0       path2/file2sym
473         100644 0aa34cae68d0878578ad119c86ca2b5ed5b28376 0       path3/file3
474         120000 8599103969b43aff7e430efea79ca4636466794f 0       path3/file3sym
475         100644 00fb5908cb97c2564a9783c0c64087333b3b464f 0       path3/subp3/file3
476         120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0       path3/subp3/file3sym
477         EOF
478         test_cmp expected current
479 '
480
481 test_expect_success 'writing tree out with git write-tree' '
482         tree=$(git write-tree)
483 '
484
485 test_expect_success 'validate object ID for a known tree' '
486         test "$tree" = "$expectedtree"
487 '
488
489 test_expect_success 'showing tree with git ls-tree' '
490     git ls-tree $tree >current
491 '
492
493 test_expect_success SYMLINKS 'git ls-tree output for a known tree' '
494         cat >expected <<-\EOF &&
495         100644 blob f87290f8eb2cbbea7857214459a0739927eab154    path0
496         120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01    path0sym
497         040000 tree 58a09c23e2ca152193f2786e06986b7b6712bdbe    path2
498         040000 tree 21ae8269cacbe57ae09138dcc3a2887f904d02b3    path3
499         EOF
500         test_cmp expected current
501 '
502
503 # This changed in ls-tree pathspec change -- recursive does
504 # not show tree nodes anymore.
505 test_expect_success 'showing tree with git ls-tree -r' '
506         git ls-tree -r $tree >current
507 '
508
509 test_expect_success 'git ls-tree -r output for a known tree' '
510         $expectfilter >expected <<-\EOF &&
511         100644 blob f87290f8eb2cbbea7857214459a0739927eab154    path0
512         120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01    path0sym
513         100644 blob 3feff949ed00a62d9f7af97c15cd8a30595e7ac7    path2/file2
514         120000 blob d8ce161addc5173867a3c3c730924388daedbc38    path2/file2sym
515         100644 blob 0aa34cae68d0878578ad119c86ca2b5ed5b28376    path3/file3
516         120000 blob 8599103969b43aff7e430efea79ca4636466794f    path3/file3sym
517         100644 blob 00fb5908cb97c2564a9783c0c64087333b3b464f    path3/subp3/file3
518         120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c    path3/subp3/file3sym
519         EOF
520         test_cmp expected current
521 '
522
523 # But with -r -t we can have both.
524 test_expect_success 'showing tree with git ls-tree -r -t' '
525         git ls-tree -r -t $tree >current
526 '
527
528 test_expect_success SYMLINKS 'git ls-tree -r output for a known tree' '
529         cat >expected <<-\EOF &&
530         100644 blob f87290f8eb2cbbea7857214459a0739927eab154    path0
531         120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01    path0sym
532         040000 tree 58a09c23e2ca152193f2786e06986b7b6712bdbe    path2
533         100644 blob 3feff949ed00a62d9f7af97c15cd8a30595e7ac7    path2/file2
534         120000 blob d8ce161addc5173867a3c3c730924388daedbc38    path2/file2sym
535         040000 tree 21ae8269cacbe57ae09138dcc3a2887f904d02b3    path3
536         100644 blob 0aa34cae68d0878578ad119c86ca2b5ed5b28376    path3/file3
537         120000 blob 8599103969b43aff7e430efea79ca4636466794f    path3/file3sym
538         040000 tree 3c5e5399f3a333eddecce7a9b9465b63f65f51e2    path3/subp3
539         100644 blob 00fb5908cb97c2564a9783c0c64087333b3b464f    path3/subp3/file3
540         120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c    path3/subp3/file3sym
541         EOF
542         test_cmp expected current
543 '
544
545 test_expect_success 'writing partial tree out with git write-tree --prefix' '
546         ptree=$(git write-tree --prefix=path3)
547 '
548
549 test_expect_success 'validate object ID for a known tree' '
550         test "$ptree" = "$expectedptree1"
551 '
552
553 test_expect_success 'writing partial tree out with git write-tree --prefix' '
554         ptree=$(git write-tree --prefix=path3/subp3)
555 '
556
557 test_expect_success 'validate object ID for a known tree' '
558         test "$ptree" = "$expectedptree2"
559 '
560
561 test_expect_success 'put invalid objects into the index' '
562         rm -f .git/index &&
563         cat >badobjects <<-\EOF &&
564         100644 blob 1000000000000000000000000000000000000000    dir/file1
565         100644 blob 2000000000000000000000000000000000000000    dir/file2
566         100644 blob 3000000000000000000000000000000000000000    dir/file3
567         100644 blob 4000000000000000000000000000000000000000    dir/file4
568         100644 blob 5000000000000000000000000000000000000000    dir/file5
569         EOF
570         git update-index --index-info <badobjects
571 '
572
573 test_expect_success 'writing this tree without --missing-ok' '
574         test_must_fail git write-tree
575 '
576
577 test_expect_success 'writing this tree with --missing-ok' '
578         git write-tree --missing-ok
579 '
580
581
582 ################################################################
583 test_expect_success 'git read-tree followed by write-tree should be idempotent' '
584         rm -f .git/index
585         git read-tree $tree &&
586         test -f .git/index &&
587         newtree=$(git write-tree) &&
588         test "$newtree" = "$tree"
589 '
590
591 test_expect_success 'validate git diff-files output for a know cache/work tree state' '
592         $expectfilter >expected <<\EOF &&
593 :100644 100644 f87290f8eb2cbbea7857214459a0739927eab154 0000000000000000000000000000000000000000 M      path0
594 :120000 120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0000000000000000000000000000000000000000 M      path0sym
595 :100644 100644 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 0000000000000000000000000000000000000000 M      path2/file2
596 :120000 120000 d8ce161addc5173867a3c3c730924388daedbc38 0000000000000000000000000000000000000000 M      path2/file2sym
597 :100644 100644 0aa34cae68d0878578ad119c86ca2b5ed5b28376 0000000000000000000000000000000000000000 M      path3/file3
598 :120000 120000 8599103969b43aff7e430efea79ca4636466794f 0000000000000000000000000000000000000000 M      path3/file3sym
599 :100644 100644 00fb5908cb97c2564a9783c0c64087333b3b464f 0000000000000000000000000000000000000000 M      path3/subp3/file3
600 :120000 120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0000000000000000000000000000000000000000 M      path3/subp3/file3sym
601 EOF
602         git diff-files >current &&
603         test_cmp current expected
604 '
605
606 test_expect_success 'git update-index --refresh should succeed' '
607         git update-index --refresh
608 '
609
610 test_expect_success 'no diff after checkout and git update-index --refresh' '
611         git diff-files >current &&
612         cmp -s current /dev/null
613 '
614
615 ################################################################
616 P=$expectedtree
617
618 test_expect_success 'git commit-tree records the correct tree in a commit' '
619         commit0=$(echo NO | git commit-tree $P) &&
620         tree=$(git show --pretty=raw $commit0 |
621                  sed -n -e "s/^tree //p" -e "/^author /q") &&
622         test "z$tree" = "z$P"
623 '
624
625 test_expect_success 'git commit-tree records the correct parent in a commit' '
626         commit1=$(echo NO | git commit-tree $P -p $commit0) &&
627         parent=$(git show --pretty=raw $commit1 |
628                 sed -n -e "s/^parent //p" -e "/^author /q") &&
629         test "z$commit0" = "z$parent"
630 '
631
632 test_expect_success 'git commit-tree omits duplicated parent in a commit' '
633         commit2=$(echo NO | git commit-tree $P -p $commit0 -p $commit0) &&
634              parent=$(git show --pretty=raw $commit2 |
635                 sed -n -e "s/^parent //p" -e "/^author /q" |
636                 sort -u) &&
637         test "z$commit0" = "z$parent" &&
638         numparent=$(git show --pretty=raw $commit2 |
639                 sed -n -e "s/^parent //p" -e "/^author /q" |
640                 wc -l) &&
641         test $numparent = 1
642 '
643
644 test_expect_success 'update-index D/F conflict' '
645         mv path0 tmp &&
646         mv path2 path0 &&
647         mv tmp path2 &&
648         git update-index --add --replace path2 path0/file2 &&
649         numpath0=$(git ls-files path0 | wc -l) &&
650         test $numpath0 = 1
651 '
652
653 test_expect_success 'very long name in the index handled sanely' '
654
655         a=a && # 1
656         a=$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a && # 16
657         a=$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a && # 256
658         a=$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a && # 4096
659         a=${a}q &&
660
661         >path4 &&
662         git update-index --add path4 &&
663         (
664                 git ls-files -s path4 |
665                 sed -e "s/      .*/     /" |
666                 tr -d "\012"
667                 echo "$a"
668         ) | git update-index --index-info &&
669         len=$(git ls-files "a*" | wc -c) &&
670         test $len = 4098
671 '
672
673 test_done