]> git.ipfire.org Git - thirdparty/git.git/blame - t/t2104-update-index-skip-worktree.sh
Merge branch 'ah/commit-graph-leakplug'
[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
5b0a78c1
NTND
10sane_unset GIT_TEST_SPLIT_INDEX
11
762ccf99
ÆAB
12test_set_index_version () {
13 GIT_INDEX_VERSION="$1"
14 export GIT_INDEX_VERSION
15}
16
5d9fc888
TG
17test_set_index_version 3
18
44a36913
NTND
19cat >expect.full <<EOF
20H 1
21H 2
22H sub/1
23H sub/2
24EOF
25
26cat >expect.skip <<EOF
27S 1
28H 2
29S sub/1
30H sub/2
31EOF
32
33test_expect_success 'setup' '
34 mkdir sub &&
35 touch ./1 ./2 sub/1 sub/2 &&
36 git add 1 2 sub/1 sub/2 &&
37 git ls-files -t | test_cmp expect.full -
38'
39
40test_expect_success 'index is at version 2' '
cc6f663d 41 test "$(test-tool index-version < .git/index)" = 2
44a36913
NTND
42'
43
44test_expect_success 'update-index --skip-worktree' '
45 git update-index --skip-worktree 1 sub/1 &&
46 git ls-files -t | test_cmp expect.skip -
47'
48
49test_expect_success 'index is at version 3 after having some skip-worktree entries' '
cc6f663d 50 test "$(test-tool index-version < .git/index)" = 3
44a36913
NTND
51'
52
53test_expect_success 'ls-files -t' '
54 git ls-files -t | test_cmp expect.skip -
55'
56
57test_expect_success 'update-index --no-skip-worktree' '
58 git update-index --no-skip-worktree 1 sub/1 &&
59 git ls-files -t | test_cmp expect.full -
60'
61
62test_expect_success 'index version is back to 2 when there is no skip-worktree entry' '
cc6f663d 63 test "$(test-tool index-version < .git/index)" = 2
44a36913
NTND
64'
65
66test_done