(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: {(SQ <'remote tracking stats'>)}
          spids: [4]
        )
      ]
    )
    (C {<.>} {<'./test-lib.sh'>})
    (command.ShFunction
      name: advance
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp]
              children: [
                (command.Simple
                  words: [{<echo>} {(DQ ($ Id.VSub_Number '$1'))}]
                  redirects: [
                    (redir
                      op: <Id.Redir_Great '>'>
                      loc: (redir_loc.Fd fd:1)
                      arg: {(DQ ($ Id.VSub_Number '$1'))}
                    )
                  ]
                  do_fork: T
                )
                (C {<git>} {<add>} {(DQ ($ Id.VSub_Number '$1'))})
                (C {<test_tick>})
                (C {<git>} {<commit>} {<-m>} {(DQ ($ Id.VSub_Number '$1'))})
              ]
            )
          ]
        )
    )
    (C {<test_expect_success>} {<setup>} 
      {
        (SQ <'\n'> <'\tadvance a &&\n'> <'\tadvance b &&\n'> <'\tadvance c &&\n'> 
          <'\tgit clone . test &&\n'> <'\t(\n'> <'\t\tcd test &&\n'> <'\t\tgit checkout -b b1 origin &&\n'> 
          <'\t\tgit reset --hard HEAD^ &&\n'> <'\t\tadvance d &&\n'> <'\t\tgit checkout -b b2 origin &&\n'> <'\t\tgit reset --hard b1 &&\n'> 
          <'\t\tgit checkout -b b3 origin &&\n'> <'\t\tgit reset --hard HEAD^ &&\n'> <'\t\tgit checkout -b b4 origin &&\n'> <'\t\tadvance e &&\n'> 
          <'\t\tadvance f &&\n'> <'\t\tgit checkout -b brokenbase origin &&\n'> <'\t\tgit checkout -b b5 --track brokenbase &&\n'> 
          <'\t\tadvance g &&\n'> <'\t\tgit branch -d brokenbase &&\n'> <'\t\tgit checkout -b b6 origin\n'> <'\t) &&\n'> 
          <'\tgit checkout -b follower --track master &&\n'> <'\tadvance h\n'>
        )
      }
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:script)
          op: assign_op.Equal
          rhs: {(SQ <'s/^..\\(b.\\) *[0-9a-f]* \\(.*\\)$/\\1 \\2/p'>)}
          spids: [99]
        )
      ]
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
              here_end_span_id: 119
              stdin_parts: [
                <'b1 [ahead 1, behind 1] d\n'>
                <'b2 [ahead 1, behind 1] d\n'>
                <'b3 [behind 1] b\n'>
                <'b4 [ahead 2] f\n'>
                <'b5 g\n'>
                <'b6 c\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'branch -v'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd test &&\n'> <'\t\tgit branch -v\n'> <'\t) |\n'> 
          <'\tsed -n -e "$script" >actual &&\n'> <'\ttest_i18ncmp expect actual\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
              here_end_span_id: 153
              stdin_parts: [
                <'b1 [origin/master: ahead 1, behind 1] d\n'>
                <'b2 [origin/master: ahead 1, behind 1] d\n'>
                <'b3 [origin/master: behind 1] b\n'>
                <'b4 [origin/master: ahead 2] f\n'>
                <'b5 [brokenbase: gone] g\n'>
                <'b6 [origin/master] c\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'branch -vv'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd test &&\n'> <'\t\tgit branch -vv\n'> <'\t) |\n'> 
          <'\tsed -n -e "$script" >actual &&\n'> <'\ttest_i18ncmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'checkout (diverged from upstream)'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd test && git checkout b1\n'> <'\t) >actual &&\n'> 
          <'\ttest_i18ngrep "have 1 and 1 different" actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'checkout with local tracked branch'>)} 
      {
        (SQ <'\n'> <'\tgit checkout master &&\n'> <'\tgit checkout follower >actual &&\n'> 
          <'\ttest_i18ngrep "is ahead of" actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'checkout (upstream is gone)'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd test &&\n'> <'\t\tgit checkout b5\n'> <'\t) >actual &&\n'> 
          <'\ttest_i18ngrep "is based on .*, but the upstream is gone." actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'checkout (up-to-date with upstream)'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd test && git checkout b6\n'> <'\t) >actual &&\n'> 
          <'\ttest_i18ngrep "Your branch is up-to-date with .origin/master" actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'status (diverged from upstream)'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd test &&\n'> <'\t\tgit checkout b1 >/dev/null &&\n'> 
          <'\t\t# reports nothing to commit\n'> <'\t\ttest_must_fail git commit --dry-run\n'> <'\t) >actual &&\n'> 
          <'\ttest_i18ngrep "have 1 and 1 different" actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'status (upstream is gone)'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd test &&\n'> <'\t\tgit checkout b5 >/dev/null &&\n'> 
          <'\t\t# reports nothing to commit\n'> <'\t\ttest_must_fail git commit --dry-run\n'> <'\t) >actual &&\n'> 
          <'\ttest_i18ngrep "is based on .*, but the upstream is gone." actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'status (up-to-date with upstream)'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd test &&\n'> <'\t\tgit checkout b6 >/dev/null &&\n'> 
          <'\t\t# reports nothing to commit\n'> <'\t\ttest_must_fail git commit --dry-run\n'> <'\t) >actual &&\n'> 
          <'\ttest_i18ngrep "Your branch is up-to-date with .origin/master" actual\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
              here_end_span_id: 296
              stdin_parts: [<'## b1...origin/master [ahead 1, behind 1]\n'>]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'status -s -b (diverged from upstream)'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd test &&\n'> <'\t\tgit checkout b1 >/dev/null &&\n'> 
          <'\t\tgit status -s -b | head -1\n'> <'\t) >actual &&\n'> <'\ttest_i18ncmp expect actual\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
              here_end_span_id: 325
              stdin_parts: [<'## b5...brokenbase [gone]\n'>]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'status -s -b (upstream is gone)'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd test &&\n'> <'\t\tgit checkout b5 >/dev/null &&\n'> 
          <'\t\tgit status -s -b | head -1\n'> <'\t) >actual &&\n'> <'\ttest_i18ncmp expect actual\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
              here_end_span_id: 354
              stdin_parts: [<'## b6...origin/master\n'>]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'status -s -b (up-to-date with upstream)'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd test &&\n'> <'\t\tgit checkout b6 >/dev/null &&\n'> 
          <'\t\tgit status -s -b | head -1\n'> <'\t) >actual &&\n'> <'\ttest_i18ncmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'fail to track lightweight tags'>)} 
      {
        (SQ <'\n'> <'\tgit checkout master &&\n'> <'\tgit tag light &&\n'> 
          <'\ttest_must_fail git branch --track lighttrack light >actual &&\n'> <'\ttest_i18ngrep ! "set up to track" actual &&\n'> <'\ttest_must_fail git checkout lighttrack\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'fail to track annotated tags'>)} 
      {
        (SQ <'\n'> <'\tgit checkout master &&\n'> <'\tgit tag -m heavy heavy &&\n'> 
          <'\ttest_must_fail git branch --track heavytrack heavy >actual &&\n'> <'\ttest_i18ngrep ! "set up to track" actual &&\n'> <'\ttest_must_fail git checkout heavytrack\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'setup tracking with branch --set-upstream on existing branch'>)} 
      {
        (SQ <'\n'> <'\tgit branch from-master master &&\n'> 
          <'\ttest_must_fail git config branch.from-master.merge > actual &&\n'> <'\tgit branch --set-upstream from-master master &&\n'> 
          <'\tgit config branch.from-master.merge > actual &&\n'> <'\tgrep -q "^refs/heads/master$" actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'--set-upstream does not change branch'>)} 
      {
        (SQ <'\n'> <'\tgit branch from-master2 master &&\n'> 
          <'\ttest_must_fail git config branch.from-master2.merge > actual &&\n'> <'\tgit rev-list from-master2 &&\n'> <'\tgit update-ref refs/heads/from-master2 from-master2^ &&\n'> 
          <'\tgit rev-parse from-master2 >expect2 &&\n'> <'\tgit branch --set-upstream from-master2 master &&\n'> 
          <'\tgit config branch.from-master.merge > actual &&\n'> <'\tgit rev-parse from-master2 >actual2 &&\n'> <'\tgrep -q "^refs/heads/master$" actual &&\n'> 
          <'\tcmp expect2 actual2\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'--set-upstream @{-1}'>)} 
      {
        (SQ <'\n'> <'\tgit checkout from-master &&\n'> <'\tgit checkout from-master2 &&\n'> 
          <'\tgit config branch.from-master2.merge > expect2 &&\n'> <'\tgit branch --set-upstream @{-1} follower &&\n'> 
          <'\tgit config branch.from-master.merge > actual &&\n'> <'\tgit config branch.from-master2.merge > actual2 &&\n'> 
          <'\tgit branch --set-upstream from-master follower &&\n'> <'\tgit config branch.from-master.merge > expect &&\n'> <'\ttest_cmp expect2 actual2 &&\n'> 
          <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_done>})
  ]
)