1#!/bin/sh 2 3# Based on a test case submitted by Björn Steinbrink. 4 5test_description='git blame on conflicted files' 6GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main 7export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 8 9. ./test-lib.sh 10 11test_expect_success 'setup first case' ' 12 # Create the old file 13 echo "Old line" > file1 && 14 git add file1 && 15 git commit --author "Old Line <ol@localhost>" -m file1.a && 16 17 # Branch 18 git checkout -b foo && 19 20 # Do an ugly move and change 21 git rm file1 && 22 echo "New line ..." > file2 && 23 echo "... and more" >> file2 && 24 git add file2 && 25 git commit --author "U Gly <ug@localhost>" -m ugly && 26 27 # Back to main and change something 28 git checkout main && 29 echo " 30 31bla" >> file1 && 32 git commit --author "Old Line <ol@localhost>" -a -m file1.b && 33 34 # Back to foo and merge main 35 git checkout foo && 36 if git merge main; then 37 echo needed conflict here 38 exit 1 39 else 40 echo merge failed - resolving automatically 41 fi && 42 echo "New line ... 43... and more 44 45bla 46Even more" > file2 && 47 git rm file1 && 48 git commit --author "M Result <mr@localhost>" -a -m merged && 49 50 # Back to main and change file1 again 51 git checkout main && 52 sed s/bla/foo/ <file1 >X && 53 rm file1 && 54 mv X file1 && 55 git commit --author "No Bla <nb@localhost>" -a -m replace && 56 57 # Try to merge into foo again 58 git checkout foo && 59 if git merge main; then 60 echo needed conflict here 61 exit 1 62 else 63 echo merge failed - test is setup 64 fi 65' 66 67test_expect_success \ 68 'blame runs on unconflicted file while other file has conflicts' ' 69 git blame file2 70' 71 72test_expect_success 'blame does not crash with conflicted file in stages 1,3' ' 73 git blame file1 74' 75 76test_done 77