File: t4127-apply-same-fn.sh

package info (click to toggle)
cgit 1.1%2Bgit2.10.2-3~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 31,812 kB
  • sloc: ansic: 179,975; sh: 150,940; perl: 29,466; tcl: 21,429; python: 7,116; makefile: 3,424; lisp: 1,786; php: 120; asm: 98; csh: 45
file content (90 lines) | stat: -rwxr-xr-x 2,042 bytes parent folder | download | duplicates (14)
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
#!/bin/sh

test_description='apply same filename'

. ./test-lib.sh

modify () {
	sed -e "$1" < "$2" > "$2".x &&
	mv "$2".x "$2"
}

test_expect_success setup '
	for i in a b c d e f g h i j k l m
	do
		echo $i
	done >same_fn &&
	cp same_fn other_fn &&
	git add same_fn other_fn &&
	git commit -m initial
'
test_expect_success 'apply same filename with independent changes' '
	modify "s/^d/z/" same_fn &&
	git diff > patch0 &&
	git add same_fn &&
	modify "s/^i/y/" same_fn &&
	git diff >> patch0 &&
	cp same_fn same_fn2 &&
	git reset --hard &&
	git apply patch0 &&
	test_cmp same_fn same_fn2
'

test_expect_success 'apply same filename with overlapping changes' '
	git reset --hard &&
	modify "s/^d/z/" same_fn &&
	git diff > patch0 &&
	git add same_fn &&
	modify "s/^e/y/" same_fn &&
	git diff >> patch0 &&
	cp same_fn same_fn2 &&
	git reset --hard &&
	git apply patch0 &&
	test_cmp same_fn same_fn2
'

test_expect_success 'apply same new filename after rename' '
	git reset --hard &&
	git mv same_fn new_fn &&
	modify "s/^d/z/" new_fn &&
	git add new_fn &&
	git diff -M --cached > patch1 &&
	modify "s/^e/y/" new_fn &&
	git diff >> patch1 &&
	cp new_fn new_fn2 &&
	git reset --hard &&
	git apply --index patch1 &&
	test_cmp new_fn new_fn2
'

test_expect_success 'apply same old filename after rename -- should fail.' '
	git reset --hard &&
	git mv same_fn new_fn &&
	modify "s/^d/z/" new_fn &&
	git add new_fn &&
	git diff -M --cached > patch1 &&
	git mv new_fn same_fn &&
	modify "s/^e/y/" same_fn &&
	git diff >> patch1 &&
	git reset --hard &&
	test_must_fail git apply patch1
'

test_expect_success 'apply A->B (rename), C->A (rename), A->A -- should pass.' '
	git reset --hard &&
	git mv same_fn new_fn &&
	modify "s/^d/z/" new_fn &&
	git add new_fn &&
	git diff -M --cached > patch1 &&
	git commit -m "a rename" &&
	git mv other_fn same_fn &&
	modify "s/^e/y/" same_fn &&
	git add same_fn &&
	git diff -M --cached >> patch1 &&
	modify "s/^g/x/" same_fn &&
	git diff >> patch1 &&
	git reset --hard HEAD^ &&
	git apply patch1
'

test_done