Skip to content

Commit 1d144aa

Browse files
samvEric Wong
authored andcommitted
git-svn: expand the svn mergeinfo test suite, highlighting some failures
As shown, git-svn has some problems; not all svn merges are correctly detected, and cherry picks may incorrectly be detected as real merges. These test cases will be marked as _success once the relevant fixes are in. Signed-off-by: Sam Vilain <[email protected]> Acked-by: Eric Wong <[email protected]>
1 parent af57b41 commit 1d144aa

File tree

3 files changed

+860
-172
lines changed

3 files changed

+860
-172
lines changed

t/t9151-svn-mergeinfo.sh

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,27 @@ test_expect_success 'load svn dump' "
1515
git svn fetch --all
1616
"
1717

18-
test_expect_success 'represent svn merges without intervening commits' "
19-
[ `git cat-file commit HEAD^1 | grep parent | wc -l` -eq 2 ]
20-
"
18+
test_expect_failure 'all svn merges became git merge commits' '
19+
unmarked=$(git rev-list --parents --all --grep=Merge |
20+
grep -v " .* " | cut -f1 -d" ")
21+
[ -z "$unmarked" ]
22+
'
2123

22-
test_expect_success 'represent svn merges with intervening commits' "
23-
[ `git cat-file commit HEAD | grep parent | wc -l` -eq 2 ]
24-
"
24+
test_expect_failure 'cherry picks did not become git merge commits' '
25+
bad_cherries=$(git rev-list --parents --all --grep=Cherry |
26+
grep " .* " | cut -f1 -d" ")
27+
[ -z "$bad_cherries" ]
28+
'
29+
30+
test_expect_success 'svn non-merge merge commits did not become git merge commits' '
31+
bad_non_merges=$(git rev-list --parents --all --grep=non-merge |
32+
grep " .* " | cut -f1 -d" ")
33+
[ -z "$bad_non_merges" ]
34+
'
35+
36+
test_expect_failure 'everything got merged in the end' '
37+
unmerged=$(git rev-list --all --not master)
38+
[ -z "$unmerged" ]
39+
'
2540

2641
test_done

t/t9151/make-svnmerge-dump

Lines changed: 112 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -11,93 +11,151 @@ mkdir foo.svn
1111
svnadmin create foo.svn
1212
svn co file://`pwd`/foo.svn foo
1313

14+
commit() {
15+
i=$(( $1 + 1 ))
16+
shift;
17+
svn commit -m "(r$i) $*" >/dev/null || exit 1
18+
echo $i
19+
}
20+
21+
say() {
22+
echo " * $*"
23+
}
24+
25+
i=0
1426
cd foo
1527
mkdir trunk
1628
mkdir branches
1729
svn add trunk branches
18-
svn commit -m "Setup trunk and branches"
19-
cd trunk
30+
i=$(commit $i "Setup trunk and branches")
2031

21-
git cat-file blob 6683463e:Makefile > Makefile
22-
svn add Makefile
32+
git cat-file blob 6683463e:Makefile > trunk/Makefile
33+
svn add trunk/Makefile
2334

24-
echo "Committing ANCESTOR"
25-
svn commit -m "ancestor"
26-
cd ..
35+
say "Committing ANCESTOR"
36+
i=$(commit $i "ancestor")
2737
svn cp trunk branches/left
2838

29-
echo "Committing BRANCH POINT"
30-
svn commit -m "make left branch"
39+
say "Committing BRANCH POINT"
40+
i=$(commit $i "make left branch")
3141
svn cp trunk branches/right
3242

33-
echo "Committing other BRANCH POINT"
34-
svn commit -m "make right branch"
35-
cd branches/left/
43+
say "Committing other BRANCH POINT"
44+
i=$(commit $i "make right branch")
3645

37-
#$sm init
38-
#svn commit -m "init svnmerge"
46+
say "Committing LEFT UPDATE"
47+
git cat-file blob 5873b67e:Makefile > branches/left/Makefile
48+
i=$(commit $i "left update 1")
3949

40-
git cat-file blob 5873b67e:Makefile > Makefile
41-
echo "Committing BRANCH UPDATE 1"
42-
svn commit -m "left update 1"
43-
cd ../..
44-
45-
cd trunk
46-
git cat-file blob 75118b13:Makefile > Makefile
47-
echo "Committing TRUNK UPDATE"
48-
svn commit -m "trunk update"
50+
git cat-file blob 75118b13:Makefile > branches/right/Makefile
51+
say "Committing RIGHT UPDATE"
52+
pre_right_update_1=$i
53+
i=$(commit $i "right update 1")
4954

50-
cd ../branches/left
51-
git cat-file blob ff5ebe39:Makefile > Makefile
52-
echo "Committing BRANCH UPDATE 2"
53-
svn commit -m "left update 2"
55+
say "Making more commits on LEFT"
56+
git cat-file blob ff5ebe39:Makefile > branches/left/Makefile
57+
i=$(commit $i "left update 2")
58+
git cat-file blob b5039db6:Makefile > branches/left/Makefile
59+
i=$(commit $i "left update 3")
5460

