git-svn: replace URL escapes with canonicalization
[git.git] / t / t7105-reset-patch.sh
blob95fab2036109c5a4aef8ff3d8100403fe335819f
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 &&
29 verify_state dir/foo work head &&
30 verify_saved_state bar
33 test_expect_success PERL 'git reset -p HEAD^' '
34 (echo n; echo y) | git reset -p HEAD^ &&
35 verify_state dir/foo work parent &&
36 verify_saved_state bar
39 # The idea in the rest is that bar sorts first, so we always say 'y'
40 # first and if the path limiter fails it'll apply to bar instead of
41 # dir/foo. There's always an extra 'n' to reject edits to dir/foo in
42 # the failure case (and thus get out of the loop).
44 test_expect_success PERL 'git reset -p dir' '
45 set_state dir/foo work work &&
46 (echo y; echo n) | git reset -p dir &&
47 verify_state dir/foo work head &&
48 verify_saved_state bar
51 test_expect_success PERL 'git reset -p -- foo (inside dir)' '
52 set_state dir/foo work work &&
53 (echo y; echo n) | (cd dir && git reset -p -- foo) &&
54 verify_state dir/foo work head &&
55 verify_saved_state bar
58 test_expect_success PERL 'git reset -p HEAD^ -- dir' '
59 (echo y; echo n) | git reset -p HEAD^ -- dir &&
60 verify_state dir/foo work parent &&
61 verify_saved_state bar
64 test_expect_success PERL 'none of this moved HEAD' '
65 verify_saved_head
69 test_done