git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git svn dcommit: avoid self-referential mergeinfo lines when svn.pushmergeinfo is configured

From
Avishay Lavie <avishay.lavie@gmail.com>
Date
Mar 14, 2012, 16:09 UTC
Message-ID
<CAHkK2bpq1J2SW2P1tkFnjw5dWEr=uQrfrTUaS2J-swuKsP4kig@mail.gmail.com>

[PATCH] git svn dcommit: avoid self-referential mergeinfo lines when svn.pushmergeinfo flag is configured

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.

[1] http://thread.gmane.org/gmane.comp.version-control.git/191932
Signed-off-by: Avishay Lavie <avishay.lavie@gmail.com>
---
This is my first time sending a patch to the group, so if I'm doing
something wrong, please let me know.
 git-svn.perl |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
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 {
 				                             $uuid,
 				                             $linear_refs,
 				                             $rewritten_parent);
+
+				$_merge_info = remove_self_referential_merge_info($_merge_info, $url, $gs);
 			}

 			my %ed_opts = ( r => $last_rev,
-- 
1.7.8.msysgit.0
Next: Bryan Jacobs
Message 1 of 6 in “git svn dcommit: avoid self-referential mergeinfo lines when svn.pushmergeinfo is configured”
  1. git svn dcommit: avoid self-referential mergeinfo lines when svn.pushmergeinfo is configuredAvishay Lavie, Mar 14, 2012
  2. Bryan JacobsMar 14, 2012
  3. Thomas RastMar 14, 2012
  4. Eric WongMar 15, 2012
  5. Bryan JacobsMar 15, 2012
  6. Sam VilainMar 15, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.