3 # Copyright (c) 2010 Bo Yang
6 test_description
='Test git log -L with merge commit'
9 .
"$TEST_DIRECTORY"/diff-lib.sh
18 test_expect_success
'Add path0 and commit.' '
20 git commit -m "Base commit"
26 printf("hello earth");
30 test_expect_success
'Change path0 in master.' '
32 git commit -m "Change path0 in master"
35 test_expect_success
'Make a new branch from the base commit' '
36 git checkout -b feature master^
46 test_expect_success
'Change path0 in feature.' '
48 git commit -m "Change path0 in feature"
51 test_expect_success
'Merge the master to feature' '
58 printf("hello earth and moon");
62 test_expect_success
'Resolve the conflict' '
64 git commit -m "Merge two branches"
67 test_expect_success
'Show the line level log of path0' '
68 git log --pretty=format:%s%n%b -L /func/,/^}/ path0 > current
74 nontrivial merge found
77 printf("hello earth and moon");
80 Change path0
in master
82 diff --git a
/path0 b
/path0
83 index
56aeee5.
.11e66c5
100644
90 + printf("hello earth");
93 Change path0
in feature
95 diff --git a
/path0 b
/path0
96 index
56aeee5.
.258fced
100644
103 + print
("hello moon");
108 diff --git a
/path0 b
/path0
110 index
0000000.
.56aeee5
120 cat > expected-graph
<<\EOF
124 | | nontrivial merge found
127 | |
printf("hello earth and moon");
130 |
* Change path0
in master
132 | |
diff --git a
/path0 b
/path0
133 | | index
56aeee5.
.11e66c5
100644
137 | |
- printf("hello");
138 | |
+ printf("hello earth");
140 * | Change path0
in feature
143 |
diff --git a
/path0 b
/path0
144 | index
56aeee5.
.258fced
100644
149 |
+ print
("hello moon");
153 diff --git a
/path0 b
/path0
155 index
0000000.
.56aeee5
162 test_expect_success
'Show the line log of the 2 line of path0 with graph' '
163 git log --pretty=format:%s%n%b --graph -L 3,+1 path0 > current-graph
166 test_expect_success
'validate the output.' '
167 test_cmp current expected
170 test_expect_success
'validate the graph output.' '
171 test_cmp current-graph expected-graph