summaryrefslogtreecommitdiff
path: root/t/t4122-apply-symlink-inside.sh
blob: 8aad20bfccc09310e2663f6bdab046520ae43fa9 (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
57
58
59
60
61
62
#!/bin/sh
 
test_description='apply to deeper directory without getting fooled with symlink'
. ./test-lib.sh
 
if ! test_have_prereq SYMLINKS
then
	say 'Symbolic links not supported, skipping tests.'
	test_done
	exit
fi
 
lecho () {
	for l_
	do
		echo "$l_"
	done
}
 
test_expect_success setup '
 
	mkdir -p arch/i386/boot arch/x86_64 &&
	lecho 1 2 3 4 5 >arch/i386/boot/Makefile &&
	ln -s ../i386/boot arch/x86_64/boot &&
	git add . &&
	test_tick &&
	git commit -m initial &&
	git branch test &&
 
	rm arch/x86_64/boot &&
	mkdir arch/x86_64/boot &&
	lecho 2 3 4 5 6 >arch/x86_64/boot/Makefile &&
	git add . &&
	test_tick &&
	git commit -a -m second &&
 
	git format-patch --binary -1 --stdout >test.patch
 
'
 
test_expect_success apply '
 
	git checkout test &&
	git diff --exit-code test &&
	git diff --exit-code --cached test &&
	git apply --index test.patch
 
'
 
test_expect_success 'check result' '
 
	git diff --exit-code master &&
	git diff --exit-code --cached master &&
	test_tick &&
	git commit -m replay &&
	T1=$(git rev-parse "master^{tree}") &&
	T2=$(git rev-parse "HEAD^{tree}") &&
	test "z$T1" = "z$T2"
 
'
 
test_done