t / lib-patch-mode.shon commit Merge branch 'jc/strcasecmp-pure-inline' (a301889)
   1: included from t2016 and others
   2
   3. ./test-lib.sh
   4
   5set_state () {
   6        echo "$3" > "$1" &&
   7        git add "$1" &&
   8        echo "$2" > "$1"
   9}
  10
  11save_state () {
  12        noslash="$(echo "$1" | tr / _)" &&
  13        cat "$1" > _worktree_"$noslash" &&
  14        git show :"$1" > _index_"$noslash"
  15}
  16
  17set_and_save_state () {
  18        set_state "$@" &&
  19        save_state "$1"
  20}
  21
  22verify_state () {
  23        test "$(cat "$1")" = "$2" &&
  24        test "$(git show :"$1")" = "$3"
  25}
  26
  27verify_saved_state () {
  28        noslash="$(echo "$1" | tr / _)" &&
  29        verify_state "$1" "$(cat _worktree_"$noslash")" "$(cat _index_"$noslash")"
  30}
  31
  32save_head () {
  33        git rev-parse HEAD > _head
  34}
  35
  36verify_saved_head () {
  37        test "$(cat _head)" = "$(git rev-parse HEAD)"
  38}