blob: 8bfe3ed2467fa17d9f1910cd76c721c73776d4ab [file] [log] [blame]
Jens Lehmann1621c992014-06-19 22:12:56 +02001#!/bin/sh
2
3test_description='revert can handle submodules'
4
5. ./test-lib.sh
6. "$TEST_DIRECTORY"/lib-submodule-update.sh
7
8# Create a revert that moves from HEAD (including any test modifications to
9# the work tree) to $1 by first checking out $1 and reverting it. Reverting
10# the revert is the transition we test for. We tar the current work tree
11# first so we can restore the work tree test setup after doing the checkout
12# and revert. We test here that the restored work tree content is identical
13# to that at the beginning. The last revert is then tested by the framework.
14git_revert () {
15 git status -su >expect &&
16 ls -1pR * >>expect &&
Đoàn Trần Công Danh5317dfe2021-05-22 14:10:08 +070017 "$TAR" cf "$TRASH_DIRECTORY/tmp.tar" * &&
Denton Liu5b0ac092020-06-24 04:50:18 -040018 may_only_be_test_must_fail "$2" &&
19 $2 git checkout "$1" &&
20 if test -n "$2"
21 then
22 return
23 fi &&
Jens Lehmann1621c992014-06-19 22:12:56 +020024 git revert HEAD &&
25 rm -rf * &&
Đoàn Trần Công Danh5317dfe2021-05-22 14:10:08 +070026 "$TAR" xf "$TRASH_DIRECTORY/tmp.tar" &&
Jens Lehmann1621c992014-06-19 22:12:56 +020027 git status -su >actual &&
28 ls -1pR * >>actual &&
29 test_cmp expect actual &&
30 git revert HEAD
31}
32
Elijah Newrenaa2faac2021-03-20 00:03:51 +000033if test "$GIT_TEST_MERGE_ALGORITHM" != ort
34then
35 KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1
36fi
Denton Liuaa061802020-06-11 13:41:49 -040037test_submodule_switch_func "git_revert"
Jens Lehmann1621c992014-06-19 22:12:56 +020038
39test_done