Skip to content

@avish /avoid-self-ref-mergeinfo.patch

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
[PATCH] git svn dcommit: avoid self-referential mergeinfo
Date: Wed, 14 Mar 2012 17:45:05 +0200
Subject: [PATCH] git svn dcommit: avoid self-referential mergeinfo
When svn.pushmergeinfo is configured, git svn dcommit tries to automatically populate svn:mergeinfo properties by merging the parent branch's mergeinfo into the committed one on each merge commit. This process can add self-referential mergeinfo lines, i.e. ones that reference the same branch being committed into (e.g. when reintegrating a branch to trunk after previously having merged trunk into it), which are then mishandled by SVN and cause errors in mixed SVN/Git environments.
For more details, see my original report on the issue at [1].
This commit adds a step to git svn dcommit that filters out any mergeinfo lines referencing the target branch from the mergeinfo, thus avoiding the problem.
git-svn.perl | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/git-svn.perl b/git-svn.perl
index eeb83d3..1ed409d 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -752,6 +752,19 @@ sub populate_merge_info {
return undef;
+sub remove_self_referential_merge_info {
+ return $_merge_info unless defined $_merge_info;
+ my ($_merge_info, $branchurl, $gs) = @_;
+ my $rooturl = $gs->repos_root;
+ unless ($branchurl =~ /^\Q$rooturl\E(.*)/) {
+ fatal "URL to commit to is not under SVN root $rooturl!";
+ }
+ my $branchpath = $1;
+ return join("\n", grep { $_ !~ m/^$branchpath\:/ } split(/\n/, $_merge_info));
sub cmd_dcommit {
my $head = shift;
command_noisy(qw/update-index --refresh/);
@@ -902,6 +915,8 @@ sub cmd_dcommit {
+ $_merge_info = remove_self_referential_merge_info($_merge_info, $url, $gs);
my %ed_opts = ( r => $last_rev,

Thanks for posting it.


Just a reference to the mail thread for the sake of completeness:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.