]> git.ipfire.org Git - thirdparty/git.git/blob - t/t2104-update-index-skip-worktree.sh
Merge branch 'gc/branch-recurse-submodules-fix'
[thirdparty/git.git] / t / t2104-update-index-skip-worktree.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2008 Nguyễn Thái Ngọc Duy
4 #
5
6 test_description='skip-worktree bit test'
7
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
10
11 sane_unset GIT_TEST_SPLIT_INDEX
12
13 test_set_index_version () {
14 GIT_INDEX_VERSION="$1"
15 export GIT_INDEX_VERSION
16 }
17
18 test_set_index_version 3
19
20 cat >expect.full <<EOF
21 H 1
22 H 2
23 H sub/1
24 H sub/2
25 EOF
26
27 cat >expect.skip <<EOF
28 S 1
29 H 2
30 S sub/1
31 H sub/2
32 EOF
33
34 test_expect_success 'setup' '
35 mkdir sub &&
36 touch ./1 ./2 sub/1 sub/2 &&
37 git add 1 2 sub/1 sub/2 &&
38 git ls-files -t | test_cmp expect.full -
39 '
40
41 test_expect_success 'index is at version 2' '
42 test "$(test-tool index-version < .git/index)" = 2
43 '
44
45 test_expect_success 'update-index --skip-worktree' '
46 git update-index --skip-worktree 1 sub/1 &&
47 git ls-files -t | test_cmp expect.skip -
48 '
49
50 test_expect_success 'index is at version 3 after having some skip-worktree entries' '
51 test "$(test-tool index-version < .git/index)" = 3
52 '
53
54 test_expect_success 'ls-files -t' '
55 git ls-files -t | test_cmp expect.skip -
56 '
57
58 test_expect_success 'update-index --no-skip-worktree' '
59 git update-index --no-skip-worktree 1 sub/1 &&
60 git ls-files -t | test_cmp expect.full -
61 '
62
63 test_expect_success 'index version is back to 2 when there is no skip-worktree entry' '
64 test "$(test-tool index-version < .git/index)" = 2
65 '
66
67 test_done