Git 2.33.8
[git.git] / t / t8004-blame-with-conflicts.sh
blob35414a53363424190e57a553302c6384e3664e2c
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-lib.sh
11 test_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 &&
17 # Branch
18 git checkout -b foo &&
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 &&
27 # Back to main and change something
28 git checkout main &&
29 echo "
31 bla" >> file1 &&
32 git commit --author "Old Line <ol@localhost>" -a -m file1.b &&
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
45 bla
46 Even more" > file2 &&
47 git rm file1 &&
48 git commit --author "M Result <mr@localhost>" -a -m merged &&
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 &&
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
67 test_expect_success \
68 'blame runs on unconflicted file while other file has conflicts' '
69 git blame file2
72 test_expect_success 'blame does not crash with conflicted file in stages 1,3' '
73 git blame file1
76 test_done