(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <"test git rev-parse diagnosis for invalid argument">)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (SimpleCommand
      words: [{(exec)}]
      redirects: [(Redir op_id:Redir_Less fd:-1 arg_word:{(/dev/null)} spids:[12])]
    )
    (C {(.)} {(./test-lib.sh)})
    (FuncDef
      name: test_did_you_mean
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (Assignment
                  keyword: Assign_None
                  pairs: [(assign_pair lhs:(LhsName name:sq) op:Equal rhs:{(DQ ("'"))} spids:[29])]
                  spids: [29]
                )
                (AndOr
                  children: [
                    (SimpleCommand
                      words: [{(cat)}]
                      redirects: [
                        (Redir
                          op_id: Redir_Great
                          fd: -1
                          arg_word: {(expected)}
                          spids: [39]
                        )
                        (HereDoc
                          op_id: Redir_DLessDash
                          fd: -1
                          body: 
                            {
                              (DQ ("fatal: Path '") ($ VSub_Number "$2") ($ VSub_Number "$3") ("' ") 
                                ($ VSub_Number "$4") (", but not ") 
                                (BracedVarSub
                                  token: <VSub_Number 5>
                                  suffix_op: 
                                    (StringUnary
                                      op_id: VTest_ColonHyphen
                                      arg_word: 
                                        {($ VSub_Name "$sq") ($ VSub_Number "$3") ($ VSub_Name "$sq")}
                                    )
                                  spids: [53 59]
                                ) (".\n") ("Did you mean '") ($ VSub_Number "$1") (":") ($ VSub_Number "$2") ($ VSub_Number "$3") ("'") 
                                (BracedVarSub
                                  token: <VSub_Number 2>
                                  suffix_op: 
                                    (StringUnary
                                      op_id: VTest_ColonPlus
                                      arg_word: 
                                        {(" aka ") ($ VSub_Name "$sq") ($ VSub_Number "$1") (":.") 
                                          (Lit_Slash /) ($ VSub_Number "$3") ($ VSub_Name "$sq")
                                        }
                                    )
                                  spids: [67 77]
                                ) ("?\n")
                              )
                            }
                          do_expansion: True
                          here_end: EOF
                          was_filled: True
                          spids: [42]
                        )
                      ]
                    )
                    (C {(test_cmp)} {(expected)} {(error)})
                  ]
                  op_id: Op_DAmp
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [26]
        )
      spids: [21 25]
    )
    (Assignment
      keyword: Assign_None
      pairs: [(assign_pair lhs:(LhsName name:HASH_file) op:Equal rhs:{(SQ )} spids:[89])]
      spids: [89]
    )
    (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)})
  ]
)