]> git.ipfire.org Git - thirdparty/git.git/blob - t/lib-patch-mode.sh
submodule: fix relative url parsing for scp-style origin
[thirdparty/git.git] / t / lib-patch-mode.sh
1 : included from t2016 and others
2
3 . ./test-lib.sh
4
5 if ! test_have_prereq PERL; then
6 say 'skipping --patch tests, perl not available'
7 test_done
8 fi
9
10 set_state () {
11 echo "$3" > "$1" &&
12 git add "$1" &&
13 echo "$2" > "$1"
14 }
15
16 save_state () {
17 noslash="$(echo "$1" | tr / _)" &&
18 cat "$1" > _worktree_"$noslash" &&
19 git show :"$1" > _index_"$noslash"
20 }
21
22 set_and_save_state () {
23 set_state "$@" &&
24 save_state "$1"
25 }
26
27 verify_state () {
28 test "$(cat "$1")" = "$2" &&
29 test "$(git show :"$1")" = "$3"
30 }
31
32 verify_saved_state () {
33 noslash="$(echo "$1" | tr / _)" &&
34 verify_state "$1" "$(cat _worktree_"$noslash")" "$(cat _index_"$noslash")"
35 }
36
37 save_head () {
38 git rev-parse HEAD > _head
39 }
40
41 verify_saved_head () {
42 test "$(cat _head)" = "$(git rev-parse HEAD)"
43 }