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