summaryrefslogtreecommitdiff
path: root/t/t4140-apply-ita.sh
blob: c614eaf04cca93a22157d08e9fc464639468eb3a (plain)
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
#!/bin/sh

test_description='git apply of i-t-a file'

. ./test-lib.sh

test_expect_success setup '
	test_write_lines 1 2 3 4 5 >blueprint &&

	cat blueprint >test-file &&
	git add -N test-file &&
	git diff >creation-patch &&
	grep "new file mode 100644" creation-patch &&

	rm -f test-file &&
	git diff >deletion-patch &&
	grep "deleted file mode 100644" deletion-patch
'

test_expect_success 'apply creation patch to ita path (--cached)' '
	git rm -f test-file &&
	cat blueprint >test-file &&
	git add -N test-file &&

	git apply --cached creation-patch &&
	git cat-file blob :test-file >actual &&
	test_cmp blueprint actual
'

test_expect_success 'apply creation patch to ita path (--index)' '
	git rm -f test-file &&
	cat blueprint >test-file &&
	git add -N test-file &&
	rm -f test-file &&

	test_must_fail git apply --index creation-patch
'

test_expect_success 'apply deletion patch to ita path (--cached)' '
	git rm -f test-file &&
	cat blueprint >test-file &&
	git add -N test-file &&

	git apply --cached deletion-patch &&
	test_must_fail git ls-files --stage --error-unmatch test-file
'

test_expect_success 'apply deletion patch to ita path (--index)' '
	cat blueprint >test-file &&
	git add -N test-file &&

	test_must_fail git apply --index deletion-patch &&
	git ls-files --stage --error-unmatch test-file
'

test_done