Junio C Hamano | c32056e | 2010-01-30 16:04:25 -0800 | [diff] [blame] | 1 | : included from t2016 and others |
| 2 | |
Thomas Rast | b319ef7 | 2009-08-13 14:29:40 +0200 | [diff] [blame] | 3 | . ./test-lib.sh |
| 4 | |
Thomas Rast | b319ef7 | 2009-08-13 14:29:40 +0200 | [diff] [blame] | 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 | } |