@matheusbsbs / matheus-bagliano / commits / 1cef6500a9
Fork 0

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>

Andrew Myrick committed Jan 6, 2010 at 16:25 UTC 1cef6500a9edc7997bd0aa4cd1f739f5106ab0a9
1 file changed +24
git-svn.perl
+24
@@ -3052,12 +3052,36 @@ sub check_cherry_pick {
3052 for my $range ( @ranges ) {
3053 delete @commits{_rev_list($range)};
3054 }
3055 + for my $commit (keys %commits) {
3056 + if (has_no_changes($commit)) {
3057 + delete $commits{$commit};
3058 + }
3059 + }
3060 return (keys %commits);
3061 }
3062
3063 +sub has_no_changes {
3064 + my $commit = shift;
3065 +
3066 + my @revs = split / /, command_oneline(
3067 + qw(rev-list --parents -1 -m), $commit);
3068 +
3069 + # Commits with no parents, e.g. the start of a partial branch,
3070 + # have changes by definition.
3071 + return 1 if (@revs < 2);
3072 +
3073 + # Commits with multiple parents, e.g a merge, have no changes
3074 + # by definition.
3075 + return 0 if (@revs > 2);
3076 +
3077 + return (command_oneline("rev-parse", "$commit^{tree}") eq
3078 + command_oneline("rev-parse", "$commit~1^{tree}"));
3079 +}
3080 +
3081 BEGIN {
3082 memoize 'lookup_svn_merge';
3083 memoize 'check_cherry_pick';
3084 + memoize 'has_no_changes';
3085 }
3086
3087 sub parents_exclude {