(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: { (SQ <'\n'> <'Test pruning of repositories with minor corruptions. The goal\n'> <'here is that we should always be erring on the side of safety. So\n'> <'if we see, for example, a ref with a bogus name, it is OK either to\n'> <'bail out or to proceed using it as a reachable tip, but it is _not_\n'> <'OK to proceed as if it did not exist. Otherwise we might silently\n'> <'delete objects that cannot be recovered.\n'> ) } spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ <'disable reflogs'>)} { (SQ <'\n'> <'\tgit config core.logallrefupdates false &&\n'> <'\tgit reflog expire --expire=all --all\n'> ) } ) (C {(test_expect_success)} {(SQ <'create history reachable only from a bogus-named ref'>)} { (SQ <'\n'> <'\ttest_tick && git commit --allow-empty -m master &&\n'> <'\tbase=$(git rev-parse HEAD) &&\n'> <'\ttest_tick && git commit --allow-empty -m bogus &&\n'> <'\tbogus=$(git rev-parse HEAD) &&\n'> <'\tgit cat-file commit $bogus >saved &&\n'> <'\techo $bogus >.git/refs/heads/bogus..name &&\n'> <'\tgit reset --hard HEAD^\n'> ) } ) (C {(test_expect_success)} {(SQ <'pruning does not drop bogus object'>)} { (SQ <'\n'> <'\ttest_when_finished "git hash-object -w -t commit saved" &&\n'> <'\ttest_might_fail git prune --expire=now &&\n'> <'\tverbose git cat-file -e $bogus\n'> ) } ) (C {(test_expect_success)} {(SQ <'put bogus object into pack'>)} { (SQ <'\n'> <'\tgit tag reachable $bogus &&\n'> <'\tgit repack -ad &&\n'> <'\tgit tag -d reachable &&\n'> <'\tverbose git cat-file -e $bogus\n'> ) } ) (C {(test_expect_success)} {(SQ <'destructive repack keeps packed object'>)} { (SQ <'\n'> <'\ttest_might_fail git repack -Ad --unpack-unreachable=now &&\n'> <'\tverbose git cat-file -e $bogus &&\n'> <'\ttest_might_fail git repack -ad &&\n'> <'\tverbose git cat-file -e $bogus\n'> ) } ) (C {(test_expect_success)} {(SQ <'clean up bogus ref'>)} {(SQ <'\n'> <'\trm .git/refs/heads/bogus..name\n'>)} ) (C {(test_expect_success)} {(SQ <'create history with missing tip commit'>)} { (SQ <'\n'> <'\ttest_tick && git commit --allow-empty -m one &&\n'> <'\trecoverable=$(git rev-parse HEAD) &&\n'> <'\tgit cat-file commit $recoverable >saved &&\n'> <'\ttest_tick && git commit --allow-empty -m two &&\n'> <'\tmissing=$(git rev-parse HEAD) &&\n'> <'\tgit checkout --detach $base &&\n'> <'\trm .git/objects/$(echo $missing | sed "s,..,&/,") &&\n'> <'\ttest_must_fail git cat-file -e $missing\n'> ) } ) (C {(test_expect_success)} {(SQ <'pruning with a corrupted tip does not drop history'>)} { (SQ <'\n'> <'\ttest_when_finished "git hash-object -w -t commit saved" &&\n'> <'\ttest_might_fail git prune --expire=now &&\n'> <'\tverbose git cat-file -e $recoverable\n'> ) } ) (C {(test_expect_success)} {(SQ <'pack-refs does not silently delete broken loose ref'>)} { (SQ <'\n'> <'\tgit pack-refs --all --prune &&\n'> <'\techo $missing >expect &&\n'> <'\tgit rev-parse refs/heads/master >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {(test_expect_success)} {(SQ <'create packed-refs file with broken ref'>)} { (SQ <'\n'> <'\trm -f .git/refs/heads/master &&\n'> <'\tcat >.git/packed-refs <<-EOF &&\n'> <'\t$missing refs/heads/master\n'> <'\t$recoverable refs/heads/other\n'> <'\tEOF\n'> <'\techo $missing >expect &&\n'> <'\tgit rev-parse refs/heads/master >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {(test_expect_success)} {(SQ <'pack-refs does not silently delete broken packed ref'>)} { (SQ <'\n'> <'\tgit pack-refs --all --prune &&\n'> <'\tgit rev-parse refs/heads/master >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {(test_expect_success)} {(SQ <'pack-refs does not drop broken refs during deletion'>)} { (SQ <'\n'> <'\tgit update-ref -d refs/heads/other &&\n'> <'\tgit rev-parse refs/heads/master >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {(test_done)}) ] )