chainlint.pl: add POSIX shell parser
[git.git] / t / t6060-merge-index.sh
blobed449abe5520e59ddb0ad27def5711007f620650
1 #!/bin/sh
3 test_description='basic git merge-index / git-merge-one-file tests'
4 . ./test-lib.sh
6 test_expect_success 'setup diverging branches' '
7 test_write_lines 1 2 3 4 5 6 7 8 9 10 >file &&
8 git add file &&
9 git commit -m base &&
10 git tag base &&
11 sed s/2/two/ <file >tmp &&
12 mv tmp file &&
13 git commit -a -m two &&
14 git tag two &&
15 git checkout -b other HEAD^ &&
16 sed s/10/ten/ <file >tmp &&
17 mv tmp file &&
18 git commit -a -m ten &&
19 git tag ten
22 cat >expect-merged <<'EOF'
24 two
32 ten
33 EOF
35 test_expect_success 'read-tree does not resolve content merge' '
36 git read-tree -i -m base ten two &&
37 echo file >expect &&
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 &&
53 (cd 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' '
61 (cd bare.git &&
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' '
69 (cd bare.git &&
70 mkdir work &&
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
77 ) &&
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' '
83 mkdir subdir &&
84 git clone . subdir/child &&
85 (cd subdir &&
86 GIT_DIR=$PWD/child/.git &&
87 export GIT_DIR &&
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
92 ) &&
93 test_cmp expect-merged subdir/child/file &&
94 test_cmp expect-merged subdir/file-index
97 test_done