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