Fix another invocation of git from gitk with an overly long command-line
[git/dscho.git] / t / t4302-log-line-merge-history.sh
blob86341163e2f17353f12308e62571509375633d98
1 #!/bin/sh
3 # Copyright (c) 2010 Bo Yang
6 test_description='Test git log -L with merge commit'
8 . ./test-lib.sh
9 . "$TEST_DIRECTORY"/diff-lib.sh
11 cat >path0 <<\EOF
12 void func()
14 printf("hello");
16 EOF
18 test_expect_success 'Add path0 and commit.' '
19 git add path0 &&
20 git commit -m "Base commit"
23 cat >path0 <<\EOF
24 void func()
26 printf("hello earth");
28 EOF
30 test_expect_success 'Change path0 in master.' '
31 git add path0 &&
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^
39 cat >path0 <<\EOF
40 void func()
42 print("hello moon");
44 EOF
46 test_expect_success 'Change path0 in feature.' '
47 git add path0 &&
48 git commit -m "Change path0 in feature"
51 test_expect_success 'Merge the master to feature' '
52 ! git merge master
55 cat >path0 <<\EOF
56 void func()
58 printf("hello earth and moon");
60 EOF
62 test_expect_success 'Resolve the conflict' '
63 git add path0 &&
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
71 cat >expected <<\EOF
72 Merge two branches
74 nontrivial merge found
75 path0
76 @@ 3,1 @@
77 printf("hello earth and moon");
80 Change path0 in master
82 diff --git a/path0 b/path0
83 index 56aeee5..11e66c5 100644
84 --- a/path0
85 +++ b/path0
86 @@ -1,4 +1,4 @@
87 void func()
89 - printf("hello");
90 + printf("hello earth");
93 Change path0 in feature
95 diff --git a/path0 b/path0
96 index 56aeee5..258fced 100644
97 --- a/path0
98 +++ b/path0
99 @@ -1,4 +1,4 @@
100 void func()
102 - printf("hello");
103 + print("hello moon");
106 Base commit
108 diff --git a/path0 b/path0
109 new file mode 100644
110 index 0000000..56aeee5
111 --- /dev/null
112 +++ b/path0
113 @@ -0,0 +1,4 @@
114 +void func()
116 + printf("hello");
120 cat > expected-graph <<\EOF
121 * Merge two branches
123 | |
124 | | nontrivial merge found
125 | | path0
126 | | @@ 3,1 @@
127 | | printf("hello earth and moon");
128 | |
129 | |
130 | * Change path0 in master
131 | |
132 | | diff --git a/path0 b/path0
133 | | index 56aeee5..11e66c5 100644
134 | | --- a/path0
135 | | +++ b/path0
136 | | @@ -3,1 +3,1 @@
137 | | - printf("hello");
138 | | + printf("hello earth");
139 | |
140 * | Change path0 in feature
143 | diff --git a/path0 b/path0
144 | index 56aeee5..258fced 100644
145 | --- a/path0
146 | +++ b/path0
147 | @@ -3,1 +3,1 @@
148 | - printf("hello");
149 | + print("hello moon");
151 * Base commit
153 diff --git a/path0 b/path0
154 new file mode 100644
155 index 0000000..56aeee5
156 --- /dev/null
157 +++ b/path0
158 @@ -0,0 +3,1 @@
159 + printf("hello");
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
174 test_done