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