t/Makefile: ensure that paths are valid on platforms we care
[git] / t / lib-patch-mode.sh
1 : included from t2016 and others
2
3 . ./test-lib.sh
4
5 set_state () {
6         echo "$3" > "$1" &&
7         git add "$1" &&
8         echo "$2" > "$1"
9 }
10
11 save_state () {
12         noslash="$(echo "$1" | tr / _)" &&
13         cat "$1" > _worktree_"$noslash" &&
14         git show :"$1" > _index_"$noslash"
15 }
16
17 set_and_save_state () {
18         set_state "$@" &&
19         save_state "$1"
20 }
21
22 verify_state () {
23         test "$(cat "$1")" = "$2" &&
24         test "$(git show :"$1")" = "$3"
25 }
26
27 verify_saved_state () {
28         noslash="$(echo "$1" | tr / _)" &&
29         verify_state "$1" "$(cat _worktree_"$noslash")" "$(cat _index_"$noslash")"
30 }
31
32 save_head () {
33         git rev-parse HEAD > _head
34 }
35
36 verify_saved_head () {
37         test "$(cat _head)" = "$(git rev-parse HEAD)"
38 }