3 test_description='basic git merge-index / git-merge-one-file tests'
6 test_expect_success 'setup diverging branches' '
7 for i in 1 2 3 4 5 6 7 8 9 10; do
13 sed s/2/two/ <file >tmp &&
15 git commit -a -m two &&
17 git checkout -b other HEAD^ &&
18 sed s/10/ten/ <file >tmp &&
20 git commit -a -m ten &&
24 cat >expect-merged <<'EOF'
37 test_expect_success 'read-tree does not resolve content merge' '
38 git read-tree -i -m base ten two &&
40 git diff-files --name-only --diff-filter=U >unmerged &&
41 test_cmp expect unmerged
44 test_expect_success 'git merge-index git-merge-one-file resolves' '
45 git merge-index git-merge-one-file -a &&
46 git diff-files --name-only --diff-filter=U >unmerged &&
48 test_cmp expect unmerged &&
49 test_cmp expect-merged file &&
50 git cat-file blob :file >file-index &&
51 test_cmp expect-merged file-index
54 test_expect_success 'setup bare merge' '
55 git clone --bare . bare.git &&
57 GIT_INDEX_FILE=$PWD/merge.index &&
58 export GIT_INDEX_FILE &&
59 git read-tree -i -m base ten two
63 test_expect_success 'merge-one-file fails without a work tree' '
65 GIT_INDEX_FILE=$PWD/merge.index &&
66 export GIT_INDEX_FILE &&
67 test_must_fail git merge-index git-merge-one-file -a
71 test_expect_success 'merge-one-file respects GIT_WORK_TREE' '
74 GIT_WORK_TREE=$PWD/work &&
75 export GIT_WORK_TREE &&
76 GIT_INDEX_FILE=$PWD/merge.index &&
77 export GIT_INDEX_FILE &&
78 git merge-index git-merge-one-file -a &&
79 git cat-file blob :file >work/file-index
81 test_cmp expect-merged bare.git/work/file &&
82 test_cmp expect-merged bare.git/work/file-index
85 test_expect_success 'merge-one-file respects core.worktree' '
87 git clone . subdir/child &&
89 GIT_DIR=$PWD/child/.git &&
91 git config core.worktree "$PWD/child" &&
92 git read-tree -i -m base ten two &&
93 git merge-index git-merge-one-file -a &&
94 git cat-file blob :file >file-index
96 test_cmp expect-merged subdir/child/file &&
97 test_cmp expect-merged subdir/file-index