(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: { (SQ <"git rebase --root\n"> <"\n"> <"Tests if git rebase --root --onto <newparent> can rebase the root commit.\n"> ) } spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (FuncDef name: log_with_names body: (BraceGroup children: [ (Pipeline children: [ (C {(git)} {(rev-list)} {(--topo-order)} {(--parents)} {(--pretty) (Lit_Other "=") (DQ ("tformat:%s"))} {(HEAD)} ) (C {(git)} {(name-rev)} {(--stdin)} {(--name-only)} {(--refs) (Lit_Other "=") (refs/heads/) ($ VSub_Number "$1")} ) ] negated: False ) ] spids: [21] ) spids: [16 20] ) (C {(test_expect_success)} {(SQ <"prepare repository">)} { (SQ <"\n"> <"\ttest_commit 1 A &&\n"> <"\ttest_commit 2 A &&\n"> <"\tgit symbolic-ref HEAD refs/heads/other &&\n"> <"\trm .git/index &&\n"> <"\ttest_commit 3 B &&\n"> <"\ttest_commit 1b A 1 &&\n"> <"\ttest_commit 4 B\n"> ) } ) (C {(test_expect_success)} {(SQ <"rebase --root fails with too many args">)} { (SQ <"\n"> <"\tgit checkout -B fail other &&\n"> <"\ttest_must_fail git rebase --onto master --root fail fail\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup pre-rebase hook">)} { (SQ <"\n"> <"\tmkdir -p .git/hooks &&\n"> <"\tcat >.git/hooks/pre-rebase <<EOF &&\n"> <"#!$SHELL_PATH\n"> <"echo \"\\$1,\\$2\" >.git/PRE-REBASE-INPUT\n"> <"EOF\n"> <"\tchmod +x .git/hooks/pre-rebase\n"> ) } ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[109]) (HereDoc op_id: Redir_DLess fd: -1 body: {(DQ ("4\n") ("3\n") ("2\n") ("1\n"))} do_expansion: True here_end: EOF was_filled: True spids: [113] ) ] ) (C {(test_expect_success)} {(SQ <"rebase --root --onto <newbase>">)} { (SQ <"\n"> <"\tgit checkout -b work other &&\n"> <"\tgit rebase --root --onto master &&\n"> <"\tgit log --pretty=tformat:\"%s\" > rebased &&\n"> <"\ttest_cmp expect rebased\n"> ) } ) (C {(test_expect_success)} {(SQ <"pre-rebase got correct input (1)">)} {(SQ <"\n"> <"\ttest \"z$(cat .git/PRE-REBASE-INPUT)\" = z--root,\n">)} ) (C {(test_expect_success)} {(SQ <"rebase --root --onto <newbase> <branch>">)} { (SQ <"\n"> <"\tgit branch work2 other &&\n"> <"\tgit rebase --root --onto master work2 &&\n"> <"\tgit log --pretty=tformat:\"%s\" > rebased2 &&\n"> <"\ttest_cmp expect rebased2\n"> ) } ) (C {(test_expect_success)} {(SQ <"pre-rebase got correct input (2)">)} {(SQ <"\n"> <"\ttest \"z$(cat .git/PRE-REBASE-INPUT)\" = z--root,work2\n">)} ) (C {(test_expect_success)} {(SQ <"rebase -i --root --onto <newbase>">)} { (SQ <"\n"> <"\tgit checkout -b work3 other &&\n"> <"\tgit rebase -i --root --onto master &&\n"> <"\tgit log --pretty=tformat:\"%s\" > rebased3 &&\n"> <"\ttest_cmp expect rebased3\n"> ) } ) (C {(test_expect_success)} {(SQ <"pre-rebase got correct input (3)">)} {(SQ <"\n"> <"\ttest \"z$(cat .git/PRE-REBASE-INPUT)\" = z--root,\n">)} ) (C {(test_expect_success)} {(SQ <"rebase -i --root --onto <newbase> <branch>">)} { (SQ <"\n"> <"\tgit branch work4 other &&\n"> <"\tgit rebase -i --root --onto master work4 &&\n"> <"\tgit log --pretty=tformat:\"%s\" > rebased4 &&\n"> <"\ttest_cmp expect rebased4\n"> ) } ) (C {(test_expect_success)} {(SQ <"pre-rebase got correct input (4)">)} {(SQ <"\n"> <"\ttest \"z$(cat .git/PRE-REBASE-INPUT)\" = z--root,work4\n">)} ) (C {(test_expect_success)} {(SQ <"rebase -i -p with linear history">)} { (SQ <"\n"> <"\tgit checkout -b work5 other &&\n"> <"\tgit rebase -i -p --root --onto master &&\n"> <"\tgit log --pretty=tformat:\"%s\" > rebased5 &&\n"> <"\ttest_cmp expect rebased5\n"> ) } ) (C {(test_expect_success)} {(SQ <"pre-rebase got correct input (5)">)} {(SQ <"\n"> <"\ttest \"z$(cat .git/PRE-REBASE-INPUT)\" = z--root,\n">)} ) (C {(test_expect_success)} {(SQ <"set up merge history">)} { (SQ <"\n"> <"\tgit checkout other^ &&\n"> <"\tgit checkout -b side &&\n"> <"\ttest_commit 5 C &&\n"> <"\tgit checkout other &&\n"> <"\tgit merge side\n"> ) } ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(expect-side)} spids:[274]) (HereDoc op_id: Redir_DLess fd: -1 body: {("commit work6 work6~1 work6^2\n") ("Merge branch 'side' into other\n") ("commit work6^2 work6~2\n") ("5\n") ("commit work6~1 work6~2\n") ("4\n") ("commit work6~2 work6~3\n") ("3\n") ("commit work6~3 work6~4\n") ("2\n") ("commit work6~4\n") ("1\n") } do_expansion: False here_end: EOF was_filled: True spids: [278] ) ] ) (C {(test_expect_success)} {(SQ <"rebase -i -p with merge">)} { (SQ <"\n"> <"\tgit checkout -b work6 other &&\n"> <"\tgit rebase -i -p --root --onto master &&\n"> <"\tlog_with_names work6 > rebased6 &&\n"> <"\ttest_cmp expect-side rebased6\n"> ) } ) (C {(test_expect_success)} {(SQ <"set up second root and merge">)} { (SQ <"\n"> <"\tgit symbolic-ref HEAD refs/heads/third &&\n"> <"\trm .git/index &&\n"> <"\trm A B C &&\n"> <"\ttest_commit 6 D &&\n"> <"\tgit checkout other &&\n"> <"\tgit merge --allow-unrelated-histories third\n"> ) } ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(expect-third)} spids:[318]) (HereDoc op_id: Redir_DLess fd: -1 body: {("commit work7 work7~1 work7^2\n") ("Merge branch 'third' into other\n") ("commit work7^2 work7~4\n") ("6\n") ("commit work7~1 work7~2 work7~1^2\n") ("Merge branch 'side' into other\n") ("commit work7~1^2 work7~3\n") ("5\n") ("commit work7~2 work7~3\n") ("4\n") ("commit work7~3 work7~4\n") ("3\n") ("commit work7~4 work7~5\n") ("2\n") ("commit work7~5\n") ("1\n") } do_expansion: False here_end: EOF was_filled: True spids: [322] ) ] ) (C {(test_expect_success)} {(SQ <"rebase -i -p with two roots">)} { (SQ <"\n"> <"\tgit checkout -b work7 other &&\n"> <"\tgit rebase -i -p --root --onto master &&\n"> <"\tlog_with_names work7 > rebased7 &&\n"> <"\ttest_cmp expect-third rebased7\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup pre-rebase hook that fails">)} { (SQ <"\n"> <"\tmkdir -p .git/hooks &&\n"> <"\tcat >.git/hooks/pre-rebase <<EOF &&\n"> <"#!$SHELL_PATH\n"> <"false\n"> <"EOF\n"> <"\tchmod +x .git/hooks/pre-rebase\n"> ) } ) (C {(test_expect_success)} {(SQ <"pre-rebase hook stops rebase">)} { (SQ <"\n"> <"\tgit checkout -b stops1 other &&\n"> <"\ttest_must_fail git rebase --root --onto master &&\n"> <"\ttest \"z$(git symbolic-ref HEAD)\" = zrefs/heads/stops1 &&\n"> <"\ttest 0 = $(git rev-list other...stops1 | wc -l)\n"> ) } ) (C {(test_expect_success)} {(SQ <"pre-rebase hook stops rebase -i">)} { (SQ <"\n"> <"\tgit checkout -b stops2 other &&\n"> <"\ttest_must_fail git rebase --root --onto master &&\n"> <"\ttest \"z$(git symbolic-ref HEAD)\" = zrefs/heads/stops2 &&\n"> <"\ttest 0 = $(git rev-list other...stops2 | wc -l)\n"> ) } ) (C {(test_expect_success)} {(SQ <"remove pre-rebase hook">)} {(SQ <"\n"> <"\trm -f .git/hooks/pre-rebase\n">)} ) (C {(test_expect_success)} {(SQ <"set up a conflict">)} { (SQ <"\n"> <"\tgit checkout master &&\n"> <"\techo conflict > B &&\n"> <"\tgit add B &&\n"> <"\tgit commit -m conflict\n"> ) } ) (C {(test_expect_success)} {(SQ <"rebase --root with conflict (first part)">)} { (SQ <"\n"> <"\tgit checkout -b conflict1 other &&\n"> <"\ttest_must_fail git rebase --root --onto master &&\n"> <"\tgit ls-files -u | grep \"B$\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"fix the conflict">)} {(SQ <"\n"> <"\techo 3 > B &&\n"> <"\tgit add B\n">)} ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(expect-conflict)} spids:[446]) (HereDoc op_id: Redir_DLess fd: -1 body: {(DQ ("6\n") ("5\n") ("4\n") ("3\n") ("conflict\n") ("2\n") ("1\n"))} do_expansion: True here_end: EOF was_filled: True spids: [450] ) ] ) (C {(test_expect_success)} {(SQ <"rebase --root with conflict (second part)">)} { (SQ <"\n"> <"\tgit rebase --continue &&\n"> <"\tgit log --pretty=tformat:\"%s\" > conflict1 &&\n"> <"\ttest_cmp expect-conflict conflict1\n"> ) } ) (C {(test_expect_success)} {(SQ <"rebase -i --root with conflict (first part)">)} { (SQ <"\n"> <"\tgit checkout -b conflict2 other &&\n"> <"\ttest_must_fail git rebase -i --root --onto master &&\n"> <"\tgit ls-files -u | grep \"B$\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"fix the conflict">)} {(SQ <"\n"> <"\techo 3 > B &&\n"> <"\tgit add B\n">)} ) (C {(test_expect_success)} {(SQ <"rebase -i --root with conflict (second part)">)} { (SQ <"\n"> <"\tgit rebase --continue &&\n"> <"\tgit log --pretty=tformat:\"%s\" > conflict2 &&\n"> <"\ttest_cmp expect-conflict conflict2\n"> ) } ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(expect-conflict-p)} spids:[518]) (HereDoc op_id: Redir_DLess fd: -1 body: {("commit conflict3 conflict3~1 conflict3^2\n") ("Merge branch 'third' into other\n") ("commit conflict3^2 conflict3~4\n") ("6\n") ("commit conflict3~1 conflict3~2 conflict3~1^2\n") ("Merge branch 'side' into other\n") ("commit conflict3~1^2 conflict3~3\n") ("5\n") ("commit conflict3~2 conflict3~3\n") ("4\n") ("commit conflict3~3 conflict3~4\n") ("3\n") ("commit conflict3~4 conflict3~5\n") ("conflict\n") ("commit conflict3~5 conflict3~6\n") ("2\n") ("commit conflict3~6\n") ("1\n") } do_expansion: False here_end: EOF was_filled: True spids: [521] ) ] ) (C {(test_expect_success)} {(SQ <"rebase -i -p --root with conflict (first part)">)} { (SQ <"\n"> <"\tgit checkout -b conflict3 other &&\n"> <"\ttest_must_fail git rebase -i -p --root --onto master &&\n"> <"\tgit ls-files -u | grep \"B$\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"fix the conflict">)} {(SQ <"\n"> <"\techo 3 > B &&\n"> <"\tgit add B\n">)} ) (C {(test_expect_success)} {(SQ <"rebase -i -p --root with conflict (second part)">)} { (SQ <"\n"> <"\tgit rebase --continue &&\n"> <"\tlog_with_names conflict3 >out &&\n"> <"\ttest_cmp expect-conflict-p out\n"> ) } ) (C {(test_done)}) ] )