unpack-trees: only clear CE_UPDATE|CE_REMOVE when skip-worktree is always set
[git] / t / lib-patch-mode.sh
1 . ./test-lib.sh
2
3 if ! test_have_prereq PERL; then
4         say 'skipping --patch tests, perl not available'
5         test_done
6 fi
7
8 set_state () {
9         echo "$3" > "$1" &&
10         git add "$1" &&
11         echo "$2" > "$1"
12 }
13
14 save_state () {
15         noslash="$(echo "$1" | tr / _)" &&
16         cat "$1" > _worktree_"$noslash" &&
17         git show :"$1" > _index_"$noslash"
18 }
19
20 set_and_save_state () {
21         set_state "$@" &&
22         save_state "$1"
23 }
24
25 verify_state () {
26         test "$(cat "$1")" = "$2" &&
27         test "$(git show :"$1")" = "$3"
28 }
29
30 verify_saved_state () {
31         noslash="$(echo "$1" | tr / _)" &&
32         verify_state "$1" "$(cat _worktree_"$noslash")" "$(cat _index_"$noslash")"
33 }
34
35 save_head () {
36         git rev-parse HEAD > _head
37 }
38
39 verify_saved_head () {
40         test "$(cat _head)" = "$(git rev-parse HEAD)"
41 }