(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <'git rebase --autostash tests'>)}
          spids: [13]
        )
      ]
      spids: [13]
    )
    (C {(.)} {(./test-lib.sh)})
    (C {(test_expect_success)} {(setup)} 
      {
        (SQ <'\n'> <'\techo hello-world >file0 &&\n'> <'\tgit add . &&\n'> <'\ttest_tick &&\n'> 
          <'\tgit commit -m "initial commit" &&\n'> <'\tgit checkout -b feature-branch &&\n'> <'\techo another-hello >file1 &&\n'> 
          <'\techo goodbye >file2 &&\n'> <'\tgit add . &&\n'> <'\ttest_tick &&\n'> <'\tgit commit -m "second commit" &&\n'> 
          <'\techo final-goodbye >file3 &&\n'> <'\tgit add . &&\n'> <'\ttest_tick &&\n'> <'\tgit commit -m "third commit" &&\n'> 
          <'\tgit checkout -b unrelated-onto-branch master &&\n'> <'\techo unrelated >file4 &&\n'> <'\tgit add . &&\n'> <'\ttest_tick &&\n'> 
          <'\tgit commit -m "unrelated commit" &&\n'> <'\tgit checkout -b related-onto-branch master &&\n'> <'\techo conflicting-change >file2 &&\n'> 
          <'\tgit add . &&\n'> <'\ttest_tick &&\n'> <'\tgit commit -m "related commit"\n'>
        )
      }
    )
    (FuncDef
      name: testrebase
      body: 
        (BraceGroup
          children: [
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:type)
                  op: Equal
                  rhs: {($ VSub_Number '$1')}
                  spids: [63]
                )
              ]
              spids: [63]
            )
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:dotest)
                  op: Equal
                  rhs: {($ VSub_Number '$2')}
                  spids: [67]
                )
              ]
              spids: [67]
            )
            (C {(test_expect_success)} 
              {(DQ (rebase) ($ VSub_Name '$type') (': dirty worktree, --no-autostash'))} 
              {
                (SQ <'\n'> <'\t\ttest_config rebase.autostash true &&\n'> <'\t\tgit reset --hard &&\n'> 
                  <'\t\tgit checkout -b rebased-feature-branch feature-branch &&\n'> <'\t\ttest_when_finished git branch -D rebased-feature-branch &&\n'> 
                  <'\t\ttest_when_finished git checkout feature-branch &&\n'> <'\t\techo dirty >>file3 &&\n'> 
                  <'\t\ttest_must_fail git rebase$type --no-autostash unrelated-onto-branch\n'> <'\t'>
                )
              }
            )
            (C {(test_expect_success)} 
              {(DQ (rebase) ($ VSub_Name '$type') (': dirty worktree, non-conflicting rebase'))} 
              {
                (SQ <'\n'> <'\t\ttest_config rebase.autostash true &&\n'> <'\t\tgit reset --hard &&\n'> 
                  <'\t\tgit checkout -b rebased-feature-branch feature-branch &&\n'> <'\t\ttest_when_finished git branch -D rebased-feature-branch &&\n'> <'\t\techo dirty >>file3 &&\n'> 
                  <'\t\tgit rebase$type unrelated-onto-branch &&\n'> <'\t\tgrep unrelated file4 &&\n'> <'\t\tgrep dirty file3 &&\n'> <'\t\tgit checkout feature-branch\n'> 
                  <'\t'>
                )
              }
            )
            (C {(test_expect_success)} 
              {(DQ (rebase) ($ VSub_Name '$type') (': dirty index, non-conflicting rebase'))} 
              {
                (SQ <'\n'> <'\t\ttest_config rebase.autostash true &&\n'> <'\t\tgit reset --hard &&\n'> 
                  <'\t\tgit checkout -b rebased-feature-branch feature-branch &&\n'> <'\t\ttest_when_finished git branch -D rebased-feature-branch &&\n'> <'\t\techo dirty >>file3 &&\n'> 
                  <'\t\tgit add file3 &&\n'> <'\t\tgit rebase$type unrelated-onto-branch &&\n'> <'\t\tgrep unrelated file4 &&\n'> 
                  <'\t\tgrep dirty file3 &&\n'> <'\t\tgit checkout feature-branch\n'> <'\t'>
                )
              }
            )
            (C {(test_expect_success)} {(DQ (rebase) ($ VSub_Name '$type') (': conflicting rebase'))} 
              {
                (SQ <'\n'> <'\t\ttest_config rebase.autostash true &&\n'> <'\t\tgit reset --hard &&\n'> 
                  <'\t\tgit checkout -b rebased-feature-branch feature-branch &&\n'> <'\t\ttest_when_finished git branch -D rebased-feature-branch &&\n'> <'\t\techo dirty >>file3 &&\n'> 
                  <'\t\ttest_must_fail git rebase$type related-onto-branch &&\n'> <'\t\ttest_path_is_file $dotest/autostash &&\n'> <'\t\t! grep dirty file3 &&\n'> 
                  <'\t\trm -rf $dotest &&\n'> <'\t\tgit reset --hard &&\n'> <'\t\tgit checkout feature-branch\n'> <'\t'>
                )
              }
            )
            (C {(test_expect_success)} {(DQ (rebase) ($ VSub_Name '$type') (': --continue'))} 
              {
                (SQ <'\n'> <'\t\ttest_config rebase.autostash true &&\n'> <'\t\tgit reset --hard &&\n'> 
                  <'\t\tgit checkout -b rebased-feature-branch feature-branch &&\n'> <'\t\ttest_when_finished git branch -D rebased-feature-branch &&\n'> <'\t\techo dirty >>file3 &&\n'> 
                  <'\t\ttest_must_fail git rebase$type related-onto-branch &&\n'> <'\t\ttest_path_is_file $dotest/autostash &&\n'> <'\t\t! grep dirty file3 &&\n'> 
                  <'\t\techo "conflicting-plus-goodbye" >file2 &&\n'> <'\t\tgit add file2 &&\n'> <'\t\tgit rebase --continue &&\n'> 
                  <'\t\ttest_path_is_missing $dotest/autostash &&\n'> <'\t\tgrep dirty file3 &&\n'> <'\t\tgit checkout feature-branch\n'> <'\t'>
                )
              }
            )
            (C {(test_expect_success)} {(DQ (rebase) ($ VSub_Name '$type') (': --skip'))} 
              {
                (SQ <'\n'> <'\t\ttest_config rebase.autostash true &&\n'> <'\t\tgit reset --hard &&\n'> 
                  <'\t\tgit checkout -b rebased-feature-branch feature-branch &&\n'> <'\t\ttest_when_finished git branch -D rebased-feature-branch &&\n'> <'\t\techo dirty >>file3 &&\n'> 
                  <'\t\ttest_must_fail git rebase$type related-onto-branch &&\n'> <'\t\ttest_path_is_file $dotest/autostash &&\n'> <'\t\t! grep dirty file3 &&\n'> 
                  <'\t\tgit rebase --skip &&\n'> <'\t\ttest_path_is_missing $dotest/autostash &&\n'> <'\t\tgrep dirty file3 &&\n'> 
                  <'\t\tgit checkout feature-branch\n'> <'\t'>
                )
              }
            )
            (C {(test_expect_success)} {(DQ (rebase) ($ VSub_Name '$type') (': --abort'))} 
              {
                (SQ <'\n'> <'\t\ttest_config rebase.autostash true &&\n'> <'\t\tgit reset --hard &&\n'> 
                  <'\t\tgit checkout -b rebased-feature-branch feature-branch &&\n'> <'\t\ttest_when_finished git branch -D rebased-feature-branch &&\n'> <'\t\techo dirty >>file3 &&\n'> 
                  <'\t\ttest_must_fail git rebase$type related-onto-branch &&\n'> <'\t\ttest_path_is_file $dotest/autostash &&\n'> <'\t\t! grep dirty file3 &&\n'> 
                  <'\t\tgit rebase --abort &&\n'> <'\t\ttest_path_is_missing $dotest/autostash &&\n'> <'\t\tgrep dirty file3 &&\n'> 
                  <'\t\tgit checkout feature-branch\n'> <'\t'>
                )
              }
            )
            (C {(test_expect_success)} 
              {(DQ (rebase) ($ VSub_Name '$type') (': non-conflicting rebase, conflicting stash'))} 
              {
                (SQ <'\n'> <'\t\ttest_config rebase.autostash true &&\n'> <'\t\tgit reset --hard &&\n'> 
                  <'\t\tgit checkout -b rebased-feature-branch feature-branch &&\n'> <'\t\ttest_when_finished git branch -D rebased-feature-branch &&\n'> <'\t\techo dirty >file4 &&\n'> 
                  <'\t\tgit add file4 &&\n'> <'\t\tgit rebase$type unrelated-onto-branch &&\n'> <'\t\ttest_path_is_missing $dotest &&\n'> 
                  <'\t\tgit reset --hard &&\n'> <'\t\tgrep unrelated file4 &&\n'> <'\t\t! grep dirty file4 &&\n'> 
                  <'\t\tgit checkout feature-branch &&\n'> <'\t\tgit stash pop &&\n'> <'\t\tgrep dirty file4\n'> <'\t'>
                )
              }
            )
          ]
          spids: [60]
        )
      spids: [56 59]
    )
    (C {(test_expect_success)} {(DQ ('rebase: fast-forward rebase'))} 
      {
        (SQ <'\n'> <'\ttest_config rebase.autostash true &&\n'> <'\tgit reset --hard &&\n'> 
          <'\tgit checkout -b behind-feature-branch feature-branch~1 &&\n'> <'\ttest_when_finished git branch -D behind-feature-branch &&\n'> <'\techo dirty >>file1 &&\n'> 
          <'\tgit rebase feature-branch &&\n'> <'\tgrep dirty file1 &&\n'> <'\tgit checkout feature-branch\n'>
        )
      }
    )
    (C {(test_expect_success)} {(DQ ('rebase: noop rebase'))} 
      {
        (SQ <'\n'> <'\ttest_config rebase.autostash true &&\n'> <'\tgit reset --hard &&\n'> 
          <'\tgit checkout -b same-feature-branch feature-branch &&\n'> <'\ttest_when_finished git branch -D same-feature-branch &&\n'> <'\techo dirty >>file1 &&\n'> 
          <'\tgit rebase feature-branch &&\n'> <'\tgrep dirty file1 &&\n'> <'\tgit checkout feature-branch\n'>
        )
      }
    )
    (C {(testrebase)} {(DQ )} {(.git/rebase-apply)})
    (C {(testrebase)} {(DQ (' --merge'))} {(.git/rebase-merge)})
    (C {(testrebase)} {(DQ (' --interactive'))} {(.git/rebase-merge)})
    (C {(test_expect_success)} {(SQ <'abort rebase -i with --autostash'>)} 
      {
        (SQ <'\n'> <'\ttest_when_finished "git reset --hard" &&\n'> 
          <'\techo uncommitted-content >file0 &&\n'> <'\t(\n'> <'\t\twrite_script abort-editor.sh <<-\\EOF &&\n'> <'\t\t\techo >"$1"\n'> <'\t\tEOF\n'> 
          <'\t\ttest_set_editor "$(pwd)/abort-editor.sh" &&\n'> <'\t\ttest_must_fail git rebase -i --autostash HEAD^ &&\n'> <'\t\trm -f abort-editor.sh\n'> 
          <'\t) &&\n'> <'\techo uncommitted-content >expected &&\n'> <'\ttest_cmp expected file0\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'restore autostash on editor failure'>)} 
      {
        (SQ <'\n'> <'\ttest_when_finished "git reset --hard" &&\n'> 
          <'\techo uncommitted-content >file0 &&\n'> <'\t(\n'> <'\t\ttest_set_editor "false" &&\n'> <'\t\ttest_must_fail git rebase -i --autostash HEAD^\n'> 
          <'\t) &&\n'> <'\techo uncommitted-content >expected &&\n'> <'\ttest_cmp expected file0\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'autostash is saved on editor failure with conflict'>)} 
      {
        (SQ <'\n'> <'\ttest_when_finished "git reset --hard" &&\n'> 
          <'\techo uncommitted-content >file0 &&\n'> <'\t(\n'> <'\t\twrite_script abort-editor.sh <<-\\EOF &&\n'> 
          <'\t\t\techo conflicting-content >file0\n'> <'\t\t\texit 1\n'> <'\t\tEOF\n'> <'\t\ttest_set_editor "$(pwd)/abort-editor.sh" &&\n'> 
          <'\t\ttest_must_fail git rebase -i --autostash HEAD^ &&\n'> <'\t\trm -f abort-editor.sh\n'> <'\t) &&\n'> <'\techo conflicting-content >expected &&\n'> 
          <'\ttest_cmp expected file0 &&\n'> <'\tgit checkout file0 &&\n'> <'\tgit stash pop &&\n'> <'\techo uncommitted-content >expected &&\n'> 
          <'\ttest_cmp expected file0\n'>
        )
      }
    )
    (C {(test_done)})
  ]
)