summaryrefslogtreecommitdiff
path: root/git-svn.perl
diff options
context:
space:
mode:
authorAndrew Myrick <amyrick@apple.com>2010-01-06 16:25:21 -0800
committerEric Wong <normalperson@yhbt.net>2010-01-23 03:23:03 -0800
commit1cef6500a9edc7997bd0aa4cd1f739f5106ab0a9 (patch)
treeaa6c6d0c3dbffead7fbd6c0ce1e273645d69599c /git-svn.perl
parentaba7dea83bfba411dee0271491d6199d2dca61d9 (diff)
downloadgit-1cef6500a9edc7997bd0aa4cd1f739f5106ab0a9.tar.gz
git-svn: ignore changeless commits when checking for a cherry-pick
Update git-svn to ignore commits that do not change the tree when it is deciding if an svn merge ticket represents a real branch merge or just a cherry-pick. Consider the following integration model in the svn repository: F---G branch1 / \ D tag1 \ E tag2 / \ / A---B C trunk branch1 is merged to trunk in commit C. With this patch, git-svn will correctly identify branch1 as a proper merge parent, instead of incorrectly ignoring it as a cherry-pick. Signed-off-by: Andrew Myrick <amyrick@apple.com> Acked-by: Sam Vilain <sam@vilain.net> Acked-by: Eric Wong <normalperson@yhbt.net>
Diffstat (limited to 'git-svn.perl')
-rwxr-xr-xgit-svn.perl24
1 files changed, 24 insertions, 0 deletions
diff --git a/git-svn.perl b/git-svn.perl
index 650c9e5f02..947184afcf 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -3052,12 +3052,36 @@ sub check_cherry_pick {
for my $range ( @ranges ) {
delete @commits{_rev_list($range)};
}
+ for my $commit (keys %commits) {
+ if (has_no_changes($commit)) {
+ delete $commits{$commit};
+ }
+ }
return (keys %commits);
}
+sub has_no_changes {
+ my $commit = shift;
+
+ my @revs = split / /, command_oneline(
+ qw(rev-list --parents -1 -m), $commit);
+
+ # Commits with no parents, e.g. the start of a partial branch,
+ # have changes by definition.
+ return 1 if (@revs < 2);
+
+ # Commits with multiple parents, e.g a merge, have no changes
+ # by definition.
+ return 0 if (@revs > 2);
+
+ return (command_oneline("rev-parse", "$commit^{tree}") eq
+ command_oneline("rev-parse", "$commit~1^{tree}"));
+}
+
BEGIN {
memoize 'lookup_svn_merge';
memoize 'check_cherry_pick';
+ memoize 'has_no_changes';
}
sub parents_exclude {