(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <"merging with large rename matrix">)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./test-lib.sh)})
    (FuncDef
      name: count
      body: 
        (BraceGroup
          children: [
            (Assignment
              keyword: Assign_None
              pairs: [(assign_pair lhs:(LhsName name:i) op:Equal rhs:{(1)} spids:[21])]
              spids: [21]
            )
            (While
              cond: [
                (Sentence
                  child: (C {(test)} {($ VSub_Name "$i")} {(-le)} {($ VSub_Number "$1")})
                  terminator: <Op_Semi ";">
                )
              ]
              body: 
                (DoGroup
                  children: [
                    (C {(echo)} {($ VSub_Name "$i")})
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:i)
                          op: Equal
                          rhs: 
                            {
                              (ArithSubPart
                                anode: 
                                  (ArithBinary
                                    op_id: Arith_Plus
                                    left: (ArithWord w:{($ VSub_Name "$i")})
                                    right: (ArithWord w:{(Lit_Digits 1)})
                                  )
                                spids: [45 52]
                              )
                            }
                          spids: [44]
                        )
                      ]
                      spids: [44]
                    )
                  ]
                  spids: [36 55]
                )
            )
          ]
          spids: [18]
        )
      spids: [14 17]
    )
    (C {(test_expect_success)} {(SQ <"setup (initial)">)} 
      {
        (SQ <"\n"> <"\ttouch file &&\n"> <"\tgit add . &&\n"> <"\tgit commit -m initial &&\n"> 
          <"\tgit tag initial\n">
        )
      }
    )
    (FuncDef
      name: make_text
      body: 
        (BraceGroup
          children: [
            (C {(echo)} {($ VSub_Number "$1") (Lit_Other ":")} {($ VSub_Number "$2")})
            (ForEach
              iter_name: i
              iter_words: [
                {
                  (CommandSubPart
                    command_list: (CommandList children:[(C {(count)} {(20)})])
                    left_token: <Left_CommandSub "$(">
                    spids: [96 100]
                  )
                }
              ]
              do_arg_iter: False
              body: 
                (DoGroup
                  children: [(C {(echo)} {($ VSub_Number "$1") (Lit_Other ":")} {($ VSub_Name "$i")})]
                  spids: [103 114]
                )
              spids: [95 101]
            )
            (C {(echo)} {($ VSub_Number "$1") (Lit_Other ":")} {($ VSub_Number "$3")})
          ]
          spids: [79]
        )
      spids: [75 78]
    )
    (FuncDef
      name: test_rename
      body: 
        (BraceGroup
          children: [
            (C {(test_expect_success)} 
              {(DQ ("rename (") ($ VSub_Number "$1") (", ") ($ VSub_Number "$2") (")"))} 
              {(SQ <"\n"> <"\tn=">) ($ VSub_Number "$1") (SQ <" &&\n"> <"\texpect=">) 
                ($ VSub_Number "$2") 
                (SQ <" &&\n"> <"\tgit checkout -f master &&\n"> 
                  <"\ttest_might_fail git branch -D test$n &&\n"> <"\tgit reset --hard initial &&\n"> <"\tfor i in $(count $n); do\n"> 
                  <"\t\tmake_text $i initial initial >$i\n"> <"\tdone &&\n"> <"\tgit add . &&\n"> <"\tgit commit -m add=$n &&\n"> <"\tfor i in $(count $n); do\n"> 
                  <"\t\tmake_text $i changed initial >$i\n"> <"\tdone &&\n"> <"\tgit commit -a -m change=$n &&\n"> <"\tgit checkout -b test$n HEAD^ &&\n"> 
                  <"\tfor i in $(count $n); do\n"> <"\t\tgit rm $i\n"> <"\t\tmake_text $i initial changed >$i.moved\n"> <"\tdone &&\n"> 
                  <"\tgit add . &&\n"> <"\tgit commit -m change+rename=$n &&\n"> <"\tcase \"$expect\" in\n"> <"\t\tok) git merge master ;;\n"> 
                  <"\t\t *) test_must_fail git merge master ;;\n"> <"\tesac\n"> <"\t">
                )
              }
            )
          ]
          spids: [131]
        )
      spids: [127 130]
    )
    (C {(test_rename)} {(5)} {(ok)})
    (C {(test_expect_success)} {(SQ <"set diff.renamelimit to 4">)} 
      {(SQ <"\n"> <"\tgit config diff.renamelimit 4\n">)}
    )
    (C {(test_rename)} {(4)} {(ok)})
    (C {(test_rename)} {(5)} {(fail)})
    (C {(test_expect_success)} {(SQ <"set merge.renamelimit to 5">)} 
      {(SQ <"\n"> <"\tgit config merge.renamelimit 5\n">)}
    )
    (C {(test_rename)} {(5)} {(ok)})
    (C {(test_rename)} {(6)} {(fail)})
    (C {(test_expect_success)} {(SQ <"setup large simple rename">)} 
      {
        (SQ <"\n"> <"\tgit config --unset merge.renamelimit &&\n"> 
          <"\tgit config --unset diff.renamelimit &&\n"> <"\n"> <"\tgit reset --hard initial &&\n"> <"\tfor i in $(count 200); do\n"> 
          <"\t\tmake_text foo bar baz >$i\n"> <"\tdone &&\n"> <"\tgit add . &&\n"> <"\tgit commit -m create-files &&\n"> <"\n"> 
          <"\tgit branch simple-change &&\n"> <"\tgit checkout -b simple-rename &&\n"> <"\n"> <"\tmkdir builtin &&\n"> 
          <"\tgit mv [0-9]* builtin/ &&\n"> <"\tgit commit -m renamed &&\n"> <"\n"> <"\tgit checkout simple-change &&\n"> 
          <"\t>unrelated-change &&\n"> <"\tgit add unrelated-change &&\n"> <"\tgit commit -m unrelated-change\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"massive simple rename does not spam added files">)} 
      {
        (SQ <"\n"> <"\tsane_unset GIT_MERGE_VERBOSITY &&\n"> 
          <"\tgit merge --no-stat simple-rename | grep -v Removing >output &&\n"> <"\ttest_line_count -lt 5 output\n">
        )
      }
    )
    (C {(test_done)})
  ]
)