(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:test_description) op: assign_op.Equal rhs: {(SQ <'stash -p'>)} spids: [4] ) ] ) (C {<.>} {<'./lib-patch-mode.sh'>}) (command.If arms: [ (if_arm cond: (condition.Shell commands: [(command.Pipeline children:[(C {<test_have_prereq>} {<PERL>})] negated:T)] ) action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:skip_all) op: assign_op.Equal rhs: {(SQ <'skipping stash -p tests, perl not available'>)} spids: [25] ) ] ) (C {<test_done>}) ] spids: [14 22] ) ] ) (C {<test_expect_success>} {(SQ <setup>)} { (SQ <'\n'> <'\tmkdir dir &&\n'> <'\techo parent > dir/foo &&\n'> <'\techo dummy > bar &&\n'> <'\techo committed > HEAD &&\n'> <'\tgit add bar dir/foo HEAD &&\n'> <'\tgit commit -m initial &&\n'> <'\ttest_tick &&\n'> <'\ttest_commit second dir/foo head &&\n'> <'\techo index > dir/foo &&\n'> <'\tgit add dir/foo &&\n'> <'\tset_and_save_state bar bar_work bar_index &&\n'> <'\tsave_head\n'> ) } ) (C {<test_expect_success>} {(SQ <'saying "n" does nothing'>)} { (SQ <'\n'> <'\tset_state HEAD HEADfile_work HEADfile_index &&\n'> <'\tset_state dir/foo work index &&\n'> <'\t(echo n; echo n; echo n) | test_must_fail git stash save -p &&\n'> <'\tverify_state HEAD HEADfile_work HEADfile_index &&\n'> <'\tverify_saved_state bar &&\n'> <'\tverify_state dir/foo work index\n'> ) } ) (C {<test_expect_success>} {(SQ <'git stash -p'>)} { (SQ <'\n'> <'\t(echo y; echo n; echo y) | git stash save -p &&\n'> <'\tverify_state HEAD committed HEADfile_index &&\n'> <'\tverify_saved_state bar &&\n'> <'\tverify_state dir/foo head index &&\n'> <'\tgit reset --hard &&\n'> <'\tgit stash apply &&\n'> <'\tverify_state HEAD HEADfile_work committed &&\n'> <'\tverify_state bar dummy dummy &&\n'> <'\tverify_state dir/foo work head\n'> ) } ) (C {<test_expect_success>} {(SQ <'git stash -p --no-keep-index'>)} { (SQ <'\n'> <'\tset_state HEAD HEADfile_work HEADfile_index &&\n'> <'\tset_state bar bar_work bar_index &&\n'> <'\tset_state dir/foo work index &&\n'> <'\t(echo y; echo n; echo y) | git stash save -p --no-keep-index &&\n'> <'\tverify_state HEAD committed committed &&\n'> <'\tverify_state bar bar_work dummy &&\n'> <'\tverify_state dir/foo head head &&\n'> <'\tgit reset --hard &&\n'> <'\tgit stash apply --index &&\n'> <'\tverify_state HEAD HEADfile_work HEADfile_index &&\n'> <'\tverify_state bar dummy bar_index &&\n'> <'\tverify_state dir/foo work index\n'> ) } ) (C {<test_expect_success>} {(SQ <'git stash --no-keep-index -p'>)} { (SQ <'\n'> <'\tset_state HEAD HEADfile_work HEADfile_index &&\n'> <'\tset_state bar bar_work bar_index &&\n'> <'\tset_state dir/foo work index &&\n'> <'\t(echo y; echo n; echo y) | git stash save --no-keep-index -p &&\n'> <'\tverify_state HEAD committed committed &&\n'> <'\tverify_state dir/foo head head &&\n'> <'\tverify_state bar bar_work dummy &&\n'> <'\tgit reset --hard &&\n'> <'\tgit stash apply --index &&\n'> <'\tverify_state HEAD HEADfile_work HEADfile_index &&\n'> <'\tverify_state bar dummy bar_index &&\n'> <'\tverify_state dir/foo work index\n'> ) } ) (C {<test_expect_success>} {(SQ <'none of this moved HEAD'>)} {(SQ <'\n'> <'\tverify_saved_head\n'>)}) (C {<test_expect_failure>} {(SQ <'stash -p with split hunk'>)} { (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tcat >test <<-\\EOF &&\n'> <'\taaa\n'> <'\tbbb\n'> <'\tccc\n'> <'\tEOF\n'> <'\tgit add test &&\n'> <'\tgit commit -m "initial" &&\n'> <'\tcat >test <<-\\EOF &&\n'> <'\taaa\n'> <'\tadded line 1\n'> <'\tbbb\n'> <'\tadded line 2\n'> <'\tccc\n'> <'\tEOF\n'> <'\tprintf "%s\\n" s n y q |\n'> <'\ttest_might_fail git stash -p 2>error &&\n'> <'\t! test_must_be_empty error &&\n'> <'\tgrep "added line 1" test &&\n'> <'\t! grep "added line 2" test\n'> ) } ) (C {<test_done>}) ] )