]> git.ipfire.org Git - thirdparty/git.git/blame - t/t2104-update-index-skip-worktree.sh
test-lib: allow setting the index format version
[thirdparty/git.git] / t / t2104-update-index-skip-worktree.sh
CommitLineData
44a36913
NTND
1#!/bin/sh
2#
3# Copyright (c) 2008 Nguyễn Thái Ngọc Duy
4#
5
6test_description='skip-worktree bit test'
7
8. ./test-lib.sh
9
5d9fc888
TG
10test_set_index_version 3
11
44a36913
NTND
12cat >expect.full <<EOF
13H 1
14H 2
15H sub/1
16H sub/2
17EOF
18
19cat >expect.skip <<EOF
20S 1
21H 2
22S sub/1
23H sub/2
24EOF
25
26test_expect_success 'setup' '
27 mkdir sub &&
28 touch ./1 ./2 sub/1 sub/2 &&
29 git add 1 2 sub/1 sub/2 &&
30 git ls-files -t | test_cmp expect.full -
31'
32
33test_expect_success 'index is at version 2' '
34 test "$(test-index-version < .git/index)" = 2
35'
36
37test_expect_success 'update-index --skip-worktree' '
38 git update-index --skip-worktree 1 sub/1 &&
39 git ls-files -t | test_cmp expect.skip -
40'
41
42test_expect_success 'index is at version 3 after having some skip-worktree entries' '
43 test "$(test-index-version < .git/index)" = 3
44'
45
46test_expect_success 'ls-files -t' '
47 git ls-files -t | test_cmp expect.skip -
48'
49
50test_expect_success 'update-index --no-skip-worktree' '
51 git update-index --no-skip-worktree 1 sub/1 &&
52 git ls-files -t | test_cmp expect.full -
53'
54
55test_expect_success 'index version is back to 2 when there is no skip-worktree entry' '
56 test "$(test-index-version < .git/index)" = 2
57'
58
59test_done