(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'test_description='> name:test_description) op: assign_op.Equal rhs: {(SQ <'.git file\n'> <'\n'> <'Verify that plumbing commands work when .git is a file\n'>)} spids: [4] ) ] redirects: [] ) (C {<.>} {<'./test-lib.sh'>}) (command.ShFunction name: objpath body: (BraceGroup left: <Id.Lit_LBrace '{'> children: [ (command.Pipeline children: [ (C {<echo>} {(DQ ($ Id.VSub_Number 1))}) (C {<sed>} {<-e>} {(SQ <'s|\\(..\\)|\\1/|'>)}) ] negated: F stderr_indices: [] ) ] redirects: [] right: <Id.Lit_RBrace '}'> ) ) (command.ShFunction name: objck body: (BraceGroup left: <Id.Lit_LBrace '{'> children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name left:<Id.Lit_VarLike 'p='> name:p) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<objpath>} {(DQ ($ Id.VSub_Number 1))}) right: <Id.Eof_RParen _> ) } spids: [49] ) ] redirects: [] ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (C {<test>} {<Id.KW_Bang '!'>} {<-f>} {(DQ ($ Id.VSub_DollarName REAL) <'/objects/'> ($ Id.VSub_DollarName p))} ) ] ) action: [ (C {<echo>} { (DQ <'Object not found: '> ($ Id.VSub_DollarName REAL) <'/objects/'> ($ Id.VSub_DollarName p) ) } ) (C {<false>}) ] spids: [59 74] ) ] else_action: [] redirects: [] ) ] redirects: [] right: <Id.Lit_RBrace '}'> ) ) (C {<test_expect_success>} {(SQ <'initial setup'>)} {(SQ <'\n'> <'\tREAL="$(pwd)/.real" &&\n'> <'\tmv .git "$REAL"\n'>)} ) (C {<test_expect_success>} {(SQ <'bad setup: invalid .git file format'>)} { (SQ <'\n'> <'\techo "gitdir $REAL" >.git &&\n'> <'\tif git rev-parse 2>.err\n'> <'\tthen\n'> <'\t\techo "git rev-parse accepted an invalid .git file"\n'> <'\t\tfalse\n'> <'\tfi &&\n'> <'\tif ! grep "Invalid gitfile format" .err\n'> <'\tthen\n'> <'\t\techo "git rev-parse returned wrong error"\n'> <'\t\tfalse\n'> <'\tfi\n'> ) } ) (C {<test_expect_success>} {(SQ <'bad setup: invalid .git file path'>)} { (SQ <'\n'> <'\techo "gitdir: $REAL.not" >.git &&\n'> <'\tif git rev-parse 2>.err\n'> <'\tthen\n'> <'\t\techo "git rev-parse accepted an invalid .git file path"\n'> <'\t\tfalse\n'> <'\tfi &&\n'> <'\tif ! grep "Not a git repository" .err\n'> <'\tthen\n'> <'\t\techo "git rev-parse returned wrong error"\n'> <'\t\tfalse\n'> <'\tfi\n'> ) } ) (C {<test_expect_success>} {(SQ <'final setup + check rev-parse --git-dir'>)} { (SQ <'\n'> <'\techo "gitdir: $REAL" >.git &&\n'> <'\ttest "$REAL" = "$(git rev-parse --git-dir)"\n'> ) } ) (C {<test_expect_success>} {(SQ <'check hash-object'>)} { (SQ <'\n'> <'\techo "foo" >bar &&\n'> <'\tSHA=$(cat bar | git hash-object -w --stdin) &&\n'> <'\tobjck $SHA\n'> ) } ) (C {<test_expect_success>} {(SQ <'check cat-file'>)} {(SQ <'\n'> <'\tgit cat-file blob $SHA >actual &&\n'> <'\ttest_cmp bar actual\n'>)} ) (C {<test_expect_success>} {(SQ <'check update-index'>)} { (SQ <'\n'> <'\tif test -f "$REAL/index"\n'> <'\tthen\n'> <'\t\techo "Hmm, $REAL/index exists?"\n'> <'\t\tfalse\n'> <'\tfi &&\n'> <'\trm -f "$REAL/objects/$(objpath $SHA)" &&\n'> <'\tgit update-index --add bar &&\n'> <'\tif ! test -f "$REAL/index"\n'> <'\tthen\n'> <'\t\techo "$REAL/index not found"\n'> <'\t\tfalse\n'> <'\tfi &&\n'> <'\tobjck $SHA\n'> ) } ) (C {<test_expect_success>} {(SQ <'check write-tree'>)} {(SQ <'\n'> <'\tSHA=$(git write-tree) &&\n'> <'\tobjck $SHA\n'>)} ) (C {<test_expect_success>} {(SQ <'check commit-tree'>)} {(SQ <'\n'> <'\tSHA=$(echo "commit bar" | git commit-tree $SHA) &&\n'> <'\tobjck $SHA\n'>)} ) (C {<test_expect_success>} {(SQ <'check rev-list'>)} {(SQ <'\n'> <'\techo $SHA >"$REAL/HEAD" &&\n'> <'\ttest "$SHA" = "$(git rev-list HEAD)"\n'>)} ) (C {<test_expect_success>} {(SQ <'setup_git_dir twice in subdir'>)} { (SQ <'\n'> <'\tgit init sgd &&\n'> <'\t(\n'> <'\t\tcd sgd &&\n'> <'\t\tgit config alias.lsfi ls-files &&\n'> <'\t\tmv .git .realgit &&\n'> <'\t\techo "gitdir: .realgit" >.git &&\n'> <'\t\tmkdir subdir &&\n'> <'\t\tcd subdir &&\n'> <'\t\t>foo &&\n'> <'\t\tgit add foo &&\n'> <'\t\tgit lsfi >actual &&\n'> <'\t\techo foo >expected &&\n'> <'\t\ttest_cmp expected actual\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'enter_repo non-strict mode'>)} { (SQ <'\n'> <'\ttest_create_repo enter_repo &&\n'> <'\t(\n'> <'\t\tcd enter_repo &&\n'> <'\t\ttest_tick &&\n'> <'\t\ttest_commit foo &&\n'> <'\t\tmv .git .realgit &&\n'> <'\t\techo "gitdir: .realgit" >.git\n'> <'\t) &&\n'> <'\tgit ls-remote enter_repo >actual &&\n'> <'\tcat >expected <<-\\EOF &&\n'> <'\t946e985ab20de757ca5b872b16d64e92ff3803a9\tHEAD\n'> <'\t946e985ab20de757ca5b872b16d64e92ff3803a9\trefs/heads/master\n'> <'\t946e985ab20de757ca5b872b16d64e92ff3803a9\trefs/tags/foo\n'> <'\tEOF\n'> <'\ttest_cmp expected actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'enter_repo linked checkout'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd enter_repo &&\n'> <'\t\tgit worktree add ../foo refs/tags/foo\n'> <'\t) &&\n'> <'\tgit ls-remote foo >actual &&\n'> <'\tcat >expected <<-\\EOF &&\n'> <'\t946e985ab20de757ca5b872b16d64e92ff3803a9\tHEAD\n'> <'\t946e985ab20de757ca5b872b16d64e92ff3803a9\trefs/heads/master\n'> <'\t946e985ab20de757ca5b872b16d64e92ff3803a9\trefs/tags/foo\n'> <'\tEOF\n'> <'\ttest_cmp expected actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'enter_repo strict mode'>)} { (SQ <'\n'> <'\tgit ls-remote --upload-pack="git upload-pack --strict" foo/.git >actual &&\n'> <'\tcat >expected <<-\\EOF &&\n'> <'\t946e985ab20de757ca5b872b16d64e92ff3803a9\tHEAD\n'> <'\t946e985ab20de757ca5b872b16d64e92ff3803a9\trefs/heads/master\n'> <'\t946e985ab20de757ca5b872b16d64e92ff3803a9\trefs/tags/foo\n'> <'\tEOF\n'> <'\ttest_cmp expected actual\n'> ) } ) (C {<test_done>}) ] )