55-
git cat-file blob b5039db6:Makefile > Makefile
56-
echo "Committing BRANCH UPDATE 3"
57-
svn commit -m "left update 3"
61+
say "Making a LEFT SUB-BRANCH"
62+
svn cp branches/left branches/left-sub
63+
sub_left_make=$i
64+
i=$(commit $i "make left sub-branch")
5865

59-
# merge to trunk
66+
say "Making a commit on LEFT SUB-BRANCH"
67+
echo "crunch" > branches/left-sub/README
68+
svn add branches/left-sub/README
69+
i=$(commit $i "left sub-branch update 1")
6070

61-
cd ../..
71+
say "Merging LEFT to TRUNK"
6272
svn update
6373
cd trunk
64-
6574
svn merge ../branches/left --accept postpone
66-
67-
git cat-file blob b51ad431:Makefile > Makefile
68-
75+
git cat-file blob b5039db6:Makefile > Makefile
6976
svn resolved Makefile
77+
i=$(commit $i "Merge left to trunk 1")
78+
cd ..
7079

71-
svn commit -m "Merge trunk 1"
72-
73-
# create commits on both branches
74-
75-
cd ../branches/left
76-
git cat-file blob ff5ebe39:Makefile > Makefile
77-
echo "Committing BRANCH UPDATE 4"
78-
svn commit -m "left update 4"
79-
80-
cd ../right
81-
git cat-file blob b5039db6:Makefile > Makefile
82-
echo "Committing other BRANCH UPDATE 1"
83-
svn commit -m "right update 1"
80+
say "Making more commits on LEFT and RIGHT"
81+
echo "touche" > branches/left/zlonk
82+
svn add branches/left/zlonk
83+
i=$(commit $i "left update 4")
84+
echo "thwacke" > branches/right/bang
85+
svn add branches/right/bang
86+
i=$(commit $i "right update 2")
8487

85-
# merge to trun again
88+
say "Squash merge of RIGHT tip 2 commits onto TRUNK"
89+
svn update
90+
cd trunk
91+
svn merge -r$pre_right_update_1:$i ../branches/right
92+
i=$(commit $i "Cherry-pick right 2 commits to trunk")
93+
cd ..
8694

87-
cd ../..
95+
say "Merging RIGHT to TRUNK"
8896
svn update
8997
cd trunk
98+
svn merge ../branches/right --accept postpone
99+
git cat-file blob b51ad431:Makefile > Makefile
100+
svn resolved Makefile
101+
i=$(commit $i "Merge right to trunk 1")
102+
cd ..
90103

91-
svn merge ../branches/left --accept postpone
104+
say "Making more commits on RIGHT and TRUNK"
105+
echo "whamm" > branches/right/urkkk
106+
svn add branches/right/urkkk
107+
i=$(commit $i "right update 3")
108+
echo "pow" > trunk/vronk
109+
svn add trunk/vronk
110+
i=$(commit $i "trunk update 1")
92111

112+
say "Merging RIGHT to LEFT SUB-BRANCH"
113+
svn update
114+
cd branches/left-sub
115+
svn merge ../right --accept postpone
93116
git cat-file blob b51ad431:Makefile > Makefile
94-
95117
svn resolved Makefile
118+
i=$(commit $i "Merge right to left sub-branch")
119+
cd ../..
96120

97-
svn commit -m "Merge trunk 2"
121+
say "Making more commits on LEFT SUB-BRANCH and LEFT"
122+
echo "zowie" > branches/left-sub/wham_eth
123+
svn add branches/left-sub/wham_eth
124+
pre_sub_left_update_2=$i
125+
i=$(commit $i "left sub-branch update 2")
126+
sub_left_update_2=$i
127+
echo "eee_yow" > branches/left/glurpp
128+
svn add branches/left/glurpp
129+
i=$(commit $i "left update 5")
130+
131+
say "Cherry pick LEFT SUB-BRANCH commit to LEFT"
132+
svn update
133+
cd branches/left
134+
svn merge -r$pre_sub_left_update_2:$sub_left_update_2 ../left-sub
135+
i=$(commit $i "Cherry-pick left sub-branch commit to left")
136+
cd ../..
98137

138+
say "Merging LEFT SUB-BRANCH back to LEFT"
139+
svn update
140+
cd branches/left
141+
# it's only a merge because the previous merge cherry-picked the top commit
142+
svn merge -r$sub_left_make:$sub_left_update_2 ../left-sub --accept postpone
143+
i=$(commit $i "Merge left sub-branch to left")
99144
cd ../..
100145

146+
say "Merging EVERYTHING to TRUNK"
147+
svn update
148+
cd trunk
149+
svn merge ../branches/left --accept postpone
150+
svn resolved bang
151+
i=$(commit $i "Merge left to trunk 2")
152+
# this merge, svn happily updates the mergeinfo, but there is actually
153+
# nothing to merge. git-svn will not make a meaningless merge commit.
154+
svn merge ../branches/right --accept postpone
155+
i=$(commit $i "non-merge right to trunk 2")
156+
cd ..
157+
158+
cd ..
101159
svnadmin dump foo.svn > svn-mergeinfo.dump
102160

103161
rm -rf foo foo.svn

0 commit comments

Comments
 (0)