]> git.ipfire.org Git - thirdparty/git.git/blame - t/lib-patch-mode.sh
Merge branch 'wb/fsmonitor-bitmap-fix'
[thirdparty/git.git] / t / lib-patch-mode.sh
CommitLineData
c32056e0
JH
1: included from t2016 and others
2
b319ef70
TR
3. ./test-lib.sh
4
4df3ec63
NTND
5# set_state <path> <worktree-content> <index-content>
6#
7# Prepare the content for path in worktree and the index as specified.
b319ef70
TR
8set_state () {
9 echo "$3" > "$1" &&
10 git add "$1" &&
11 echo "$2" > "$1"
12}
13
4df3ec63
NTND
14# save_state <path>
15#
16# Save index/worktree content of <path> in the files _worktree_<path>
17# and _index_<path>
b319ef70
TR
18save_state () {
19 noslash="$(echo "$1" | tr / _)" &&
20 cat "$1" > _worktree_"$noslash" &&
21 git show :"$1" > _index_"$noslash"
22}
23
4df3ec63 24# set_and_save_state <path> <worktree-content> <index-content>
b319ef70
TR
25set_and_save_state () {
26 set_state "$@" &&
27 save_state "$1"
28}
29
4df3ec63 30# verify_state <path> <expected-worktree-content> <expected-index-content>
b319ef70
TR
31verify_state () {
32 test "$(cat "$1")" = "$2" &&
33 test "$(git show :"$1")" = "$3"
34}
35
4df3ec63
NTND
36# verify_saved_state <path>
37#
38# Call verify_state with expected contents from the last save_state
b319ef70
TR
39verify_saved_state () {
40 noslash="$(echo "$1" | tr / _)" &&
41 verify_state "$1" "$(cat _worktree_"$noslash")" "$(cat _index_"$noslash")"
42}
43
44save_head () {
45 git rev-parse HEAD > _head
46}
47
48verify_saved_head () {
49 test "$(cat _head)" = "$(git rev-parse HEAD)"
50}