about summary refs log tree commit diff
path: root/t/t1015-read-index-unmerged.sh
blob: 55d22da32ccdca701014c655a32041d0b5b89440 (plain) (blame)
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
#!/bin/sh

test_description='Test various callers of read_index_unmerged'
. ./test-lib.sh

test_expect_success 'setup modify/delete + directory/file conflict' '
	test_create_repo df_plus_modify_delete &&
	(
		cd df_plus_modify_delete &&

		test_write_lines a b c d e f g h >letters &&
		git add letters &&
		git commit -m initial &&

		git checkout -b modify &&
		# Throw in letters.txt for sorting order fun
		# ("letters.txt" sorts between "letters" and "letters/file")
		echo i >>letters &&
		echo "version 2" >letters.txt &&
		git add letters letters.txt &&
		git commit -m modified &&

		git checkout -b delete HEAD^ &&
		git rm letters &&
		mkdir letters &&
		>letters/file &&
		echo "version 1" >letters.txt &&
		git add letters letters.txt &&
		git commit -m deleted
	)
'

test_expect_success 'read-tree --reset cleans unmerged entries' '
	test_when_finished "git -C df_plus_modify_delete clean -f" &&
	test_when_finished "git -C df_plus_modify_delete reset --hard" &&
	(
		cd df_plus_modify_delete &&

		git checkout delete^0 &&
		test_must_fail git merge modify &&

		git read-tree --reset HEAD &&
		git ls-files -u >conflicts &&
		test_must_be_empty conflicts
	)
'

test_expect_success 'One reset --hard cleans unmerged entries' '
	test_when_finished "git -C df_plus_modify_delete clean -f" &&
	test_when_finished "git -C df_plus_modify_delete reset --hard" &&
	(
		cd df_plus_modify_delete &&

		git checkout delete^0 &&
		test_must_fail git merge modify &&

		git reset --hard &&
		test_path_is_missing .git/MERGE_HEAD &&
		git ls-files -u >conflicts &&
		test_must_be_empty conflicts
	)
'

test_expect_success 'setup directory/file conflict + simple edit/edit' '
	test_create_repo df_plus_edit_edit &&
	(
		cd df_plus_edit_edit &&

		test_seq 1 10 >numbers &&
		git add numbers &&
		git commit -m initial &&

		git checkout -b d-edit &&
		mkdir foo &&
		echo content >foo/bar &&
		git add foo &&
		echo 11 >>numbers &&
		git add numbers &&
		git commit -m "directory and edit" &&

		git checkout -b f-edit d-edit^1 &&
		echo content >foo &&
		git add foo &&
		echo eleven >>numbers &&
		git add numbers &&
		git commit -m "file and edit"
	)
'

test_expect_success 'git merge --abort succeeds despite D/F conflict' '
	test_when_finished "git -C df_plus_edit_edit clean -f" &&
	test_when_finished "git -C df_plus_edit_edit reset --hard" &&
	(
		cd df_plus_edit_edit &&

		git checkout f-edit^0 &&
		test_must_fail git merge d-edit^0 &&

		git merge --abort &&
		test_path_is_missing .git/MERGE_HEAD &&
		git ls-files -u >conflicts &&
		test_must_be_empty conflicts
	)
'

test_expect_success 'git am --skip succeeds despite D/F conflict' '
	test_when_finished "git -C df_plus_edit_edit clean -f" &&
	test_when_finished "git -C df_plus_edit_edit reset --hard" &&
	(
		cd df_plus_edit_edit &&

		git checkout f-edit^0 &&
		git format-patch -1 d-edit &&
		test_must_fail git am -3 0001*.patch &&

		git am --skip &&
		test_path_is_missing .git/rebase-apply &&
		git ls-files -u >conflicts &&
		test_must_be_empty conflicts
	)
'

test_done