(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: {(SQ <'ancestor culling and limiting by parent number'>)}
          spids: [4]
        )
      ]
    )
    (C {<.>} {<'./test-lib.sh'>})
    (command.ShFunction
      name: check_revlist
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp]
              children: [
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:rev_list_args)
                      op: assign_op.Equal
                      rhs: {(DQ ($ Id.VSub_Number '$1'))}
                      spids: [23]
                    )
                  ]
                )
                (C {<shift>})
                (command.Simple
                  words: [{<git>} {<rev-parse>} {(DQ ($ Id.VSub_At '$@'))}]
                  redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})]
                  do_fork: T
                )
                (command.Simple
                  words: [{<git>} {<rev-list>} {($ Id.VSub_DollarName '$rev_list_args')} {<--all>}]
                  redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<actual>})]
                  do_fork: T
                )
                (C {<test_cmp>} {<expect>} {<actual>})
              ]
            )
          ]
        )
    )
    (C {<test_expect_success>} {<setup>} 
      {
        (SQ <'\n'> <'\n'> <'\ttouch file &&\n'> <'\tgit add file &&\n'> <'\n'> <'\ttest_commit one &&\n'> 
          <'\n'> <'\ttest_tick=$(($test_tick - 2400)) &&\n'> <'\n'> <'\ttest_commit two &&\n'> 
          <'\ttest_commit three &&\n'> <'\ttest_commit four &&\n'> <'\n'> <'\tgit log --pretty=oneline --abbrev-commit\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'one is ancestor of others and should not be shown'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit rev-list one --not four >result &&\n'> <'\t>expect &&\n'> 
          <'\ttest_cmp expect result\n'> <'\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'setup roots, merges and octopuses'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit checkout --orphan newroot &&\n'> <'\ttest_commit five &&\n'> 
          <'\tgit checkout -b sidebranch two &&\n'> <'\ttest_commit six &&\n'> <'\tgit checkout -b anotherbranch three &&\n'> <'\ttest_commit seven &&\n'> 
          <'\tgit checkout -b yetanotherbranch four &&\n'> <'\ttest_commit eight &&\n'> <'\tgit checkout master &&\n'> <'\ttest_tick &&\n'> 
          <'\tgit merge --allow-unrelated-histories -m normalmerge newroot &&\n'> <'\tgit tag normalmerge &&\n'> <'\ttest_tick &&\n'> 
          <'\tgit merge -m tripus sidebranch anotherbranch &&\n'> <'\tgit tag tripus &&\n'> <'\tgit checkout -b tetrabranch normalmerge &&\n'> <'\ttest_tick &&\n'> 
          <'\tgit merge -m tetrapus sidebranch anotherbranch yetanotherbranch &&\n'> <'\tgit tag tetrapus &&\n'> <'\tgit checkout master\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rev-list roots'>)} 
      {(SQ <'\n'> <'\n'> <'\tcheck_revlist "--max-parents=0" one five\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'rev-list no merges'>)} 
      {
        (SQ <'\n'> <'\n'> 
          <'\tcheck_revlist "--max-parents=1" one eight seven six five four three two &&\n'> <'\tcheck_revlist "--no-merges" one eight seven six five four three two\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rev-list no octopuses'>)} 
      {
        (SQ <'\n'> <'\n'> 
          <
'\tcheck_revlist "--max-parents=2" one normalmerge eight seven six five four three two\n'
          >
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rev-list no roots'>)} 
      {
        (SQ <'\n'> <'\n'> 
          <
'\tcheck_revlist "--min-parents=1" tetrapus tripus normalmerge eight seven six four three two\n'
          >
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rev-list merges'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tcheck_revlist "--min-parents=2" tetrapus tripus normalmerge &&\n'> 
          <'\tcheck_revlist "--merges" tetrapus tripus normalmerge\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rev-list octopus'>)} 
      {(SQ <'\n'> <'\n'> <'\tcheck_revlist "--min-parents=3" tetrapus tripus\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'rev-list ordinary commits'>)} 
      {
        (SQ <'\n'> <'\n'> 
          <'\tcheck_revlist "--min-parents=1 --max-parents=1" eight seven six four three two\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rev-list --merges --no-merges yields empty set'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tcheck_revlist "--min-parents=2 --no-merges" &&\n'> 
          <'\tcheck_revlist "--merges --no-merges" &&\n'> <'\tcheck_revlist "--no-merges --merges"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rev-list override and infinities'>)} 
      {
        (SQ <'\n'> <'\n'> 
          <
'\tcheck_revlist "--min-parents=2 --max-parents=1 --max-parents=3" tripus normalmerge &&\n'
          > 
          <
'\tcheck_revlist "--min-parents=1 --min-parents=2 --max-parents=7" tetrapus tripus normalmerge &&\n'
          > <'\tcheck_revlist "--min-parents=2 --max-parents=8" tetrapus tripus normalmerge &&\n'> 
          <'\tcheck_revlist "--min-parents=2 --max-parents=-1" tetrapus tripus normalmerge &&\n'> <'\tcheck_revlist "--min-parents=2 --no-max-parents" tetrapus tripus normalmerge &&\n'> 
          <'\tcheck_revlist "--max-parents=0 --min-parents=1 --no-min-parents" one five\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <dodecapus>)} 
      {
        (SQ <'\n'> <'\n'> <'\troots= &&\n'> <'\tfor i in 1 2 3 4 5 6 7 8 9 10 11\n'> <'\tdo\n'> 
          <'\t\tgit checkout -b root$i five &&\n'> <'\t\ttest_commit $i &&\n'> <'\t\troots="$roots root$i" ||\n'> <'\t\treturn\n'> <'\tdone &&\n'> 
          <'\tgit checkout master &&\n'> <'\ttest_tick &&\n'> <'\tgit merge -m dodecapus $roots &&\n'> <'\tgit tag dodecapus &&\n'> <'\n'> 
          <'\tcheck_revlist "--min-parents=4" dodecapus tetrapus &&\n'> <'\tcheck_revlist "--min-parents=8" dodecapus &&\n'> 
          <'\tcheck_revlist "--min-parents=12" dodecapus &&\n'> <'\tcheck_revlist "--min-parents=13" &&\n'> 
          <'\tcheck_revlist "--min-parents=4 --max-parents=11" tetrapus\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'ancestors with the same commit time'>)} 
      {
        (SQ <'\n'> <'\n'> <'\ttest_tick_keep=$test_tick &&\n'> <'\tfor i in 1 2 3 4 5 6 7 8; do\n'> 
          <'\t\ttest_tick=$test_tick_keep\n'> <'\t\ttest_commit t$i\n'> <'\tdone &&\n'> <'\tgit rev-list t1^! --not t$i >result &&\n'> 
          <'\t>expect &&\n'> <'\ttest_cmp expect result\n'>
        )
      }
    )
    (C {<test_done>})
  ]
)