Git-SVN with svn.pushmergeinfo: how to avoid self-referencing mergeinfo lines
Asked Answered
L

1

11

In recent versions of git, the configuration svn.pushmergeinfo was introduced:

config key: svn.pushmergeinfo

This option will cause git-svn to attempt to automatically populate the svn:mergeinfo property in the SVN repository when possible. Currently, this can only be done when dcommitting non-fast-forward merges where all parents but the first have already been pushed into SVN.

We're using this to have a mixed environment where some developers use SVN and some use Git-SVN. This works great when branching and merging SVN-branches in Git and then git svn dcommit-ing back to SVN, and it actually correctly populates the mergeinfo property in almost all cases. However, in specific situations it does so incorrectly.

This happens mainly when merging a branch into master (trunk), after having merged trunk into that branch (effectively, the equivalent of a SVN reintegrate).

The merge from trunk to the branch adds a mergeinfo line for trunk on that branch (as desired), but the reintegrate-merge from the branch back to trunk copies that line into trunk's mergeinfo, effectively creating a self-referencing line in trunk's mergeinfo property that points to itself. As far as I know this self-reference should never happen, and doesn't happen when using SVN alone. So, I consider this a git-svn bug (which I've reported here). This in turn creates problems down the road which affect other SVN users and corrupt the mergeinfo on future commits.

What I'm looking for is a workaround: how can I easily tell git not to copy mergeinfo lines for the branch being merged into, or alternatively how can I tell SVN to remove those self-references upon commit (or any other solution which doesn't result in a self-referencing mergeinfo line but does preserve the other qualities of automatic svn:mergeinfo creation from git).

(For clarification, I am not looking for people to quote the git manual to me or tell me that "merging with Git-SVN is dangerous and not supported". Please only answer if you can help with the issue or propose an alternative workflow. Pointers into the relevant git code would also be helpful since they might allow me to create a patch to solve this. Thanks!)

Luzluzader answered 14/3, 2012 at 11:24 Comment(2)
What was the workflow you used to actually do the git-svn merges?Paling
We merge regularly in git, but always from the "remote" (svn-y) branch and always with --no-ff (since svn doesn't support fast forwarding). Then we dcommit it. Note that you can't svn rebase if you have an unpushed merge; this will re-copy all the merged-in commits. A solution for this scenario will be included in the next version of Git.Luzluzader
T
8

just an update. looks like you created a patch.

http://lists-archives.com/git/765571-git-svn-dcommit-avoid-self-referential-mergeinfo-lines-when-svn-pushmergeinfo-is-configured.html

Turney answered 11/4, 2012 at 3:35 Comment(5)
Yes. I meant to answer my own question but then got side tracked since the patch needs some cleanup work to get accepted. But we've been using it for a few weeks now (shortly after posting this question, actually) and it seems to solve the problem.Luzluzader
@Avish: What's the status of your patch? Are you going to resend it? It's an important interoperability fix, so it should go into git.git as soon as possible IMHO, hopefully even in upcoming Git v1.7.11 and v1.7.10.5. TIAHagler
The main problems with the patch are the git-svn tests it breaks, which are pretty hard to run on a Windows machine. Unfortunately I have very little time to work on this; sorry. You're more than welcome to pick it up and re-send it if you can, or just apply it locally to your git-svn file. Hopefully in the future I'll find the time to finalize it but right now this isn't getting the attention it deserves.Luzluzader
@Avish: I see. Could you upload latest version of your patch to e.g. gist for easier reference and possible future reuse? Then please post a link to it. Thanks!Hagler
It looks like a fix for this issue went into git 1.8.3.Dizen

© 2022 - 2024 — McMap. All rights reserved.