All of lore.kernel.org
 help / color / mirror / Atom feed
* git-svn: Handling of branches created from subfolders
@ 2017-08-19 12:45 Jan Teske
  2017-08-20 10:27 ` Andreas Heiduk
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Teske @ 2017-08-19 12:45 UTC (permalink / raw)
  To: git

Hello,

I’m trying to do a one-time conversion of a large SVN repository to git using git-svn. Unfortunately, this SVN repo contains a substantial amount of non-standard branches created from a subfolder of trunk/. Users that only need to work on part of the code inside the repo usually create such branches to avoid having to download unneeded files.

A toy example showing what I’m talking about:

trunk/
    - subfolder1/
        - …
    - subfolder2/
        - …
branches/
    - branch1/ (initially cp’ed from trunk/subfolder1)
        - …
    - branch2/ (initially cp’ed from trunk/subfolder2)
        - …
    - branch3/ (initially cp’ed from trunk)
        - …

While in my experience, git-svn is able to correctly handle branches/branch3, it fails on branch1 and branch2. By "fails" I mean that it still performs the conversion, but any relationship to the trunk is completely missing. Instead, in the resulting git repository it looks like those branches have a completely separate history, starting from nothing.

Is there any way to fix such branches from subfolders in a way that they integrate correctly with the converted git repository, without losing any (or at least too much) history? If this is not possible with git-svn directly, maybe I could prepare the SVN repo or post-process the converted git repository somehow?

Thanks!
    

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: git-svn: Handling of branches created from subfolders
  2017-08-19 12:45 git-svn: Handling of branches created from subfolders Jan Teske
@ 2017-08-20 10:27 ` Andreas Heiduk
  2017-08-20 17:42   ` Jan Teske
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Heiduk @ 2017-08-20 10:27 UTC (permalink / raw)
  To: Jan Teske, git

Am 19.08.2017 um 14:45 schrieb Jan Teske:
> Is there any way to fix such branches from subfolders in a way that they integrate correctly with the converted git repository, without losing any (or at least too much) history? If this is not possible with git-svn directly, maybe I could prepare the SVN repo or post-process the converted git repository somehow?

You can use `git replace --graft` to connect the first commit of the
loose branches with their source. After all connections are in place you
can use `git filter-branch` to make the replacements permanent.

This will not change the content or directory structure of branch1 or
branch2 but the diff with their parent commits will show up as a huge
delete/rename operation. So merging/Cherry-picking between trunk and
branch1/branch2 will be ... challenging.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: git-svn: Handling of branches created from subfolders
  2017-08-20 10:27 ` Andreas Heiduk
@ 2017-08-20 17:42   ` Jan Teske
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Teske @ 2017-08-20 17:42 UTC (permalink / raw)
  To: Andreas Heiduk; +Cc: git


> On 20. Aug 2017, at 12:27 , Andreas Heiduk <asheiduk@gmail.com> wrote:
> 
> Am 19.08.2017 um 14:45 schrieb Jan Teske:
>> Is there any way to fix such branches from subfolders in a way that they integrate correctly with the converted git repository, without losing any (or at least too much) history? If this is not possible with git-svn directly, maybe I could prepare the SVN repo or post-process the converted git repository somehow?
> 
> You can use `git replace --graft` to connect the first commit of the
> loose branches with their source. After all connections are in place you
> can use `git filter-branch` to make the replacements permanent.
> 
> This will not change the content or directory structure of branch1 or
> branch2 but the diff with their parent commits will show up as a huge
> delete/rename operation. So merging/Cherry-picking between trunk and
> branch1/branch2 will be ... challenging.

That’s really helpful, thanks!

I even solved the problem of the challenging merging between the converted branches and trunk by using another filter-branch to rewrite all the commits in branch1/branch2 to make all their modifications in the respective subfolders (effectively fixing the directory structure to fit trunk). This answer was helpful for how to do this: https://unix.stackexchange.com/a/280229

So, for future reference, the following post-processing seems to work:

1. Use filter-branch to move all the commits the the correct subfolder.
2. Use `git replace --graft` to connect the first commit of the branch to its correct parent commit.
3. Use `git replace --graft` to add the missing parents of any merge commits the branch was part of.
4. Use filter-branch again to make the replacements permanent.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-20 17:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-19 12:45 git-svn: Handling of branches created from subfolders Jan Teske
2017-08-20 10:27 ` Andreas Heiduk
2017-08-20 17:42   ` Jan Teske

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.