(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:test_description) op: assign_op.Equal rhs: { (SQ <'git rebase --root\n'> <'\n'> <'Tests if git rebase --root --onto <newparent> can rebase the root commit.\n'> ) } spids: [4] ) ] ) (C {<.>} {<'./test-lib.sh'>}) (command.ShFunction name: log_with_names body: (BraceGroup children: [ (command.Pipeline children: [ (C {<git>} {<rev-list>} {<--topo-order>} {<--parents>} {<--pretty> <Id.Lit_Equals '='> (DQ <'tformat:%s'>)} {<HEAD>} ) (C {<git>} {<name-rev>} {<--stdin>} {<--name-only>} {<--refs> <Id.Lit_Equals '='> <'refs/heads/'> ($ Id.VSub_Number '$1')} ) ] negated: F ) ] ) ) (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'> ) } ) (command.Simple words: [{<cat>}] redirects: [ (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>}) (redir op: <Id.Redir_DLess '<<'> loc: (redir_loc.Fd fd:0) arg: (redir_param.MultiLine here_begin: {<EOF>} here_end_span_id: 121 stdin_parts: [<'4\n'> <'3\n'> <'2\n'> <'1\n'>] ) ) ] do_fork: T ) (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'> ) } ) (command.Simple words: [{<cat>}] redirects: [ (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect-side>}) (redir op: <Id.Redir_DLess '<<'> loc: (redir_loc.Fd fd:0) arg: (redir_param.MultiLine here_begin: {(SQ <EOF>)} here_end_span_id: 297 stdin_parts: [ <'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_fork: T ) (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'> ) } ) (command.Simple words: [{<cat>}] redirects: [ (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect-third>}) (redir op: <Id.Redir_DLess '<<'> loc: (redir_loc.Fd fd:0) arg: (redir_param.MultiLine here_begin: {(SQ <EOF>)} here_end_span_id: 358 stdin_parts: [ <'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_fork: T ) (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'>)} ) (command.Simple words: [{<cat>}] redirects: [ (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect-conflict>}) (redir op: <Id.Redir_DLess '<<'> loc: (redir_loc.Fd fd:0) arg: (redir_param.MultiLine here_begin: {<EOF>} here_end_span_id: 493 stdin_parts: [<'6\n'> <'5\n'> <'4\n'> <'3\n'> <'conflict\n'> <'2\n'> <'1\n'>] ) ) ] do_fork: T ) (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'> ) } ) (command.Simple words: [{<cat>}] redirects: [ (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect-conflict-p>}) (redir op: <Id.Redir_DLess '<<'> loc: (redir_loc.Fd fd:0) arg: (redir_param.MultiLine here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>} here_end_span_id: 577 stdin_parts: [ <'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_fork: T ) (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>}) ] )