(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: {(SQ <'test git rev-parse diagnosis for invalid argument'>)}
          spids: [4]
        )
      ]
    )
    (command.Simple
      words: [{<exec>}]
      redirects: [(redir op:<Id.Redir_Less '<'> loc:(redir_loc.Fd fd:0) arg:{<'/dev/null'>})]
      do_fork: T
    )
    (C {<.>} {<'./test-lib.sh'>})
    (command.ShFunction
      name: test_did_you_mean
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DAmp Id.Op_DAmp]
              children: [
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:sq)
                      op: assign_op.Equal
                      rhs: {(DQ <'\''>)}
                      spids: [29]
                    )
                  ]
                )
                (command.Simple
                  words: [{<cat>}]
                  redirects: [
                    (redir
                      op: <Id.Redir_Great '>'>
                      loc: (redir_loc.Fd fd:1)
                      arg: {<expected>}
                    )
                    (redir
                      op: <Id.Redir_DLessDash '<<-'>
                      loc: (redir_loc.Fd fd:0)
                      arg: 
                        (redir_param.MultiLine
                          here_begin: {<EOF>}
                          here_end_span_id: 80
                          stdin_parts: [
                            <'fatal: Path \''>
                            ($ Id.VSub_Number '$2')
                            ($ Id.VSub_Number '$3')
                            <'\' '>
                            ($ Id.VSub_Number '$4')
                            <', but not '>
                            (braced_var_sub
                              token: <Id.VSub_Number 5>
                              suffix_op: 
                                (suffix_op.Unary
                                  op_id: Id.VTest_ColonHyphen
                                  arg_word: 
                                    {($ Id.VSub_DollarName '$sq') ($ Id.VSub_Number '$3') 
                                      ($ Id.VSub_DollarName '$sq')
                                    }
                                )
                            )
                            <'.\n'>
                            <'Did you mean \''>
                            ($ Id.VSub_Number '$1')
                            <':'>
                            ($ Id.VSub_Number '$2')
                            ($ Id.VSub_Number '$3')
                            <'\''>
                            (braced_var_sub
                              token: <Id.VSub_Number 2>
                              suffix_op: 
                                (suffix_op.Unary
                                  op_id: Id.VTest_ColonPlus
                                  arg_word: 
                                    {<' aka '> ($ Id.VSub_DollarName '$sq') ($ Id.VSub_Number '$1') 
                                      <':.'> <Id.Lit_Slash '/'> ($ Id.VSub_Number '$3') ($ Id.VSub_DollarName '$sq')
                                    }
                                )
                            )
                            <'?\n'>
                          ]
                        )
                    )
                  ]
                  do_fork: T
                )
                (C {<test_cmp>} {<expected>} {<error>})
              ]
            )
          ]
        )
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:HASH_file)
          op: assign_op.Equal
          rhs: (word.Empty)
          spids: [91]
        )
      ]
    )
    (C {<test_expect_success>} {(SQ <'set up basic repo'>)} 
      {
        (SQ <'\n'> <'\techo one > file.txt &&\n'> <'\tmkdir subdir &&\n'> 
          <'\techo two > subdir/file.txt &&\n'> <'\techo three > subdir/file2.txt &&\n'> <'\tgit add . &&\n'> <'\tgit commit -m init &&\n'> 
          <'\techo four > index-only.txt &&\n'> <'\tgit add index-only.txt &&\n'> <'\techo five > disk-only.txt\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'correct file objects'>)} 
      {
        (SQ <'\n'> <'\tHASH_file=$(git rev-parse HEAD:file.txt) &&\n'> 
          <'\tgit rev-parse HEAD:subdir/file.txt &&\n'> <'\tgit rev-parse :index-only.txt &&\n'> <'\t(cd subdir &&\n'> 
          <'\t git rev-parse HEAD:subdir/file2.txt &&\n'> <'\t test $HASH_file = $(git rev-parse HEAD:file.txt) &&\n'> 
          <'\t test $HASH_file = $(git rev-parse :file.txt) &&\n'> <'\t test $HASH_file = $(git rev-parse :0:file.txt) )\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'correct relative file objects (0)'>)} 
      {
        (SQ <'\n'> <'\tgit rev-parse :file.txt >expected &&\n'> 
          <'\tgit rev-parse :./file.txt >result &&\n'> <'\ttest_cmp expected result &&\n'> <'\tgit rev-parse :0:./file.txt >result &&\n'> 
          <'\ttest_cmp expected result\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'correct relative file objects (1)'>)} 
      {
        (SQ <'\n'> <'\tgit rev-parse HEAD:file.txt >expected &&\n'> 
          <'\tgit rev-parse HEAD:./file.txt >result &&\n'> <'\ttest_cmp expected result\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'correct relative file objects (2)'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd subdir &&\n'> <'\t\tgit rev-parse HEAD:../file.txt >result &&\n'> 
          <'\t\ttest_cmp ../expected result\n'> <'\t)\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'correct relative file objects (3)'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd subdir &&\n'> 
          <'\t\tgit rev-parse HEAD:../subdir/../file.txt >result &&\n'> <'\t\ttest_cmp ../expected result\n'> <'\t)\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'correct relative file objects (4)'>)} 
      {
        (SQ <'\n'> <'\tgit rev-parse HEAD:subdir/file.txt >expected &&\n'> <'\t(\n'> 
          <'\t\tcd subdir &&\n'> <'\t\tgit rev-parse HEAD:./file.txt >result &&\n'> <'\t\ttest_cmp ../expected result\n'> <'\t)\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'correct relative file objects (5)'>)} 
      {
        (SQ <'\n'> <'\tgit rev-parse :subdir/file.txt >expected &&\n'> <'\t(\n'> <'\t\tcd subdir &&\n'> 
          <'\t\tgit rev-parse :./file.txt >result &&\n'> <'\t\ttest_cmp ../expected result &&\n'> <'\t\tgit rev-parse :0:./file.txt >result &&\n'> 
          <'\t\ttest_cmp ../expected result\n'> <'\t)\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'correct relative file objects (6)'>)} 
      {
        (SQ <'\n'> <'\tgit rev-parse :file.txt >expected &&\n'> <'\t(\n'> <'\t\tcd subdir &&\n'> 
          <'\t\tgit rev-parse :../file.txt >result &&\n'> <'\t\ttest_cmp ../expected result &&\n'> <'\t\tgit rev-parse :0:../file.txt >result &&\n'> 
          <'\t\ttest_cmp ../expected result\n'> <'\t)\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'incorrect revision id'>)} 
      {
        (SQ <'\n'> <'\ttest_must_fail git rev-parse foobar:file.txt 2>error &&\n'> 
          <'\tgrep "Invalid object name '>
        ) (DQ <'\''>) (SQ <foobar>) (DQ <'\''>) 
        (SQ <'." error &&\n'> <'\ttest_must_fail git rev-parse foobar 2> error &&\n'> 
          <'\ttest_i18ngrep "unknown revision or path not in the working tree." error\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'incorrect file in sha1:path'>)} 
      {
        (SQ <'\n'> <'\ttest_must_fail git rev-parse HEAD:nothing.txt 2> error &&\n'> 
          <'\tgrep "fatal: Path '>
        ) (DQ <'\''>) (SQ <nothing.txt>) (DQ <'\''>) (SQ <' does not exist in '>) (DQ <'\''>) (SQ <HEAD>) (DQ <'\''>) 
        (SQ <'" error &&\n'> <'\ttest_must_fail git rev-parse HEAD:index-only.txt 2> error &&\n'> 
          <'\tgrep "fatal: Path '>
        ) (DQ <'\''>) (SQ <index-only.txt>) (DQ <'\''>) (SQ <' exists on disk, but not in '>) (DQ <'\''>) (SQ <HEAD>) 
        (DQ <'\''>) 
        (SQ <'." error &&\n'> <'\t(cd subdir &&\n'> 
          <'\t test_must_fail git rev-parse HEAD:file2.txt 2> error &&\n'> <'\t test_did_you_mean HEAD subdir/ file2.txt exists )\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'incorrect file in :path and :N:path'>)} 
      {
        (SQ <'\n'> <'\ttest_must_fail git rev-parse :nothing.txt 2> error &&\n'> 
          <'\tgrep "fatal: Path '>
        ) (DQ <'\''>) (SQ <nothing.txt>) (DQ <'\''>) 
        (SQ <' does not exist (neither on disk nor in the index)." error &&\n'> 
          <'\ttest_must_fail git rev-parse :1:nothing.txt 2> error &&\n'> <'\tgrep "Path '>
        ) (DQ <'\''>) (SQ <nothing.txt>) (DQ <'\''>) 
        (SQ <' does not exist (neither on disk nor in the index)." error &&\n'> 
          <'\ttest_must_fail git rev-parse :1:file.txt 2> error &&\n'> <'\ttest_did_you_mean ":0" "" file.txt "is in the index" "at stage 1" &&\n'> <'\t(cd subdir &&\n'> 
          <'\t test_must_fail git rev-parse :1:file.txt 2> error &&\n'> <'\t test_did_you_mean ":0" "" file.txt "is in the index" "at stage 1" &&\n'> 
          <'\t test_must_fail git rev-parse :file2.txt 2> error &&\n'> <'\t test_did_you_mean ":0" subdir/ file2.txt "is in the index" &&\n'> 
          <'\t test_must_fail git rev-parse :2:file2.txt 2> error &&\n'> <'\t test_did_you_mean :0 subdir/ file2.txt "is in the index") &&\n'> 
          <'\ttest_must_fail git rev-parse :disk-only.txt 2> error &&\n'> <'\tgrep "fatal: Path '>
        ) (DQ <'\''>) (SQ <disk-only.txt>) (DQ <'\''>) (SQ <' exists on disk, but not in the index." error\n'>)
      }
    )
    (C {<test_expect_success>} {(SQ <'invalid @{n} reference'>)} 
      {
        (SQ <'\n'> <'\ttest_must_fail git rev-parse master@{99999} >output 2>error &&\n'> 
          <'\ttest -z "$(cat output)" &&\n'> <'\tgrep "fatal: Log for [^ ]* only has [0-9][0-9]* entries." error  &&\n'> 
          <'\ttest_must_fail git rev-parse --verify master@{99999} >output 2>error &&\n'> <'\ttest -z "$(cat output)" &&\n'> 
          <'\tgrep "fatal: Log for [^ ]* only has [0-9][0-9]* entries." error\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'relative path not found'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd subdir &&\n'> 
          <'\t\ttest_must_fail git rev-parse HEAD:./nonexistent.txt 2>error &&\n'> <'\t\tgrep subdir/nonexistent.txt error\n'> <'\t)\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'relative path outside worktree'>)} 
      {
        (SQ <'\n'> <'\ttest_must_fail git rev-parse HEAD:../file.txt >output 2>error &&\n'> 
          <'\ttest -z "$(cat output)" &&\n'> <'\tgrep "outside repository" error\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'relative path when cwd is outside worktree'>)} 
      {
        (SQ <'\n'> 
          <
'\ttest_must_fail git --git-dir=.git --work-tree=subdir rev-parse HEAD:./file.txt >output 2>error &&\n'
          > <'\ttest -z "$(cat output)" &&\n'> 
          <'\tgrep "relative path syntax can.t be used outside working tree." error\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'<commit>:file correctly diagnosed after a pathname'>)} 
      {
        (SQ <'\n'> <'\ttest_must_fail git rev-parse file.txt HEAD:file.txt 1>actual 2>error &&\n'> 
          <'\ttest_i18ngrep ! "exists on disk" error &&\n'> <'\ttest_i18ngrep "no such path in the working tree" error &&\n'> <'\tcat >expect <<-\\EOF &&\n'> 
          <'\tfile.txt\n'> <'\tHEAD:file.txt\n'> <'\tEOF\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'dotdot is not an empty set'>)} 
      {
        (SQ <'\n'> <'\t( H=$(git rev-parse HEAD) && echo $H && echo ^$H ) >expect &&\n'> <'\n'> 
          <'\tgit rev-parse HEAD.. >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\n'> <'\tgit rev-parse ..HEAD >actual &&\n'> 
          <'\ttest_cmp expect actual &&\n'> <'\n'> <'\techo .. >expect &&\n'> <'\tgit rev-parse .. >actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'arg before dashdash must be a revision (missing)'>)} 
      {
        (SQ <'\n'> <'\ttest_must_fail git rev-parse foobar -- 2>stderr &&\n'> 
          <'\ttest_i18ngrep "bad revision" stderr\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'arg before dashdash must be a revision (file)'>)} 
      {
        (SQ <'\n'> <'\t>foobar &&\n'> <'\ttest_must_fail git rev-parse foobar -- 2>stderr &&\n'> 
          <'\ttest_i18ngrep "bad revision" stderr\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'arg before dashdash must be a revision (ambiguous)'>)} 
      {
        (SQ <'\n'> <'\t>foobar &&\n'> <'\tgit update-ref refs/heads/foobar HEAD &&\n'> <'\t{\n'> 
          <'\t\t# we do not want to use rev-parse here, because\n'> <'\t\t# we are testing it\n'> <'\t\tcat .git/refs/heads/foobar &&\n'> <'\t\tprintf "%s\\n" --\n'> 
          <'\t} >expect &&\n'> <'\tgit rev-parse foobar -- >actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_done>})
  ]
)