(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <"test smart fetching over http via http-backend">)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./test-lib.sh)})
    (C {(.)} {(DQ ($ VSub_Name "$TEST_DIRECTORY")) (/lib-httpd.sh)})
    (C {(start_httpd)})
    (C {(test_expect_success)} {(SQ <"setup repository">)} 
      {
        (SQ <"\n"> <"\tgit config push.default matching &&\n"> <"\techo content >file &&\n"> 
          <"\tgit add file &&\n"> <"\tgit commit -m one\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"create http-accessible bare repository">)} 
      {
        (SQ <"\n"> <"\tmkdir \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n"> 
          <"\t(cd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n"> <"\t git --bare init\n"> <"\t) &&\n"> 
          <"\tgit remote add public \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n"> <"\tgit push public master:master\n">
        )
      }
    )
    (C {(setup_askpass_helper)})
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(exp)} spids:[60])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: 
            {
              (DQ ("> GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1\n") 
                ("> Accept: */*\n") ("> Accept-Encoding: gzip\n") ("> Pragma: no-cache\n") ("< HTTP/1.1 200 OK\n") ("< Pragma: no-cache\n") 
                ("< Cache-Control: no-cache, max-age=0, must-revalidate\n") ("< Content-Type: application/x-git-upload-pack-advertisement\n") 
                ("> POST /smart/repo.git/git-upload-pack HTTP/1.1\n") ("> Accept-Encoding: gzip\n") ("> Content-Type: application/x-git-upload-pack-request\n") 
                ("> Accept: application/x-git-upload-pack-result\n") ("> Content-Length: xxx\n") ("< HTTP/1.1 200 OK\n") ("< Pragma: no-cache\n") 
                ("< Cache-Control: no-cache, max-age=0, must-revalidate\n") ("< Content-Type: application/x-git-upload-pack-result\n")
              )
            }
          do_expansion: True
          here_end: EOF
          was_filled: True
          spids: [63]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <"clone http repository">)} 
      {
        (SQ <"\n"> 
          <"\tGIT_TRACE_CURL=true git clone --quiet $HTTPD_URL/smart/repo.git clone 2>err &&\n"> <"\ttest_cmp file clone/file &&\n"> <"\ttr ">
        ) (EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <"\\015">) 
        (EscapedLiteralPart token:<Lit_EscapedChar "\\'">) 
        (SQ <" Q <err |\n"> <"\tsed -e \"\n"> <"\t\ts/Q\\$//\n"> <"\t\t/^[*] /d\n"> 
          <"\t\t/^== Info:/d\n"> <"\t\t/^=> Send header, /d\n"> <"\t\t/^=> Send header:$/d\n"> <"\t\t/^<= Recv header, /d\n"> 
          <"\t\t/^<= Recv header:$/d\n"> <"\t\ts/=> Send header: //\n"> <"\t\ts/= Recv header://\n"> <"\t\t/^<= Recv data/d\n"> 
          <"\t\t/^=> Send data/d\n"> <"\t\t/^$/d\n"> <"\t\t/^< $/d\n"> <"\n"> <"\t\t/^[^><]/{\n"> <"\t\t\ts/^/> /\n"> <"\t\t}\n"> <"\n"> 
          <"\t\t/^> User-Agent: /d\n"> <"\t\t/^> Host: /d\n"> <"\t\t/^> POST /,$ {\n"> <"\t\t\t/^> Accept: [*]\\\\/[*]/d\n"> <"\t\t}\n"> 
          <"\t\ts/^> Content-Length: .*/> Content-Length: xxx/\n"> <"\t\t/^> 00..want /d\n"> <"\t\t/^> 00.*done/d\n"> <"\n"> <"\t\t/^< Server: /d\n"> 
          <"\t\t/^< Expires: /d\n"> <"\t\t/^< Date: /d\n"> <"\t\t/^< Content-Length: /d\n"> <"\t\t/^< Transfer-Encoding: /d\n"> 
          <"\t\" >act &&\n"> <"\ttest_cmp exp act\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"fetch changes via http">)} 
      {
        (SQ <"\n"> <"\techo content >>file &&\n"> <"\tgit commit -a -m two &&\n"> 
          <"\tgit push public &&\n"> <"\t(cd clone && git pull) &&\n"> <"\ttest_cmp file clone/file\n">
        )
      }
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(exp)} spids:[158])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: 
            {
              (DQ ("GET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200\n") 
                ("POST /smart/repo.git/git-upload-pack HTTP/1.1 200\n") ("GET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200\n") 
                ("POST /smart/repo.git/git-upload-pack HTTP/1.1 200\n")
              )
            }
          do_expansion: True
          here_end: EOF
          was_filled: True
          spids: [161]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <"used upload-pack service">)} 
      {
        (SQ <"\n"> <"\tsed -e \"\n"> <"\t\ts/^.* \\\"//\n"> <"\t\ts/\\\"//\n"> 
          <"\t\ts/ [1-9][0-9]*\\$//\n"> <"\t\ts/^GET /GET  /\n"> <"\t\" >act <\"$HTTPD_ROOT_PATH\"/access.log &&\n"> <"\ttest_cmp exp act\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"follow redirects (301)">)} 
      {(SQ <"\n"> <"\tgit clone $HTTPD_URL/smart-redir-perm/repo.git --quiet repo-p\n">)}
    )
    (C {(test_expect_success)} {(SQ <"follow redirects (302)">)} 
      {(SQ <"\n"> <"\tgit clone $HTTPD_URL/smart-redir-temp/repo.git --quiet repo-t\n">)}
    )
    (C {(test_expect_success)} {(SQ <"redirects re-root further requests">)} 
      {(SQ <"\n"> <"\tgit clone $HTTPD_URL/smart-redir-limited/repo.git repo-redir-limited\n">)}
    )
    (C {(test_expect_success)} {(SQ <"clone from password-protected repository">)} 
      {
        (SQ <"\n"> <"\techo two >expect &&\n"> <"\tset_askpass user@host pass@host &&\n"> 
          <"\tgit clone --bare \"$HTTPD_URL/auth/smart/repo.git\" smart-auth &&\n"> <"\texpect_askpass both user@host &&\n"> 
          <"\tgit --git-dir=smart-auth log -1 --format=%s >actual &&\n"> <"\ttest_cmp expect actual\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"clone from auth-only-for-push repository">)} 
      {
        (SQ <"\n"> <"\techo two >expect &&\n"> <"\tset_askpass wrong &&\n"> 
          <"\tgit clone --bare \"$HTTPD_URL/auth-push/smart/repo.git\" smart-noauth &&\n"> <"\texpect_askpass none &&\n"> <"\tgit --git-dir=smart-noauth log -1 --format=%s >actual &&\n"> 
          <"\ttest_cmp expect actual\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"clone from auth-only-for-objects repository">)} 
      {
        (SQ <"\n"> <"\techo two >expect &&\n"> <"\tset_askpass user@host pass@host &&\n"> 
          <"\tgit clone --bare \"$HTTPD_URL/auth-fetch/smart/repo.git\" half-auth &&\n"> <"\texpect_askpass both user@host &&\n"> <"\tgit --git-dir=half-auth log -1 --format=%s >actual &&\n"> 
          <"\ttest_cmp expect actual\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"no-op half-auth fetch does not require a password">)} 
      {
        (SQ <"\n"> <"\tset_askpass wrong &&\n"> <"\tgit --git-dir=half-auth fetch &&\n"> 
          <"\texpect_askpass none\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"redirects send auth to new location">)} 
      {
        (SQ <"\n"> <"\tset_askpass user@host pass@host &&\n"> 
          <"\tgit -c credential.useHttpPath=true \\\n"> <"\t  clone $HTTPD_URL/smart-redir-auth/repo.git repo-redir-auth &&\n"> 
          <"\texpect_askpass both user@host auth/smart/repo.git\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"disable dumb http on server">)} 
      {
        (SQ <"\n"> <"\tgit --git-dir=\"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" \\\n"> 
          <"\t\tconfig http.getanyfile false\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"GIT_SMART_HTTP can disable smart http">)} 
      {
        (SQ <"\n"> <"\t(GIT_SMART_HTTP=0 &&\n"> <"\t export GIT_SMART_HTTP &&\n"> <"\t cd clone &&\n"> 
          <"\t test_must_fail git fetch)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"invalid Content-Type rejected">)} 
      {
        (SQ <"\n"> <"\ttest_must_fail git clone $HTTPD_URL/broken_smart/repo.git 2>actual &&\n"> 
          <"\tgrep \"not valid:\" actual\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"create namespaced refs">)} 
      {
        (SQ <"\n"> <"\ttest_commit namespaced &&\n"> 
          <"\tgit push public HEAD:refs/namespaces/ns/refs/heads/master &&\n"> <"\tgit --git-dir=\"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" \\\n"> 
          <"\t\tsymbolic-ref refs/namespaces/ns/HEAD refs/namespaces/ns/refs/heads/master\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"smart clone respects namespace">)} 
      {
        (SQ <"\n"> <"\tgit clone \"$HTTPD_URL/smart_namespace/repo.git\" ns-smart &&\n"> 
          <"\techo namespaced >expect &&\n"> <"\tgit --git-dir=ns-smart/.git log -1 --format=%s >actual &&\n"> <"\ttest_cmp expect actual\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"dumb clone via http-backend respects namespace">)} 
      {
        (SQ <"\n"> <"\tgit --git-dir=\"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" \\\n"> 
          <"\t\tconfig http.getanyfile true &&\n"> <"\tGIT_SMART_HTTP=0 git clone \\\n"> <"\t\t\"$HTTPD_URL/smart_namespace/repo.git\" ns-dumb &&\n"> 
          <"\techo namespaced >expect &&\n"> <"\tgit --git-dir=ns-dumb/.git log -1 --format=%s >actual &&\n"> <"\ttest_cmp expect actual\n">
        )
      }
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(cookies.txt)} spids:[393])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: {(DQ ("127.0.0.1\tFALSE\t/smart_cookies/\tFALSE\t0\tothername\tothervalue\n"))}
          do_expansion: True
          here_end: EOF
          was_filled: True
          spids: [396]
        )
      ]
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(expect_cookies.txt)} spids:[402])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: 
            {
              (DQ ("\n") ("127.0.0.1\tFALSE\t/smart_cookies/\tFALSE\t0\tothername\tothervalue\n") 
                ("127.0.0.1\tFALSE\t/smart_cookies/repo.git/info/\tFALSE\t0\tname\tvalue\n")
              )
            }
          do_expansion: True
          here_end: EOF
          was_filled: True
          spids: [405]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <"cookies stored in http.cookiefile when http.savecookies set">)} 
      {
        (SQ <"\n"> <"\tgit config http.cookiefile cookies.txt &&\n"> 
          <"\tgit config http.savecookies true &&\n"> <"\tgit ls-remote $HTTPD_URL/smart_cookies/repo.git master &&\n"> 
          <"\ttail -3 cookies.txt >cookies_tail.txt &&\n"> <"\ttest_cmp expect_cookies.txt cookies_tail.txt\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"transfer.hiderefs works over smart-http">)} 
      {
        (SQ <"\n"> <"\ttest_commit hidden &&\n"> <"\ttest_commit visible &&\n"> 
          <"\tgit push public HEAD^:refs/heads/a HEAD:refs/heads/b &&\n"> <"\tgit --git-dir=\"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" \\\n"> 
          <"\t\tconfig transfer.hiderefs refs/heads/a &&\n"> <"\tgit clone --bare \"$HTTPD_URL/smart/repo.git\" hidden.git &&\n"> 
          <"\ttest_must_fail git -C hidden.git rev-parse --verify a &&\n"> <"\tgit -C hidden.git rev-parse --verify b\n">
        )
      }
    )
    (FuncDef
      name: create_tags
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (C {(rm)} {(-f)} {(marks)})
                (AndOr
                  children: [
                    (Pipeline
                      children: [
                        (ForEach
                          iter_name: i
                          iter_words: [
                            {
                              (CommandSubPart
                                command_list: 
                                  (CommandList
                                    children: [
                                      (C {(test_seq)} {(DQ ($ VSub_Number "$1"))} 
                                        {(DQ ($ VSub_Number "$2"))}
                                      )
                                    ]
                                  )
                                left_token: <Left_CommandSub "$(">
                                spids: [472 482]
                              )
                            }
                          ]
                          do_arg_iter: False
                          body: 
                            (DoGroup
                              children: [
                                (AndOr
                                  children: [
                                    (C {(echo)} 
                                      {
                                        (DQ ("commit refs/heads/too-many-refs-") ($ VSub_Number "$1"))
                                      }
                                    )
                                    (AndOr
                                      children: [
                                        (C {(echo)} {(DQ ("mark :") ($ VSub_Name "$i"))})
                                        (AndOr
                                          children: [
                                            (C {(echo)} 
                                              {
                                                (DQ ("committer git <git@example.com> ") 
                                                  ($ VSub_Name "$i") (" +0000")
                                                )
                                              }
                                            )
                                            (AndOr
                                              children: [
                                                (C {(echo)} {(DQ ("data 0"))})
                                                (AndOr
                                                  children: [
                                                    (C {(echo)} {(DQ ("M 644 inline bla.txt"))})
                                                    (AndOr
                                                      children: [
                                                        (C {(echo)} {(DQ ("data 4"))})
                                                        (AndOr
                                                          children: [
                                                            (C {(echo)} {(DQ (bla))})
                                                            (AndOr
                                                              children: [
                                                                (C {(echo)} 
                                                                  {
                                                                    (DQ 
                                                                      (
"reset refs/heads/too-many-refs-"
                                                                      ) ($ VSub_Number "$1")
                                                                    )
                                                                  }
                                                                )
                                                                (C {(echo)} 
                                                                  {
                                                                    (DQ ("from :") 
                                                                      ($ VSub_Number "$1")
                                                                    )
                                                                  }
                                                                )
                                                              ]
                                                              op_id: Op_DAmp
                                                            )
                                                          ]
                                                          op_id: Op_DAmp
                                                        )
                                                      ]
                                                      op_id: Op_DAmp
                                                    )
                                                  ]
                                                  op_id: Op_DAmp
                                                )
                                              ]
                                              op_id: Op_DAmp
                                            )
                                          ]
                                          op_id: Op_DAmp
                                        )
                                      ]
                                      op_id: Op_DAmp
                                    )
                                  ]
                                  op_id: Op_DAmp
                                )
                              ]
                              spids: [485 589]
                            )
                          spids: [471 -1]
                        )
                        (C {(git)} {(fast-import)} {(--export-marks) (Lit_Other "=") (marks)})
                      ]
                      negated: False
                    )
                    (AndOr
                      children: [
                        (Assignment
                          keyword: Assign_None
                          pairs: [
                            (assign_pair
                              lhs: (LhsName name:tag)
                              op: Equal
                              rhs: 
                                {
                                  (CommandSubPart
                                    command_list: 
                                      (CommandList
                                        children: [
                                          (C {(perl)} {(-e)} 
                                            {
                                              (DQ ("print ") 
                                                (EscapedLiteralPart
                                                  token: <Lit_EscapedChar "\\\"">
                                                ) (bla) (EscapedLiteralPart token:<Lit_EscapedChar "\\\"">) (" x 30")
                                              )
                                            }
                                          )
                                        ]
                                      )
                                    left_token: <Left_CommandSub "$(">
                                    spids: [610 622]
                                  )
                                }
                              spids: [609]
                            )
                          ]
                          spids: [609]
                        )
                        (SimpleCommand
                          words: [
                            {(sed)}
                            {(-e)}
                            {
                              (DQ ("s|^:") (EscapedLiteralPart token:<Lit_EscapedChar "\\(">) ("[^ ]*") 
                                (EscapedLiteralPart
                                  token: <Lit_EscapedChar "\\)">
                                ) (" ") (EscapedLiteralPart token:<Lit_EscapedChar "\\(">) (".*") 
                                (EscapedLiteralPart
                                  token: <Lit_EscapedChar "\\)">
                                ) (Lit_Other "$") ("|") (EscapedLiteralPart token:<Lit_EscapedChar "\\2">) (" refs/tags/") 
                                ($ VSub_Name "$tag") (-) (EscapedLiteralPart token:<Lit_EscapedChar "\\1">) ("|")
                              )
                            }
                          ]
                          redirects: [
                            (Redir
                              op_id: Redir_Less
                              fd: -1
                              arg_word: {(marks)}
                              spids: [650]
                            )
                            (Redir
                              op_id: Redir_DGreat
                              fd: -1
                              arg_word: {(packed-refs)}
                              spids: [653]
                            )
                          ]
                        )
                      ]
                      op_id: Op_DAmp
                    )
                  ]
                  op_id: Op_DAmp
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [454]
        )
      spids: [449 453]
    )
    (C {(test_expect_success)} {(SQ <"create 2,000 tags in the repo">)} 
      {
        (SQ <"\n"> <"\t(\n"> <"\t\tcd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n"> 
          <"\t\tcreate_tags 1 2000\n"> <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(CMDLINE_LIMIT)} 
      {(SQ <"clone the 2,000 tag repo to check OS command line overflow">)} 
      {
        (SQ <"\n"> 
          <"\trun_with_limited_cmdline git clone $HTTPD_URL/smart/repo.git too-many-refs &&\n"> <"\t(\n"> <"\t\tcd too-many-refs &&\n"> <"\t\tgit for-each-ref refs/tags >actual &&\n"> 
          <"\t\ttest_line_count = 2000 actual\n"> <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"large fetch-pack requests can be split across POSTs">)} 
      {
        (SQ <"\n"> <"\tGIT_TRACE_CURL=true git -c http.postbuffer=65536 \\\n"> 
          <"\t\tclone --bare \"$HTTPD_URL/smart/repo.git\" split.git 2>err &&\n"> <"\tgrep \"^=> Send header: POST\" err >posts &&\n"> <"\ttest_line_count = 2 posts\n">
        )
      }
    )
    (C {(test_expect_success)} {(EXPENSIVE)} {(SQ <"http can handle enormous ref negotiation">)} 
      {
        (SQ <"\n"> <"\t(\n"> <"\t\tcd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n"> 
          <"\t\tcreate_tags 2001 50000\n"> <"\t) &&\n"> <"\tgit -C too-many-refs fetch -q --tags &&\n"> <"\t(\n"> 
          <"\t\tcd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n"> <"\t\tcreate_tags 50001 100000\n"> <"\t) &&\n"> <"\tgit -C too-many-refs fetch -q --tags &&\n"> 
          <"\tgit -C too-many-refs for-each-ref refs/tags >tags &&\n"> <"\ttest_line_count = 100000 tags\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"custom http headers">)} 
      {
        (SQ <"\n"> <"\ttest_must_fail git -c http.extraheader=\"x-magic-two: cadabra\" \\\n"> 
          <"\t\tfetch \"$HTTPD_URL/smart_headers/repo.git\" &&\n"> <"\tgit -c http.extraheader=\"x-magic-one: abra\" \\\n"> 
          <"\t    -c http.extraheader=\"x-magic-two: cadabra\" \\\n"> <"\t    fetch \"$HTTPD_URL/smart_headers/repo.git\" &&\n"> 
          <"\tgit update-index --add --cacheinfo 160000,$(git rev-parse HEAD),sub &&\n"> <"\tgit config -f .gitmodules submodule.sub.path sub &&\n"> 
          <"\tgit config -f .gitmodules submodule.sub.url \\\n"> <"\t\t\"$HTTPD_URL/smart_headers/repo.git\" &&\n"> <"\tgit submodule init sub &&\n"> 
          <"\ttest_must_fail git submodule update sub &&\n"> <"\tgit -c http.extraheader=\"x-magic-one: abra\" \\\n"> 
          <"\t    -c http.extraheader=\"x-magic-two: cadabra\" \\\n"> <"\t\tsubmodule update sub\n">
        )
      }
    )
    (C {(stop_httpd)})
    (C {(test_done)})
  ]
)