Skip to content

Commit 14d3ce1

Browse files
srwalterEric Wong
authored andcommitted
git-svn.perl: keep processing all commits in parents_exclude
This fixes a bug where git finds the incorrect merge parent. Consider a repository with trunk, branch1 of trunk, and branch2 of branch1. Without this change, git interprets a merge of branch2 into trunk as a merge of branch1 into trunk. Signed-off-by: Steven Walter <[email protected]> Reviewed-by: Sam Vilain <[email protected]> Signed-off-by: Eric Wong <[email protected]>
1 parent f271fad commit 14d3ce1

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

perl/Git/SVN.pm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1679,7 +1679,6 @@ sub parents_exclude {
16791679
if ( $commit eq $excluded ) {
16801680
push @excluded, $commit;
16811681
$found++;
1682-
last;
16831682
}
16841683
else {
16851684
push @new, $commit;
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2012 Steven Walter
4+
#
5+
6+
test_description='git svn merge detection'
7+
. ./lib-git-svn.sh
8+
9+
svn_ver="$(svn --version --quiet)"
10+
case $svn_ver in
11+
0.* | 1.[0-4].*)
12+
skip_all="skipping git-svn test - SVN too old ($svn_ver)"
13+
test_done
14+
;;
15+
esac
16+
17+
test_expect_success 'initialize source svn repo' '
18+
svn_cmd mkdir -m x "$svnrepo"/trunk &&
19+
svn_cmd mkdir -m x "$svnrepo"/branches &&
20+
svn_cmd co "$svnrepo"/trunk "$SVN_TREE" &&
21+
(
22+
cd "$SVN_TREE" &&
23+
touch foo &&
24+
svn_cmd add foo &&
25+
svn_cmd commit -m "initial commit" &&
26+
svn_cmd cp -m branch "$svnrepo"/trunk "$svnrepo"/branches/branch1 &&
27+
svn_cmd switch "$svnrepo"/branches/branch1 &&
28+
touch bar &&
29+
svn_cmd add bar &&
30+
svn_cmd commit -m branch1 &&
31+
svn_cmd cp -m branch "$svnrepo"/branches/branch1 "$svnrepo"/branches/branch2 &&
32+
svn_cmd switch "$svnrepo"/branches/branch2 &&
33+
touch baz &&
34+
svn_cmd add baz &&
35+
svn_cmd commit -m branch2 &&
36+
svn_cmd switch "$svnrepo"/trunk &&
37+
svn_cmd merge --reintegrate "$svnrepo"/branches/branch2 &&
38+
svn_cmd commit -m "merge branch2"
39+
) &&
40+
rm -rf "$SVN_TREE"
41+
'
42+
43+
test_expect_success 'clone svn repo' '
44+
git svn init -s "$svnrepo" &&
45+
git svn fetch
46+
'
47+
48+
test_expect_success 'verify merge commit' 'x=$(git rev-parse HEAD^2) &&
49+
y=$(git rev-parse branch2) &&
50+
test "x$x" = "x$y"
51+
'
52+
53+
test_done

0 commit comments

Comments
 (0)