(command.CommandList
  children: [
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:test_description)
          op: Equal
          rhs: {(SQ <'merge simplification'>)}
        )
      ]
    )
    (C {(.)} {(./test-lib.sh)})
    (command.FuncDef
      name: note
      body: (command.BraceGroup children:[(C {(git)} {(tag)} {(DQ ($ VSub_Number '$1'))})])
    )
    (command.FuncDef
      name: unnote
      body: 
        (command.BraceGroup
          children: [
            (command.Pipeline
              children: [
                (C {(git)} {(name-rev)} {(--tags)} {(--stdin)})
                (C {(sed)} {(-e)} 
                  {
                    (DQ ('s|') ($ VSub_DollarName '$_x40') (' (tags/') (Lit_Other '\\') ('([^)]*') 
                      (Lit_Other '\\') (')) |') (Lit_Other '\\') ('1 |g')
                    )
                  }
                )
              ]
              negated: F
            )
          ]
        )
    )
    (C {(test_expect_success)} {(setup)} 
      {
        (SQ <'\n'> <'\techo "Hi there" >file &&\n'> <'\techo "initial" >lost &&\n'> 
          <'\tgit add file lost &&\n'> <'\ttest_tick && git commit -m "Initial file and lost" &&\n'> <'\tnote A &&\n'> <'\n'> 
          <'\tgit branch other-branch &&\n'> <'\n'> <'\techo "Hello" >file &&\n'> <'\techo "second" >lost &&\n'> <'\tgit add file lost &&\n'> 
          <'\ttest_tick && git commit -m "Modified file and lost" &&\n'> <'\tnote B &&\n'> <'\n'> <'\tgit checkout other-branch &&\n'> <'\n'> <'\techo "Hello" >file &&\n'> 
          <'\t>lost &&\n'> <'\tgit add file lost &&\n'> <'\ttest_tick && git commit -m "Modified the file identically" &&\n'> 
          <'\tnote C &&\n'> <'\n'> <'\techo "This is a stupid example" >another-file &&\n'> <'\tgit add another-file &&\n'> 
          <'\ttest_tick && git commit -m "Add another file" &&\n'> <'\tnote D &&\n'> <'\n'> <'\ttest_tick &&\n'> <'\ttest_must_fail git merge -m "merge" master &&\n'> 
          <'\t>lost && git commit -a -m "merge" &&\n'> <'\tnote E &&\n'> <'\n'> <'\techo "Yet another" >elif &&\n'> <'\tgit add elif &&\n'> 
          <'\ttest_tick && git commit -m "Irrelevant change" &&\n'> <'\tnote F &&\n'> <'\n'> <'\tgit checkout master &&\n'> <'\techo "Yet another" >elif &&\n'> 
          <'\tgit add elif &&\n'> <'\ttest_tick && git commit -m "Another irrelevant change" &&\n'> <'\tnote G &&\n'> <'\n'> 
          <'\ttest_tick && git merge -m "merge" other-branch &&\n'> <'\tnote H &&\n'> <'\n'> <'\techo "Final change" >file &&\n'> 
          <'\ttest_tick && git commit -a -m "Final change" &&\n'> <'\tnote I &&\n'> <'\n'> <'\tgit symbolic-ref HEAD refs/heads/unrelated &&\n'> <'\tgit rm -f "*" &&\n'> 
          <'\techo "Unrelated branch" >side &&\n'> <'\tgit add side &&\n'> <'\ttest_tick && git commit -m "Side root" &&\n'> <'\tnote J &&\n'> <'\n'> 
          <'\tgit checkout master &&\n'> <'\ttest_tick && git merge --allow-unrelated-histories -m "Coolest" unrelated &&\n'> <'\tnote K &&\n'> 
          <'\n'> <'\techo "Immaterial" >elif &&\n'> <'\tgit add elif &&\n'> <'\ttest_tick && git commit -m "Last" &&\n'> 
          <'\tnote L\n'>
        )
      }
    )
    (command.Assignment
      keyword: Assign_None
      pairs: [(assign_pair lhs:(lhs_expr.LhsName name:FMT) op:Equal rhs:{(SQ <'tformat:%P \t%H | %s'>)})]
    )
    (command.FuncDef
      name: check_outcome
      body: 
        (command.BraceGroup
          children: [
            (command.Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (lhs_expr.LhsName name:outcome)
                  op: Equal
                  rhs: {($ VSub_Number '$1')}
                )
              ]
            )
            (C {(shift)})
            (command.AndOr
              ops: [Op_DAmp Op_DAmp Op_DAmp]
              children: [
                (command.ForEach
                  iter_name: c
                  iter_words: [{($ VSub_Number '$1')}]
                  do_arg_iter: F
                  body: (command.DoGroup children:[(C {(echo)} {(DQ ($ VSub_DollarName '$c'))})])
                  redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect)})]
                )
                (C {(shift)})
                (command.Assignment
                  keyword: Assign_None
                  pairs: [
                    (assign_pair
                      lhs: (lhs_expr.LhsName name:param)
                      op: Equal
                      rhs: {(DQ ($ VSub_Star '$*'))}
                    )
                  ]
                )
                (C {(test_expect_) ($ VSub_DollarName '$outcome')} 
                  {(DQ ('log ') ($ VSub_DollarName '$param'))} 
                  {
                    (SQ <'\n'> <'\t\tgit log --pretty="$FMT" --parents $param |\n'> 
                      <'\t\tunnote >actual &&\n'> <'\t\tsed -e "s/^.*\t\\([^ ]*\\) .*/\\1/" >check <actual &&\n'> <'\t\ttest_cmp expect check\n'> <'\t'>
                    )
                  }
                )
              ]
            )
          ]
        )
    )
    (command.FuncDef
      name: check_result
      body: (command.BraceGroup children:[(C {(check_outcome)} {(success)} {(DQ ($ VSub_At '$@'))})])
    )
    (C {(check_result)} {(SQ <'L K J I H G F E D C B A'>)} {(--full-history)})
    (C {(check_result)} {(SQ <'K I H E C B A'>)} {(--full-history)} {(--)} {(file)})
    (C {(check_result)} {(SQ <'K I H E C B A'>)} {(--full-history)} {(--topo-order)} {(--)} {(file)})
    (C {(check_result)} {(SQ <'K I H E C B A'>)} {(--full-history)} {(--date-order)} {(--)} {(file)})
    (C {(check_result)} {(SQ <'I E C B A'>)} {(--simplify-merges)} {(--)} {(file)})
    (C {(check_result)} {(SQ <'I B A'>)} {(--)} {(file)})
    (C {(check_result)} {(SQ <'I B A'>)} {(--topo-order)} {(--)} {(file)})
    (C {(check_result)} {(SQ <H>)} {(--first-parent)} {(--)} {(another-file)})
    (C {(check_result)} {(SQ <'E C B A'>)} {(--full-history)} {(E)} {(--)} {(lost)})
    (C {(test_expect_success)} {(SQ <'full history simplification without parent'>)} 
      {
        (SQ <'\n'> <'\tprintf "%s\\n" E C B A >expect &&\n'> 
          <'\tgit log --pretty="$FMT" --full-history E -- lost |\n'> <'\tunnote >actual &&\n'> <'\tsed -e "s/^.*\t\\([^ ]*\\) .*/\\1/" >check <actual &&\n'> 
          <'\ttest_cmp expect check\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'--full-diff is not affected by --parents'>)} 
      {
        (SQ <'\n'> <'\tgit log -p --pretty="%H" --full-diff -- file >expected &&\n'> 
          <'\tgit log -p --pretty="%H" --full-diff --parents -- file >actual &&\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {(test_done)})
  ]
)