Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t6060-merge-index.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t6060-merge-index.sh` 98 lines ยท 2275 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='basic git merge-index / git-merge-one-file tests' 4 5 . ./test-lib.sh 6 7 test_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/ 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/ tmp && 18 mv tmp file && 19 git commit -a -m ten && 20 git tag ten 21 ' 22 23 cat >expect-merged <<'EOF' 24 1 25 two 26 3 27 4 28 5 29 6 30 7 31 8 32 9 33 ten 34 EOF 35 36 test_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 43 test_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 52 test_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 61 test_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 69 test_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 83 test_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 98 test_done