diff: clarify textconv interface
[git/debian.git] / t / t7105-reset-patch.sh
blob98b7d7b969e4eb3ded40aba1f12d2afc8bad849a
1 #!/bin/sh
3 test_description='git reset --patch'
4 . ./lib-patch-mode.sh
6 test_expect_success PERL 'setup' '
7 mkdir dir &&
8 echo parent > dir/foo &&
9 echo dummy > bar &&
10 git add dir &&
11 git commit -m initial &&
12 test_tick &&
13 test_commit second dir/foo head &&
14 set_and_save_state bar bar_work bar_index &&
15 save_head
18 # note: bar sorts before foo, so the first 'n' is always to skip 'bar'
20 test_expect_success PERL 'saying "n" does nothing' '
21 set_and_save_state dir/foo work work &&
22 (echo n; echo n) | git reset -p &&
23 verify_saved_state dir/foo &&
24 verify_saved_state bar
27 test_expect_success PERL 'git reset -p' '
28 (echo n; echo y) | git reset -p >output &&
29 verify_state dir/foo work head &&
30 verify_saved_state bar &&
31 test_i18ngrep "Unstage" output
34 test_expect_success PERL 'git reset -p HEAD^' '
35 (echo n; echo y) | git reset -p HEAD^ >output &&
36 verify_state dir/foo work parent &&
37 verify_saved_state bar &&
38 test_i18ngrep "Apply" output
41 # The idea in the rest is that bar sorts first, so we always say 'y'
42 # first and if the path limiter fails it'll apply to bar instead of
43 # dir/foo. There's always an extra 'n' to reject edits to dir/foo in
44 # the failure case (and thus get out of the loop).
46 test_expect_success PERL 'git reset -p dir' '
47 set_state dir/foo work work &&
48 (echo y; echo n) | git reset -p dir &&
49 verify_state dir/foo work head &&
50 verify_saved_state bar
53 test_expect_success PERL 'git reset -p -- foo (inside dir)' '
54 set_state dir/foo work work &&
55 (echo y; echo n) | (cd dir && git reset -p -- foo) &&
56 verify_state dir/foo work head &&
57 verify_saved_state bar
60 test_expect_success PERL 'git reset -p HEAD^ -- dir' '
61 (echo y; echo n) | git reset -p HEAD^ -- dir &&
62 verify_state dir/foo work parent &&
63 verify_saved_state bar
66 test_expect_success PERL 'none of this moved HEAD' '
67 verify_saved_head
71 test_done