(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <'test dumb fetching over http via static file'>)}
          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 content1 >file &&\n'> 
          <'\tgit add file &&\n'> <'\tgit commit -m one &&\n'> <'\techo content2 >file &&\n'> <'\tgit add file &&\n'> 
          <'\tgit commit -m two\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'create http-accessible bare repository with loose objects'>)} 
      {
        (SQ <'\n'> <'\tcp -R .git "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&\n'> 
          <'\t(cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&\n'> <'\t git config core.bare true &&\n'> <'\t mkdir -p hooks &&\n'> 
          <'\t echo "exec git update-server-info" >hooks/post-update &&\n'> <'\t chmod +x hooks/post-update &&\n'> <'\t hooks/post-update\n'> <'\t) &&\n'> 
          <'\tgit remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&\n'> <'\tgit push public master:master\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'clone http repository'>)} 
      {
        (SQ <'\n'> <'\tgit clone $HTTPD_URL/dumb/repo.git clone-tmpl &&\n'> 
          <'\tcp -R clone-tmpl clone &&\n'> <'\ttest_cmp file clone/file\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'create password-protected repository'>)} 
      {
        (SQ <'\n'> <'\tmkdir -p "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/" &&\n'> 
          <'\tcp -Rf "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \\\n'> <'\t       "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/repo.git"\n'>
        )
      }
    )
    (C {(setup_askpass_helper)})
    (C {(test_expect_success)} {(SQ <'cloning password-protected repository can fail'>)} 
      {
        (SQ <'\n'> <'\tset_askpass wrong &&\n'> 
          <'\ttest_must_fail git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-fail &&\n'> <'\texpect_askpass both wrong\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'http auth can use user/pass in URL'>)} 
      {
        (SQ <'\n'> <'\tset_askpass wrong &&\n'> 
          <'\tgit clone "$HTTPD_URL_USER_PASS/auth/dumb/repo.git" clone-auth-none &&\n'> <'\texpect_askpass none\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'http auth can use just user in URL'>)} 
      {
        (SQ <'\n'> <'\tset_askpass wrong pass@host &&\n'> 
          <'\tgit clone "$HTTPD_URL_USER/auth/dumb/repo.git" clone-auth-pass &&\n'> <'\texpect_askpass pass user@host\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'http auth can request both user and pass'>)} 
      {
        (SQ <'\n'> <'\tset_askpass user@host pass@host &&\n'> 
          <'\tgit clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-both &&\n'> <'\texpect_askpass both user@host\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'http auth respects credential helper config'>)} 
      {
        (SQ <'\n'> <'\ttest_config_global credential.helper "!f() {\n'> <'\t\tcat >/dev/null\n'> 
          <'\t\techo username=user@host\n'> <'\t\techo password=pass@host\n'> <'\t}; f" &&\n'> <'\tset_askpass wrong &&\n'> 
          <'\tgit clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-helper &&\n'> <'\texpect_askpass none\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'http auth can get username from config'>)} 
      {
        (SQ <'\n'> <'\ttest_config_global "credential.$HTTPD_URL.username" user@host &&\n'> 
          <'\tset_askpass wrong pass@host &&\n'> <'\tgit clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-user &&\n'> 
          <'\texpect_askpass pass user@host\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'configured username does not override URL'>)} 
      {
        (SQ <'\n'> <'\ttest_config_global "credential.$HTTPD_URL.username" wrong &&\n'> 
          <'\tset_askpass wrong pass@host &&\n'> <'\tgit clone "$HTTPD_URL_USER/auth/dumb/repo.git" clone-auth-user2 &&\n'> 
          <'\texpect_askpass pass user@host\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'set up repo with http submodules'>)} 
      {
        (SQ <'\n'> <'\tgit init super &&\n'> <'\tset_askpass user@host pass@host &&\n'> <'\t(\n'> 
          <'\t\tcd super &&\n'> <'\t\tgit submodule add "$HTTPD_URL/auth/dumb/repo.git" sub &&\n'> 
          <'\t\tgit commit -m "add submodule"\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'cmdline credential config passes to submodule via clone'>)} 
      {
        (SQ <'\n'> <'\tset_askpass wrong pass@host &&\n'> 
          <'\ttest_must_fail git clone --recursive super super-clone &&\n'> <'\trm -rf super-clone &&\n'> <'\n'> <'\tset_askpass wrong pass@host &&\n'> 
          <'\tgit -c "credential.$HTTPD_URL.username=user@host" \\\n'> <'\t\tclone --recursive super super-clone &&\n'> <'\texpect_askpass pass user@host\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'cmdline credential config passes submodule via fetch'>)} 
      {
        (SQ <'\n'> <'\tset_askpass wrong pass@host &&\n'> 
          <'\ttest_must_fail git -C super-clone fetch --recurse-submodules &&\n'> <'\n'> <'\tset_askpass wrong pass@host &&\n'> <'\tgit -C super-clone \\\n'> 
          <'\t    -c "credential.$HTTPD_URL.username=user@host" \\\n'> <'\t    fetch --recurse-submodules &&\n'> <'\texpect_askpass pass user@host\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'cmdline credential config passes submodule update'>)} 
      {
        (SQ <'\n'> <'\t# advance the submodule HEAD so that a fetch is required\n'> 
          <'\tgit commit --allow-empty -m foo &&\n'> <'\tgit push "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/repo.git" HEAD &&\n'> 
          <'\tsha1=$(git rev-parse HEAD) &&\n'> <'\tgit -C super-clone update-index --cacheinfo 160000,$sha1,sub &&\n'> <'\n'> 
          <'\tset_askpass wrong pass@host &&\n'> <'\ttest_must_fail git -C super-clone submodule update &&\n'> <'\n'> 
          <'\tset_askpass wrong pass@host &&\n'> <'\tgit -C super-clone \\\n'> <'\t    -c "credential.$HTTPD_URL.username=user@host" \\\n'> 
          <'\t    submodule update &&\n'> <'\texpect_askpass pass user@host\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'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fetch changes via manual http-fetch'>)} 
      {
        (SQ <'\n'> <'\tcp -R clone-tmpl clone2 &&\n'> <'\n'> 
          <'\tHEAD=$(git rev-parse --verify HEAD) &&\n'> <'\t(cd clone2 &&\n'> 
          <'\t git http-fetch -a -w heads/master-new $HEAD $(git config remote.origin.url) &&\n'> <'\t git checkout master-new &&\n'> <'\t test $HEAD = $(git rev-parse --verify HEAD)) &&\n'> 
          <'\ttest_cmp file clone2/file\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'http remote detects correct HEAD'>)} 
      {
        (SQ <'\n'> <'\tgit push public master:other &&\n'> <'\t(cd clone &&\n'> 
          <'\t git remote set-head origin -d &&\n'> <'\t git remote set-head origin -a &&\n'> 
          <'\t git symbolic-ref refs/remotes/origin/HEAD > output &&\n'> <'\t echo refs/remotes/origin/master > expect &&\n'> <'\t test_cmp expect output\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fetch packed objects'>)} 
      {
        (SQ <'\n'> 
          <
'\tcp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git &&\n'
          > <'\t(cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git &&\n'> <'\t git --bare repack -a -d\n'> <'\t) &&\n'> 
          <'\tgit clone $HTTPD_URL/dumb/repo_pack.git\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fetch notices corrupt pack'>)} 
      {
        (SQ <'\n'> 
          <
'\tcp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git &&\n'
          > <'\t(cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git &&\n'> <'\t p=$(ls objects/pack/pack-*.pack) &&\n'> 
          <'\t chmod u+w $p &&\n'> <'\t printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc\n'> <'\t) &&\n'> 
          <'\tmkdir repo_bad1.git &&\n'> <'\t(cd repo_bad1.git &&\n'> <'\t git --bare init &&\n'> 
          <'\t test_must_fail git --bare fetch $HTTPD_URL/dumb/repo_bad1.git &&\n'> <'\t test 0 = $(ls objects/pack/pack-*.pack | wc -l)\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fetch notices corrupt idx'>)} 
      {
        (SQ <'\n'> 
          <
'\tcp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad2.git &&\n'
          > <'\t(cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad2.git &&\n'> <'\t p=$(ls objects/pack/pack-*.idx) &&\n'> 
          <'\t chmod u+w $p &&\n'> <'\t printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc\n'> <'\t) &&\n'> 
          <'\tmkdir repo_bad2.git &&\n'> <'\t(cd repo_bad2.git &&\n'> <'\t git --bare init &&\n'> 
          <'\t test_must_fail git --bare fetch $HTTPD_URL/dumb/repo_bad2.git &&\n'> <'\t test 0 = $(ls objects/pack | wc -l)\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fetch can handle previously-fetched .idx files'>)} 
      {
        (SQ <'\n'> <'\tgit checkout --orphan branch1 &&\n'> <'\techo base >file &&\n'> 
          <'\tgit add file &&\n'> <'\tgit commit -m base &&\n'> 
          <'\tgit --bare init "$HTTPD_DOCUMENT_ROOT_PATH"/repo_packed_branches.git &&\n'> <'\tgit push "$HTTPD_DOCUMENT_ROOT_PATH"/repo_packed_branches.git branch1 &&\n'> 
          <'\tgit --git-dir="$HTTPD_DOCUMENT_ROOT_PATH"/repo_packed_branches.git repack -d &&\n'> <'\tgit checkout -b branch2 branch1 &&\n'> <'\techo b2 >>file &&\n'> <'\tgit commit -a -m b2 &&\n'> 
          <'\tgit push "$HTTPD_DOCUMENT_ROOT_PATH"/repo_packed_branches.git branch2 &&\n'> <'\tgit --git-dir="$HTTPD_DOCUMENT_ROOT_PATH"/repo_packed_branches.git repack -d &&\n'> 
          <'\tgit --bare init clone_packed_branches.git &&\n'> 
          <
'\tgit --git-dir=clone_packed_branches.git fetch "$HTTPD_URL"/dumb/repo_packed_branches.git branch1:branch1 &&\n'
          > 
          <
'\tgit --git-dir=clone_packed_branches.git fetch "$HTTPD_URL"/dumb/repo_packed_branches.git branch2:branch2\n'
          >
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'did not use upload-pack service'>)} 
      {(SQ <'\n'> <'\ttest_might_fail grep '>) (/git-upload-pack) 
        (SQ <' <"$HTTPD_ROOT_PATH"/access.log >act &&\n'> <'\t: >exp &&\n'> <'\ttest_cmp exp act\n'>)
      }
    )
    (C {(test_expect_success)} {(SQ <'git client shows text/plain errors'>)} 
      {
        (SQ <'\n'> <'\ttest_must_fail git clone "$HTTPD_URL/error/text" 2>stderr &&\n'> 
          <'\tgrep "this is the error message" stderr\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'git client does not show html errors'>)} 
      {
        (SQ <'\n'> <'\ttest_must_fail git clone "$HTTPD_URL/error/html" 2>stderr &&\n'> 
          <'\t! grep "this is the error message" stderr\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'git client shows text/plain with a charset'>)} 
      {
        (SQ <'\n'> <'\ttest_must_fail git clone "$HTTPD_URL/error/charset" 2>stderr &&\n'> 
          <'\tgrep "this is the error message" stderr\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'http error messages are reencoded'>)} 
      {
        (SQ <'\n'> <'\ttest_must_fail git clone "$HTTPD_URL/error/utf16" 2>stderr &&\n'> 
          <'\tgrep "this is the error message" stderr\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'reencoding is robust to whitespace oddities'>)} 
      {
        (SQ <'\n'> <'\ttest_must_fail git clone "$HTTPD_URL/error/odd-spacing" 2>stderr &&\n'> 
          <'\tgrep "this is the error message" stderr\n'>
        )
      }
    )
    (FuncDef
      name: check_language
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (Case
                  to_match: {(DQ ($ VSub_Number '$2'))}
                  arms: [
                    (case_arm
                      pat_list: [{(SQ )}]
                      action: [
                        (SimpleCommand
                          redirects: [
                            (Redir
                              op_id: Redir_Great
                              fd: 16777215
                              arg_word: {(expect)}
                              spids: [526]
                            )
                          ]
                        )
                      ]
                      spids: [16777215 523 530 16777215]
                    )
                    (case_arm
                      pat_list: [{(Lit_Other '?') (Lit_Other '*')}]
                      action: [
                        (SimpleCommand
                          words: [
                            {(echo)}
                            {(DQ ('=> Send header: Accept-Language: ') ($ VSub_Number '$1'))}
                          ]
                          redirects: [
                            (Redir
                              op_id: Redir_Great
                              fd: 16777215
                              arg_word: {(expect)}
                              spids: [545]
                            )
                          ]
                        )
                      ]
                      spids: [533 535 549 16777215]
                    )
                  ]
                  spids: [512 518 552]
                )
                (AndOr
                  children: [
                    (SimpleCommand
                      words: [{(git)} {(ls-remote)} {(DQ ($ VSub_Name '$HTTPD_URL') (/dumb/repo.git))}]
                      redirects: [
                        (Redir
                          op_id: Redir_Great
                          fd: 16777215
                          arg_word: {(output)}
                          spids: [576]
                        )
                        (Redir
                          op_id: Redir_GreatAnd
                          fd: 2
                          arg_word: {(1)}
                          spids: [579]
                        )
                      ]
                      more_env: [
                        (env_pair
                          name: GIT_TRACE_CURL
                          val: {(true)}
                          spids: [557]
                        )
                        (env_pair
                          name: LANGUAGE
                          val: {($ VSub_Number '$2')}
                          spids: [562]
                        )
                      ]
                    )
                    (AndOr
                      children: [
                        (Pipeline
                          children: [
                            (SimpleCommand
                              words: [{(tr)} {(-d)} {(SQ <'\\015'>)}]
                              redirects: [
                                (Redir
                                  op_id: Redir_Less
                                  fd: 16777215
                                  arg_word: {(output)}
                                  spids: [593]
                                )
                              ]
                            )
                            (C {(sort)} {(-u)})
                            (SimpleCommand
                              words: [{(sed)} {(-ne)} {(SQ <'/^=> Send header: Accept-Language:/ p'>)}]
                              redirects: [
                                (Redir
                                  op_id: Redir_Great
                                  fd: 16777215
                                  arg_word: {(actual)}
                                  spids: [614]
                                )
                              ]
                            )
                          ]
                          negated: False
                        )
                        (C {(test_cmp)} {(expect)} {(actual)})
                      ]
                      op_id: Op_DAmp
                    )
                  ]
                  op_id: Op_DAmp
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [509]
        )
      spids: [504 508]
    )
    (C {(test_expect_success)} {(SQ <'git client sends Accept-Language based on LANGUAGE'>)} 
      {(SQ <'\n'> <'\tcheck_language "ko-KR, *;q=0.9" ko_KR.UTF-8'>)}
    )
    (C {(test_expect_success)} 
      {(SQ <'git client sends Accept-Language correctly with unordinary LANGUAGE'>)} 
      {
        (SQ <'\n'> <'\tcheck_language "ko-KR, *;q=0.9" "ko_KR:" &&\n'> 
          <'\tcheck_language "ko-KR, en-US;q=0.9, *;q=0.8" "ko_KR::en_US" &&\n'> <'\tcheck_language "ko-KR, *;q=0.9" ":::ko_KR" &&\n'> 
          <'\tcheck_language "ko-KR, en-US;q=0.9, *;q=0.8" "ko_KR!!:en_US" &&\n'> <'\tcheck_language "ko-KR, ja-JP;q=0.9, *;q=0.8" "ko_KR en_US:ja_JP"'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'git client sends Accept-Language with many preferred languages'>)} 
      {
        (SQ <'\n'> <'\tcheck_language "ko-KR, en-US;q=0.9, fr-CA;q=0.8, de;q=0.7, sr;q=0.6, \\\n'> 
          <'ja;q=0.5, zh;q=0.4, sv;q=0.3, pt;q=0.2, *;q=0.1" \\\n'> <'\t\tko_KR.EUC-KR:en_US.UTF-8:fr_CA:de.UTF-8@euro:sr@latin:ja:zh:sv:pt &&\n'> 
          <'\tcheck_language "ko-KR, en-US;q=0.99, fr-CA;q=0.98, de;q=0.97, sr;q=0.96, \\\n'> <'ja;q=0.95, zh;q=0.94, sv;q=0.93, pt;q=0.92, nb;q=0.91, *;q=0.90" \\\n'> 
          <'\t\tko_KR.EUC-KR:en_US.UTF-8:fr_CA:de.UTF-8@euro:sr@latin:ja:zh:sv:pt:nb\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'git client does not send an empty Accept-Language'>)} 
      {
        (SQ <'\n'> 
          <
'\tGIT_TRACE_CURL=true LANGUAGE= git ls-remote "$HTTPD_URL/dumb/repo.git" 2>stderr &&\n'
          > <'\t! grep "^=> Send header: Accept-Language:" stderr\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'remote-http complains cleanly about malformed urls'>)} 
      {
        (SQ <'\n'> <'\t# do not actually issue "list" or other commands, as we do not\n'> 
          <'\t# want to rely on what curl would actually do with such a broken\n'> <'\t# URL. This is just about making sure we do not segfault during\n'> <'\t# initialization.\n'> 
          <'\ttest_must_fail git remote-http http::/example.com/repo.git\n'>
        )
      }
    )
    (C {(stop_httpd)})
    (C {(test_done)})
  ]
)