git svn - Git-svn merge two SVN branches -
i have read numerous questions , blogs on git-svn
, merging. of them (notably git-svn
man page) warns against using merge anywhere near branch plan dcommit
from.
others, so answer, state merging fine long use one-off feature branches delete before dcommitting
.
i have setup 2 long-living svn (and git) branches:
- trunk (git-svn:
svn/trunk
, git:master
) - stable branch - branches/devel (git-svn:
svn/devel
, git:devel
) - main development branch fork off feature branches (and can live rebasing themdevel
instead of merging).
in picture above, (1) shows past svn history, branches/devel
has been merged trunk
.
(2) shows have dcommitted
current development svn.
the question: can use git-svn
merge two svn branches history shows merge point (as svn can do)? in other words: happens if dcommit
master
shown in (3)?
will mess svn (or git) history? or plain forget devel
merged master
@ all?
edit: if git
forgets devel
merged master
, there difference between dcommiting
point (3) , applying commits single patch?
digging more matter, found out git supports setting svn:mergeinfo
property on svn branch when dcommit
'ing:
git svn dcommit --mergeinfo "/branches/somebranch:1-3"
nb! svn:mergeinfo
overwritten whatever given on command-line, careful list previous merges too.
while more recent git version added config parameter automatically set property:
config key: svn.pushmergeinfo
i had troubles automatic mergeinfo - 1 reason or other git calculated wrong , couldn't work.
solution: git-merge-svn
to automate process, wrote shell script git-merge-svn can used merge 2 svn branches correct svn:mergeinfo
set on dcommit.
the script handles both situations:
- the branch not merged in git -
git merge
beforehand - the branches have been merged in git (but not in svn) - traverse until previous ancestor merged commit revisions.
with script able produce these merges solely on git-side , retain merge info git graph shows log nicely:
example usage:
- make commits on devel6
dcommit
devel6 svn (required svn revision numbers commits)- check out testtunk6 - yes, know made typo in name ;-)
git merge-svn devel6
the last commant outputs:
% git merge-svn devel6 svn merge: devel6 -> testtunk6 * new merge commit |\ | * devel6 [7b71187] (r102) * | testtunk6 [0682a45] (r101) \| * [273d6d6] (r100) step 1: git merge executing: git merge devel6 continue? (y/n) [n]: y merge made 'recursive' strategy. testfile | 1 + 1 file changed, 1 insertion(+) step 2: svn dcommit executing: git svn dcommit --mergeinfo /idp/branches/devel:9-32,35-41 /idp/branches/devel6:89 /idp/branches/devel6:94 /idp/branches/devel6:93 /idp/branches/devel6:96 /idp/branches/devel6:97 /idp/branches/devel6:99 /idp/branches/devel6:100 /idp/branches/devel6:102 continue? (y/n) [n]: y committing https://my.svn.host/svn/auth/idp/branches/testtunk6 ... m testfile committed r103 m testfile found merge parent (svn:mergeinfo prop): 7b71187fc371d3f86658c5850009e63be88157ac r103 = 87759323cbadd38bac78087d57b6870a926287e7 (refs/remotes/svn/testtunk6) no changes between 3fb2168cfbbe605fbd810d76513443203a85a549 , refs/remotes/svn/testtunk6 resetting latest refs/remotes/svn/testtunk6
Comments
Post a Comment