(command.CommandList children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:test_description) op: Equal rhs: {(SQ <'Test the post-rewrite hook.'>)} ) ] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ <setup>)} { (SQ <'\n'> <'\ttest_commit A foo A &&\n'> <'\ttest_commit B foo B &&\n'> <'\ttest_commit C foo C &&\n'> <'\ttest_commit D foo D &&\n'> <'\tgit checkout A^0 &&\n'> <'\ttest_commit E bar E &&\n'> <'\ttest_commit F foo F &&\n'> <'\tgit checkout master\n'> ) } ) (C {(mkdir)} {(.git/hooks)}) (command.SimpleCommand words: [{(cat)}] redirects: [ (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(.git/hooks/post-rewrite)}) (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(EOF)} here_end_span_id: 69 stdin_parts: [ ('#!/bin/sh\n') ('echo ') (word_part.EscapedLiteralPart token:<Lit_EscapedChar '\\$'>) ('@ > ') (Right_DoubleQuote '"') ($ VSub_DollarName '$TRASH_DIRECTORY') (Right_DoubleQuote '"') ('/post-rewrite.args\n') ('cat > ') (Right_DoubleQuote '"') ($ VSub_DollarName '$TRASH_DIRECTORY') (Right_DoubleQuote '"') ('/post-rewrite.data\n') ] ) ] ) (C {(chmod)} {(u) (Lit_Other '+') (x)} {(.git/hooks/post-rewrite)}) (command.FuncDef name: clear_hook_input body: (command.BraceGroup children: [(C {(rm)} {(-f)} {(post-rewrite.args)} {(post-rewrite.data)})] ) ) (command.FuncDef name: verify_hook_input body: (command.BraceGroup children: [ (command.AndOr ops: [Op_DAmp] children: [ (C {(test_cmp)} {(expected.args)} {(DQ ($ VSub_DollarName '$TRASH_DIRECTORY')) (/post-rewrite.args)} ) (C {(test_cmp)} {(expected.data)} {(DQ ($ VSub_DollarName '$TRASH_DIRECTORY')) (/post-rewrite.data)} ) ] ) ] ) ) (C {(test_expect_success)} {(SQ <'git commit --amend'>)} { (SQ <'\n'> <'\tclear_hook_input &&\n'> <'\techo "D new message" > newmsg &&\n'> <'\toldsha=$(git rev-parse HEAD^0) &&\n'> <'\tgit commit -Fnewmsg --amend &&\n'> <'\techo amend > expected.args &&\n'> <'\techo $oldsha $(git rev-parse HEAD^0) > expected.data &&\n'> <'\tverify_hook_input\n'> ) } ) (C {(test_expect_success)} {(SQ <'git commit --amend --no-post-rewrite'>)} { (SQ <'\n'> <'\tclear_hook_input &&\n'> <'\techo "D new message again" > newmsg &&\n'> <'\tgit commit --no-post-rewrite -Fnewmsg --amend &&\n'> <'\ttest ! -f post-rewrite.args &&\n'> <'\ttest ! -f post-rewrite.data\n'> ) } ) (C {(test_expect_success)} {(SQ <'git rebase'>)} { (SQ <'\n'> <'\tgit reset --hard D &&\n'> <'\tclear_hook_input &&\n'> <'\ttest_must_fail git rebase --onto A B &&\n'> <'\techo C > foo &&\n'> <'\tgit add foo &&\n'> <'\tgit rebase --continue &&\n'> <'\techo rebase >expected.args &&\n'> <'\tcat >expected.data <<-EOF &&\n'> <'\t$(git rev-parse C) $(git rev-parse HEAD^)\n'> <'\t$(git rev-parse D) $(git rev-parse HEAD)\n'> <'\tEOF\n'> <'\tverify_hook_input\n'> ) } ) (C {(test_expect_success)} {(SQ <'git rebase --skip'>)} { (SQ <'\n'> <'\tgit reset --hard D &&\n'> <'\tclear_hook_input &&\n'> <'\ttest_must_fail git rebase --onto A B &&\n'> <'\ttest_must_fail git rebase --skip &&\n'> <'\techo D > foo &&\n'> <'\tgit add foo &&\n'> <'\tgit rebase --continue &&\n'> <'\techo rebase >expected.args &&\n'> <'\tcat >expected.data <<-EOF &&\n'> <'\t$(git rev-parse D) $(git rev-parse HEAD)\n'> <'\tEOF\n'> <'\tverify_hook_input\n'> ) } ) (C {(test_expect_success)} {(SQ <'git rebase --skip the last one'>)} { (SQ <'\n'> <'\tgit reset --hard F &&\n'> <'\tclear_hook_input &&\n'> <'\ttest_must_fail git rebase --onto D A &&\n'> <'\tgit rebase --skip &&\n'> <'\techo rebase >expected.args &&\n'> <'\tcat >expected.data <<-EOF &&\n'> <'\t$(git rev-parse E) $(git rev-parse HEAD)\n'> <'\tEOF\n'> <'\tverify_hook_input\n'> ) } ) (C {(test_expect_success)} {(SQ <'git rebase -m'>)} { (SQ <'\n'> <'\tgit reset --hard D &&\n'> <'\tclear_hook_input &&\n'> <'\ttest_must_fail git rebase -m --onto A B &&\n'> <'\techo C > foo &&\n'> <'\tgit add foo &&\n'> <'\tgit rebase --continue &&\n'> <'\techo rebase >expected.args &&\n'> <'\tcat >expected.data <<-EOF &&\n'> <'\t$(git rev-parse C) $(git rev-parse HEAD^)\n'> <'\t$(git rev-parse D) $(git rev-parse HEAD)\n'> <'\tEOF\n'> <'\tverify_hook_input\n'> ) } ) (C {(test_expect_success)} {(SQ <'git rebase -m --skip'>)} { (SQ <'\n'> <'\tgit reset --hard D &&\n'> <'\tclear_hook_input &&\n'> <'\ttest_must_fail git rebase --onto A B &&\n'> <'\ttest_must_fail git rebase --skip &&\n'> <'\techo D > foo &&\n'> <'\tgit add foo &&\n'> <'\tgit rebase --continue &&\n'> <'\techo rebase >expected.args &&\n'> <'\tcat >expected.data <<-EOF &&\n'> <'\t$(git rev-parse D) $(git rev-parse HEAD)\n'> <'\tEOF\n'> <'\tverify_hook_input\n'> ) } ) (C {(.)} {(DQ ($ VSub_DollarName '$TEST_DIRECTORY')) (/lib-rebase.sh)}) (C {(set_fake_editor)}) (command.FuncDef name: test_fail_interactive_rebase body: (command.BraceGroup children: [ (command.Subshell command_list: (command.CommandList children: [ (command.AndOr ops: [Op_DAmp Op_DAmp Op_DAmp] children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:FAKE_LINES) op: Equal rhs: {(DQ ($ VSub_Number '$1'))} ) ] ) (C {(shift)}) (C {(export)} {(FAKE_LINES)}) (C {(test_must_fail)} {(git)} {(rebase)} {(-i)} {(DQ ($ VSub_At '$@'))}) ] ) ] ) ) ] ) ) (C {(test_expect_success)} {(SQ <'git rebase -i (unchanged)'>)} { (SQ <'\n'> <'\tgit reset --hard D &&\n'> <'\tclear_hook_input &&\n'> <'\ttest_fail_interactive_rebase "1 2" --onto A B &&\n'> <'\techo C > foo &&\n'> <'\tgit add foo &&\n'> <'\tgit rebase --continue &&\n'> <'\techo rebase >expected.args &&\n'> <'\tcat >expected.data <<-EOF &&\n'> <'\t$(git rev-parse C) $(git rev-parse HEAD^)\n'> <'\t$(git rev-parse D) $(git rev-parse HEAD)\n'> <'\tEOF\n'> <'\tverify_hook_input\n'> ) } ) (C {(test_expect_success)} {(SQ <'git rebase -i (skip)'>)} { (SQ <'\n'> <'\tgit reset --hard D &&\n'> <'\tclear_hook_input &&\n'> <'\ttest_fail_interactive_rebase "2" --onto A B &&\n'> <'\techo D > foo &&\n'> <'\tgit add foo &&\n'> <'\tgit rebase --continue &&\n'> <'\techo rebase >expected.args &&\n'> <'\tcat >expected.data <<-EOF &&\n'> <'\t$(git rev-parse D) $(git rev-parse HEAD)\n'> <'\tEOF\n'> <'\tverify_hook_input\n'> ) } ) (C {(test_expect_success)} {(SQ <'git rebase -i (squash)'>)} { (SQ <'\n'> <'\tgit reset --hard D &&\n'> <'\tclear_hook_input &&\n'> <'\ttest_fail_interactive_rebase "1 squash 2" --onto A B &&\n'> <'\techo C > foo &&\n'> <'\tgit add foo &&\n'> <'\tgit rebase --continue &&\n'> <'\techo rebase >expected.args &&\n'> <'\tcat >expected.data <<-EOF &&\n'> <'\t$(git rev-parse C) $(git rev-parse HEAD)\n'> <'\t$(git rev-parse D) $(git rev-parse HEAD)\n'> <'\tEOF\n'> <'\tverify_hook_input\n'> ) } ) (C {(test_expect_success)} {(SQ <'git rebase -i (fixup without conflict)'>)} { (SQ <'\n'> <'\tgit reset --hard D &&\n'> <'\tclear_hook_input &&\n'> <'\tFAKE_LINES="1 fixup 2" git rebase -i B &&\n'> <'\techo rebase >expected.args &&\n'> <'\tcat >expected.data <<-EOF &&\n'> <'\t$(git rev-parse C) $(git rev-parse HEAD)\n'> <'\t$(git rev-parse D) $(git rev-parse HEAD)\n'> <'\tEOF\n'> <'\tverify_hook_input\n'> ) } ) (C {(test_expect_success)} {(SQ <'git rebase -i (double edit)'>)} { (SQ <'\n'> <'\tgit reset --hard D &&\n'> <'\tclear_hook_input &&\n'> <'\tFAKE_LINES="edit 1 edit 2" git rebase -i B &&\n'> <'\tgit rebase --continue &&\n'> <'\techo something > foo &&\n'> <'\tgit add foo &&\n'> <'\tgit rebase --continue &&\n'> <'\techo rebase >expected.args &&\n'> <'\tcat >expected.data <<-EOF &&\n'> <'\t$(git rev-parse C) $(git rev-parse HEAD^)\n'> <'\t$(git rev-parse D) $(git rev-parse HEAD)\n'> <'\tEOF\n'> <'\tverify_hook_input\n'> ) } ) (C {(test_expect_success)} {(SQ <'git rebase -i (exec)'>)} { (SQ <'\n'> <'\tgit reset --hard D &&\n'> <'\tclear_hook_input &&\n'> <'\tFAKE_LINES="edit 1 exec_false 2" git rebase -i B &&\n'> <'\techo something >bar &&\n'> <'\tgit add bar &&\n'> <'\t# Fails because of exec false\n'> <'\ttest_must_fail git rebase --continue &&\n'> <'\tgit rebase --continue &&\n'> <'\techo rebase >expected.args &&\n'> <'\tcat >expected.data <<-EOF &&\n'> <'\t$(git rev-parse C) $(git rev-parse HEAD^)\n'> <'\t$(git rev-parse D) $(git rev-parse HEAD)\n'> <'\tEOF\n'> <'\tverify_hook_input\n'> ) } ) (C {(test_done)}) ] )