3 test_description
='basic git merge-index / git-merge-one-file tests'
6 test_expect_success
'setup diverging branches' '
7 test_write_lines 1 2 3 4 5 6 7 8 9 10 >file &&
11 sed s/2/two/ <file >tmp &&
13 git commit -a -m two &&
15 git checkout -b other HEAD^ &&
16 sed s/10/ten/ <file >tmp &&
18 git commit -a -m ten &&
22 cat >expect-merged
<<'EOF'
35 test_expect_success
'read-tree does not resolve content merge' '
36 git read-tree -i -m base ten two &&
38 git diff-files --name-only --diff-filter=U >unmerged &&
39 test_cmp expect unmerged
42 test_expect_success
'git merge-index git-merge-one-file resolves' '
43 git merge-index git-merge-one-file -a &&
44 git diff-files --name-only --diff-filter=U >unmerged &&
45 test_must_be_empty unmerged &&
46 test_cmp expect-merged file &&
47 git cat-file blob :file >file-index &&
48 test_cmp expect-merged file-index
51 test_expect_success
'setup bare merge' '
52 git clone --bare . bare.git &&
54 GIT_INDEX_FILE=$PWD/merge.index &&
55 export GIT_INDEX_FILE &&
56 git read-tree -i -m base ten two
60 test_expect_success
'merge-one-file fails without a work tree' '
62 GIT_INDEX_FILE=$PWD/merge.index &&
63 export GIT_INDEX_FILE &&
64 test_must_fail git merge-index git-merge-one-file -a
68 test_expect_success
'merge-one-file respects GIT_WORK_TREE' '
71 GIT_WORK_TREE=$PWD/work &&
72 export GIT_WORK_TREE &&
73 GIT_INDEX_FILE=$PWD/merge.index &&
74 export GIT_INDEX_FILE &&
75 git merge-index git-merge-one-file -a &&
76 git cat-file blob :file >work/file-index
78 test_cmp expect-merged bare.git/work/file &&
79 test_cmp expect-merged bare.git/work/file-index
82 test_expect_success
'merge-one-file respects core.worktree' '
84 git clone . subdir/child &&
86 GIT_DIR=$PWD/child/.git &&
88 git config core.worktree "$PWD/child" &&
89 git read-tree -i -m base ten two &&
90 git merge-index git-merge-one-file -a &&
91 git cat-file blob :file >file-index
93 test_cmp expect-merged subdir/child/file &&
94 test_cmp expect-merged subdir/file-index