Git 2.45
[git/gitster.git] / t / t2104-update-index-skip-worktree.sh
blob7ec7f30b442b3bc04be5ac64cbf1898c0b5268b6
1 #!/bin/sh
3 # Copyright (c) 2008 Nguyễn Thái Ngọc Duy
6 test_description='skip-worktree bit test'
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
11 sane_unset GIT_TEST_SPLIT_INDEX
13 test_set_index_version () {
14 GIT_INDEX_VERSION="$1"
15 export GIT_INDEX_VERSION
18 test_set_index_version 3
20 test_expect_success 'setup' '
21 cat >expect.full <<-\EOF &&
22 H 1
23 H 2
24 H sub/1
25 H sub/2
26 EOF
28 cat >expect.skip <<-\EOF &&
29 S 1
30 H 2
31 S sub/1
32 H sub/2
33 EOF
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 -
41 test_expect_success 'index is at version 2' '
42 test "$(git update-index --show-index-version)" = 2
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 -
50 test_expect_success 'index is at version 3 after having some skip-worktree entries' '
51 test "$(git update-index --show-index-version)" = 3
54 test_expect_success 'ls-files -t' '
55 git ls-files -t | test_cmp expect.skip -
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 -
63 test_expect_success 'index version is back to 2 when there is no skip-worktree entry' '
64 test "$(git update-index --show-index-version)" = 2
67 test_done