Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t7105-reset-patch.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t7105-reset-patch.sh` 97 lines ยท 2544 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='git reset --patch' 4 5 . ./lib-patch-mode.sh 6 7 test_expect_success 'setup' ' 8 mkdir dir && 9 echo parent > dir/foo && 10 echo dummy > bar && 11 git add dir && 12 git commit -m initial && 13 test_tick && 14 test_commit second dir/foo head && 15 set_and_save_state bar bar_work bar_index && 16 save_head 17 ' 18 19 # note: bar sorts before foo, so the first 'n' is always to skip 'bar' 20 21 test_expect_success 'saying "n" does nothing' ' 22 set_and_save_state dir/foo work work && 23 test_write_lines n n | git reset -p && 24 verify_saved_state dir/foo && 25 verify_saved_state bar 26 ' 27 28 for opt in "HEAD" "@" "" 29 do 30 test_expect_success "git reset -p $opt" ' 31 set_and_save_state dir/foo work work && 32 test_write_lines n y | git reset -p $opt >output && 33 verify_state dir/foo work head && 34 verify_saved_state bar && 35 test_grep "Unstage" output 36 ' 37 done 38 39 test_expect_success 'git reset -p HEAD^' ' 40 test_write_lines n y | git reset -p HEAD^ >output && 41 verify_state dir/foo work parent && 42 verify_saved_state bar && 43 test_grep "Apply" output 44 ' 45 46 test_expect_success 'git reset -p HEAD^^{tree}' ' 47 test_write_lines n y | git reset -p HEAD^^{tree} >output && 48 verify_state dir/foo work parent && 49 verify_saved_state bar && 50 test_grep "Apply" output 51 ' 52 53 test_expect_success 'git reset -p HEAD^:dir/foo (blob fails)' ' 54 set_and_save_state dir/foo work work && 55 test_must_fail git reset -p HEAD^:dir/foo && 56 verify_saved_state dir/foo && 57 verify_saved_state bar 58 ' 59 60 test_expect_success 'git reset -p aaaaaaaa (unknown fails)' ' 61 set_and_save_state dir/foo work work && 62 test_must_fail git reset -p aaaaaaaa && 63 verify_saved_state dir/foo && 64 verify_saved_state bar 65 ' 66 67 # The idea in the rest is that bar sorts first, so we always say 'y' 68 # first and if the path limiter fails it'll apply to bar instead of 69 # dir/foo. There's always an extra 'n' to reject edits to dir/foo in 70 # the failure case (and thus get out of the loop). 71 72 test_expect_success 'git reset -p dir' ' 73 set_state dir/foo work work && 74 test_write_lines y n | git reset -p dir && 75 verify_state dir/foo work head && 76 verify_saved_state bar 77 ' 78 79 test_expect_success 'git reset -p -- foo (inside dir)' ' 80 set_state dir/foo work work && 81 test_write_lines y n | (cd dir && git reset -p -- foo) && 82 verify_state dir/foo work head && 83 verify_saved_state bar 84 ' 85 86 test_expect_success 'git reset -p HEAD^ -- dir' ' 87 test_write_lines y n | git reset -p HEAD^ -- dir && 88 verify_state dir/foo work parent && 89 verify_saved_state bar 90 ' 91 92 test_expect_success 'none of this moved HEAD' ' 93 verify_saved_head 94 ' 95 96 97 test_done