Skip to content

Commit a3c7505

Browse files
Steven WalterEric Wong
authored andcommitted
git-svn: check_cherry_pick should exclude commits already in our history
The merge-base between @$parents and $merge_tip may have been reached through a merge commit. This means that some commits that are ancestors of @$parents will not be ancestors of $merge_base. The mergeinfo property will not list commits that are ancestors of @$parents, so we need to explicitly exclude them. [ew: squashed and cleaned up test case from Steven] Signed-off-by: Steven Walter <[email protected]> Acked-by: Eric Wong <[email protected]>
1 parent c9be27f commit a3c7505

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

git-svn.perl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3118,9 +3118,10 @@ sub _rev_list {
31183118
sub check_cherry_pick {
31193119
my $base = shift;
31203120
my $tip = shift;
3121+
my $parents = shift;
31213122
my @ranges = @_;
31223123
my %commits = map { $_ => 1 }
3123-
_rev_list("--no-merges", $tip, "--not", $base);
3124+
_rev_list("--no-merges", $tip, "--not", $base, @$parents);
31243125
for my $range ( @ranges ) {
31253126
delete @commits{_rev_list($range)};
31263127
}
@@ -3296,6 +3297,7 @@ sub find_extra_svn_parents {
32963297
# double check that there are no missing non-merge commits
32973298
my (@incomplete) = check_cherry_pick(
32983299
$merge_base, $merge_tip,
3300+
$parents,
32993301
@$ranges,
33003302
);
33013303

t/t9157-git-svn-fetch-merge.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2010 Steven Walter
4+
#
5+
6+
test_description='git svn merge detection'
7+
. ./lib-git-svn.sh
8+
9+
test_expect_success 'initialize source svn repo' '
10+
svn_cmd mkdir -m x "$svnrepo"/trunk &&
11+
svn_cmd mkdir -m x "$svnrepo"/branches &&
12+
svn_cmd co "$svnrepo"/trunk "$SVN_TREE" &&
13+
(
14+
cd "$SVN_TREE" &&
15+
touch foo &&
16+
svn add foo &&
17+
svn commit -m "initial commit" &&
18+
svn cp -m branch "$svnrepo"/trunk "$svnrepo"/branches/branch1 &&
19+
touch bar &&
20+
svn add bar &&
21+
svn commit -m x &&
22+
svn cp -m branch "$svnrepo"/trunk "$svnrepo"/branches/branch2 &&
23+
svn switch "$svnrepo"/branches/branch1 &&
24+
touch baz &&
25+
svn add baz &&
26+
svn commit -m x &&
27+
svn switch "$svnrepo"/trunk &&
28+
svn merge "$svnrepo"/branches/branch1 &&
29+
svn commit -m "merge" &&
30+
svn switch "$svnrepo"/branches/branch1 &&
31+
svn commit -m x &&
32+
svn switch "$svnrepo"/branches/branch2 &&
33+
svn merge "$svnrepo"/branches/branch1 &&
34+
svn commit -m "merge branch1" &&
35+
svn switch "$svnrepo"/trunk &&
36+
svn merge "$svnrepo"/branches/branch2 &&
37+
svn resolved baz &&
38+
svn 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' 'git rev-parse HEAD^2'
49+
50+
test_done

0 commit comments

Comments
 (0)