(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <"checkout can switch to last branch and merge base">)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./test-lib.sh)})
    (C {(test_expect_success)} {(SQ <setup>)} 
      {
        (SQ <"\n"> <"\techo hello >world &&\n"> <"\tgit add world &&\n"> 
          <"\tgit commit -m initial &&\n"> <"\tgit branch other &&\n"> <"\techo \"hello again\" >>world &&\n"> <"\tgit add world &&\n"> 
          <"\tgit commit -m second\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"\"checkout -\" does not work initially">)} 
      {(SQ <"\n"> <"\ttest_must_fail git checkout -\n">)}
    )
    (C {(test_expect_success)} {(SQ <"first branch switch">)} {(SQ <"\n"> <"\tgit checkout other\n">)})
    (C {(test_expect_success)} {(SQ <"\"checkout -\" switches back">)} 
      {
        (SQ <"\n"> <"\tgit checkout - &&\n"> 
          <"\ttest \"z$(git symbolic-ref HEAD)\" = \"zrefs/heads/master\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"\"checkout -\" switches forth">)} 
      {
        (SQ <"\n"> <"\tgit checkout - &&\n"> 
          <"\ttest \"z$(git symbolic-ref HEAD)\" = \"zrefs/heads/other\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"detach HEAD">)} 
      {(SQ <"\n"> <"\tgit checkout $(git rev-parse HEAD)\n">)}
    )
    (C {(test_expect_success)} {(SQ <"\"checkout -\" attaches again">)} 
      {
        (SQ <"\n"> <"\tgit checkout - &&\n"> 
          <"\ttest \"z$(git symbolic-ref HEAD)\" = \"zrefs/heads/other\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"\"checkout -\" detaches again">)} 
      {
        (SQ <"\n"> <"\tgit checkout - &&\n"> 
          <"\ttest \"z$(git rev-parse HEAD)\" = \"z$(git rev-parse other)\" &&\n"> <"\ttest_must_fail git symbolic-ref HEAD\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"more switches">)} 
      {
        (SQ <"\n"> <"\tfor i in 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1\n"> <"\tdo\n"> 
          <"\t\tgit checkout -b branch$i\n"> <"\tdone\n">
        )
      }
    )
    (FuncDef
      name: more_switches
      body: 
        (BraceGroup
          children: [
            (ForEach
              iter_name: i
              iter_words: [
                {(16)}
                {(15)}
                {(14)}
                {(13)}
                {(12)}
                {(11)}
                {(10)}
                {(9)}
                {(8)}
                {(7)}
                {(6)}
                {(5)}
                {(4)}
                {(3)}
                {(2)}
                {(1)}
              ]
              do_arg_iter: False
              body: 
                (DoGroup
                  children: [(C {(git)} {(checkout)} {(branch) ($ VSub_Name "$i")})]
                  spids: [184 195]
                )
              spids: [150 -1]
            )
          ]
          spids: [142]
        )
      spids: [137 141]
    )
    (C {(test_expect_success)} {(SQ <"switch to the last">)} 
      {
        (SQ <"\n"> <"\tmore_switches &&\n"> <"\tgit checkout @{-1} &&\n"> 
          <"\ttest \"z$(git symbolic-ref HEAD)\" = \"zrefs/heads/branch2\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"switch to second from the last">)} 
      {
        (SQ <"\n"> <"\tmore_switches &&\n"> <"\tgit checkout @{-2} &&\n"> 
          <"\ttest \"z$(git symbolic-ref HEAD)\" = \"zrefs/heads/branch3\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"switch to third from the last">)} 
      {
        (SQ <"\n"> <"\tmore_switches &&\n"> <"\tgit checkout @{-3} &&\n"> 
          <"\ttest \"z$(git symbolic-ref HEAD)\" = \"zrefs/heads/branch4\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"switch to fourth from the last">)} 
      {
        (SQ <"\n"> <"\tmore_switches &&\n"> <"\tgit checkout @{-4} &&\n"> 
          <"\ttest \"z$(git symbolic-ref HEAD)\" = \"zrefs/heads/branch5\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"switch to twelfth from the last">)} 
      {
        (SQ <"\n"> <"\tmore_switches &&\n"> <"\tgit checkout @{-12} &&\n"> 
          <"\ttest \"z$(git symbolic-ref HEAD)\" = \"zrefs/heads/branch13\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"merge base test setup">)} 
      {
        (SQ <"\n"> <"\tgit checkout -b another other &&\n"> <"\techo \"hello again\" >>world &&\n"> 
          <"\tgit add world &&\n"> <"\tgit commit -m third\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <another...master>)} 
      {
        (SQ <"\n"> <"\tgit checkout another &&\n"> <"\tgit checkout another...master &&\n"> 
          <"\ttest \"z$(git rev-parse --verify HEAD)\" = \"z$(git rev-parse --verify master^)\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <...master>)} 
      {
        (SQ <"\n"> <"\tgit checkout another &&\n"> <"\tgit checkout ...master &&\n"> 
          <"\ttest \"z$(git rev-parse --verify HEAD)\" = \"z$(git rev-parse --verify master^)\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <master...>)} 
      {
        (SQ <"\n"> <"\tgit checkout another &&\n"> <"\tgit checkout master... &&\n"> 
          <"\ttest \"z$(git rev-parse --verify HEAD)\" = \"z$(git rev-parse --verify master^)\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"\"checkout -\" works after a rebase A">)} 
      {
        (SQ <"\n"> <"\tgit checkout master &&\n"> <"\tgit checkout other &&\n"> 
          <"\tgit rebase master &&\n"> <"\tgit checkout - &&\n"> <"\ttest \"z$(git symbolic-ref HEAD)\" = \"zrefs/heads/master\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"\"checkout -\" works after a rebase A B">)} 
      {
        (SQ <"\n"> <"\tgit branch moodle master~1 &&\n"> <"\tgit checkout master &&\n"> 
          <"\tgit checkout other &&\n"> <"\tgit rebase master moodle &&\n"> <"\tgit checkout - &&\n"> 
          <"\ttest \"z$(git symbolic-ref HEAD)\" = \"zrefs/heads/master\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"\"checkout -\" works after a rebase -i A">)} 
      {
        (SQ <"\n"> <"\tgit checkout master &&\n"> <"\tgit checkout other &&\n"> 
          <"\tgit rebase -i master &&\n"> <"\tgit checkout - &&\n"> <"\ttest \"z$(git symbolic-ref HEAD)\" = \"zrefs/heads/master\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"\"checkout -\" works after a rebase -i A B">)} 
      {
        (SQ <"\n"> <"\tgit branch foodle master~1 &&\n"> <"\tgit checkout master &&\n"> 
          <"\tgit checkout other &&\n"> <"\tgit rebase master foodle &&\n"> <"\tgit checkout - &&\n"> 
          <"\ttest \"z$(git symbolic-ref HEAD)\" = \"zrefs/heads/master\"\n">
        )
      }
    )
    (C {(test_done)})
  ]
)