interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t6060-merge-index.sh

98 lines · 2275 bytes Raw Blame History
1#!/bin/sh
2
3test_description='basic git merge-index / git-merge-one-file tests'
4
5. ./test-lib.sh
6
7test_expect_success 'setup diverging branches' '
8 test_write_lines 1 2 3 4 5 6 7 8 9 10 >file &&
9 git add file &&
10 git commit -m base &&
11 git tag base &&
12 sed s/2/two/ <file >tmp &&
13 mv tmp file &&
14 git commit -a -m two &&
15 git tag two &&
16 git checkout -b other HEAD^ &&
17 sed s/10/ten/ <file >tmp &&
18 mv tmp file &&
19 git commit -a -m ten &&
20 git tag ten
21'
22
23cat >expect-merged <<'EOF'
241
25two
263
274
285
296
307
318
329
33ten
34EOF
35
36test_expect_success 'read-tree does not resolve content merge' '
37 git read-tree -i -m base ten two &&
38 echo file >expect &&
39 git diff-files --name-only --diff-filter=U >unmerged &&
40 test_cmp expect unmerged
41'
42
43test_expect_success 'git merge-index git-merge-one-file resolves' '
44 git merge-index git-merge-one-file -a &&
45 git diff-files --name-only --diff-filter=U >unmerged &&
46 test_must_be_empty unmerged &&
47 test_cmp expect-merged file &&
48 git cat-file blob :file >file-index &&
49 test_cmp expect-merged file-index
50'
51
52test_expect_success 'setup bare merge' '
53 git clone --bare . bare.git &&
54 (cd bare.git &&
55 GIT_INDEX_FILE=$PWD/merge.index &&
56 export GIT_INDEX_FILE &&
57 git read-tree -i -m base ten two
58 )
59'
60
61test_expect_success 'merge-one-file fails without a work tree' '
62 (cd bare.git &&
63 GIT_INDEX_FILE=$PWD/merge.index &&
64 export GIT_INDEX_FILE &&
65 test_must_fail git merge-index git-merge-one-file -a
66 )
67'
68
69test_expect_success 'merge-one-file respects GIT_WORK_TREE' '
70 (cd bare.git &&
71 mkdir work &&
72 GIT_WORK_TREE=$PWD/work &&
73 export GIT_WORK_TREE &&
74 GIT_INDEX_FILE=$PWD/merge.index &&
75 export GIT_INDEX_FILE &&
76 git merge-index git-merge-one-file -a &&
77 git cat-file blob :file >work/file-index
78 ) &&
79 test_cmp expect-merged bare.git/work/file &&
80 test_cmp expect-merged bare.git/work/file-index
81'
82
83test_expect_success 'merge-one-file respects core.worktree' '
84 mkdir subdir &&
85 git clone . subdir/child &&
86 (cd subdir &&
87 GIT_DIR=$PWD/child/.git &&
88 export GIT_DIR &&
89 git config core.worktree "$PWD/child" &&
90 git read-tree -i -m base ten two &&
91 git merge-index git-merge-one-file -a &&
92 git cat-file blob :file >file-index
93 ) &&
94 test_cmp expect-merged subdir/child/file &&
95 test_cmp expect-merged subdir/file-index
96'
97
98test_done