git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
7476781979c3ff164ce9eeba1079d41f15bdaa5c blob 3820 bytes (raw)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
 
#!/bin/sh
#
# Copyright (c) 2008 Nguyễn Thái Ngọc Duy
#

test_description='test worktree writing operations when skip-worktree is used'

. ./test-lib.sh

test_expect_success 'setup' '
	test_commit init &&
	echo modified >> init.t &&
	touch added &&
	git add init.t added &&
	git commit -m "modified and added" &&
	git tag top
'

test_expect_success 'read-tree updates worktree, absent case' '
	git checkout -f top &&
	git update-index --skip-worktree init.t &&
	rm init.t &&
	git read-tree -m -u HEAD^ &&
	echo init > expected &&
	test_cmp expected init.t
'

test_expect_success 'read-tree updates worktree, dirty case' '
	git checkout -f top &&
	git update-index --skip-worktree init.t &&
	echo dirty >> init.t &&
	test_must_fail git read-tree -m -u HEAD^ &&
	grep -q dirty init.t &&
	test "$(git ls-files -t init.t)" = "S init.t" &&
	git update-index --no-skip-worktree init.t
'

test_expect_success 'read-tree removes worktree, absent case' '
	git checkout -f top &&
	git update-index --skip-worktree added &&
	rm added &&
	git read-tree -m -u HEAD^ &&
	test ! -f added
'

test_expect_success 'read-tree removes worktree, dirty case' '
	git checkout -f top &&
	git update-index --skip-worktree added &&
	echo dirty >> added &&
	test_must_fail git read-tree -m -u HEAD^ &&
	grep -q dirty added &&
	test "$(git ls-files -t added)" = "S added" &&
	git update-index --no-skip-worktree added
'

setup_absent() {
	test -f 1 && rm 1
	git update-index --remove 1 &&
	git update-index --add --cacheinfo 100644 $EMPTY_BLOB 1 &&
	git update-index --skip-worktree 1
}

test_absent() {
	echo "100644 $EMPTY_BLOB 0	1" > expected &&
	git ls-files --stage 1 > result &&
	test_cmp expected result &&
	test ! -f 1
}

setup_dirty() {
	git update-index --force-remove 1 &&
	echo dirty > 1 &&
	git update-index --add --cacheinfo 100644 $EMPTY_BLOB 1 &&
	git update-index --skip-worktree 1
}

test_dirty() {
	echo "100644 $EMPTY_BLOB 0	1" > expected &&
	git ls-files --stage 1 > result &&
	test_cmp expected result &&
	echo dirty > expected
	test_cmp expected 1
}

cat >expected <<EOF
S 1
H 2
H init.t
S sub/1
H sub/2
EOF

test_expect_success 'index setup' '
	git checkout -f init &&
	mkdir sub &&
	touch ./1 ./2 sub/1 sub/2 &&
	git add 1 2 sub/1 sub/2 &&
	git update-index --skip-worktree 1 sub/1 &&
	git ls-files -t > result &&
	test_cmp expected result
'

test_expect_success 'git-add ignores worktree content' '
	setup_absent &&
	git add 1 &&
	test_absent
'

test_expect_success 'git-add ignores worktree content' '
	setup_dirty &&
	git add 1 &&
	test_dirty
'

test_expect_success 'git-rm fails if worktree is dirty' '
	setup_dirty &&
	test_must_fail git rm 1 &&
	test_dirty
'

cat >expected <<EOF
Would remove expected
Would remove result
EOF
test_expect_success 'git-clean, absent case' '
	setup_absent &&
	git clean -n > result &&
	test_i18ncmp expected result
'

test_expect_success 'git-clean, dirty case' '
	setup_dirty &&
	git clean -n > result &&
	test_i18ncmp expected result
'

test_expect_success '--ignore-skip-worktree-entries leaves worktree alone' '
	test_commit keep-me &&
	git update-index --skip-worktree keep-me.t &&
	rm keep-me.t &&

	: ignoring the worktree &&
	git update-index --remove --ignore-skip-worktree-entries keep-me.t &&
	git diff-index --cached --exit-code HEAD &&

	: not ignoring the worktree, a deletion is staged &&
	git update-index --remove keep-me.t &&
	test_must_fail git diff-index --cached --exit-code HEAD \
		--diff-filter=D -- keep-me.t
'

#TODO test_expect_failure 'git-apply adds file' false
#TODO test_expect_failure 'git-apply updates file' false
#TODO test_expect_failure 'git-apply removes file' false
#TODO test_expect_failure 'git-mv to skip-worktree' false
#TODO test_expect_failure 'git-mv from skip-worktree' false
#TODO test_expect_failure 'git-checkout' false

test_done
debug log:

solving 7476781979 ...
found 7476781979 in git.git.git

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).