Skip to content

Commit d51c527

Browse files
Thomas Rastgitster
authored andcommitted
log -L: test merge of parallel modify/rename
This tests a toy example of a history like * Merge | \ | * Modify foo | | * | Rename foo->bar | / * Create foo Current log -L fails on this; we'll fix it in the next commit. Signed-off-by: Thomas Rast <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 035ff39 commit d51c527

File tree

3 files changed

+250
-6
lines changed

3 files changed

+250
-6
lines changed

t/t4211-line-log.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,20 @@ test_expect_success 'setup (import history)' '
88
git reset --hard
99
'
1010

11-
canned_test () {
12-
test_expect_success "$1" "
13-
git log $1 >actual &&
14-
test_cmp \"\$TEST_DIRECTORY\"/t4211/expect.$2 actual
11+
canned_test_1 () {
12+
test_expect_$1 "$2" "
13+
git log $2 >actual &&
14+
test_cmp \"\$TEST_DIRECTORY\"/t4211/expect.$3 actual
1515
"
1616
}
1717

18+
canned_test () {
19+
canned_test_1 success "$@"
20+
}
21+
canned_test_failure () {
22+
canned_test_1 failure "$@"
23+
}
24+
1825
test_bad_opts () {
1926
test_expect_success "invalid args: $1" "
2027
test_must_fail git log $1 2>errors &&
@@ -38,6 +45,7 @@ canned_test "-L '/long f/',/^}/:a.c -L /main/,/^}/:a.c simple" two-ranges
3845
canned_test "-L 24,+1:a.c simple" vanishes-early
3946

4047
canned_test "-M -L '/long f/,/^}/:b.c' move-support" move-support-f
48+
canned_test_failure "-M -L ':f:b.c' parallel-change" parallel-change-f-to-main
4149

4250
canned_test "-L 4,12:a.c -L :main:a.c simple" multiple
4351
canned_test "-L 4,18:a.c -L :main:a.c simple" multiple-overlapping
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
commit 0469c60bc4837d52d97b1f081dec5f98dea20fed
2+
Merge: ba227c6 6ce3c4f
3+
Author: Thomas Rast <[email protected]>
4+
Date: Fri Apr 12 16:16:24 2013 +0200
5+
6+
Merge across the rename
7+
8+
9+
commit 6ce3c4ff690136099bb17e1a8766b75764726ea7
10+
Author: Thomas Rast <[email protected]>
11+
Date: Thu Feb 28 10:49:50 2013 +0100
12+
13+
another simple change
14+
15+
diff --git a/b.c b/b.c
16+
--- a/b.c
17+
+++ b/b.c
18+
@@ -4,14 +4,14 @@
19+
long f(long x)
20+
{
21+
int s = 0;
22+
while (x) {
23+
- x >>= 1;
24+
+ x /= 2;
25+
s++;
26+
}
27+
return s;
28+
}
29+
30+
/*
31+
* This is only an example!
32+
*/
33+
34+
35+
commit ba227c6632349700fbb957dec2b50f5e2358be3f
36+
Author: Thomas Rast <[email protected]>
37+
Date: Fri Apr 12 16:15:57 2013 +0200
38+
39+
change on another line of history while rename happens
40+
41+
diff --git a/a.c b/a.c
42+
--- a/a.c
43+
+++ b/a.c
44+
@@ -4,14 +4,14 @@
45+
long f(long x)
46+
{
47+
int s = 0;
48+
while (x) {
49+
x >>= 1;
50+
s++;
51+
}
52+
return s;
53+
}
54+
55+
/*
56+
- * This is only an example!
57+
+ * This is only a short example!
58+
*/
59+
60+
61+
commit 39b6eb2d5b706d3322184a169f666f25ed3fbd00
62+
Author: Thomas Rast <[email protected]>
63+
Date: Thu Feb 28 10:45:41 2013 +0100
64+
65+
touch comment
66+
67+
diff --git a/a.c b/a.c
68+
--- a/a.c
69+
+++ b/a.c
70+
@@ -3,14 +3,14 @@
71+
long f(long x)
72+
{
73+
int s = 0;
74+
while (x) {
75+
x >>= 1;
76+
s++;
77+
}
78+
return s;
79+
}
80+
81+
/*
82+
- * A comment.
83+
+ * This is only an example!
84+
*/
85+
86+
87+
commit a6eb82647d5d67f893da442f8f9375fd89a3b1e2
88+
Author: Thomas Rast <[email protected]>
89+
Date: Thu Feb 28 10:45:16 2013 +0100
90+
91+
touch both functions
92+
93+
diff --git a/a.c b/a.c
94+
--- a/a.c
95+
+++ b/a.c
96+
@@ -3,14 +3,14 @@
97+
-int f(int x)
98+
+long f(long x)
99+
{
100+
int s = 0;
101+
while (x) {
102+
x >>= 1;
103+
s++;
104+
}
105+
return s;
106+
}
107+
108+
/*
109+
* A comment.
110+
*/
111+
112+
113+
commit f04fb20f2c77850996cba739709acc6faecc58f7
114+
Author: Thomas Rast <[email protected]>
115+
Date: Thu Feb 28 10:44:55 2013 +0100
116+
117+
change f()
118+
119+
diff --git a/a.c b/a.c
120+
--- a/a.c
121+
+++ b/a.c
122+
@@ -3,13 +3,14 @@
123+
int f(int x)
124+
{
125+
int s = 0;
126+
while (x) {
127+
x >>= 1;
128+
s++;
129+
}
130+
+ return s;
131+
}
132+
133+
/*
134+
* A comment.
135+
*/
136+
137+
138+
commit de4c48ae814792c02a49c4c3c0c757ae69c55f6a
139+
Author: Thomas Rast <[email protected]>
140+
Date: Thu Feb 28 10:44:48 2013 +0100
141+
142+
initial
143+
144+
diff --git a/a.c b/a.c
145+
--- /dev/null
146+
+++ b/a.c
147+
@@ -0,0 +3,13 @@
148+
+int f(int x)
149+
+{
150+
+ int s = 0;
151+
+ while (x) {
152+
+ x >>= 1;
153+
+ s++;
154+
+ }
155+
+}
156+
+
157+
+/*
158+
+ * A comment.
159+
+ */
160+
+

t/t4211/history.export

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,82 @@ move within the file
325325
from :17
326326
M 100644 :18 b.c
327327

328-
reset refs/heads/master
329-
from :19
328+
blob
329+
mark :20
330+
data 243
331+
#include <unistd.h>
332+
#include <stdio.h>
333+
334+
long f(long x)
335+
{
336+
int s = 0;
337+
while (x) {
338+
x >>= 1;
339+
s++;
340+
}
341+
return s;
342+
}
343+
344+
/*
345+
* This is only a short example!
346+
*/
347+
348+
int main ()
349+
{
350+
printf("%ld\n", f(15));
351+
return 0;
352+
}
353+
354+
/* incomplete lines are bad! */
355+
356+
commit refs/heads/parallel-change
357+
mark :21
358+
author Thomas Rast <[email protected]> 1365776157 +0200
359+
committer Thomas Rast <[email protected]> 1365776157 +0200
360+
data 55
361+
change on another line of history while rename happens
362+
from :14
363+
M 100644 :20 a.c
364+
365+
blob
366+
mark :22
367+
data 242
368+
#include <unistd.h>
369+
#include <stdio.h>
370+
371+
long f(long x)
372+
{
373+
int s = 0;
374+
while (x) {
375+
x /= 2;
376+
s++;
377+
}
378+
return s;
379+
}
380+
381+
/*
382+
* This is only a short example!
383+
*/
384+
385+
int main ()
386+
{
387+
printf("%ld\n", f(15));
388+
return 0;
389+
}
390+
391+
/* incomplete lines are bad! */
392+
393+
commit refs/heads/parallel-change
394+
mark :23
395+
author Thomas Rast <[email protected]> 1365776184 +0200
396+
committer Thomas Rast <[email protected]> 1365776191 +0200
397+
data 24
398+
Merge across the rename
399+
from :21
400+
merge :17
401+
D a.c
402+
M 100644 :22 b.c
403+
404+
reset refs/heads/parallel-change
405+
from :23
330406

0 commit comments

Comments
 (0)