git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] git-svn: ignore changeless commits when checking for a cherry-pick
@ 2010-01-06 20:08 Andrew Myrick
  2010-01-06 20:08 ` [PATCH 2/2] git-svn: handle merge-base failures Andrew Myrick
  2010-01-06 21:43 ` [PATCH 1/2] git-svn: ignore changeless commits when checking for a cherry-pick Eric Wong
  0 siblings, 2 replies; 11+ messages in thread
From: Andrew Myrick @ 2010-01-06 20:08 UTC (permalink / raw)
  To: git; +Cc: sam, normalperson, Andrew Myrick

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>
---
 git-svn.perl |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 650c9e5..8c7c034 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 {
-- 
1.6.6.2.g18c9a

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-01-21 21:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-06 20:08 [PATCH 1/2] git-svn: ignore changeless commits when checking for a cherry-pick Andrew Myrick
2010-01-06 20:08 ` [PATCH 2/2] git-svn: handle merge-base failures Andrew Myrick
2010-01-06 21:43 ` [PATCH 1/2] git-svn: ignore changeless commits when checking for a cherry-pick Eric Wong
2010-01-06 22:38   ` [spf:guess] " Sam Vilain
2010-01-07  6:49     ` Eric Wong
2010-01-07  9:05       ` [spf:guess] " Sam Vilain
2010-01-06 22:52   ` Andrew Myrick
2010-01-07  0:25     ` Andrew Myrick
2010-01-07  0:25       ` [PATCH 2/2] git-svn: handle merge-base failures Andrew Myrick
2010-01-07  9:50       ` [PATCH 1/2] git-svn: ignore changeless commits when checking for a cherry-pick Eric Wong
2010-01-21 21:55     ` [PATCH] git-svn: update svn mergeinfo test suite Andrew Myrick

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).