(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: 
            {
              (SQ <"merge-recursive rename options\n"> <"\n"> 
                <"Test rename detection by examining rename/delete conflicts.\n"> <"\n"> <"* (HEAD -> rename) rename\n"> <"| * (master) delete\n"> <"|/\n"> <"* base\n"> <"\n"> 
                <"git diff --name-status base master\n"> <"D\t0-old\n"> <"D\t1-old\n"> <"D\t2-old\n"> <"D\t3-old\n"> <"\n"> 
                <"git diff --name-status -M01 base rename\n"> <"R025    0-old   0-new\n"> <"R050    1-old   1-new\n"> <"R075    2-old   2-new\n"> 
                <"R100    3-old   3-new\n"> <"\n"> <"Actual similarity indices are parsed from diff output. We rely on the fact that\n"> 
                <
"they are rounded down (see, e.g., Documentation/diff-generate-patch.txt, which\n"
                > <"mentions this in a different context).\n">
              )
            }
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./test-lib.sh)})
    (FuncDef
      name: get_expected_stages
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (C {(git)} {(checkout)} {(rename)} {(--)} {($ VSub_Number "$1") (-new)})
                (AndOr
                  children: [
                    (SimpleCommand
                      words: [{(git)} {(ls-files)} {(--stage)} {($ VSub_Number "$1") (-new)}]
                      redirects: [
                        (Redir
                          op_id: Redir_Great
                          fd: -1
                          arg_word: {(expected-stages-undetected-) ($ VSub_Number "$1")}
                          spids: [69]
                        )
                      ]
                    )
                    (AndOr
                      children: [
                        (SimpleCommand
                          words: [{(sed)} {(DQ ("s/ 0\t/ 2\t/"))}]
                          redirects: [
                            (Redir
                              op_id: Redir_Less
                              fd: -1
                              arg_word: {(expected-stages-undetected-) ($ VSub_Number "$1")}
                              spids: [82]
                            )
                            (Redir
                              op_id: Redir_Great
                              fd: -1
                              arg_word: {(expected-stages-detected-) ($ VSub_Number "$1")}
                              spids: [88]
                            )
                          ]
                        )
                        (C {(git)} {(read-tree)} {(-u)} {(--reset)} {(HEAD)})
                      ]
                      op_id: Op_DAmp
                    )
                  ]
                  op_id: Op_DAmp
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [43]
        )
      spids: [38 42]
    )
    (FuncDef
      name: rename_detected
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (SimpleCommand
                  words: [
                    {(git)}
                    {(ls-files)}
                    {(--stage)}
                    {($ VSub_Number "$1") (-old)}
                    {($ VSub_Number "$1") (-new)}
                  ]
                  redirects: [
                    (Redir
                      op_id: Redir_Great
                      fd: -1
                      arg_word: {(stages-actual-) ($ VSub_Number "$1")}
                      spids: [128]
                    )
                  ]
                )
                (C {(test_cmp)} {(expected-stages-detected-) ($ VSub_Number "$1")} 
                  {(stages-actual-) ($ VSub_Number "$1")}
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [113]
        )
      spids: [108 112]
    )
    (FuncDef
      name: rename_undetected
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (SimpleCommand
                  words: [
                    {(git)}
                    {(ls-files)}
                    {(--stage)}
                    {($ VSub_Number "$1") (-old)}
                    {($ VSub_Number "$1") (-new)}
                  ]
                  redirects: [
                    (Redir
                      op_id: Redir_Great
                      fd: -1
                      arg_word: {(stages-actual-) ($ VSub_Number "$1")}
                      spids: [166]
                    )
                  ]
                )
                (C {(test_cmp)} {(expected-stages-undetected-) ($ VSub_Number "$1")} 
                  {(stages-actual-) ($ VSub_Number "$1")}
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [151]
        )
      spids: [146 150]
    )
    (FuncDef
      name: check_common
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (SimpleCommand
                  words: [{(git)} {(ls-files)} {(--stage)}]
                  redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(stages-actual)} spids:[198])]
                )
                (C {(test_line_count)} {(Lit_Other "=")} {(4)} {(stages-actual)})
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [189]
        )
      spids: [184 188]
    )
    (FuncDef
      name: check_threshold_0
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (C {(check_common)})
                (AndOr
                  children: [
                    (C {(rename_detected)} {(0)})
                    (AndOr
                      children: [
                        (C {(rename_detected)} {(1)})
                        (AndOr
                          children: [(C {(rename_detected)} {(2)}) (C {(rename_detected)} {(3)})]
                          op_id: Op_DAmp
                        )
                      ]
                      op_id: Op_DAmp
                    )
                  ]
                  op_id: Op_DAmp
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [220]
        )
      spids: [215 219]
    )
    (FuncDef
      name: check_threshold_1
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (C {(check_common)})
                (AndOr
                  children: [
                    (C {(rename_undetected)} {(0)})
                    (AndOr
                      children: [
                        (C {(rename_detected)} {(1)})
                        (AndOr
                          children: [(C {(rename_detected)} {(2)}) (C {(rename_detected)} {(3)})]
                          op_id: Op_DAmp
                        )
                      ]
                      op_id: Op_DAmp
                    )
                  ]
                  op_id: Op_DAmp
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [261]
        )
      spids: [256 260]
    )
    (FuncDef
      name: check_threshold_2
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (C {(check_common)})
                (AndOr
                  children: [
                    (C {(rename_undetected)} {(0)})
                    (AndOr
                      children: [
                        (C {(rename_undetected)} {(1)})
                        (AndOr
                          children: [(C {(rename_detected)} {(2)}) (C {(rename_detected)} {(3)})]
                          op_id: Op_DAmp
                        )
                      ]
                      op_id: Op_DAmp
                    )
                  ]
                  op_id: Op_DAmp
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [302]
        )
      spids: [297 301]
    )
    (FuncDef
      name: check_exact_renames
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (C {(check_common)})
                (AndOr
                  children: [
                    (C {(rename_undetected)} {(0)})
                    (AndOr
                      children: [
                        (C {(rename_undetected)} {(1)})
                        (AndOr
                          children: [(C {(rename_undetected)} {(2)}) (C {(rename_detected)} {(3)})]
                          op_id: Op_DAmp
                        )
                      ]
                      op_id: Op_DAmp
                    )
                  ]
                  op_id: Op_DAmp
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [343]
        )
      spids: [338 342]
    )
    (FuncDef
      name: check_no_renames
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (C {(check_common)})
                (AndOr
                  children: [
                    (C {(rename_undetected)} {(0)})
                    (AndOr
                      children: [
                        (C {(rename_undetected)} {(1)})
                        (AndOr
                          children: [(C {(rename_undetected)} {(2)}) (C {(rename_undetected)} {(3)})]
                          op_id: Op_DAmp
                        )
                      ]
                      op_id: Op_DAmp
                    )
                  ]
                  op_id: Op_DAmp
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [384]
        )
      spids: [379 383]
    )
    (C {(test_expect_success)} {(SQ <"setup repo">)} 
      {
        (SQ <"\n"> <"\tcat <<-\\EOF >3-old &&\n"> <"\t33a\n"> <"\t33b\n"> <"\t33c\n"> <"\t33d\n"> 
          <"\tEOF\n"> <"\tsed s/33/22/ <3-old >2-old &&\n"> <"\tsed s/33/11/ <3-old >1-old &&\n"> 
          <"\tsed s/33/00/ <3-old >0-old &&\n"> <"\tgit add [0-3]-old &&\n"> <"\tgit commit -m base &&\n"> <"\tgit rm [0-3]-old &&\n"> 
          <"\tgit commit -m delete &&\n"> <"\tgit checkout -b rename HEAD^ &&\n"> <"\tcp 3-old 3-new &&\n"> 
          <"\tsed 1,1s/./x/ <2-old >2-new &&\n"> <"\tsed 1,2s/./x/ <1-old >1-new &&\n"> <"\tsed 1,3s/./x/ <0-old >0-new &&\n"> 
          <"\tgit add [0-3]-new &&\n"> <"\tgit rm [0-3]-old &&\n"> <"\tgit commit -m rename &&\n"> <"\tget_expected_stages 0 &&\n"> 
          <"\tget_expected_stages 1 &&\n"> <"\tget_expected_stages 2 &&\n"> <"\tget_expected_stages 3 &&\n"> <"\tcheck_50=\"false\" &&\n"> 
          <"\ttail=\"HEAD^ -- HEAD master\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"setup thresholds">)} 
      {
        (SQ <"\n"> <"\tgit diff --name-status -M01 HEAD^ HEAD >diff-output &&\n"> 
          <"\ttest_debug \"cat diff-output\" &&\n"> <"\ttest_line_count = 4 diff-output &&\n"> 
          <"\tgrep \"R[0-9][0-9][0-9]\t\\([0-3]\\)-old\t\\1-new\" diff-output \\\n"> <"\t\t>grep-output &&\n"> <"\ttest_cmp diff-output grep-output &&\n"> 
          <"\tth0=$(sed -n \"s/R\\(...\\)\t0-old\t0-new/\\1/p\" <diff-output) &&\n"> <"\tth1=$(sed -n \"s/R\\(...\\)\t1-old\t1-new/\\1/p\" <diff-output) &&\n"> 
          <"\tth2=$(sed -n \"s/R\\(...\\)\t2-old\t2-new/\\1/p\" <diff-output) &&\n"> <"\tth3=$(sed -n \"s/R\\(...\\)\t3-old\t3-new/\\1/p\" <diff-output) &&\n"> 
          <"\ttest \"$th0\" -lt \"$th1\" &&\n"> <"\ttest \"$th1\" -lt \"$th2\" &&\n"> <"\ttest \"$th2\" -lt \"$th3\" &&\n"> 
          <"\ttest \"$th3\" = 100 &&\n"> <"\tif test 50 -le \"$th0\"\n"> <"\tthen\n"> <"\t\tcheck_50=check_threshold_0\n"> 
          <"\telif test 50 -le \"$th1\"\n"> <"\tthen\n"> <"\t\tcheck_50=check_threshold_1\n"> <"\telif test 50 -le \"$th2\"\n"> <"\tthen\n"> 
          <"\t\tcheck_50=check_threshold_2\n"> <"\tfi &&\n"> <"\tth0=\"$th0%\" &&\n"> <"\tth1=\"$th1%\" &&\n"> <"\tth2=\"$th2%\" &&\n"> 
          <"\tth3=\"$th3%\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"assumption for tests: rename detection with diff">)} 
      {
        (SQ <"\n"> <"\tgit diff --name-status -M$th0 --diff-filter=R HEAD^ HEAD \\\n"> 
          <"\t\t>diff-output-0 &&\n"> <"\tgit diff --name-status -M$th1 --diff-filter=R HEAD^ HEAD \\\n"> <"\t\t>diff-output-1 &&\n"> 
          <"\tgit diff --name-status -M$th2 --diff-filter=R HEAD^ HEAD \\\n"> <"\t\t>diff-output-2 &&\n"> <"\tgit diff --name-status -M100% --diff-filter=R HEAD^ HEAD \\\n"> 
          <"\t\t>diff-output-3 &&\n"> <"\ttest_line_count = 4 diff-output-0 &&\n"> <"\ttest_line_count = 3 diff-output-1 &&\n"> 
          <"\ttest_line_count = 2 diff-output-2 &&\n"> <"\ttest_line_count = 1 diff-output-3\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"default similarity threshold is 50%">)} 
      {
        (SQ <"\n"> <"\tgit read-tree --reset -u HEAD &&\n"> 
          <"\ttest_must_fail git merge-recursive $tail &&\n"> <"\t$check_50\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"low rename threshold">)} 
      {
        (SQ <"\n"> <"\tgit read-tree --reset -u HEAD &&\n"> 
          <"\ttest_must_fail git merge-recursive --find-renames=$th0 $tail &&\n"> <"\tcheck_threshold_0\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"medium rename threshold">)} 
      {
        (SQ <"\n"> <"\tgit read-tree --reset -u HEAD &&\n"> 
          <"\ttest_must_fail git merge-recursive --find-renames=$th1 $tail &&\n"> <"\tcheck_threshold_1\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"high rename threshold">)} 
      {
        (SQ <"\n"> <"\tgit read-tree --reset -u HEAD &&\n"> 
          <"\ttest_must_fail git merge-recursive --find-renames=$th2 $tail &&\n"> <"\tcheck_threshold_2\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"exact renames only">)} 
      {
        (SQ <"\n"> <"\tgit read-tree --reset -u HEAD &&\n"> 
          <"\ttest_must_fail git merge-recursive --find-renames=100% $tail &&\n"> <"\tcheck_exact_renames\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"rename threshold is truncated">)} 
      {
        (SQ <"\n"> <"\tgit read-tree --reset -u HEAD &&\n"> 
          <"\ttest_must_fail git merge-recursive --find-renames=200% $tail &&\n"> <"\tcheck_exact_renames\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"disabled rename detection">)} 
      {
        (SQ <"\n"> <"\tgit read-tree --reset -u HEAD &&\n"> 
          <"\tgit merge-recursive --no-renames $tail &&\n"> <"\tcheck_no_renames\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"last wins in --find-renames=<m> --find-renames=<n>">)} 
      {
        (SQ <"\n"> <"\tgit read-tree --reset -u HEAD &&\n"> 
          <"\ttest_must_fail git merge-recursive \\\n"> <"\t\t--find-renames=$th0 --find-renames=$th2 $tail &&\n"> <"\tcheck_threshold_2\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"--find-renames resets threshold">)} 
      {
        (SQ <"\n"> <"\tgit read-tree --reset -u HEAD &&\n"> 
          <"\ttest_must_fail git merge-recursive \\\n"> <"\t\t--find-renames=$th0 --find-renames $tail &&\n"> <"\t$check_50\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"last wins in --no-renames --find-renames">)} 
      {
        (SQ <"\n"> <"\tgit read-tree --reset -u HEAD &&\n"> 
          <"\ttest_must_fail git merge-recursive --no-renames --find-renames $tail &&\n"> <"\t$check_50\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"last wins in --find-renames --no-renames">)} 
      {
        (SQ <"\n"> <"\tgit read-tree --reset -u HEAD &&\n"> 
          <"\tgit merge-recursive --find-renames --no-renames $tail &&\n"> <"\tcheck_no_renames\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"assumption for further tests: trivial merge succeeds">)} 
      {
        (SQ <"\n"> <"\tgit read-tree --reset -u HEAD &&\n"> 
          <"\tgit merge-recursive HEAD -- HEAD HEAD &&\n"> <"\tgit diff --quiet --cached &&\n"> 
          <"\tgit merge-recursive --find-renames=$th0 HEAD -- HEAD HEAD &&\n"> <"\tgit diff --quiet --cached &&\n"> 
          <"\tgit merge-recursive --find-renames=$th2 HEAD -- HEAD HEAD &&\n"> <"\tgit diff --quiet --cached &&\n"> 
          <"\tgit merge-recursive --find-renames=100% HEAD -- HEAD HEAD &&\n"> <"\tgit diff --quiet --cached &&\n"> <"\tgit merge-recursive --no-renames HEAD -- HEAD HEAD &&\n"> 
          <"\tgit diff --quiet --cached\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"--find-renames rejects negative argument">)} 
      {
        (SQ <"\n"> <"\tgit read-tree --reset -u HEAD &&\n"> 
          <"\ttest_must_fail git merge-recursive --find-renames=-25 \\\n"> <"\t\tHEAD -- HEAD HEAD &&\n"> <"\tgit diff --quiet --cached\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"--find-renames rejects non-numbers">)} 
      {
        (SQ <"\n"> <"\tgit read-tree --reset -u HEAD &&\n"> 
          <"\ttest_must_fail git merge-recursive --find-renames=0xf \\\n"> <"\t\tHEAD -- HEAD HEAD &&\n"> <"\tgit diff --quiet --cached\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"rename-threshold=<n> is a synonym for find-renames=<n>">)} 
      {
        (SQ <"\n"> <"\tgit read-tree --reset -u HEAD &&\n"> 
          <"\ttest_must_fail git merge-recursive --rename-threshold=$th0 $tail &&\n"> <"\tcheck_threshold_0\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"last wins in --no-renames --rename-threshold=<n>">)} 
      {
        (SQ <"\n"> <"\tgit read-tree --reset -u HEAD &&\n"> 
          <"\ttest_must_fail git merge-recursive --no-renames --rename-threshold=$th0 $tail &&\n"> <"\tcheck_threshold_0\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"last wins in --rename-threshold=<n> --no-renames">)} 
      {
        (SQ <"\n"> <"\tgit read-tree --reset -u HEAD &&\n"> 
          <"\tgit merge-recursive --rename-threshold=$th0 --no-renames $tail &&\n"> <"\tcheck_no_renames\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"--rename-threshold=<n> rejects negative argument">)} 
      {
        (SQ <"\n"> <"\tgit read-tree --reset -u HEAD &&\n"> 
          <"\ttest_must_fail git merge-recursive --rename-threshold=-25 \\\n"> <"\t\tHEAD -- HEAD HEAD &&\n"> <"\tgit diff --quiet --cached\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"--rename-threshold=<n> rejects non-numbers">)} 
      {
        (SQ <"\n"> <"\tgit read-tree --reset -u HEAD &&\n"> 
          <"\ttest_must_fail git merge-recursive --rename-threshold=0xf \\\n"> <"\t\tHEAD -- HEAD HEAD &&\n"> <"\tgit diff --quiet --cached\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"last wins in --rename-threshold=<m> --find-renames=<n>">)} 
      {
        (SQ <"\n"> <"\tgit read-tree --reset -u HEAD &&\n"> 
          <"\ttest_must_fail git merge-recursive \\\n"> <"\t\t--rename-threshold=$th0 --find-renames=$th2 $tail &&\n"> <"\tcheck_threshold_2\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"last wins in --find-renames=<m> --rename-threshold=<n>">)} 
      {
        (SQ <"\n"> <"\tgit read-tree --reset -u HEAD &&\n"> 
          <"\ttest_must_fail git merge-recursive \\\n"> <"\t\t--find-renames=$th2 --rename-threshold=$th0 $tail &&\n"> <"\tcheck_threshold_0\n">
        )
      }
    )
    (C {(test_done)})
  ]
)