How to trick git-svn into recognizing merges done with svn?

We have an SVN setup with a stable branch and an unstable development branch. Dev work (mostly) is done on a branch, and then merged with the trunk before deployment.

I use git-svn as my SVN client. My process of merging from an unstable state to a trunk is as follows:

git svn fetch
git co -b trunk svn/trunk 
git merge --no-ff svn/unstable
git svn dcommit

svn/* - remote branches of SVN.

This, of course, requires that no one do anything with the chest before I finish, but in practice this is not a problem.

The benefits of this process are that git now records merge parents in my local repository. This does not help my colleagues, but allows git to calculate a common ancestor when I do a merge. This is very desirable.

And here it is rub. When someone does a merge, git doesn't know about it. Here is an example:

  o-...-A---o---C--- unstable
 /
X--...--B---o---o--- stable

An unstable branch was created at point X. At point A, we decided to merge the changes from the unstable branch to the stable branch at point B. The common ancestor is correct X.

Since the merge is not recorded in the git history, the next merge in C again assumes that X is a common ancestor. I would like it to be A, as in the following graph:

  o-...-A---o---C--- unstable
 /       \
X---...---B---o---o--- stable

It is not necessary to get a graph that looks the same as the one shown in the picture. Any graph that recognizes A as a common ancestor is fine with me.

I have some options, such as the correct use of a git filter branch or a "fake" commit, which is never given to SVN. However, none of my attempts have so far worked.

, . . , , "".

+5
4

Grafts, .

, , SVN, .git/info/grafts SHA-1 (M) (A, B).

      o-...-A---o---D--- unstable
     /       
    X-----B---M---o---o--- stable

A = 31423cd8a838f984547a908777308d846043cbda
B = d99cfccb1f859a8f1dbfac95eec75227fe518b23
M = 13319a54d3e3d61b501e7cc6474c46f37784aaa3

A-M, M B A. :

commit newparent1 ... newparentN

, ( ) :

13319a54d3e3d61b501e7cc6474c46f37784aaa3 d99cfccb1f859a8f1dbfac95eec75227fe518b23 31423cd8a838f984547a908777308d846043cbda

Git , . git push/fetch/clone, .

+2

SVN, svnmergeinfo git :
, SVN Git, git SVN;)

git-svn svnmergeinfo SVN, " ".

git-filter-branch , git.
"A->B" SVN, git ** "merge", ( ), .

    o-.....-A---o---C--- unstable
   /         \
  /           o-------\__ merge recorder branch
 /           /         \
X---.....---B---o---o---o__ stable

C A .

+2
+1

.

  • , git gc ( )
  • If you click on another host, it will not know about transplants and may end in a broken story.
0
source

All Articles