]> git.ipfire.org Git - thirdparty/git.git/blame - t/t8004-blame-with-conflicts.sh
The fifteenth batch
[thirdparty/git.git] / t / t8004-blame-with-conflicts.sh
CommitLineData
cd8ae201
LT
1#!/bin/sh
2
3# Based on a test case submitted by Björn Steinbrink.
4
5test_description='git blame on conflicted files'
747f6c68 6GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
7export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8
cd8ae201
LT
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
747f6c68
JS
27 # Back to main and change something
28 git checkout main &&
cd8ae201
LT
29 echo "
30
31bla" >> file1 &&
32 git commit --author "Old Line <ol@localhost>" -a -m file1.b &&
33
747f6c68 34 # Back to foo and merge main
cd8ae201 35 git checkout foo &&
747f6c68 36 if git merge main; then
cd8ae201
LT
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
747f6c68
JS
50 # Back to main and change file1 again
51 git checkout main &&
cd8ae201
LT
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 &&
747f6c68 59 if git merge main; then
cd8ae201
LT
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
ffcabccf 72test_expect_success 'blame does not crash with conflicted file in stages 1,3' '
9aeaab68 73 git blame file1
cd8ae201
LT
74'
75
76test_done