(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <'Per branch config variables affects "git fetch".\n'> <'\n'>)}
          spids: [7]
        )
      ]
      spids: [7]
    )
    (C {(.)} {(./test-lib.sh)})
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:D)
          op: Equal
          rhs: 
            {
              (CommandSubPart
                command_list: (CommandList children:[(C {(pwd)})])
                left_token: <Left_CommandSub '$('>
                spids: [20 22]
              )
            }
          spids: [19]
        )
      ]
      spids: [19]
    )
    (FuncDef
      name: test_bundle_object_count
      body: 
        (BraceGroup
          children: [
            (AndOr
              ops: [Op_DAmp]
              children: [
                (SimpleCommand
                  words: [{(git)} {(verify-pack)} {(-v)} {(DQ ($ VSub_Number '$1'))}]
                  redirects: [
                    (Redir
                      op_id: Redir_Great
                      fd: 16777215
                      arg_word: {(verify.out)}
                      spids: [43]
                    )
                  ]
                )
                (C {(test)} {(DQ ($ VSub_Number '$2'))} {(Lit_Other '=')} 
                  {
                    (CommandSubPart
                      command_list: 
                        (CommandList
                          children: [
                            (Pipeline
                              children: [
                                (C {(grep)} {(SQ <'^[0-9a-f]\\{40\\} '>)} {(verify.out)})
                                (C {(wc)} {(-l)})
                              ]
                              negated: F
                            )
                          ]
                        )
                      left_token: <Left_CommandSub '$('>
                      spids: [57 71]
                    )
                  }
                )
              ]
            )
          ]
          spids: [30]
        )
      spids: [25 29]
    )
    (FuncDef
      name: convert_bundle_to_pack
      body: 
        (BraceGroup
          children: [
            (While
              cond: [
                (AndOr
                  ops: [Op_DAmp]
                  children: [(C {(read)} {(x)}) (C {(test)} {(-n)} {(DQ ($ VSub_Name '$x'))})]
                )
              ]
              body: 
                (DoGroup
                  children: [(Sentence child:(C {(Lit_Other ':')}) terminator:<Op_Semi ';'>)]
                  spids: [101 108]
                )
            )
            (C {(cat)})
          ]
          spids: [81]
        )
      spids: [76 80]
    )
    (C {(test_expect_success)} {(setup)} 
      {
        (SQ <'\n'> <'\techo >file original &&\n'> <'\tgit add file &&\n'> 
          <'\tgit commit -a -m original'>
        )
      }
    )
    (C {(test_expect_success)} {(DQ ('clone and setup child repos'))} 
      {
        (SQ <'\n'> <'\tgit clone . one &&\n'> <'\t(\n'> <'\t\tcd one &&\n'> 
          <'\t\techo >file updated by one &&\n'> <'\t\tgit commit -a -m "updated by one"\n'> <'\t) &&\n'> <'\tgit clone . two &&\n'> <'\t(\n'> 
          <'\t\tcd two &&\n'> <'\t\tgit config branch.master.remote one &&\n'> <'\t\tgit config remote.one.url ../one/.git/ &&\n'> 
          <'\t\tgit config remote.one.fetch refs/heads/master:refs/heads/one\n'> <'\t) &&\n'> <'\tgit clone . three &&\n'> <'\t(\n'> <'\t\tcd three &&\n'> 
          <'\t\tgit config branch.master.remote two &&\n'> <'\t\tgit config branch.master.merge refs/heads/one &&\n'> <'\t\tmkdir -p .git/remotes &&\n'> 
          <'\t\t{\n'> <'\t\t\techo "URL: ../two/.git/"\n'> <'\t\t\techo "Pull: refs/heads/master:refs/heads/two"\n'> 
          <'\t\t\techo "Pull: refs/heads/one:refs/heads/one"\n'> <'\t\t} >.git/remotes/two\n'> <'\t) &&\n'> <'\tgit clone . bundle &&\n'> <'\tgit clone . seven\n'>
        )
      }
    )
    (C {(test_expect_success)} {(DQ ('fetch test'))} 
      {
        (SQ <'\n'> <'\tcd "$D" &&\n'> <'\techo >file updated by origin &&\n'> 
          <'\tgit commit -a -m "updated by origin" &&\n'> <'\tcd two &&\n'> <'\tgit fetch &&\n'> <'\ttest -f .git/refs/heads/one &&\n'> 
          <'\tmine=$(git rev-parse refs/heads/one) &&\n'> <'\this=$(cd ../one && git rev-parse refs/heads/master) &&\n'> <'\ttest "z$mine" = "z$his"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(DQ ('fetch test for-merge'))} 
      {
        (SQ <'\n'> <'\tcd "$D" &&\n'> <'\tcd three &&\n'> <'\tgit fetch &&\n'> 
          <'\ttest -f .git/refs/heads/two &&\n'> <'\ttest -f .git/refs/heads/one &&\n'> <'\tmaster_in_two=$(cd ../two && git rev-parse master) &&\n'> 
          <'\tone_in_two=$(cd ../two && git rev-parse one) &&\n'> <'\t{\n'> <'\t\techo "$one_in_two\t"\n'> <'\t\techo "$master_in_two\tnot-for-merge"\n'> 
          <'\t} >expected &&\n'> <'\tcut -f -2 .git/FETCH_HEAD >actual &&\n'> <'\ttest_cmp expected actual'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fetch --prune on its own works as expected'>)} 
      {
        (SQ <'\n'> <'\tcd "$D" &&\n'> <'\tgit clone . prune &&\n'> <'\tcd prune &&\n'> 
          <'\tgit update-ref refs/remotes/origin/extrabranch master &&\n'> <'\n'> <'\tgit fetch --prune origin &&\n'> <'\ttest_must_fail git rev-parse origin/extrabranch\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fetch --prune with a branch name keeps branches'>)} 
      {
        (SQ <'\n'> <'\tcd "$D" &&\n'> <'\tgit clone . prune-branch &&\n'> <'\tcd prune-branch &&\n'> 
          <'\tgit update-ref refs/remotes/origin/extrabranch master &&\n'> <'\n'> <'\tgit fetch --prune origin master &&\n'> <'\tgit rev-parse origin/extrabranch\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fetch --prune with a namespace keeps other namespaces'>)} 
      {
        (SQ <'\n'> <'\tcd "$D" &&\n'> <'\tgit clone . prune-namespace &&\n'> 
          <'\tcd prune-namespace &&\n'> <'\n'> <'\tgit fetch --prune origin refs/heads/a/*:refs/remotes/origin/a/* &&\n'> 
          <'\tgit rev-parse origin/master\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fetch --prune handles overlapping refspecs'>)} 
      {
        (SQ <'\n'> <'\tcd "$D" &&\n'> <'\tgit update-ref refs/pull/42/head master &&\n'> 
          <'\tgit clone . prune-overlapping &&\n'> <'\tcd prune-overlapping &&\n'> 
          <'\tgit config --add remote.origin.fetch refs/pull/*/head:refs/remotes/origin/pr/* &&\n'> <'\n'> <'\tgit fetch --prune origin &&\n'> <'\tgit rev-parse origin/master &&\n'> 
          <'\tgit rev-parse origin/pr/42 &&\n'> <'\n'> <'\tgit config --unset-all remote.origin.fetch &&\n'> 
          <'\tgit config remote.origin.fetch refs/pull/*/head:refs/remotes/origin/pr/* &&\n'> <'\tgit config --add remote.origin.fetch refs/heads/*:refs/remotes/origin/* &&\n'> <'\n'> 
          <'\tgit fetch --prune origin &&\n'> <'\tgit rev-parse origin/master &&\n'> <'\tgit rev-parse origin/pr/42\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fetch --prune --tags prunes branches but not tags'>)} 
      {
        (SQ <'\n'> <'\tcd "$D" &&\n'> <'\tgit clone . prune-tags &&\n'> <'\tcd prune-tags &&\n'> 
          <'\tgit tag sometag master &&\n'> <'\t# Create what looks like a remote-tracking branch from an earlier\n'> 
          <'\t# fetch that has since been deleted from the remote:\n'> <'\tgit update-ref refs/remotes/origin/fake-remote master &&\n'> <'\n'> 
          <'\tgit fetch --prune --tags origin &&\n'> <'\tgit rev-parse origin/master &&\n'> <'\ttest_must_fail git rev-parse origin/fake-remote &&\n'> 
          <'\tgit rev-parse sometag\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fetch --prune --tags with branch does not prune other things'>)} 
      {
        (SQ <'\n'> <'\tcd "$D" &&\n'> <'\tgit clone . prune-tags-branch &&\n'> 
          <'\tcd prune-tags-branch &&\n'> <'\tgit tag sometag master &&\n'> <'\tgit update-ref refs/remotes/origin/extrabranch master &&\n'> 
          <'\n'> <'\tgit fetch --prune --tags origin master &&\n'> <'\tgit rev-parse origin/extrabranch &&\n'> 
          <'\tgit rev-parse sometag\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fetch --prune --tags with refspec prunes based on refspec'>)} 
      {
        (SQ <'\n'> <'\tcd "$D" &&\n'> <'\tgit clone . prune-tags-refspec &&\n'> 
          <'\tcd prune-tags-refspec &&\n'> <'\tgit tag sometag master &&\n'> <'\tgit update-ref refs/remotes/origin/foo/otherbranch master &&\n'> 
          <'\tgit update-ref refs/remotes/origin/extrabranch master &&\n'> <'\n'> <'\tgit fetch --prune --tags origin refs/heads/foo/*:refs/remotes/origin/foo/* &&\n'> 
          <'\ttest_must_fail git rev-parse refs/remotes/origin/foo/otherbranch &&\n'> <'\tgit rev-parse origin/extrabranch &&\n'> <'\tgit rev-parse sometag\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fetch tags when there is no tags'>)} 
      {
        (SQ <'\n'> <'\n'> <'    cd "$D" &&\n'> <'\n'> <'    mkdir notags &&\n'> <'    cd notags &&\n'> 
          <'    git init &&\n'> <'\n'> <'    git fetch -t ..\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fetch following tags'>)} 
      {(SQ <'\n'> <'\n'> <'\tcd "$D" &&\n'> <'\tgit tag -a -m '>) (annotated) 
        (SQ <' anno HEAD &&\n'> <'\tgit tag light HEAD &&\n'> <'\n'> <'\tmkdir four &&\n'> 
          <'\tcd four &&\n'> <'\tgit init &&\n'> <'\n'> <'\tgit fetch .. :track &&\n'> 
          <'\tgit show-ref --verify refs/tags/anno &&\n'> <'\tgit show-ref --verify refs/tags/light\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fetch uses remote ref names to describe new refs'>)} 
      {
        (SQ <'\n'> <'\tcd "$D" &&\n'> <'\tgit init descriptive &&\n'> <'\t(\n'> 
          <'\t\tcd descriptive &&\n'> <'\t\tgit config remote.o.url .. &&\n'> 
          <'\t\tgit config remote.o.fetch "refs/heads/*:refs/crazyheads/*" &&\n'> <'\t\tgit config --add remote.o.fetch "refs/others/*:refs/heads/*" &&\n'> <'\t\tgit fetch o\n'> 
          <'\t) &&\n'> <'\tgit tag -a -m "Descriptive tag" descriptive-tag &&\n'> <'\tgit branch descriptive-branch &&\n'> 
          <'\tgit checkout descriptive-branch &&\n'> <'\techo "Nuts" >crazy &&\n'> <'\tgit add crazy &&\n'> <'\tgit commit -a -m "descriptive commit" &&\n'> 
          <'\tgit update-ref refs/others/crazy HEAD &&\n'> <'\t(\n'> <'\t\tcd descriptive &&\n'> <'\t\tgit fetch o 2>actual &&\n'> 
          <'\t\tgrep " -> refs/crazyheads/descriptive-branch$" actual |\n'> <'\t\ttest_i18ngrep "new branch" &&\n'> <'\t\tgrep " -> descriptive-tag$" actual |\n'> 
          <'\t\ttest_i18ngrep "new tag" &&\n'> <'\t\tgrep " -> crazy$" actual |\n'> <'\t\ttest_i18ngrep "new ref"\n'> <'\t) &&\n'> 
          <'\tgit checkout master\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fetch must not resolve short tag name'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tcd "$D" &&\n'> <'\n'> <'\tmkdir five &&\n'> <'\tcd five &&\n'> 
          <'\tgit init &&\n'> <'\n'> <'\ttest_must_fail git fetch .. anno:five\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fetch can now resolve short remote name'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tcd "$D" &&\n'> <'\tgit update-ref refs/remotes/six/HEAD HEAD &&\n'> <'\n'> 
          <'\tmkdir six &&\n'> <'\tcd six &&\n'> <'\tgit init &&\n'> <'\n'> <'\tgit fetch .. six:six\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'create bundle 1'>)} 
      {
        (SQ <'\n'> <'\tcd "$D" &&\n'> <'\techo >file updated again by origin &&\n'> 
          <'\tgit commit -a -m "tip" &&\n'> <'\tgit bundle create bundle1 master^..master\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'header of bundle looks right'>)} 
      {
        (SQ <'\n'> <'\thead -n 1 "$D"/bundle1 | grep "^#" &&\n'> 
          <'\thead -n 2 "$D"/bundle1 | grep "^-[0-9a-f]\\{40\\} " &&\n'> <'\thead -n 3 "$D"/bundle1 | grep "^[0-9a-f]\\{40\\} " &&\n'> 
          <'\thead -n 4 "$D"/bundle1 | grep "^$"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'create bundle 2'>)} 
      {(SQ <'\n'> <'\tcd "$D" &&\n'> <'\tgit bundle create bundle2 master~2..master\n'>)}
    )
    (C {(test_expect_success)} {(SQ <'unbundle 1'>)} 
      {
        (SQ <'\n'> <'\tcd "$D/bundle" &&\n'> <'\tgit checkout -b some-branch &&\n'> 
          <'\ttest_must_fail git fetch "$D/bundle1" master:master\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'bundle 1 has only 3 files '>)} 
      {
        (SQ <'\n'> <'\tcd "$D" &&\n'> <'\tconvert_bundle_to_pack <bundle1 >bundle.pack &&\n'> 
          <'\tgit index-pack bundle.pack &&\n'> <'\ttest_bundle_object_count bundle.pack 3\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'unbundle 2'>)} 
      {
        (SQ <'\n'> <'\tcd "$D/bundle" &&\n'> <'\tgit fetch ../bundle2 master:master &&\n'> 
          <'\ttest "tip" = "$(git log -1 --pretty=oneline master | cut -b42-)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'bundle does not prerequisite objects'>)} 
      {
        (SQ <'\n'> <'\tcd "$D" &&\n'> <'\ttouch file2 &&\n'> <'\tgit add file2 &&\n'> 
          <'\tgit commit -m add.file2 file2 &&\n'> <'\tgit bundle create bundle3 -1 HEAD &&\n'> <'\tconvert_bundle_to_pack <bundle3 >bundle.pack &&\n'> 
          <'\tgit index-pack bundle.pack &&\n'> <'\ttest_bundle_object_count bundle.pack 3\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'bundle should be able to create a full history'>)} 
      {(SQ <'\n'> <'\n'> <'\tcd "$D" &&\n'> <'\tgit tag -a -m '>) (1.0) 
        (SQ <' v1.0 master &&\n'> <'\tgit bundle create bundle4 v1.0\n'> <'\n'>)
      }
    )
    (C {(test_expect_success)} {(SQ <'fetch with a non-applying branch.<name>.merge'>)} 
      {
        (SQ <'\n'> <'\tgit config branch.master.remote yeti &&\n'> 
          <'\tgit config branch.master.merge refs/heads/bigfoot &&\n'> <'\tgit config remote.blub.url one &&\n'> 
          <'\tgit config remote.blub.fetch "refs/heads/*:refs/remotes/one/*" &&\n'> <'\tgit fetch blub\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fetch from GIT URL with a non-applying branch.<name>.merge [1]'>)} 
      {
        (SQ <'\n'> <'\tone_head=$(cd one && git rev-parse HEAD) &&\n'> 
          <'\tthis_head=$(git rev-parse HEAD) &&\n'> <'\tgit update-ref -d FETCH_HEAD &&\n'> <'\tgit fetch one &&\n'> 
          <'\ttest $one_head = "$(git rev-parse --verify FETCH_HEAD)" &&\n'> <'\ttest $this_head = "$(git rev-parse --verify HEAD)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fetch from GIT URL with a non-applying branch.<name>.merge [2]'>)} 
      {
        (SQ <'\n'> <'\tone_ref=$(cd one && git symbolic-ref HEAD) &&\n'> 
          <'\tgit config branch.master.remote blub &&\n'> <'\tgit config branch.master.merge "$one_ref" &&\n'> <'\tgit update-ref -d FETCH_HEAD &&\n'> 
          <'\tgit fetch one &&\n'> <'\ttest $one_head = "$(git rev-parse --verify FETCH_HEAD)" &&\n'> 
          <'\ttest $this_head = "$(git rev-parse --verify HEAD)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fetch from GIT URL with a non-applying branch.<name>.merge [3]'>)} 
      {
        (SQ <'\n'> <'\tgit config branch.master.merge "${one_ref}_not" &&\n'> 
          <'\tgit update-ref -d FETCH_HEAD &&\n'> <'\tgit fetch one &&\n'> <'\ttest $one_head = "$(git rev-parse --verify FETCH_HEAD)" &&\n'> 
          <'\ttest $this_head = "$(git rev-parse --verify HEAD)"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'quoting of a strangely named repo'>)} 
      {(SQ <'\n'> <'\ttest_must_fail git fetch "a\\\\!'>) 
        (EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <'b" > result 2>&1 &&\n'> <'\tcat result &&\n'> <'\tgrep "fatal: '>) 
        (EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <'a\\\\\\\\!'>) (EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <b>) 
        (EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <'" result\n'>)
      }
    )
    (C {(test_expect_success)} {(SQ <'bundle should record HEAD correctly'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tcd "$D" &&\n'> <'\tgit bundle create bundle5 HEAD master &&\n'> 
          <'\tgit bundle list-heads bundle5 >actual &&\n'> <'\tfor h in HEAD refs/heads/master\n'> <'\tdo\n'> <'\t\techo "$(git rev-parse --verify $h) $h"\n'> 
          <'\tdone >expect &&\n'> <'\ttest_cmp expect actual\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'mark initial state of origin/master'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd three &&\n'> 
          <'\t\tgit tag base-origin-master refs/remotes/origin/master\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'explicit fetch should update tracking'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tcd "$D" &&\n'> <'\tgit branch -f side &&\n'> <'\t(\n'> <'\t\tcd three &&\n'> 
          <'\t\tgit update-ref refs/remotes/origin/master base-origin-master &&\n'> <'\t\to=$(git rev-parse --verify refs/remotes/origin/master) &&\n'> 
          <'\t\tgit fetch origin master &&\n'> <'\t\tn=$(git rev-parse --verify refs/remotes/origin/master) &&\n'> <'\t\ttest "$o" != "$n" &&\n'> 
          <'\t\ttest_must_fail git rev-parse --verify refs/remotes/origin/side\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'explicit pull should update tracking'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tcd "$D" &&\n'> <'\tgit branch -f side &&\n'> <'\t(\n'> <'\t\tcd three &&\n'> 
          <'\t\tgit update-ref refs/remotes/origin/master base-origin-master &&\n'> <'\t\to=$(git rev-parse --verify refs/remotes/origin/master) &&\n'> 
          <'\t\tgit pull origin master &&\n'> <'\t\tn=$(git rev-parse --verify refs/remotes/origin/master) &&\n'> <'\t\ttest "$o" != "$n" &&\n'> 
          <'\t\ttest_must_fail git rev-parse --verify refs/remotes/origin/side\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'explicit --refmap is allowed only with command-line refspec'>)} 
      {
        (SQ <'\n'> <'\tcd "$D" &&\n'> <'\t(\n'> <'\t\tcd three &&\n'> 
          <'\t\ttest_must_fail git fetch --refmap="*:refs/remotes/none/*"\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'explicit --refmap option overrides remote.*.fetch'>)} 
      {
        (SQ <'\n'> <'\tcd "$D" &&\n'> <'\tgit branch -f side &&\n'> <'\t(\n'> <'\t\tcd three &&\n'> 
          <'\t\tgit update-ref refs/remotes/origin/master base-origin-master &&\n'> <'\t\to=$(git rev-parse --verify refs/remotes/origin/master) &&\n'> 
          <'\t\tgit fetch --refmap="refs/heads/*:refs/remotes/other/*" origin master &&\n'> <'\t\tn=$(git rev-parse --verify refs/remotes/origin/master) &&\n'> <'\t\ttest "$o" = "$n" &&\n'> 
          <'\t\ttest_must_fail git rev-parse --verify refs/remotes/origin/side &&\n'> <'\t\tgit rev-parse --verify refs/remotes/other/master\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'explicitly empty --refmap option disables remote.*.fetch'>)} 
      {
        (SQ <'\n'> <'\tcd "$D" &&\n'> <'\tgit branch -f side &&\n'> <'\t(\n'> <'\t\tcd three &&\n'> 
          <'\t\tgit update-ref refs/remotes/origin/master base-origin-master &&\n'> <'\t\to=$(git rev-parse --verify refs/remotes/origin/master) &&\n'> 
          <'\t\tgit fetch --refmap="" origin master &&\n'> <'\t\tn=$(git rev-parse --verify refs/remotes/origin/master) &&\n'> <'\t\ttest "$o" = "$n" &&\n'> 
          <'\t\ttest_must_fail git rev-parse --verify refs/remotes/origin/side\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'configured fetch updates tracking'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tcd "$D" &&\n'> <'\tgit branch -f side &&\n'> <'\t(\n'> <'\t\tcd three &&\n'> 
          <'\t\tgit update-ref refs/remotes/origin/master base-origin-master &&\n'> <'\t\to=$(git rev-parse --verify refs/remotes/origin/master) &&\n'> <'\t\tgit fetch origin &&\n'> 
          <'\t\tn=$(git rev-parse --verify refs/remotes/origin/master) &&\n'> <'\t\ttest "$o" != "$n" &&\n'> <'\t\tgit rev-parse --verify refs/remotes/origin/side\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'non-matching refspecs do not confuse tracking update'>)} 
      {
        (SQ <'\n'> <'\tcd "$D" &&\n'> <'\tgit update-ref refs/odd/location HEAD &&\n'> <'\t(\n'> 
          <'\t\tcd three &&\n'> <'\t\tgit update-ref refs/remotes/origin/master base-origin-master &&\n'> 
          <'\t\tgit config --add remote.origin.fetch \\\n'> <'\t\t\trefs/odd/location:refs/remotes/origin/odd &&\n'> 
          <'\t\to=$(git rev-parse --verify refs/remotes/origin/master) &&\n'> <'\t\tgit fetch origin master &&\n'> 
          <'\t\tn=$(git rev-parse --verify refs/remotes/origin/master) &&\n'> <'\t\ttest "$o" != "$n" &&\n'> <'\t\ttest_must_fail git rev-parse --verify refs/remotes/origin/odd\n'> 
          <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'pushing nonexistent branch by mistake should not segv'>)} 
      {(SQ <'\n'> <'\n'> <'\tcd "$D" &&\n'> <'\ttest_must_fail git push seven no:no\n'> <'\n'>)}
    )
    (C {(test_expect_success)} {(SQ <'auto tag following fetches minimum'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tcd "$D" &&\n'> <'\tgit clone .git follow &&\n'> 
          <'\tgit checkout HEAD^0 &&\n'> <'\t(\n'> <'\t\tfor i in 1 2 3 4 5 6 7\n'> <'\t\tdo\n'> <'\t\t\techo $i >>file &&\n'> 
          <'\t\t\tgit commit -m $i -a &&\n'> <'\t\t\tgit tag -a -m $i excess-$i || exit 1\n'> <'\t\tdone\n'> <'\t) &&\n'> 
          <'\tgit checkout master &&\n'> <'\t(\n'> <'\t\tcd follow &&\n'> <'\t\tgit fetch\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'refuse to fetch into the current branch'>)} 
      {(SQ <'\n'> <'\n'> <'\ttest_must_fail git fetch . side:master\n'> <'\n'>)}
    )
    (C {(test_expect_success)} {(SQ <'fetch into the current branch with --update-head-ok'>)} 
      {(SQ <'\n'> <'\n'> <'\tgit fetch --update-head-ok . side:master\n'> <'\n'>)}
    )
    (C {(test_expect_success)} {(SQ <'fetch --dry-run'>)} 
      {
        (SQ <'\n'> <'\n'> <'\trm -f .git/FETCH_HEAD &&\n'> <'\tgit fetch --dry-run . &&\n'> 
          <'\t! test -f .git/FETCH_HEAD\n'>
        )
      }
    )
    (C {(test_expect_success)} {(DQ ('should be able to fetch with duplicate refspecs'))} 
      {
        (SQ <'\n'> <'\tmkdir dups &&\n'> <'\t(\n'> <'\t\tcd dups &&\n'> <'\t\tgit init &&\n'> 
          <'\t\tgit config branch.master.remote three &&\n'> <'\t\tgit config remote.three.url ../three/.git &&\n'> 
          <'\t\tgit config remote.three.fetch +refs/heads/*:refs/remotes/origin/* &&\n'> <'\t\tgit config --add remote.three.fetch +refs/heads/*:refs/remotes/origin/* &&\n'> 
          <'\t\tgit fetch three\n'> <'\t)\n'>
        )
      }
    )
    (FuncDef
      name: set_config_tristate
      body: 
        (BraceGroup
          children: [
            (Case
              to_match: {(DQ ($ VSub_Number '$2'))}
              arms: [
                (case_arm
                  pat_list: [{(unset)}]
                  action: [(C {(test_unconfig)} {(DQ ($ VSub_Number '$1'))})]
                  spids: [1045 1046 1054 16777215]
                )
                (case_arm
                  pat_list: [{(Lit_Other '*')}]
                  action: [
                    (C {(git)} {(config)} {(DQ ($ VSub_Number '$1'))} {(DQ ($ VSub_Number '$2'))})
                  ]
                  spids: [1057 1058 1072 16777215]
                )
              ]
              spids: [1036 1042 1075]
            )
          ]
          spids: [1029]
        )
      spids: [1024 1028]
    )
    (FuncDef
      name: test_configured_prune
      body: 
        (BraceGroup
          children: [
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:fetch_prune)
                  op: Equal
                  rhs: {($ VSub_Number '$1')}
                  spids: [1088]
                )
                (assign_pair
                  lhs: (LhsName name:remote_origin_prune)
                  op: Equal
                  rhs: {($ VSub_Number '$2')}
                  spids: [1091]
                )
                (assign_pair
                  lhs: (LhsName name:cmdline)
                  op: Equal
                  rhs: {($ VSub_Number '$3')}
                  spids: [1094]
                )
                (assign_pair
                  lhs: (LhsName name:expected)
                  op: Equal
                  rhs: {($ VSub_Number '$4')}
                  spids: [1097]
                )
              ]
              spids: [1088]
            )
            (C {(test_expect_success)} 
              {
                (DQ ('prune fetch.prune=') ($ VSub_Number '$1') (' remote.origin.prune=') 
                  ($ VSub_Number '$2') 
                  (BracedVarSub
                    token: <VSub_Number 3>
                    suffix_op: 
                      (StringUnary
                        op_id: VTest_ColonPlus
                        arg_word: {(' ') ($ VSub_Number '$3')}
                      )
                    spids: [1109 1114]
                  ) ('; ') ($ VSub_Number '$4')
                )
              } 
              {
                (SQ <'\n'> <'\t\t# make sure a newbranch is there in . and also in one\n'> 
                  <'\t\tgit branch -f newbranch &&\n'> <'\t\t(\n'> <'\t\t\tcd one &&\n'> <'\t\t\ttest_unconfig fetch.prune &&\n'> 
                  <'\t\t\ttest_unconfig remote.origin.prune &&\n'> <'\t\t\tgit fetch &&\n'> <'\t\t\tgit rev-parse --verify refs/remotes/origin/newbranch\n'> 
                  <'\t\t) &&\n'> <'\n'> <'\t\t# now remove it\n'> <'\t\tgit branch -d newbranch &&\n'> <'\n'> <'\t\t# then test\n'> 
                  <'\t\t(\n'> <'\t\t\tcd one &&\n'> <'\t\t\tset_config_tristate fetch.prune $fetch_prune &&\n'> 
                  <'\t\t\tset_config_tristate remote.origin.prune $remote_origin_prune &&\n'> <'\n'> <'\t\t\tgit fetch $cmdline &&\n'> <'\t\t\tcase "$expected" in\n'> <'\t\t\tpruned)\n'> 
                  <'\t\t\t\ttest_must_fail git rev-parse --verify refs/remotes/origin/newbranch\n'> <'\t\t\t\t;;\n'> <'\t\t\tkept)\n'> <'\t\t\t\tgit rev-parse --verify refs/remotes/origin/newbranch\n'> 
                  <'\t\t\t\t;;\n'> <'\t\t\tesac\n'> <'\t\t)\n'> <'\t'>
                )
              }
            )
          ]
          spids: [1085]
        )
      spids: [1080 1084]
    )
    (C {(test_configured_prune)} {(unset)} {(unset)} {(DQ )} {(kept)})
    (C {(test_configured_prune)} {(unset)} {(unset)} {(DQ (--no-prune))} {(kept)})
    (C {(test_configured_prune)} {(unset)} {(unset)} {(DQ (--prune))} {(pruned)})
    (C {(test_configured_prune)} {(false)} {(unset)} {(DQ )} {(kept)})
    (C {(test_configured_prune)} {(false)} {(unset)} {(DQ (--no-prune))} {(kept)})
    (C {(test_configured_prune)} {(false)} {(unset)} {(DQ (--prune))} {(pruned)})
    (C {(test_configured_prune)} {(true)} {(unset)} {(DQ )} {(pruned)})
    (C {(test_configured_prune)} {(true)} {(unset)} {(DQ (--prune))} {(pruned)})
    (C {(test_configured_prune)} {(true)} {(unset)} {(DQ (--no-prune))} {(kept)})
    (C {(test_configured_prune)} {(unset)} {(false)} {(DQ )} {(kept)})
    (C {(test_configured_prune)} {(unset)} {(false)} {(DQ (--no-prune))} {(kept)})
    (C {(test_configured_prune)} {(unset)} {(false)} {(DQ (--prune))} {(pruned)})
    (C {(test_configured_prune)} {(false)} {(false)} {(DQ )} {(kept)})
    (C {(test_configured_prune)} {(false)} {(false)} {(DQ (--no-prune))} {(kept)})
    (C {(test_configured_prune)} {(false)} {(false)} {(DQ (--prune))} {(pruned)})
    (C {(test_configured_prune)} {(true)} {(false)} {(DQ )} {(kept)})
    (C {(test_configured_prune)} {(true)} {(false)} {(DQ (--prune))} {(pruned)})
    (C {(test_configured_prune)} {(true)} {(false)} {(DQ (--no-prune))} {(kept)})
    (C {(test_configured_prune)} {(unset)} {(true)} {(DQ )} {(pruned)})
    (C {(test_configured_prune)} {(unset)} {(true)} {(DQ (--no-prune))} {(kept)})
    (C {(test_configured_prune)} {(unset)} {(true)} {(DQ (--prune))} {(pruned)})
    (C {(test_configured_prune)} {(false)} {(true)} {(DQ )} {(pruned)})
    (C {(test_configured_prune)} {(false)} {(true)} {(DQ (--no-prune))} {(kept)})
    (C {(test_configured_prune)} {(false)} {(true)} {(DQ (--prune))} {(pruned)})
    (C {(test_configured_prune)} {(true)} {(true)} {(DQ )} {(pruned)})
    (C {(test_configured_prune)} {(true)} {(true)} {(DQ (--prune))} {(pruned)})
    (C {(test_configured_prune)} {(true)} {(true)} {(DQ (--no-prune))} {(kept)})
    (C {(test_expect_success)} {(SQ <'all boundary commits are excluded'>)} 
      {
        (SQ <'\n'> <'\ttest_commit base &&\n'> <'\ttest_commit oneside &&\n'> 
          <'\tgit checkout HEAD^ &&\n'> <'\ttest_commit otherside &&\n'> <'\tgit checkout master &&\n'> <'\ttest_tick &&\n'> 
          <'\tgit merge otherside &&\n'> <'\tad=$(git log --no-walk --format=%ad HEAD) &&\n'> 
          <'\tgit bundle create twoside-boundary.bdl master --since="$ad" &&\n'> <'\tconvert_bundle_to_pack <twoside-boundary.bdl >twoside-boundary.pack &&\n'> 
          <'\tpack=$(git index-pack --fix-thin --stdin <twoside-boundary.pack) &&\n'> <'\ttest_bundle_object_count .git/objects/pack/pack-${pack##pack\t}.pack 3\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fetch --prune prints the remotes url'>)} 
      {
        (SQ <'\n'> <'\tgit branch goodbye &&\n'> <'\tgit clone . only-prunes &&\n'> 
          <'\tgit branch -D goodbye &&\n'> <'\t(\n'> <'\t\tcd only-prunes &&\n'> <'\t\tgit fetch --prune origin 2>&1 | head -n1 >../actual\n'> 
          <'\t) &&\n'> <'\techo "From ${D}/." >expect &&\n'> <'\ttest_i18ncmp expect actual\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'branchname D/F conflict resolved by --prune'>)} 
      {
        (SQ <'\n'> <'\tgit branch dir/file &&\n'> <'\tgit clone . prune-df-conflict &&\n'> 
          <'\tgit branch -D dir/file &&\n'> <'\tgit branch dir &&\n'> <'\t(\n'> <'\t\tcd prune-df-conflict &&\n'> <'\t\tgit fetch --prune &&\n'> 
          <'\t\tgit rev-parse origin/dir >../actual\n'> <'\t) &&\n'> <'\tgit rev-parse dir >expect &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fetching a one-level ref works'>)} 
      {
        (SQ <'\n'> <'\ttest_commit extra &&\n'> <'\tgit reset --hard HEAD^ &&\n'> 
          <'\tgit update-ref refs/foo extra &&\n'> <'\tgit init one-level &&\n'> <'\t(\n'> <'\t\tcd one-level &&\n'> <'\t\tgit fetch .. HEAD refs/foo\n'> 
          <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fetching with auto-gc does not lock up'>)} 
      {
        (SQ <'\n'> <'\twrite_script askyesno <<-\\EOF &&\n'> <'\techo "$*" &&\n'> <'\tfalse\n'> 
          <'\tEOF\n'> <'\tgit clone "file://$D" auto-gc &&\n'> <'\ttest_commit test2 &&\n'> <'\t(\n'> <'\t\tcd auto-gc &&\n'> 
          <'\t\tgit config gc.autoPackLimit 1 &&\n'> <'\t\tgit config gc.autoDetach false &&\n'> 
          <'\t\tGIT_ASK_YESNO="$D/askyesno" git fetch >fetch.out 2>&1 &&\n'> <'\t\t! grep "Should I try again" fetch.out\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(C_LOCALE_OUTPUT)} {(SQ <'fetch aligned output'>)} 
      {
        (SQ <'\n'> <'\tgit clone . full-output &&\n'> <'\ttest_commit looooooooooooong-tag &&\n'> 
          <'\t(\n'> <'\t\tcd full-output &&\n'> <'\t\tgit -c fetch.output=full fetch origin 2>&1 | \\\n'> 
          <'\t\t\tgrep -e "->" | cut -c 22- >../actual\n'> <'\t) &&\n'> <'\tcat >expect <<-\\EOF &&\n'> <'\tmaster               -> origin/master\n'> 
          <'\tlooooooooooooong-tag -> looooooooooooong-tag\n'> <'\tEOF\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {(test_expect_success)} {(C_LOCALE_OUTPUT)} {(SQ <'fetch compact output'>)} 
      {
        (SQ <'\n'> <'\tgit clone . compact &&\n'> <'\ttest_commit extraaa &&\n'> <'\t(\n'> 
          <'\t\tcd compact &&\n'> <'\t\tgit -c fetch.output=compact fetch origin 2>&1 | \\\n'> 
          <'\t\t\tgrep -e "->" | cut -c 22- >../actual\n'> <'\t) &&\n'> <'\tcat >expect <<-\\EOF &&\n'> <'\tmaster     -> origin/*\n'> <'\textraaa    -> *\n'> 
          <'\tEOF\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {(test_done)})
  ]
)