diff options
Diffstat (limited to 't/t6403-merge-file.sh')
-rwxr-xr-x | t/t6403-merge-file.sh | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/t/t6403-merge-file.sh b/t/t6403-merge-file.sh index 1a7082323d..2c92209eca 100755 --- a/t/t6403-merge-file.sh +++ b/t/t6403-merge-file.sh @@ -65,11 +65,30 @@ test_expect_success 'merge with no changes' ' test_cmp test.txt orig.txt ' +test_expect_success 'merge with no changes with --object-id' ' + git add orig.txt && + git merge-file -p --object-id :orig.txt :orig.txt :orig.txt >actual && + test_cmp actual orig.txt +' + test_expect_success "merge without conflict" ' cp new1.txt test.txt && git merge-file test.txt orig.txt new2.txt ' +test_expect_success 'merge without conflict with --object-id' ' + git add orig.txt new2.txt && + git merge-file --object-id :orig.txt :orig.txt :new2.txt >actual && + git rev-parse :new2.txt >expected && + test_cmp actual expected +' + +test_expect_success 'can accept object ID with --object-id' ' + git merge-file --object-id $(test_oid empty_blob) $(test_oid empty_blob) :new2.txt >actual && + git rev-parse :new2.txt >expected && + test_cmp actual expected +' + test_expect_success 'works in subdirectory' ' mkdir dir && cp new1.txt dir/a.txt && @@ -138,6 +157,31 @@ test_expect_success "expected conflict markers" ' test_cmp expect.txt test.txt ' +test_expect_success "merge with conflicts with --object-id" ' + git add backup.txt orig.txt new3.txt && + test_must_fail git merge-file -p --object-id :backup.txt :orig.txt :new3.txt >actual && + sed -e "s/<< test.txt/<< :backup.txt/" \ + -e "s/>> new3.txt/>> :new3.txt/" \ + expect.txt >expect && + test_cmp expect actual && + test_must_fail git merge-file --object-id :backup.txt :orig.txt :new3.txt >oid && + git cat-file blob "$(cat oid)" >actual && + test_cmp expect actual +' + +test_expect_success "merge with conflicts with --object-id with labels" ' + git add backup.txt orig.txt new3.txt && + test_must_fail git merge-file -p --object-id \ + -L test.txt -L orig.txt -L new3.txt \ + :backup.txt :orig.txt :new3.txt >actual && + test_cmp expect.txt actual && + test_must_fail git merge-file --object-id \ + -L test.txt -L orig.txt -L new3.txt \ + :backup.txt :orig.txt :new3.txt >oid && + git cat-file blob "$(cat oid)" >actual && + test_cmp expect.txt actual +' + test_expect_success "merge conflicting with --ours" ' cp backup.txt test.txt && @@ -256,6 +300,14 @@ test_expect_success 'binary files cannot be merged' ' grep "Cannot merge binary files" merge.err ' +test_expect_success 'binary files cannot be merged with --object-id' ' + cp "$TEST_DIRECTORY"/test-binary-1.png . && + git add orig.txt new1.txt test-binary-1.png && + test_must_fail git merge-file --object-id \ + :orig.txt :test-binary-1.png :new1.txt 2> merge.err && + grep "Cannot merge binary files" merge.err +' + test_expect_success 'MERGE_ZEALOUS simplifies non-conflicts' ' sed -e "s/deerit.\$/deerit;/" -e "s/me;\$/me./" <new5.txt >new6.txt && sed -e "s/deerit.\$/deerit,/" -e "s/me;\$/me,/" <new5.txt >new7.txt && @@ -389,4 +441,10 @@ test_expect_success 'conflict sections match existing line endings' ' test $(tr "\015" Q <nolf.txt | grep "^[<=>].*Q$" | wc -l) = 0 ' +test_expect_success '--object-id fails without repository' ' + empty="$(test_oid empty_blob)" && + nongit test_must_fail git merge-file --object-id $empty $empty $empty 2>err && + grep "not a git repository" err +' + test_done |