Skip to contentSkip to conversation

git-svn.perl: consider all ranges for a given merge, instead of only tip-by-tip

PATCH Superseded Steven Walter 2 participants 3 messages Jun 15, 2016

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 git-svn.perl: consider all ranges for a given merge, instead of only tip-by-tip

Consider the case where you have trunk, branchA of trunk, and branchB of branchA. trunk is merged back into branchB, and then branchB is reintegrated into trunk. The merge of branchB into trunk will have svn:mergeinfo property references to both branchA and branchB. When performing the check_cherry_pick check on branchB, it is necessary to eliminate the merged contents of branchA as well as branchB, or else the merge will be incorrectly ignored as a cherry-pick.

---
 git-svn.perl                                    |    8 ++-
 t/t9163-git-svn-fetch-merge-branch-of-branch.sh |   60 +++++++++++++++++++++++
 2 files changed, 63 insertions(+), 5 deletions(-)
 create mode 100755 t/t9163-git-svn-fetch-merge-branch-of-branch.sh
git-svn.perl +3 -5
index ca038ec..abcec11 100755
@@ -3657,14 +3657,14 @@ sub find_extra_svn_parents {
 	my @merge_tips;
 	my $url = $self->{url};
 	my $uuid = $self->ra_uuid;
-	my %ranges;
+	my @all_ranges;
 	for my $merge ( @merges ) {
 		my ($tip_commit, @ranges) =
 			lookup_svn_merge( $uuid, $url, $merge );
 		unless (!$tip_commit or
 				grep { $_ eq $tip_commit } @$parents ) {
 			push @merge_tips, $tip_commit;
-			$ranges{$tip_commit} = \@ranges;
+			push @all_ranges, @ranges;
 		} else {
 			push @merge_tips, undef;
 		}
@@ -3679,8 +3679,6 @@ sub find_extra_svn_parents {
 		my $spec = shift @merges;
 		next unless $merge_tip and $excluded{$merge_tip};
 
-		my $ranges = $ranges{$merge_tip};
-
 		# check out 'new' tips
 		my $merge_base;
 		eval {
@@ -3702,7 +3700,7 @@ sub find_extra_svn_parents {
 		my (@incomplete) = check_cherry_pick(
 			$merge_base, $merge_tip,
 			$parents,
-			@$ranges,
+			@all_ranges,
 		       );
 
 		if ( @incomplete ) {
t/t9163-git-svn-fetch-merge-branch-of-branch.sh new file +60 -0

60 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 2/2 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.

---
 git-svn.perl                                     |    1 -
 t/t9164-git-svn-fetch-merge-branch-of-branch2.sh |   53 ++++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletion(-)
 create mode 100755 t/t9164-git-svn-fetch-merge-branch-of-branch2.sh
git-svn.perl +0 -1
index abcec11..c4678c1 100755
@@ -3623,7 +3623,6 @@ sub parents_exclude {
 				if ( $commit eq $excluded ) {
 					push @excluded, $commit;
 					$found++;
-					last;
 				}
 				else {
 					push @new, $commit;
t/t9164-git-svn-fetch-merge-branch-of-branch2.sh new file +53 -0

53 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw
In reply to Steven Walter

Steven Walter <[email protected]> wrote:

I'll wait for input on others who understand mergeinfo better than I do to chime in on the actual changes. Some nits on the tests:

Quoted 1 line

+# Copyright (c) 2010 Steven Walter

2010?

t/t9163-git-svn-fetch-merge-branch-of-branch.sh line 57

Quoted 3 lines
t/t9163-git-svn-fetch-merge-branch-of-branch.sh new file +3 -0
+test_expect_success 'verify merge commit' 'x=$(git rev-parse HEAD^2) &&
+	y=$(git rev-parse branch2) &&
+	[ $x == $y ]

== is a bash-ism, and we prefer 'test'. A single '=' works fine here, but it's probably better to prefix and quote if you're paranoid:

	test "x$x" = "x$y"